From 77694f530954dfeaf76662ebaae67ac39239a24b Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Fri, 15 Jan 2010 15:06:35 -0500 Subject: Relax sdt address check for attach to running process case. * uprobes-common.c (stap_uprobe_change_plus): Relax VM_EXEC check. --- runtime/uprobes-common.c | 4 ++-- testsuite/systemtap.base/sdt_misc.exp | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/runtime/uprobes-common.c b/runtime/uprobes-common.c index 58e3a05f..17ed69fc 100644 --- a/runtime/uprobes-common.c +++ b/runtime/uprobes-common.c @@ -37,7 +37,7 @@ static int stap_uprobe_change_plus (struct task_struct *tsk, unsigned long reloc if (likely(sups->tfi != tfi)) continue; /* skip probes with an address beyond this map event; should not happen unless a shlib/exec got mmapped in weirdly piecemeal */ - if (likely((vm_flags & VM_EXEC) && ((sups->address >= length) || (sups->sdt_sem_offset >= length)))) continue; + if (likely((vm_flags & VM_EXEC) && sups->address >= length)) continue; /* Found a uprobe_spec for this stap_uprobe_tf. Need to lock the stap_uprobes[] array to allocate a free spot, but then we can @@ -159,7 +159,7 @@ static int stap_uprobe_change_semaphore_plus (struct task_struct *tsk, unsigned _stp_dbug(__FUNCTION__,__LINE__, "+semaphore %#x @ %#lx spec %d idx %d task %d\n", sdt_semaphore, sup->sdt_sem_address, sup->spec_index, i, tsk->tgid); } #endif - rc = put_user (sdt_semaphore, (unsigned short __user*) sup->sdt_sem_address); + rc = put_user (sdt_semaphore, (unsigned short __user*) sup->sdt_sem_address); /* XXX: need to analyze possibility of race condition */ } } diff --git a/testsuite/systemtap.base/sdt_misc.exp b/testsuite/systemtap.base/sdt_misc.exp index 74ebdc4e..3ba38c45 100644 --- a/testsuite/systemtap.base/sdt_misc.exp +++ b/testsuite/systemtap.base/sdt_misc.exp @@ -74,13 +74,13 @@ int main () { #ifdef LOOP + #include + signal (SIGINT, &int_handler); + signal (SIGALRM, &alrm_handler); alarm (30); while (!loop_check()) { } - #include - signal (SIGINT, &int_handler); - signal (SIGALRM, &alrm_handler); #endif bar(2); baz(3,(char*)\"abc\"); @@ -379,6 +379,11 @@ if {$ok == 5} { # 5. Test attaching to a running process with markers in a shared object if { $pbtype_mssg != "kprobe" } { +set loop_flags "additional_flags=-I$srcdir/../includes/sys" +set loop_flags "$loop_flags additional_flags=-I$sdtdir" +set loop_flags "$loop_flags additional_flags=-g" +set loop_flags "$loop_flags additional_flags=-I. $pbtype_flag" +set loop_flags "$loop_flags additional_flags=-DLOOP" set loop_flags "$loop_flags additional_flags=-DONLY_MAIN" set loop_flags "$loop_flags additional_flags=-Wl,-rpath,[pwd]" set loop_flags "$loop_flags additional_flags=-L[pwd] additional_flags=-lsdt-$pbtype_mssg" -- cgit From 27ca40f711f4ab4b0234390443e63b7916a61551 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 15 Jan 2010 16:25:16 -0500 Subject: PR11105: forget about packaging stap-server-request --- systemtap.spec | 1 - 1 file changed, 1 deletion(-) diff --git a/systemtap.spec b/systemtap.spec index 17eff400..3a0a1205 100644 --- a/systemtap.spec +++ b/systemtap.spec @@ -457,7 +457,6 @@ exit 0 %{_libexecdir}/%{name}/stap-stop-server %{_libexecdir}/%{name}/stap-gen-cert %{_libexecdir}/%{name}/stap-server-connect -%{_libexecdir}/%{name}/stap-server-request %{_libexecdir}/%{name}/stap-sign-module %{_mandir}/man8/stap-server.8* %{_mandir}/man8/stap-authorize-server-cert.8* -- cgit From 08d1d520616557f6ff7dd023e260ad6577e9e0e8 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 18 Jan 2010 09:13:30 +0100 Subject: PR11173 Markers get a bad address in prelinked libraries. Our literal_addr_to_sym_addr() function was just wrong. To compensate for raw addresses read from elf (either given by the user or through a mark transformation) we need to know what the elf_bias is (as returned by dwfl_module_getelf) before feeding them to any libdwfl functions. * tapsets.cxx (query_module_dwarf): Always add elf_bias to raw function or statement addresses before calling query_addr(). (query_addr): Don't call literal_addr_to_sym_addr(). * dwflpp.h (literal_addr_to_sym_addr): Removed. * dwflpp.cxx (literal_addr_to_sym_addr): Likewise. --- dwflpp.cxx | 39 --------------------------------------- dwflpp.h | 2 -- tapsets.cxx | 11 +++++++++-- 3 files changed, 9 insertions(+), 43 deletions(-) diff --git a/dwflpp.cxx b/dwflpp.cxx index 7dd31d06..e6fe017d 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -2771,45 +2771,6 @@ dwflpp::relocate_address(Dwarf_Addr dw_addr, string& reloc_section) return reloc_addr; } -/* Converts a "global" literal address to the module symbol address - * space. If necessary (not for kernel and executables using absolute - * addresses), this adjust the address for the current module symbol - * bias. Literal addresses are provided by the user (or contained on - * the .probes section) based on the "on disk" layout of the module. - */ -Dwarf_Addr -dwflpp::literal_addr_to_sym_addr(Dwarf_Addr lit_addr) -{ - if (sess.verbose > 2) - clog << "literal_addr_to_sym_addr 0x" << hex << lit_addr << dec << endl; - - // Assume the address came from the symbol list. - // If we cannot get the symbol bias fall back on the dw bias. - // The kernel (and other absolute executable modules) is special though. - if (module_name != TOK_KERNEL - && dwfl_module_relocations (module) > 0) - { - Dwarf_Addr symbias = ~0; - if (dwfl_module_getsymtab (module) != -1) - dwfl_module_info (module, NULL, NULL, NULL, NULL, - &symbias, NULL, NULL); - - if (sess.verbose > 3) - clog << "symbias 0x" << hex << symbias << dec - << ", dwbias 0x" << hex << module_bias << dec << endl; - - if (symbias == (Dwarf_Addr) ~0) - symbias = module_bias; - - lit_addr += symbias; - } - - if (sess.verbose > 2) - clog << "literal_addr_to_sym_addr ret 0x" << hex << lit_addr << dec << endl; - - return lit_addr; -} - /* Returns the call frame address operations for the given program counter * in the libdw address space. */ diff --git a/dwflpp.h b/dwflpp.h index cdc6ad98..523dd883 100644 --- a/dwflpp.h +++ b/dwflpp.h @@ -284,8 +284,6 @@ struct dwflpp Dwarf_Addr relocate_address(Dwarf_Addr addr, std::string& reloc_section); - Dwarf_Addr literal_addr_to_sym_addr(Dwarf_Addr lit_addr); - private: DwflPtr dwfl_ptr; diff --git a/tapsets.cxx b/tapsets.cxx index 071f92db..d5c6b25e 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -761,6 +761,13 @@ dwarf_query::query_module_dwarf() // number plus the module's bias. Dwarf_Addr addr = has_function_num ? function_num_val : statement_num_val; + + // These are raw addresses, we need to know what the elf_bias + // is to feed it to libdwfl based functions. + Dwarf_Addr elf_bias; + Elf *elf = dwfl_module_getelf (dw.module, &elf_bias); + assert(elf); + addr += elf_bias; query_addr(addr, this); } else @@ -1168,8 +1175,8 @@ query_addr(Dwarf_Addr addr, dwarf_query *q) { dwflpp &dw = q->dw; - // Translate to and actual sumbol address. - addr = dw.literal_addr_to_sym_addr(addr); + if (q->sess.verbose > 2) + clog << "query_addr 0x" << hex << addr << dec << endl; // First pick which CU contains this address Dwarf_Die* cudie = dw.query_cu_containing_address(addr); -- cgit