summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStan Cox <scox@redhat.com>2009-02-18 18:00:42 -0500
committerStan Cox <scox@redhat.com>2009-02-18 18:00:42 -0500
commit59b2ec52534f90cf22a741cfb482b36f9dcb6a78 (patch)
treef0329c6e254038b5cd0a967dd662c477a9c30772
parent37d42f2a8792be9c25a71b2ad6b4c55252a1b204 (diff)
downloadsystemtap-steved-59b2ec52534f90cf22a741cfb482b36f9dcb6a78.tar.gz
systemtap-steved-59b2ec52534f90cf22a741cfb482b36f9dcb6a78.tar.xz
systemtap-steved-59b2ec52534f90cf22a741cfb482b36f9dcb6a78.zip
Always emit .probes section; use .label method as a backup strategy
-rw-r--r--ChangeLog6
-rwxr-xr-xdtrace3
-rw-r--r--includes/sys/sdt.h17
-rw-r--r--tapsets.cxx9
-rw-r--r--testsuite/ChangeLog5
-rw-r--r--testsuite/systemtap.base/static_uprobes.exp6
6 files changed, 28 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 3cad046e..1f44c6de 100644
--- 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 46da93a8..d6d5ce21 100755
--- 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):
diff --git a/includes/sys/sdt.h b/includes/sys/sdt.h
index 2eb47990..d68fed6c 100644
--- a/includes/sys/sdt.h
+++ b/includes/sys/sdt.h
@@ -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 */
diff --git a/tapsets.cxx b/tapsets.cxx
index 6ce574f0..78d5a5b3 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -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("*");
diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog
index 2a2dcd79..65244185 100644
--- a/testsuite/ChangeLog
+++ b/testsuite/ChangeLog
@@ -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>
diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp
index 64cb6434..d80bd0c4 100644
--- a/testsuite/systemtap.base/static_uprobes.exp
+++ b/testsuite/systemtap.base/static_uprobes.exp
@@ -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}