]> sourceware.org Git - systemtap.git/commitdiff
2005-08-22 Frank Ch. Eigler <fche@elastic.org>
authorfche <fche>
Mon, 22 Aug 2005 19:14:35 +0000 (19:14 +0000)
committerfche <fche>
Mon, 22 Aug 2005 19:14:35 +0000 (19:14 +0000)
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.

ChangeLog
elaborate.h
tapsets.cxx

index 56df0301a9b718c7acaba2b161d31f2fad2b1764..d5b8d033b2c806e3233b2434def188c49d769df3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-08-22  Frank Ch. Eigler  <fche@elastic.org>
+
+       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.
+
 2005-08-21  Frank Ch. Eigler  <fche@redhat.com>
 
        PR systemtap/1195, systemtap/1193
index c3c35fee631f0853e8367dacf9127f472137365f..43816e61a64f66560d1c2668d160c5840921954f 100644 (file)
@@ -231,6 +231,9 @@ struct systemtap_session
   std::vector<derived_probe*> probes;
   std::vector<embeddedcode*> embeds;
 
+  // module-referencing file handles
+  std::map<std::string,int> module_fds;
+
   // unparser data
   translator_output* op;
   unparser* up;
index 43f18c663eaeca1426c09c0027f6407b30fb2f5d..34834033318f0eb9c7e4b74821f6fe91fa60e718 100644 (file)
@@ -22,6 +22,7 @@
 #include <cstdarg>
 
 extern "C" {
+#include <fcntl.h>
 #include <elfutils/libdwfl.h>
 #include <elfutils/libdw.h>
 #include <dwarf.h>
@@ -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<probe_point::component*> comps;
   comps.push_back
This page took 0.038969 seconds and 5 git commands to generate.