diff options
author | Mark Wielaard <mjw@redhat.com> | 2010-02-02 13:47:19 +0100 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2010-02-02 13:54:19 +0100 |
commit | 87748e2b87e574d3c83866ccd0d83678c3c68d93 (patch) | |
tree | f3db83626aa63188c6cf0f41489f6908d78a1255 | |
parent | 42eca8cc5a5b1073332596dd3fc0ecfe98394f60 (diff) | |
download | systemtap-steved-87748e2b87e574d3c83866ccd0d83678c3c68d93.tar.gz systemtap-steved-87748e2b87e574d3c83866ccd0d83678c3c68d93.tar.xz systemtap-steved-87748e2b87e574d3c83866ccd0d83678c3c68d93.zip |
Make sure cfa_ops are always retrieved through dwfl global address.
dwflpp::translate_location() works on the dw address space, but
get_cfa_ops() starts out with dwfl calls (only dwarf_cfi_addrframe()
needs to be adjusted for bias).
* dwflpp.cxx (translate_location): Pass pc plus module bias through to
get_cfa_ops.
(get_cfa_ops): Adjust for bias when calling dwarf_cfi_addrframe(),
add frame start/end address when found if verbose logging.
* testsuite/systemtap.exelib/lib.stp: Add $foo and $bar variables to
process.function probes.
* testsuite/systemtap.exelib/libmarkunamestack.stp: Likewise.
* testsuite/systemtap.exelib/lib.tcl: Expect correct values for
process.function probe variables.
* testsuite/systemtap.exelib/libmarkunamestack.tcl: Likewise.
-rw-r--r-- | dwflpp.cxx | 34 | ||||
-rw-r--r-- | testsuite/systemtap.exelib/lib.stp | 4 | ||||
-rw-r--r-- | testsuite/systemtap.exelib/lib.tcl | 12 | ||||
-rw-r--r-- | testsuite/systemtap.exelib/libmarkunamestack.stp | 4 | ||||
-rw-r--r-- | testsuite/systemtap.exelib/libmarkunamestack.tcl | 4 |
5 files changed, 36 insertions, 22 deletions
@@ -1726,9 +1726,10 @@ dwflpp::translate_location(struct obstack *pool, e->tok); } - // pc is relative to current module, which is what get_cfa_ops - // and c_translate_location expects. - Dwarf_Op *cfa_ops = get_cfa_ops (pc); + // pc is in the dw address space of the current module, which is what + // c_translate_location expects. get_cfa_ops wants the global dwfl address. + Dwarf_Addr addr = pc + module_bias; + Dwarf_Op *cfa_ops = get_cfa_ops (addr); return c_translate_location (pool, &loc2c_error, this, &loc2c_emit_address, 1, 0 /* PR9768 */, @@ -2783,17 +2784,17 @@ dwflpp::get_cfa_ops (Dwarf_Addr pc) clog << "get_cfa_ops @0x" << hex << pc << dec << ", module_start @0x" << hex << module_start << dec << endl; -#if _ELFUTILS_PREREQ(0,142) // Try debug_frame first, then fall back on eh_frame. - size_t cfa_nops; - Dwarf_Addr bias; + size_t cfa_nops = 0; + Dwarf_Addr bias = 0; + Dwarf_Frame *frame = NULL; +#if _ELFUTILS_PREREQ(0,142) Dwarf_CFI *cfi = dwfl_module_dwarf_cfi (module, &bias); if (cfi != NULL) { if (sess.verbose > 3) clog << "got dwarf cfi bias: 0x" << hex << bias << dec << endl; - Dwarf_Frame *frame = NULL; - if (dwarf_cfi_addrframe (cfi, pc, &frame) == 0) + if (dwarf_cfi_addrframe (cfi, pc - bias, &frame) == 0) dwarf_frame_cfa (frame, &cfa_ops, &cfa_nops); else if (sess.verbose > 3) clog << "dwarf_cfi_addrframe failed: " << dwarf_errmsg(-1) << endl; @@ -2809,7 +2810,7 @@ dwflpp::get_cfa_ops (Dwarf_Addr pc) if (sess.verbose > 3) clog << "got eh cfi bias: 0x" << hex << bias << dec << endl; Dwarf_Frame *frame = NULL; - if (dwarf_cfi_addrframe (cfi, pc, &frame) == 0) + if (dwarf_cfi_addrframe (cfi, pc - bias, &frame) == 0) dwarf_frame_cfa (frame, &cfa_ops, &cfa_nops); else if (sess.verbose > 3) clog << "dwarf_cfi_addrframe failed: " << dwarf_errmsg(-1) << endl; @@ -2821,7 +2822,20 @@ dwflpp::get_cfa_ops (Dwarf_Addr pc) #endif if (sess.verbose > 2) - clog << (cfa_ops == NULL ? "not " : " ") << "found cfa" << endl; + { + if (cfa_ops == NULL) + clog << "not found cfa" << endl; + else + { + Dwarf_Addr frame_start, frame_end; + bool frame_signalp; + int info = dwarf_frame_info (frame, &frame_start, &frame_end, + &frame_signalp); + clog << "found cfa, info:" << info << " [start: 0x" << hex + << frame_start << dec << ", end: 0x" << hex << frame_end + << dec << "), nops: " << cfa_nops << endl; + } + } return cfa_ops; } diff --git a/testsuite/systemtap.exelib/lib.stp b/testsuite/systemtap.exelib/lib.stp index 0151282e..3fdc6db9 100644 --- a/testsuite/systemtap.exelib/lib.stp +++ b/testsuite/systemtap.exelib/lib.stp @@ -6,7 +6,7 @@ probe process(@1).function("main") { } probe process(@1).function("main_func") { - printf("main_func\n"); + printf("main_func %d\n", $foo); } probe process(@2).function("lib_main") { @@ -14,5 +14,5 @@ probe process(@2).function("lib_main") { } probe process(@2).function("lib_func") { - printf("lib_func\n"); + printf("lib_func %d\n", $bar); } diff --git a/testsuite/systemtap.exelib/lib.tcl b/testsuite/systemtap.exelib/lib.tcl index c5b7402a..a33290b1 100644 --- a/testsuite/systemtap.exelib/lib.tcl +++ b/testsuite/systemtap.exelib/lib.tcl @@ -1,11 +1,11 @@ set ::result_string {main -main_func -main_func -main_func +main_func 3 +main_func 2 +main_func 1 lib_main -lib_func -lib_func -lib_func} +lib_func 3 +lib_func 2 +lib_func 1} # Only run on make installcheck if {! [installtest_p]} { untested "lib-$testname"; return } diff --git a/testsuite/systemtap.exelib/libmarkunamestack.stp b/testsuite/systemtap.exelib/libmarkunamestack.stp index 0efbae0e..5ee229df 100644 --- a/testsuite/systemtap.exelib/libmarkunamestack.stp +++ b/testsuite/systemtap.exelib/libmarkunamestack.stp @@ -7,7 +7,7 @@ probe process(@1).function("main") { } probe process(@1).function("main_func") { - printf("main_func\n"); + printf("main_func: %d\n", $foo); } probe process(@2).function("lib_main") { @@ -15,7 +15,7 @@ probe process(@2).function("lib_main") { } probe process(@2).function("lib_func") { - printf("lib_func\n"); + printf("lib_func: %d\n", $bar); } #mark diff --git a/testsuite/systemtap.exelib/libmarkunamestack.tcl b/testsuite/systemtap.exelib/libmarkunamestack.tcl index 55dc10ee..20111b3f 100644 --- a/testsuite/systemtap.exelib/libmarkunamestack.tcl +++ b/testsuite/systemtap.exelib/libmarkunamestack.tcl @@ -47,9 +47,9 @@ expect { # lib -re {^main\r\n} {incr lib; exp_continue} - -re {^main_func\r\n} {incr lib; exp_continue} + -re {^main_func: [1-3]\r\n} {incr lib; exp_continue} -re {^lib_main\r\n} {incr lib; exp_continue} - -re {^lib_func\r\n} {incr lib; exp_continue} + -re {^lib_func: [1-3]\r\n} {incr lib; exp_continue} # mark -re {^main_count: [1-3]\r\n} {incr mark; exp_continue} |