From df8fadee215f81b07f809f4d3ebb016e390f2c9b Mon Sep 17 00:00:00 2001 From: fche Date: Mon, 22 Aug 2005 19:14:35 +0000 Subject: 2005-08-22 Frank Ch. Eigler PR systemtap/1134 * elaborate.h (module_fds): New member in systemtap_session. * tapsets.cxx (dwarf_derived_probe ctor): Open /sys/module/$MOD/.text for the duration of a systemtap session, to lock module in memory. --- tapsets.cxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index 43f18c66..34834033 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -22,6 +22,7 @@ #include extern "C" { +#include #include #include #include @@ -1484,6 +1485,22 @@ dwarf_derived_probe::dwarf_derived_probe (dwarf_query & q, module_bias(q.dw.module_bias), has_return (q.has_return) { + // Lock the kernel module in memory. + if (module_name != TOK_KERNEL) + { + // XXX: There is a race window here, between the time that libdw + // opened up this same file for its relocation duties, and now. + int fd = q.sess.module_fds[module_name]; + if (fd == 0) + { + string sys_module = "/sys/module/" + module_name + "/sections/.text"; + fd = open (sys_module.c_str(), O_RDONLY); + if (fd < 0) + throw semantic_error ("error opening module refcount-bumping file."); + q.sess.module_fds[module_name] = fd; + } + } + // first synthesize an "expanded" location vector comps; comps.push_back -- cgit