]> sourceware.org Git - systemtap.git/commitdiff
stapdyn: separate enter_dyninst_uprobe_regs
authorJosh Stone <jistone@redhat.com>
Wed, 22 May 2013 23:14:18 +0000 (16:14 -0700)
committerJosh Stone <jistone@redhat.com>
Wed, 22 May 2013 23:14:18 +0000 (16:14 -0700)
That function calls enter_dyninst_uprobe, which is only defined when
uprobes are active, so we have a weak binding in place.  By instead
splitting this into a new file, which is only included when uprobes are
known to be active, it doesn't need the weak reference.

runtime/dyninst/uprobes-regs.c [new file with mode: 0644]
runtime/dyninst/uprobes.c
tapsets.cxx

diff --git a/runtime/dyninst/uprobes-regs.c b/runtime/dyninst/uprobes-regs.c
new file mode 100644 (file)
index 0000000..cd6d2ea
--- /dev/null
@@ -0,0 +1,67 @@
+/* -*- linux-c -*-
+ * function for preparing registers for dyninst-based uprobes
+ * Copyright (C) 2012-2013 Red Hat Inc.
+ *
+ * This file is part of systemtap, and is free software.  You can
+ * redistribute it and/or modify it under the terms of the GNU General
+ * Public License (GPL); either version 2, or (at your option) any
+ * later version.
+ */
+
+#ifndef _UPROBES_REGS_DYNINST_C_
+#define _UPROBES_REGS_DYNINST_C_
+
+int enter_dyninst_uprobe_regs(uint64_t index, unsigned long nregs, ...)
+{
+       struct pt_regs regs = {0};
+
+       va_list varegs;
+       va_start(varegs, nregs);
+
+#ifdef __i386__
+       // XXX Dyninst currently has a bug where it's only passing a 32-bit
+       // index, which means nregs gets stuffed into the upper bits of index,
+       // and the varegs are all off by one.  Hacking it into shape for now...
+       if (index > UINT32_MAX) {
+               SET_REG_IP((&regs), nregs);
+                nregs = index >> 32;
+                index &= UINT32_MAX;
+        } else
+#endif
+       if (likely(nregs > 0))
+               SET_REG_IP((&regs), va_arg(varegs, unsigned long));
+
+       /* NB: pt_regs_store_register() expects literal register numbers to
+        * paste as CPP tokens, so unfortunately this has to be unrolled.  */
+#define SET_REG(n) if (likely(n < nregs - 1)) \
+                       pt_regs_store_register((&regs), n, \
+                                       va_arg(varegs, unsigned long))
+#if defined(__i386__) || defined(__x86_64__)
+       SET_REG(0);
+       SET_REG(1);
+       SET_REG(2);
+       SET_REG(3);
+       SET_REG(4);
+       SET_REG(5);
+       SET_REG(6);
+       SET_REG(7);
+#endif
+#if defined(__x86_64__)
+       SET_REG(8);
+       SET_REG(9);
+       SET_REG(10);
+       SET_REG(11);
+       SET_REG(12);
+       SET_REG(13);
+       SET_REG(14);
+       SET_REG(15);
+#endif
+#undef SET_REG
+
+       va_end(varegs);
+
+        return enter_dyninst_uprobe(index, &regs);
+}
+
+#endif /* _UPROBES_REGS_DYNINST_C_ */
+
index a94208c9cac5df2fc0954a20b5e7c591c0dddbe9..38254aeefa2f0f76b60944ae6dc9dba10ccc0589 100644 (file)
@@ -71,62 +71,5 @@ uint64_t stp_dyninst_probe_flags(uint64_t index)
        return stapdu_probes[index].flags;
 }
 
-int enter_dyninst_uprobe(uint64_t index, struct pt_regs *regs)
-       __attribute__((weak));
-
-int enter_dyninst_uprobe_regs(uint64_t index, unsigned long nregs, ...)
-{
-       struct pt_regs regs = {0};
-
-       va_list varegs;
-       va_start(varegs, nregs);
-
-#ifdef __i386__
-       // XXX Dyninst currently has a bug where it's only passing a 32-bit
-       // index, which means nregs gets stuffed into the upper bits of index,
-       // and the varegs are all off by one.  Hacking it into shape for now...
-       if (index > UINT32_MAX) {
-               SET_REG_IP((&regs), nregs);
-                nregs = index >> 32;
-                index &= UINT32_MAX;
-        } else
-#endif
-       if (nregs > 0)
-               SET_REG_IP((&regs), va_arg(varegs, unsigned long));
-
-       /* NB: pt_regs_store_register() expects literal register numbers to
-        * paste as CPP tokens, so unfortunately this has to be unrolled.  */
-#define SET_REG(n) if (n < nregs - 1) \
-                       pt_regs_store_register((&regs), n, \
-                                       va_arg(varegs, unsigned long))
-#if defined(__i386__) || defined(__x86_64__)
-       SET_REG(0);
-       SET_REG(1);
-       SET_REG(2);
-       SET_REG(3);
-       SET_REG(4);
-       SET_REG(5);
-       SET_REG(6);
-       SET_REG(7);
-#endif
-#if defined(__x86_64__)
-       SET_REG(8);
-       SET_REG(9);
-       SET_REG(10);
-       SET_REG(11);
-       SET_REG(12);
-       SET_REG(13);
-       SET_REG(14);
-       SET_REG(15);
-#endif
-#undef SET_REG
-
-       va_end(varegs);
-
-       if (enter_dyninst_uprobe)
-               return enter_dyninst_uprobe(index, &regs);
-       return -1;
-}
-
 #endif /* _UPROBES_DYNINST_C_ */
 
index d04d9d34ab2dcdb563339a8d4534347d3b020fc0..04ff3490ee2b12704f30ddd9731d77754343e29d 100644 (file)
@@ -7889,6 +7889,7 @@ uprobe_derived_probe_group::emit_module_dyninst_decls (systemtap_session& s)
   common_probe_entryfn_epilogue (s, true);
   s.op->newline() << "return 0;";
   s.op->newline(-1) << "}";
+  s.op->newline() << "#include \"dyninst/uprobes-regs.c\"";
   s.op->assert_0_indent();
 }
 
This page took 0.038937 seconds and 5 git commands to generate.