summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfche <fche>2005-11-03 21:20:52 +0000
committerfche <fche>2005-11-03 21:20:52 +0000
commit703621ae2cb0bec9cc12786f33381dbb890b9251 (patch)
tree25fa3746c1d2c60071a784e75feaa1d6b037da25
parent3c9dd85f7066ec8fe086c83c40ec4d4f70fd2128 (diff)
downloadsystemtap-steved-703621ae2cb0bec9cc12786f33381dbb890b9251.tar.gz
systemtap-steved-703621ae2cb0bec9cc12786f33381dbb890b9251.tar.xz
systemtap-steved-703621ae2cb0bec9cc12786f33381dbb890b9251.zip
2005-11-03 Frank Ch. Eigler <fche@elastic.org>
PR 1329. * tapsets.cxx (dwarf_query::add_probe_point): Look up section name containing given address. Skip request if it came from .init.*. * testsuite/semko/thirtytwo.stp: New test.
-rw-r--r--ChangeLog7
-rw-r--r--tapsets.cxx39
-rwxr-xr-xtestsuite/semko/thirtytwo.stp4
3 files changed, 50 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 260cc2fd..df1c6b5a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-11-03 Frank Ch. Eigler <fche@elastic.org>
+
+ PR 1329.
+ * tapsets.cxx (dwarf_query::add_probe_point): Look up section name
+ containing given address. Skip request if it came from .init.*.
+ * testsuite/semko/thirtytwo.stp: New test.
+
2005-11-02 Martin Hunt <hunt@redhat.com>
* Makefile.am (EXTRA_DIST): Add session.h.
diff --git a/tapsets.cxx b/tapsets.cxx
index f9969434..ede2092f 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -1635,6 +1635,7 @@ target_variable_flavour_calculating_visitor::visit_target_symbol (target_symbol
}
}
+
void
dwarf_query::add_probe_point(string const & funcname,
char const * filename,
@@ -1644,6 +1645,44 @@ dwarf_query::add_probe_point(string const & funcname,
{
dwarf_derived_probe *probe = NULL;
+ // Check whether the given address points into an .init section,
+ // which will have been unmapped by the kernel by the time we get to
+ // insert the probe. In this case, just ignore this call.
+ Dwarf_Addr baseaddr;
+ Elf* elf = dwfl_module_getelf (dw.module, & baseaddr);
+ Dwarf_Addr rel_addr = addr - baseaddr;
+ if (elf)
+ {
+ // Iterate through section headers to find which one
+ // contains the given rel_addr.
+ Elf_Scn* scn = 0;
+ size_t shstrndx;
+ dw.dwfl_assert ("getshstrndx", elf_getshstrndx (elf, &shstrndx));
+ while (scn = elf_nextscn (elf, scn))
+ {
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (! shdr) continue; // XXX error?
+
+ // check for address inclusion
+ GElf_Addr start = shdr->sh_addr;
+ GElf_Addr end = start + shdr->sh_size;
+ if (! (rel_addr >= start && rel_addr < end))
+ continue;
+
+ // check for section name
+ const char* name = elf_strptr (elf, shstrndx, shdr->sh_name);
+ if (name && strncmp (name, ".init.", 6) == 0)
+ {
+ if (sess.verbose)
+ clog << "skipping function '" << funcname << "' base 0x"
+ << hex << addr << dec << " is within section '"
+ << name << "'" << endl;
+ return;
+ }
+ }
+ }
+
if (probe_has_no_target_variables)
{
assert(probe_flavours.size() == 1);
diff --git a/testsuite/semko/thirtytwo.stp b/testsuite/semko/thirtytwo.stp
new file mode 100755
index 00000000..f2fae56d
--- /dev/null
+++ b/testsuite/semko/thirtytwo.stp
@@ -0,0 +1,4 @@
+#! stap -p2
+
+// should fail since init_setup should be skipped because it is in .init.text
+probe kernel.function("init_setup") { }