]> sourceware.org Git - systemtap.git/commitdiff
Always emit .probes section; use .label method as a backup strategy
authorStan Cox <scox@redhat.com>
Wed, 18 Feb 2009 23:00:42 +0000 (18:00 -0500)
committerStan Cox <scox@redhat.com>
Wed, 18 Feb 2009 23:00:42 +0000 (18:00 -0500)
ChangeLog
dtrace
includes/sys/sdt.h
tapsets.cxx
testsuite/ChangeLog
testsuite/systemtap.base/static_uprobes.exp

index 3cad046ef72bf3846a48bac48a2ce42dec4ceffc..1f44c6dee8316171e00cdb9f370f9ce81b031981 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-02-18  Stan Cox  <scox@redhat.com>
+
+       * tapsets.cxx (dwarf_builder::build): If not found in .probes, use .label
+       * includes/sys/sdt.h (STAP_PROBE): Always create .probes section.
+       * dtrace: Use basename of -s if no -o given.
+
 2009-02-18  Josh Stone  <jistone@redhat.com>
 
        * loc2c.c (c_translate_argument): Create a dummy location to start
diff --git a/dtrace b/dtrace
index 46da93a8117ec073121fd02b3ef9260a84895957..d6d5ce21c1920cdb2a82a4557c4e534668736f4f 100755 (executable)
--- a/dtrace
+++ b/dtrace
@@ -60,7 +60,7 @@ class provider:
                 if (len(new_args) > 0):
                     self.arglist[this_probe] = ('%s arg%d' % (new_args, c))
                 if (len(new_args) == 0):
-                    self.h.write ('#define %s STAP_PROBE(provider,%s)\n' % (this_probe_canon, this_probe))
+                    self.h.write ('#define %s() STAP_PROBE(provider,%s)\n' % (this_probe_canon, this_probe))
                 elif (c == 0):
                     self.h.write ('#define %s(arg1) STAP_PROBE%d(provider,%s,arg1)\n' % (this_probe_canon, c+1, this_probe))
                 elif (c == 1):
@@ -125,6 +125,7 @@ if (build_header == False and build_source == False):
 if (filename == ""):
     if (s_filename != ""):
        (filename,ext) = os.path.splitext(s_filename)
+        filename = os.path.basename(filename)
        if (build_header):
            filename = filename + ".h"
        elif (build_source):
index 2eb4799066b7079bc8dd984208dfe68ecfb21cfb..d68fed6c64aa5d6aa9797b868e9558c793715a14 100644 (file)
@@ -6,6 +6,9 @@
 // Public License (GPL); either version 2, or (at your option) any
 // later version.
 
+#ifndef _SYS_SDT_H
+#define _SYS_SDT_H    1
+
 #include <string.h>
 
 #if _LP64
@@ -18,8 +21,6 @@
 
 #define STAP_SENTINEL 0x31425250
 
