我在 ArchLinux 4.7.4-1 上运行 SystemTap,并按照ArchLinux Wiki上的说明使用重建的内核。SystemTap 的版本是:
$ stap -V
Systemtap translator/driver (version 3.0/0.167, non-git sources)
Copyright (C) 2005-2015 Red Hat, Inc. and others
This is free software; see the source for copying conditions.
enabled features: AVAHI LIBSQLITE3 LIBXML2 NLS NSS TR1_UNORDERED_MAP READLINE
$ uname -a
Linux eva-dummy 4.7.4-1-ARCH #1 SMP PREEMPT Sun Sep 25 14:32:13 EDT 2016 x86_64 GNU/Linux
我有 SystemTap 脚本:
#!/usr/bin/stap
probe kernel.function("*@net/socket.c").call
{
printf ("%s -> %s\n", thread_indent(1), probefunc())
}
probe kernel.function("*@net/socket.c").return
{
printf ("%s <- %s\n", thread_indent(-1), probefunc())
}
使用选项运行的输出-vvv
是:
$ stap -vvv hello-world.stp
Systemtap translator/driver (version 3.0/0.167, non-git sources)
Copyright (C) 2005-2015 Red Hat, Inc. and others
This is free software; see the source for copying conditions.
enabled features: AVAHI LIBSQLITE3 LIBXML2 NLS NSS TR1_UNORDERED_MAP READLINE
Created temporary directory "/tmp/stap4mY4hm"
Session arch: x86_64 release: 4.7.4-1-ARCH
Parsed kernel "/lib/modules/4.7.4-1-ARCH/build/.config", containing 5396 tuples
Parsed kernel "/lib/modules/4.7.4-1-ARCH/build/Module.symvers", containing 7295 vmlinux exports
Kernel symbol table /lib/modules/4.7.4-1-ARCH/build/System.map unavailable, (No such file or directory)
Parsed kernel "/boot/System.map-4.7.4-1-ARCH", containing 32456 symbols
Processing tapset "/usr/share/systemtap/tapset/linux/context.stpm"
Processing tapset "/usr/share/systemtap/tapset/linux/json.stpm"
Processing tapset "/usr/share/systemtap/tapset/linux/nfs_proc.stpm"
Processing tapset "/usr/share/systemtap/tapset/linux/syscalls.stpm"
Processing tapset "/usr/share/systemtap/tapset/linux/task.stpm"
Searched for library macro files: "/usr/share/systemtap/tapset/linux/*.stpm", found: 5, processed: 5
Processing tapset "/usr/share/systemtap/tapset/choose_defined.stpm"
Processing tapset "/usr/share/systemtap/tapset/container_of.stpm"
Processing tapset "/usr/share/systemtap/tapset/macros.stpm"
Processing tapset "/usr/share/systemtap/tapset/offsetof.stpm"
Processing tapset "/usr/share/systemtap/tapset/print_stats.stpm"
Processing tapset "/usr/share/systemtap/tapset/private30.stpm"
Processing tapset "/usr/share/systemtap/tapset/try_assign.stpm"
Processing tapset "/usr/share/systemtap/tapset/type_defined.stpm"
Searched for library macro files: "/usr/share/systemtap/tapset/*.stpm", found: 8, processed: 8
Processing tapset "/usr/share/systemtap/tapset/linux/x86_64/aux_syscalls.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/x86_64/nd_syscalls.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/x86_64/syscalls.stp"
Searched: "/usr/share/systemtap/tapset/linux/x86_64/*.stp", found: 3, processed: 3
Processing tapset "/usr/share/systemtap/tapset/linux/atomic.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/aux_syscalls.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/context-caller.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/context-envvar.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/context.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/context-symbols.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/context-unwind.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/conversions-guru.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/conversions.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/ctime.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/dentry.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/dev.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/endian.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/guru-delay.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/guru-signal.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/inet_sock.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/inet.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/ioblock.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/ioscheduler.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/ipmib-filter-default.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/ipmib.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/ip.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/irq.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/json.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/kprocess.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/kretprobe.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/linuxmib-filter-default.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/linuxmib.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/loadavg.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/logging.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/memory.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/nd_syscalls2.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/nd_syscalls.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/netfilter.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/networking.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/nfsderrno.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/nfsd.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/nfs_proc.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/nfs.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/panic.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/perf.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/proc_mem.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/pstrace.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/rcu.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/rlimit.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/rpc.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/scheduler.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/scsi.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/signal.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/socket.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/syscalls2.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/syscalls_cfg_trunc.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/syscalls.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/target_set.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/task_ancestry.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/task.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/task_time.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/tcpmib-filter-default.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/tcpmib.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/tcp.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/timestamp_gtod.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/timestamp_monotonic.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/timestamp.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/tty.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/tzinfo.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/ucontext.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/ucontext-symbols.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/ucontext-unwind.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/udp.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/utrace.stp"
Processing tapset "/usr/share/systemtap/tapset/linux/vfs.stp"
Searched: "/usr/share/systemtap/tapset/linux/*.stp", found: 71, processed: 71
Processing tapset "/usr/share/systemtap/tapset/x86_64/registers.stp"
Searched: "/usr/share/systemtap/tapset/x86_64/*.stp", found: 1, processed: 1
Processing tapset "/usr/share/systemtap/tapset/ansi.stp"
Processing tapset "/usr/share/systemtap/tapset/argv.stp"
Processing tapset "/usr/share/systemtap/tapset/context.stp"
Processing tapset "/usr/share/systemtap/tapset/errno.stp"
Processing tapset "/usr/share/systemtap/tapset/indent-default.stp"
Processing tapset "/usr/share/systemtap/tapset/indent.stp"
Processing tapset "/usr/share/systemtap/tapset/init.stp"
Processing tapset "/usr/share/systemtap/tapset/java.stp"
Processing tapset "/usr/share/systemtap/tapset/logging.stp"
Processing tapset "/usr/share/systemtap/tapset/null.stp"
Processing tapset "/usr/share/systemtap/tapset/oneshot.stp"
Processing tapset "/usr/share/systemtap/tapset/pn.stp"
Processing tapset "/usr/share/systemtap/tapset/queue_stats.stp"
Processing tapset "/usr/share/systemtap/tapset/random.stp"
Processing tapset "/usr/share/systemtap/tapset/registers.stp"
Processing tapset "/usr/share/systemtap/tapset/speculative.stp"
Processing tapset "/usr/share/systemtap/tapset/stap_staticmarkers.stp"
Processing tapset "/usr/share/systemtap/tapset/stopwatch.stp"
Processing tapset "/usr/share/systemtap/tapset/string.stp"
Processing tapset "/usr/share/systemtap/tapset/switchfile.stp"
Processing tapset "/usr/share/systemtap/tapset/system.stp"
Processing tapset "/usr/share/systemtap/tapset/timers.stp"
Processing tapset "/usr/share/systemtap/tapset/tokenize.stp"
Processing tapset "/usr/share/systemtap/tapset/tzinfo.stp"
Processing tapset "/usr/share/systemtap/tapset/uconversions.stp"
Searched: "/usr/share/systemtap/tapset/*.stp", found: 25, processed: 25
Pass 1: parsed user script and 113 library scripts using 116784virt/38632res/6676shr/32184data kb, in 100usr/0sys/239real ms.
Attempting to extract kernel debuginfo build ID from /lib/modules/4.7.4-1-ARCH/build/vmlinux.id
Attempting to extract kernel debuginfo build ID from /sys/kernel/notes
blacklist regexps:
blfn: ^(atomic_notifier_call_chain|default_do_nmi|__die|die_nmi|do_debug|do_general_protection|do_int3|do_IRQ|do_page_fault|do_sparc64_fault|do_trap|dummy_nmi_callback|flush_icache_range|ia64_bad_break|ia64_do_page_fault|ia64_fault|io_check_error|mem_parity_error|nmi_watchdog_tick|notifier_call_chain|oops_begin|oops_end|program_check_exception|single_step_exception|sync_regs|unhandled_fault|unknown_nmi_error|xen_[gs]et_debugreg|xen_irq_.*|xen_.*_fl_direct.*|check_events|xen_adjust_exception_frame|xen_iret.*|xen_sysret64.*|test_ti_thread_flag.*|inat_get_opcode_attribute|system_call_after_swapgs|HYPERVISOR_[gs]et_debugreg|HYPERVISOR_event_channel_op|hash_64|hash_ptr|native_set_pte|.*raw_.*_lock.*|.*raw_.*_unlock.*|.*raw_.*_trylock.*|.*read_lock.*|.*read_unlock.*|.*read_trylock.*|.*write_lock.*|.*write_unlock.*|.*write_trylock.*|.*write_seqlock.*|.*write_sequnlock.*|.*spin_lock.*|.*spin_unlock.*|.*spin_trylock.*|.*spin_is_locked.*|rwsem_.*lock.*|.*mutex_.*lock.*|raw_.*|atomic_.*|atomic64_.*|get_bh|put_bh|.*apic.*|.*APIC.*|.*softirq.*|.*IRQ.*|.*_intr.*|__delay|.*kernel_text.*|get_current|current_.*|.*exception_tables.*|.*setup_rt_frame.*|.*preempt_count.*|preempt_schedule|__switch_to|special_mapping_.*|.*_pte_.*)$
blfn_ret: ^(do_exit|sys_exit|sys_exit_group)$
blfile: ^(kernel/kprobes\.c|arch/.*/kernel/kprobes\.c|.*/include/asm/io\.h|.*/include/asm/io-defs\.h|.*/include/asm/io_64\.h|.*/include/asm/bitops\.h|drivers/ide/ide-iops\.c|arch/.*/kernel/paravirt\.c|.*/include/asm/paravirt\.h|fs/seq_file\.c)$
blsection: ^(\.init\.|\.exit\.|\.devinit\.|\.devexit\.|\.cpuinit\.|\.cpuexit\.|\.meminit\.|\.memexit\.)
parse '*@net/socket.c', func '*', file 'net/socket.c'
focused on module 'kernel' = [0xffffffff81000000-0xffffffff81b7e000, bias 0 file /lib/modules/4.7.4-1-ARCH/build/vmlinux ELF machine |x86_64 (code 62)
focused on module 'kernel'
selected source file 'net/socket.c'
suggesting 29554 dwarf functions from modules:
kernel
semantic error: while resolving probe point: identifier 'kernel' at hello-world.stp:3:7
thrown from: elaborate.cxx:1068
source: probe kernel.function("*@net/socket.c").call
^
semantic error: no match (similar functions: f, lf, up, die, gcd)
thrown from: tapsets.cxx:8329
parse '*@net/socket.c', func '*', file 'net/socket.c'
focused on module 'kernel' = [0xffffffff81000000-0xffffffff81b7e000, bias 0 file /lib/modules/4.7.4-1-ARCH/build/vmlinux ELF machine |x86_64 (code 62)
focused on module 'kernel'
selected source file 'net/socket.c'
suggesting 29554 dwarf functions from modules:
kernel
semantic error: while resolving probe point: identifier 'kernel' at :8:7
thrown from: elaborate.cxx:1068
source: probe kernel.function("*@net/socket.c").return
^
semantic error: no match (similar functions: f, lf, up, die, gcd)
thrown from: tapsets.cxx:8329
Pass 2: analyzed script: 0 probes, 0 functions, 0 embeds, 0 globals using 118068virt/41172res/7648shr/33468data kb, in 560usr/20sys/967real ms.
Pass 2: analysis failed. [man error::pass2]
Running rm -rf /tmp/stap4mY4hm
Spawn waitpid result (0x0): 0
Removed temporary directory "/tmp/stap4mY4hm"
SystemTap 似乎无法识别kernel.xxxx
探针。如何让脚本在 ArchLinux 上成功运行?