sudo stap -ve 'probe begin { log("hello world") exit() }'
Pass 1: parsed user script and 89 library script(s) using 19148virt/12608res/1796shr/11596data kb, in 0usr/200sys/207real ms.
Pass 2: analyzed script: 1 probe(s), 2 function(s), 0 embed(s), 0 global(s) using 19412virt/13132res/1848shr/11860data kb, in 0usr/10sys/5real ms.
Pass 3: using cached /home/dc/.systemtap/cache/1f/stap_1f5133ce3514dc50604e91539f4453b8_975.c
Pass 4: using cached /home/dc/.systemtap/cache/1f/stap_1f5133ce3514dc50604e91539f4453b8_975.ko
Pass 5: starting run.
hello world
Pass 5: run completed in 0usr/40sys/328real ms.
但是执行如下脚本:
global syscalllist
probe begin {
printf("System Call Monitoring Started (10 seconds)...\n")
}
probe syscall.*
{
syscalllist[pid(), execname()]++
}
probe timer.ms(10000) {
foreach ( [pid, procname] in syscalllist ) {
printf("%s[%d] = %d\n", procname, pid, syscalllist[pid, procname] )
}
exit()
}
stap会core掉,core文件执行bt内容如下:
warning: Can't read pathname for load map: Input/output error.
Core was generated by `stap net.stp'.
Program terminated with signal 11, Segmentation fault.
#0 0xb77a1fda in ?? () from /usr/lib/i386-linux-gnu/libdw.so.1
(gdb) bt
#0 0xb77a1fda in ?? () from /usr/lib/i386-linux-gnu/libdw.so.1
#1 0xb77a2334 in ?? () from /usr/lib/i386-linux-gnu/libdw.so.1
#2 0xb7792e29 in ?? () from /usr/lib/i386-linux-gnu/libdw.so.1
#3 0xb7799259 in ?? () from /usr/lib/i386-linux-gnu/libdw.so.1
#4 0xb7799337 in dwfl_module_dwarf_cfi () from /usr/lib/i386-linux-gnu/libdw.so.1
#5 0x0818e3eb in dwflpp::get_cfa_ops (this=0x99b5840, pc=3243091088) at dwflpp.cxx:3564
#6 0x08195272 in dwflpp::translate_location (this=0x99b5840, pool=0xbfb2f0e8, attr=0xbfb2f150, die=0xbfb2f130, pc=3243091088, fb_attr=0xbfb2f140,
tail=0xbfb2f198, e=0xae57ec0) at dwflpp.cxx:2360
#7 0x0819b232 in dwflpp::literal_stmt_for_local (this=0x99b5840, scopes=..., pc=3243091088, local=..., e=0xae57ea0, lvalue=false, ty=@0xae606e0: pe_unknown)
at dwflpp.cxx:2956
#8 0x08120904 in dwarf_var_expanding_visitor::visit_target_symbol (this=0xbfb2f610, e=0xae57ea0) at tapsets.cxx:3673
#9 0x08092f0e in require<_expression_> (clearok=false, src="" out>, this=0xbfb2f610) at staptree.h:947
#10 update_visitor::replace<_expression_> (this=0xbfb2f610, src="" 0xae57ea0, clearok=false) at staptree.h:963
#11 0x0808d4ea in update_visitor::visit_functioncall (this=0xbfb2f610, e=0xae59028) at staptree.cxx:2783
#12 0x081174f5 in require<_expression_> (clearok=<optimized out>, src="" out>, this=<optimized out>) at staptree.h:947
#13 replace<_expression_> (clearok=<optimized out>, src="" out>, this=<optimized out>) at staptree.h:963
#14 var_expanding_visitor::rewrite_lvalue (this=0xbfb2f610, tok=0x9360760, eop=..., lvalue=@0xae570cc: 0xae57008, rvalue=@0xae570d4: 0xae59028)
at tapsets.cxx:2268
#15 0x08119217 in var_expanding_visitor::visit_assignment (this=0xbfb2f610, e=0xae570c0) at tapsets.cxx:2314
#16 0x08089eaa in assignment::visit (this=0xae570c0, u=0xbfb2f610) at staptree.cxx:1401
#17 0x08092f0e in require<_expression_> (clearok=false, src="" out>, this=0xbfb2f610) at staptree.h:947
#18 update_visitor::replace<_expression_> (this=0xbfb2f610, src="" 0xae570c0, clearok=false) at staptree.h:963
#19 0x08090bea in update_visitor::visit_expr_statement (this=0xbfb2f610, s=0xa0aed50) at staptree.cxx:2564
#20 0x0808c804 in require<statement> (clearok=false, src="" out>, this=0xbfb2f610) at staptree.h:947
#21 replace<statement> (clearok=false, src="" 0xa0aed50, this=0xbfb2f610) at staptree.h:963
#22 update_visitor::visit_block (this=0xbfb2f610, s=0xae57df8) at staptree.cxx:2536
#23 0x0808c804 in require<statement> (clearok=false, src="" out>, this=0xbfb2f610) at staptree.h:947
#24 replace<statement> (clearok=false, src="" 0xae57df8, this=0xbfb2f610) at staptree.h:963
#25 update_visitor::visit_block (this=0xbfb2f610, s=0xae57d98) at staptree.cxx:2536
#26 0x0810722b in require<statement> (clearok=<optimized out>, src="" out>, this=<optimized out>) at staptree.h:947
#27 replace<statement> (clearok=<optimized out>, src="" out>, this=<optimized out>) at staptree.h:963
#28 dwarf_derived_probe::dwarf_derived_probe (this=0xae58a50, funcname=..., filename=..., line=3284, module=..., section=..., dwfl_addr=3243091088,
addr=5084080, q=..., scope_die=0xadfd454) at tapsets.cxx:4276
#29 0x08108173 in dwarf_query::add_probe_point (this=0xbfb2fdd0, dw_funcname=...,
filename=0xae58a50 "ȣ\034\bX\312\035\n\\\312\035\n\\\312\035\n\230}\345\n@\022\227\t", line=3284, scope_die=0xadfd454, addr=3243091088)
at tapsets.cxx:1230
#30 0x08108636 in query_statement (func=..., file=<optimized out>, line=<optimized out>, scope_die=0xadfd454, stmt_addr=3243091088, q=0xbfb2fdd0)
at tapsets.cxx:1317
#31 0x0810877b in query_func_info (entrypc=<optimized out>, fi=..., q=0xbfb2fdd0) at tapsets.cxx:1519
#32 0x08108c30 in query_cu (cudie=0xadfd2a8, arg=0xbfb2fdd0) at tapsets.cxx:1806
---Type <return> to continue, or q <return> to quit---
#33 0x081090fc in dwarf_query::query_module_functions (this=0xbfb2fdd0) at tapsets.cxx:1863
#34 0x0810a3fe in dwarf_query::query_module_dwarf (this=0xbfb2fdd0) at tapsets.cxx:906
#35 0x0810f9a8 in dwarf_query::handle_query_module (this=0xbfb2fdd0) at tapsets.cxx:1017
#36 0x080fe60a in query_module (mod=0x99b7f98, name=0x99b5730 "kernel", addr=3238002688, arg=0xbfb2fdd0) at tapsets.cxx:2056
#37 0xb7791624 in dwfl_getmodules () from /usr/lib/i386-linux-gnu/libdw.so.1
#38 0x08189e78 in dwflpp::iterate_over_modules (this=0x99b5840, callback=0x80fe480 <query_module(Dwfl_Module*, void**, char const*, Dwarf_Addr, void*)>,
data="" at dwflpp.cxx:393
#39 0x0810cb03 in dwarf_builder::build (this=0x99b1498, sess=..., base=0x99b54f8, location=0x99b56f0, parameters=..., finished_results=...)
at tapsets.cxx:6763
#40 0x0809fa72 in match_node::find_and_build (this=0x99b15d8, s=..., p=0x99b54f8, loc=0x99b56f0, pos=2, results=...) at elaborate.cxx:457
#41 0x0809fb29 in match_node::find_and_build (this=0x99af738, s=..., p=0x99b54f8, loc=0x99b56f0, pos=1, results=...) at elaborate.cxx:623
#42 0x0809fb29 in match_node::find_and_build (this=0x8f0bd28, s=..., p=0x99b54f8, loc=0x99b56f0, pos=0, results=...) at elaborate.cxx:623
#43 0x080a0850 in derive_probes (s=..., p=0x99b54f8, dps=..., optional=false, rethrow_errors=false) at elaborate.cxx:967
#44 0x080a2608 in alias_expansion_builder::build_with_suffix (this=0x99896e0, sess=..., use=0x99712e0, location=0x98b4990, finished_results=..., suffix=...)
at elaborate.cxx:885
#45 0x08094ad5 in alias_expansion_builder::build (this=0x99896e0, sess=..., use=0x99712e0, location=0x98b4990, parameters=..., finished_results=...)
at elaborate.cxx:820
#46 0x0809fa72 in match_node::find_and_build (this=0x9989688, s=..., p=0x99712e0, loc=0x98b4990, pos=2, results=...) at elaborate.cxx:457
#47 0x0809fb29 in match_node::find_and_build (this=0x9989630, s=..., p=0x99712e0, loc=0x98b4990, pos=1, results=...) at elaborate.cxx:623
#48 0x0809fb29 in match_node::find_and_build (this=0x8f0bd28, s=..., p=0x99712e0, loc=0x98b4990, pos=0, results=...) at elaborate.cxx:623
#49 0x080a0850 in derive_probes (s=..., p=0x99712e0, dps=..., optional=false, rethrow_errors=false) at elaborate.cxx:967
#50 0x080a421e in semantic_pass_symbols (s=...) at elaborate.cxx:1539
#51 semantic_pass (s=...) at elaborate.cxx:1893
#52 0x080582e4 in passes_0_4 (s=...) at main.cxx:743
#53 0x0804fbe7 in main (argc=<error reading variable: Cannot access memory at address 0x0>,
argv=<error reading variable: Cannot access memory at address 0x4>) at main.cxx:1109