-// g++ 4.3.2 doesn't emit DW_TAG_label
-#ifdef __cplusplus
 #define STAP_PROBE_STRUCT(probe,argc)  \
 struct _probe_ ## probe                                \
 {                                              \
@@ -31,20 +32,10 @@ static char probe ## _ ## probe_name [strlen(#probe)+1]     \
        __attribute__ ((section (".probes")))   \
        = #probe;                               \
 static volatile struct _probe_ ## probe _probe_ ## probe __attribute__ ((section (".probes"))) = {STAP_SENTINEL,(size_t)& probe ## _ ## probe_name[0],argc};
-#else
-#define STAP_PROBE_STRUCT(probe,argc)  
-#endif
 
-#ifdef __cplusplus
 #define STAP_LABEL_REF(probe) \
   if (__builtin_expect(_probe_ ## probe.probe_type < 0, 0)) \
     goto STAP_LABEL(probe,__LINE__);
-#else
-#define STAP_LABEL_REF(probe)          \
-  volatile static int sentinel_ ## probe = 0;  \
-  if (__builtin_expect(sentinel_ ## probe < 0, 0)) \
-    goto STAP_LABEL(probe,__LINE__);
-#endif
 
 #define STAP_CONCAT(a,b) a ## b
 #define STAP_LABEL(p,n) \
@@ -178,3 +169,5 @@ STAP_PROBE7(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7)
 STAP_PROBE8(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8) 
 #define DTRACE_PROBE9(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9) \
 STAP_PROBE9(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9) 
+
+#endif /* sys/sdt.h */
index 6ce574f05253d47ce4030bdbd5a3e463bcd16026..78d5a5b3f00bba566e752987440cb8a804824257 100644 (file)
@@ -5705,6 +5705,7 @@ dwarf_builder::build(systemtap_session & sess,
     Elf* elf = dwfl_module_getelf (dw->module, &bias);
     size_t shstrndx;
     Elf_Scn *probe_scn = NULL;
+    bool probe_found = false;
 
     dwfl_assert ("getshstrndx", elf_getshstrndx (elf, &shstrndx));
     GElf_Shdr *shdr = NULL;
@@ -5748,7 +5749,10 @@ dwarf_builder::build(systemtap_session & sess,
              probe_scn_offset += sizeof(__uint64_t) - (probe_scn_offset % sizeof(__uint64_t));
            probe_arg = *((__uint64_t*)((char*)pdata->d_buf + probe_scn_offset));
            if (strcmp (location->components[1]->arg->tok->content.c_str(), probe_name.c_str()) == 0)
-             break;
+             {
+               probe_found = true;
+               break;
+             }
            if (probe_scn_offset % (sizeof(__uint64_t)*2))
              probe_scn_offset = (probe_scn_offset + sizeof(__uint64_t)*2) - (probe_scn_offset % (sizeof(__uint64_t)*2));
          }
@@ -5756,7 +5760,8 @@ dwarf_builder::build(systemtap_session & sess,
        location->components[1]->arg = new literal_number((int)probe_arg);
        ((literal_map_t&)parameters)[TOK_STATEMENT] = location->components[1]->arg;
       }
-    else if (probe_type == dwarf_no_probes)
+
+    if (probe_type == dwarf_no_probes || ! probe_found)
       {
        location->components[1]->functor = TOK_FUNCTION;
        location->components[1]->arg = new literal_string("*");
index 2a2dcd7927572edc59cb79f60977c95195061320..65244185f930f9ec9dd462416c4edc924e622471 100644 (file)
@@ -1,8 +1,11 @@
+2009-02-18  Stan Cox  <scox@redhat.com>
+
+       * systemtap.base/static_uprobes.exp: Also test without .probes section.
+
 2009-02-18  David Smith  <dsmith@redhat.com>
 
        * systemtap.base/static_uprobes.exp: Handles errors from running
        'dtrace' python script better.
-
        * systemtap.base/labels.exp: Better cleanup.
 
 2009-02-17  Frank Ch. Eigler  <fche@elastic.org>
index 64cb64347b18ec6b74fa869a64f8a35aff7a37d4..d80bd0c4424068b8c1faa994840fb682fab036ed 100644 (file)
@@ -4,6 +4,7 @@ set test "sduprobes"
 # Compile a C program to use as the user-space probing target
 set sup_srcpath "[pwd]/static_uprobes.c"
 set sup_exepath "[pwd]/static_uprobes.x"
+set supcplus_exepath "[pwd]/static_uprobes_cplus.x"
 set fp [open $sup_srcpath "w"]
 puts $fp "
 #include <stdlib.h>
@@ -117,7 +118,7 @@ if { $res != "" } {
 spawn mv $sup_srcpath "[pwd]/static_uprobes.cc"
 set sup_srcpath "[pwd]/static_uprobes.cc"
 set sup_flags "$sup_flags c++"
-set res [target_compile $sup_srcpath $sup_exepath executable $sup_flags]
+set res [target_compile $sup_srcpath $supcplus_exepath executable $sup_flags]
 if { $res != "" } {
     verbose "target_compile failed: $res" 2
     fail "compiling $sup_srcpath -g"
@@ -162,6 +163,7 @@ if {$ok == 4} { pass "$test" } { fail "$test ($ok)" }
 
 set ok 0
 
+spawn objcopy -R .probes $supcplus_exepath $sup_exepath 
 verbose -log "spawn stap -c $sup_exepath $sup_stppath"
 spawn stap -c $sup_exepath $sup_stppath
 expect {
@@ -178,4 +180,4 @@ expect {
 wait
 
 if {$ok == 4} { pass "$test" } { fail "$test ($ok)" }
-catch {exec rm -f $sup_srcpath $sup_exepath $sup_hpath $sup_stppath}
+catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_hpath $sup_stppath}
This page took 0.050498 seconds and 5 git commands to generate.