summaryrefslogtreecommitdiffstats
path: root/dwflpp.cxx
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2009-11-17 10:10:31 +0100
committerMark Wielaard <mjw@redhat.com>2009-11-17 10:10:31 +0100
commitf685b2fea262d1e517d75d69c84ec0d1edea6cf0 (patch)
tree825dd34bbe400170a5446fa87d5d60e811d2a665 /dwflpp.cxx
parent110a589704c72327ba80aaf75bff496a6b6334f6 (diff)
downloadsystemtap-steved-f685b2fea262d1e517d75d69c84ec0d1edea6cf0.tar.gz
systemtap-steved-f685b2fea262d1e517d75d69c84ec0d1edea6cf0.tar.xz
systemtap-steved-f685b2fea262d1e517d75d69c84ec0d1edea6cf0.zip
Remove caching of emit_address for kernel modules and shared libraries.
Caching of the address is only safe for kernel addresses that can never change. For kernel module or dynamic shared library addresses it isn't safe to cache the address since they can be unloaded, reloaded or mapped differently in separate executables. * dwflpp.cxx (emit_address): Remove static from addr definition for kernel and dynamic modules.
Diffstat (limited to 'dwflpp.cxx')
-rw-r--r--dwflpp.cxx11
1 files changed, 7 insertions, 4 deletions
diff --git a/dwflpp.cxx b/dwflpp.cxx
index 35637568..53f3d8eb 100644
--- a/dwflpp.cxx
+++ b/dwflpp.cxx
@@ -1484,8 +1484,8 @@ dwflpp::emit_address (struct obstack *pool, Dwarf_Addr address)
{
// This gives us the module name, and section name within the
// module, for a kernel module (or other ET_REL module object).
- obstack_printf (pool, "({ static unsigned long addr = 0; ");
- obstack_printf (pool, "if (addr==0) addr = _stp_module_relocate (\"%s\",\"%s\",%#" PRIx64 "); ",
+ obstack_printf (pool, "({ unsigned long addr = 0; ");
+ obstack_printf (pool, "addr = _stp_module_relocate (\"%s\",\"%s\",%#" PRIx64 "); ",
modname, secname, reloc_address);
obstack_printf (pool, "addr; })");
}
@@ -1495,6 +1495,9 @@ dwflpp::emit_address (struct obstack *pool, Dwarf_Addr address)
// need to treat the same way here as dwarf_query::add_probe_point does: _stext.
address -= sess.sym_stext;
secname = "_stext";
+ // Note we "cache" the result here through a static because the
+ // kernel will never move after being loaded (unlike modules and
+ // user-space dynamic share libraries).
obstack_printf (pool, "({ static unsigned long addr = 0; ");
obstack_printf (pool, "if (addr==0) addr = _stp_module_relocate (\"%s\",\"%s\",%#" PRIx64 "); ",
modname, secname, address); // PR10000 NB: not reloc_address
@@ -1503,8 +1506,8 @@ dwflpp::emit_address (struct obstack *pool, Dwarf_Addr address)
else
{
enable_task_finder (sess);
- obstack_printf (pool, "({ static unsigned long addr = 0; ");
- obstack_printf (pool, "if (addr==0) addr = _stp_module_relocate (\"%s\",\"%s\",%#" PRIx64 "); ",
+ obstack_printf (pool, "({ unsigned long addr = 0; ");
+ obstack_printf (pool, "addr = _stp_module_relocate (\"%s\",\"%s\",%#" PRIx64 "); ",
modname, ".dynamic", reloc_address);
obstack_printf (pool, "addr; })");
}