From 9b692b91ee25c33281c32c7ba86f5f0734e46be9 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Sun, 8 Mar 2009 19:55:05 -0400 Subject: Fix and add tests for function(".so").statement(N) * tapsets.cxx (query_dwarf_func): die_has_pc (dwarf_haspc) does not expect a module_start for shared objects so don't call module_address_to_global for the statement address. * testsuite/systemtap.base/labels.exp: Add tests for executable .statement(N), shared object .label("L") and so .statement(N). --- tapsets.cxx | 6 +-- testsuite/systemtap.base/labels.exp | 86 +++++++++++++++++++++++++++++++++++-- 2 files changed, 86 insertions(+), 6 deletions(-) diff --git a/tapsets.cxx b/tapsets.cxx index 02f0b553..d99eebe2 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -3920,9 +3920,9 @@ query_dwarf_func (Dwarf_Die * func, base_query * bq) else if (q->has_function_num || q->has_statement_num) { Dwarf_Addr query_addr = - q->dw.module_address_to_global(q->has_function_num ? q->function_num_val : - q->has_statement_num ? q->statement_num_val : - (assert(0) , 0)); + (q->has_function_num ? q->function_num_val : + q->has_statement_num ? q->statement_num_val : + (assert(0) , 0)); Dwarf_Die d; q->dw.function_die (&d); diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp index 9c92d69c..54640268 100644 --- a/testsuite/systemtap.base/labels.exp +++ b/testsuite/systemtap.base/labels.exp @@ -13,6 +13,7 @@ if {$utrace_support_found == 0} { untested "$test"; return } # Compile a C program to use as the user-space probing target set label_srcpath "[pwd]/labels.c" set label_exepath "[pwd]/labels.x" +set label_sopath "[pwd]/labels.so" set label_flags "additional_flags=-g" set fp [open $label_srcpath "w"] puts $fp " @@ -54,9 +55,12 @@ if { $res != "" } { pass "compiling labels.c -g" } +# label in an executable + verbose -log "spawn stap -c $label_exepath $label_stppath" spawn stap -c $label_exepath $label_stppath +wait expect { -timeout 180 -re {VARS a=0x0 b=0x0.*VARS a=0x2 b=0x0.*VARS a=0x2 b=0x3 c=0x[a-f01-9]} { incr ok; exp_continue } @@ -64,7 +68,83 @@ expect { eof { } } -wait +if {$ok == 1} { pass "$test exe .label" } { fail "$test exe .label" } + +# address of label in an executable + +set label_shpath "[pwd]/label.sh" +set fp [open $label_shpath "w"] +puts $fp " +readelf --debug-dump $label_exepath | awk \" +/init_another_int/ {have_label=1} +/DW_AT_low_pc/ {if (have_label) {print \$3;exit;}} +\" +" +close $fp +spawn sh $label_shpath +expect { + -re {0x[0-9a-f]*} +} +set ok 0 +spawn stap -p2 -l "process\(\"$label_exepath\"\).statement($expect_out(0,string))" +expect { + -timeout 180 + -re {no match} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} + +if {$ok == 0} { pass "$test exe .statement" } { xfail "$test exe .statement" } + +set ok 0 + +set label_flags "additional_flags=-g additional_flags=-shared additional_flags=-fPIC" +set res [target_compile $label_srcpath $label_sopath executable $label_flags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "compiling labels.c -g" + catch {exec rm -f $label_srcpath $label_stppath} + return +} else { + pass "compiling labels.c -g" +} + +# label in a shared object + +spawn stap -p2 -l "process\(\"$label_sopath\"\).function\(\"\*\"\).label\(\"init_another_int\"\)" +expect { + -timeout 180 + -re {process.*function} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} + +if {$ok == 1} { pass "$test so .label" } { fail "$test so .label" } + +# address of label in a shared object + +set label_shpath "[pwd]/label.sh" +set fp [open $label_shpath "w"] +puts $fp " +readelf --debug-dump $label_sopath | awk \" +/init_another_int/ {have_label=1} +/DW_AT_low_pc/ {if (have_label) {print \$3;exit;}} +\" +" +close $fp +spawn sh $label_shpath +expect { + -re {0x[0-9a-f]*} +} +set ok 0 +spawn stap -p2 -l "process\(\"$label_sopath\"\).statement($expect_out(0,string))" +expect { + -timeout 180 + -re {no match} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} + +if {$ok == 0} { pass "$test so .statement" } { xfail "$test so .statement" } -if {$ok == 1} { pass "$test" } { fail "$test ($ok)" } -catch {exec rm -f $label_srcpath $label_stppath $label_exepath} +# catch {exec rm -f $label_srcpath $label_stppath $label_exepath} -- cgit From 4be9af07213db548443da4ae7ed365e98ed2b29c Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Sun, 8 Mar 2009 20:17:10 -0400 Subject: Minor changes to labels.exp. --- testsuite/systemtap.base/labels.exp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp index 54640268..1b538dbb 100644 --- a/testsuite/systemtap.base/labels.exp +++ b/testsuite/systemtap.base/labels.exp @@ -85,16 +85,16 @@ spawn sh $label_shpath expect { -re {0x[0-9a-f]*} } -set ok 0 +set nomatch 0 spawn stap -p2 -l "process\(\"$label_exepath\"\).statement($expect_out(0,string))" expect { -timeout 180 - -re {no match} { incr ok; exp_continue } + -re {semantic error: no match} { incr nomatch; exp_continue } timeout { fail "$test (timeout)" } eof { } } -if {$ok == 0} { pass "$test exe .statement" } { xfail "$test exe .statement" } +if {$nomatch == 0} { pass "$test exe .statement" } { fail "$test exe .statement" } set ok 0 @@ -136,15 +136,15 @@ spawn sh $label_shpath expect { -re {0x[0-9a-f]*} } -set ok 0 +set nomatch 0 spawn stap -p2 -l "process\(\"$label_sopath\"\).statement($expect_out(0,string))" expect { -timeout 180 - -re {no match} { incr ok; exp_continue } + -re {semantic error: no match} { incr nomatch; exp_continue } timeout { fail "$test (timeout)" } eof { } } -if {$ok == 0} { pass "$test so .statement" } { xfail "$test so .statement" } +if {$nomatch == 0} { pass "$test so .statement" } { fail "$test so .statement" } # catch {exec rm -f $label_srcpath $label_stppath $label_exepath} -- cgit From b1f85b93f4cdc5eaad45891399c30341d4d6ce93 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Sun, 8 Mar 2009 22:28:03 -0400 Subject: Adapt to linux-next commit changing __alloc_percpu API. After linux-next commit f2a8205c, it takes two parameters again, so we autoconf for it rather than use KERNEL_VERSION ifdefs. --- buildrun.cxx | 1 + runtime/alloc.c | 25 +++---------------------- runtime/autoconf-alloc-percpu-align.c | 6 ++++++ 3 files changed, 10 insertions(+), 22 deletions(-) create mode 100644 runtime/autoconf-alloc-percpu-align.c diff --git a/buildrun.cxx b/buildrun.cxx index 2685949d..b9d648ef 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -147,6 +147,7 @@ compile_pass (systemtap_session& s) output_autoconf(s, o, "autoconf-task-uid.c", "STAPCONF_TASK_UID", NULL); output_autoconf(s, o, "autoconf-vm-area.c", "STAPCONF_VM_AREA", NULL); output_autoconf(s, o, "autoconf-procfs-owner.c", "STAPCONF_PROCFS_OWNER", NULL); + output_autoconf(s, o, "autoconf-alloc-percpu-align.c", "STAPCONF_ALLOC_PERCPU_ALIGN", NULL); #if 0 /* NB: For now, the performance hit of probe_kernel_read/write (vs. our diff --git a/runtime/alloc.c b/runtime/alloc.c index 89d16612..439e8a7e 100644 --- a/runtime/alloc.c +++ b/runtime/alloc.c @@ -233,30 +233,14 @@ static void *_stp_vmalloc(unsigned long size) } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15) static void *_stp_alloc_percpu(size_t size) { -#ifdef DEBUG_MEM +#ifdef STAPCONF_ALLOC_PERCPU_ALIGN void *ret = __alloc_percpu(size, 8); - if (likely(ret)) { - struct _stp_mem_entry *m = kmalloc(sizeof(struct _stp_mem_entry), STP_ALLOC_FLAGS); - if (unlikely(m == NULL)) { - free_percpu(ret); - return NULL; - } - _stp_mem_debug_percpu(m, ret, size); - _stp_allocated_memory += size * num_online_cpus(); - } - return ret; #else - return __alloc_percpu(size, 8); + void *ret = __alloc_percpu(size); #endif -} -#else -static void *_stp_alloc_percpu(size_t size) -{ #ifdef DEBUG_MEM - void *ret = __alloc_percpu(size); if (likely(ret)) { struct _stp_mem_entry *m = kmalloc(sizeof(struct _stp_mem_entry), STP_ALLOC_FLAGS); if (unlikely(m == NULL)) { @@ -266,12 +250,9 @@ static void *_stp_alloc_percpu(size_t size) _stp_mem_debug_percpu(m, ret, size); _stp_allocated_memory += size * num_online_cpus(); } - return ret; -#else - return __alloc_percpu(size); #endif + return ret; } -#endif /* LINUX_VERSION_CODE */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12) #define _stp_kmalloc_node(size,node) _stp_kmalloc(size) diff --git a/runtime/autoconf-alloc-percpu-align.c b/runtime/autoconf-alloc-percpu-align.c new file mode 100644 index 00000000..158d579c --- /dev/null +++ b/runtime/autoconf-alloc-percpu-align.c @@ -0,0 +1,6 @@ +#include + +/* kernel commit f2a8205c */ +void foo (void) { + (void) __alloc_percpu(sizeof(int), 8); +} -- cgit From ee53a613180a780ea377b4f1c857aaeabcf44240 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Sun, 8 Mar 2009 22:30:03 -0400 Subject: Check pending_interrupts more frequently during unwindsyms (pass 3) processing --- translate.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/translate.cxx b/translate.cxx index c679e0f1..b2ba5c72 100644 --- a/translate.cxx +++ b/translate.cxx @@ -4458,6 +4458,9 @@ dump_unwindsyms (Dwfl_Module *m, string modname = name; + if (pending_interrupts) + return DWARF_CB_ABORT; + // skip modules/files we're not actually interested in if (c->session.unwindsym_modules.find(modname) == c->session.unwindsym_modules.end()) return DWARF_CB_OK; -- cgit From f9355a6c0645c7efa0b7bc7894231b51b9f7e91c Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Sun, 8 Mar 2009 22:30:30 -0400 Subject: tracepoint probes: clear session derived_probe_groups pointer in ctor to avoid SEGV --- elaborate.cxx | 1 + session.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/elaborate.cxx b/elaborate.cxx index 0a00ebf2..34e6ab16 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -1448,6 +1448,7 @@ systemtap_session::systemtap_session (): timer_derived_probes(0), profile_derived_probes(0), mark_derived_probes(0), + tracepoint_derived_probes(0), hrtimer_derived_probes(0), perfmon_derived_probes(0), procfs_derived_probes(0), diff --git a/session.h b/session.h index 8fa491fd..bc99385b 100644 --- a/session.h +++ b/session.h @@ -167,6 +167,8 @@ struct systemtap_session hrtimer_derived_probe_group* hrtimer_derived_probes; perfmon_derived_probe_group* perfmon_derived_probes; procfs_derived_probe_group* procfs_derived_probes; + // NB: It is very important for all of the above (and below) fields + // to be cleared in the systemtap_session ctor (elaborate.cxx). // unparser data translator_output* op; -- cgit