summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStan Cox <scox@redhat.com>2009-01-22 14:23:49 -0500
committerStan Cox <scox@redhat.com>2009-01-22 14:23:49 -0500
commitc1008fd01d322bb12e66cb8dc513d488082777a4 (patch)
tree85845768afe0984b6ac6cff7a6f8d2248e0a0b3f
parent457d4c2f5266962f622197fcd16ac30b7d6fe685 (diff)
downloadsystemtap-steved-c1008fd01d322bb12e66cb8dc513d488082777a4.tar.gz
systemtap-steved-c1008fd01d322bb12e66cb8dc513d488082777a4.tar.xz
systemtap-steved-c1008fd01d322bb12e66cb8dc513d488082777a4.zip
Add dtrace -h support
-rw-r--r--ChangeLog7
-rwxr-xr-xdtrace174
-rw-r--r--runtime/sdt.h112
-rw-r--r--tapsets.cxx23
-rw-r--r--testsuite/ChangeLog4
-rw-r--r--testsuite/systemtap.base/static_uprobes.exp80
6 files changed, 287 insertions, 113 deletions
diff --git a/ChangeLog b/ChangeLog
index d4896029..68887086 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-01-22 Stan Cox <scox@redhat.com>
+
+ * dtrace: Rewritten to handle dtrace -h -G
+ * runtime/sdt.h: New .probes layout. Make labels unique, args unused.
+ * tapsets.cxx (dwarf_builder::build): New .probes layout.
+ Don't reset location->components[0].
+
2009-01-21 Mark Wielaard <mjw@redhat.com>
* configure.ac: Create PIECFLAGS and PIECXXFLAGS, like PIELDFLAGS.
diff --git a/dtrace b/dtrace
index b8a1237e..1eb53bf9 100755
--- a/dtrace
+++ b/dtrace
@@ -1,35 +1,145 @@
-# This is a stub to handle a Makefile which does:
+#!/usr/bin/python
+
+# This handles the systemtap equivalent of
# $(DTRACE) $(DTRACEFLAGS) -G -s $^ -o $@
+# $(DTRACE) $(DTRACEFLAGS) -h -s $^ -o $@
# which is a step that builds DTrace provider and probe definitions
-usage() {
-echo "Usage $0 -s file.d {-o file} file1.o file2.o ..."
-}
-
-if [ -z "$1" ] ; then
- usage
- exit
-fi
-while test ! -z "$1" ; do
- if [ $(expr "$1" : "-o") -gt 0 ] ; then
- shift
- filename=$1
- elif [ $(expr "$1" : "-s") -gt 0 ] ; then
- shift
- s_filename=$1
- fi
- shift
-done
-
-if [ -z "$filename" ] ; then
- if [ ! -z "$s_filename" ] ; then
- filename=$(basename $s_filename .d).o
- else
- usage
- exit
- fi
-fi
-
-echo "_dtrace_ () {}" >| /tmp/$$.c
-gcc -c /tmp/$$.c -o $filename
-rm /tmp/$$.c
+# Copyright (C) 2009 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.
+
+import os,posix,sys
+from subprocess import *
+
+class provider:
+ arglist = dict()
+ def open(self, provider, header):
+ have_provider = False
+ self.f = open(provider)
+ self.h = open(header,mode='w')
+ self.h.write("// Generated by /usr/bin/dtrace\n")
+ self.h.write("\n#include <sys/sdt.h>\n\n")
+ in_comment = False
+ while (True):
+ line = self.f.readline()
+ if (line == ""):
+ break
+ if (line.find("/*") >= 0):
+ in_comment = True
+ if (line.find("*/") >= 0):
+ in_comment = False
+ continue
+ if (in_comment):
+ continue
+ if (line.find("provider") >= 0):
+ tokens = line.split()
+ have_provider = True
+ self.provider = tokens[1]
+ elif (have_provider and line.find("probe ") > 0):
+ while (line.find(")") < 0):
+ line += self.f.readline()
+ this_probe = line[line.find("probe ")+5:line.find("(")].strip()
+ this_probe_canon = self.provider.upper() + "_" + this_probe.replace("__","_").upper()
+ args = (line[line.find("(")+1:line.find(")")])
+ new_args = ""
+ i = 0
+ c = 0
+ self.arglist[this_probe] = ""
+ while (i < len(args)):
+ if (args[i:i+1] == ","):
+ new_args = ('%s%s' % (new_args, args[i]))
+ c += 1
+ else:
+ new_args = new_args + args[i]
+ i += 1
+ 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))
+ 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):
+ self.h.write ('#define %s(arg1,arg2) STAP_PROBE%d(provider,%s,arg1,arg2)\n' % (this_probe_canon, c+1, this_probe))
+ elif (c == 2):
+ self.h.write ('#define %s(arg1,arg2,arg3) STAP_PROBE%d(provider,%s,arg1,arg2,arg3)\n' % (this_probe_canon, c+1, this_probe))
+ elif (c == 3):
+ self.h.write ('#define %s(arg1,arg2,arg3,arg4) STAP_PROBE%d(provider,%s,arg1,arg2,arg3,arg4)\n' % (this_probe_canon, c+1, this_probe))
+ elif (c == 4):
+ self.h.write ('#define %s(arg1,arg2,arg3,arg4,arg5) STAP_PROBE%d(provider,%s,arg1,arg2,arg3,arg4,arg5)\n' % (this_probe_canon, c+1, this_probe))
+ elif (c == 5):
+ self.h.write ('#define %s(arg1,arg2,arg3,arg4,arg5,arg6) STAP_PROBE%d(provider,%s,arg1,arg2,arg3,arg4,arg5,arg6)\n' % (this_probe_canon, c+1, this_probe))
+ self.h.write ('#define %s_ENABLED() 1\n' % this_probe_canon)
+
+ def get(self, arg):
+ print arg
+ if (arg in self.arglist):
+ return self.arglist[arg]
+ else:
+ return ""
+########################################################################
+# main
+########################################################################
+
+def usage ():
+ print "Usage " + sys.argv[0] + "[-h | -G] -s File.d -o File {Files}"
+ sys.exit(1)
+
+def open_file (arg):
+ if (len (sys.argv) <= arg):
+ return False
+ try:
+ file = open(sys.argv[arg], 'r')
+ except IOError:
+ print (sys.argv[arg] + " not found")
+ sys.exit(1)
+ return file
+
+if (len (sys.argv) < 2):
+ usage()
+
+i = 1
+build_header = False
+build_source = False
+filename = ""
+while (i < len (sys.argv)):
+ if (sys.argv[i] == "-o"):
+ i += 1
+ filename = sys.argv[i]
+ elif (sys.argv[i] == "-s"):
+ i += 1
+ s_filename = sys.argv[i]
+ elif (sys.argv[i] == "-h"):
+ build_header = True
+ elif (sys.argv[i] == "-G"):
+ build_source = True
+ i += 1
+# print build_header == False and build_source == False
+if (build_header == False and build_source == False):
+ usage()
+ sys.exit(1)
+
+if (filename == ""):
+ if (s_filename != ""):
+ filename = s_filename.replace(".d","")
+ else:
+ usage
+ sys.exit(1)
+
+if (build_header):
+ providers = provider()
+ providers.open(s_filename, filename + ".h")
+elif (build_source):
+ fn = "/tmp/" + os.path.basename(s_filename).replace(".d", ".c")
+ f = open(fn,mode='w')
+ f.write("static __dtrace () {}\n")
+ f.close()
+ call("gcc -fPIC -c " + fn + " -o " + filename + ".o", shell=True)
+ f.close()
+ os.remove(fn)
+
+
+
diff --git a/runtime/sdt.h b/runtime/sdt.h
index 17c1be71..9fe7b176 100644
--- a/runtime/sdt.h
+++ b/runtime/sdt.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2005-2008 Red Hat Inc.
+// Copyright (C) 2005-2009 Red Hat Inc.
// Copyright (C) 2006 Intel Corporation.
//
// This file is part of systemtap, and is free software. You can
@@ -16,14 +16,23 @@
long arg __attribute__ ((aligned(8)));
#endif
+#define STAP_SENTINEL 0x31425250
+
#define STAP_PROBE_STRUCT(probe,type,argc) \
struct _probe_ ## probe \
{ \
- char probe_name [strlen(#probe)+1]; \
- int probe_type; \
+ int probe_type; \
+ char *probe_name; \
STAP_PROBE_STRUCT_ARG (probe_arg); \
}; \
- static volatile struct _probe_ ## probe _probe_ ## probe __attribute__ ((section (".probes"))) = {#probe,type,argc};
+static char probe_name [strlen(#probe)+1] \
+ __attribute__ ((section (".probes"))) \
+ = #probe; \
+static volatile struct _probe_ ## probe _probe_ ## probe __attribute__ ((section (".probes"))) = {STAP_SENTINEL,&probe_name[0],argc};
+
+#define STAP_CONCAT(a,b) a ## b
+#define STAP_LABEL(p,n) \
+ STAP_CONCAT(_probe_ ## p ## _, n)
// The goto _probe_ prevents the label from "drifting"
#ifdef USE_STAP_PROBE
@@ -32,42 +41,40 @@ struct _probe_ ## probe \
_stap_probe_0 (_probe_ ## probe.probe_name);
#else
#define STAP_PROBE(provider,probe) \
-_probe_ ## probe: \
+STAP_LABEL(probe,__LINE__): \
asm volatile ("nop"); \
- STAP_PROBE_STRUCT(probe,1,(size_t)&& _probe_ ## probe) \
+ STAP_PROBE_STRUCT(probe,1,(size_t)&& STAP_LABEL(probe,__LINE__)) \
if (__builtin_expect(_probe_ ## probe.probe_type < 0, 0)) \
- goto _probe_ ## probe;
+ goto STAP_LABEL(probe,__LINE__);
#endif
-
#ifdef USE_STAP_PROBE
#define STAP_PROBE1(provider,probe,arg1) \
STAP_PROBE_STRUCT(probe,0,1) \
_stap_probe_1 (_probe_ ## probe.probe_name,(size_t)arg1);
#else
#define STAP_PROBE1(provider,probe,parm1) \
- {volatile typeof(parm1) arg1 = parm1; \
-_probe_ ## probe: \
+ {volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \
+STAP_LABEL(probe,__LINE__): \
asm volatile ("nop" :: "r"(arg1)); \
- STAP_PROBE_STRUCT(probe,1,(size_t)&& _probe_ ## probe) \
+ STAP_PROBE_STRUCT(probe,1,(size_t)&& STAP_LABEL(probe,__LINE__)) \
if (__builtin_expect(_probe_ ## probe.probe_type < 0, 0)) \
- goto _probe_ ## probe;}
+ goto STAP_LABEL(probe,__LINE__);}
#endif
-
#ifdef USE_STAP_PROBE
#define STAP_PROBE2(provider,probe,arg1,arg2) \
STAP_PROBE_STRUCT(probe,0,2) \
_stap_probe_2 (_probe_ ## probe.probe_name,(size_t)arg1,(size_t)arg2);
#else
#define STAP_PROBE2(provider,probe,parm1,parm2) \
- {volatile typeof(parm1) arg1 = parm1; \
- volatile typeof(parm2) arg2 = parm2; \
-_probe_ ## probe: \
+ {volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \
+ volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \
+STAP_LABEL(probe,__LINE__): \
asm volatile ("nop" :: "r"(arg1), "r"(arg2)); \
- STAP_PROBE_STRUCT(probe,1,(size_t)&& _probe_ ## probe)\
+ STAP_PROBE_STRUCT(probe,1,(size_t)&& STAP_LABEL(probe,__LINE__)) \
if (__builtin_expect(_probe_ ## probe.probe_type < 0, 0)) \
- goto _probe_ ## probe;}
+ goto STAP_LABEL(probe,__LINE__);}
#endif
#ifdef USE_STAP_PROBE
@@ -76,14 +83,14 @@ _probe_ ## probe: \
_stap_probe_3 (_probe_ ## probe.probe_name,(size_t)arg1,(size_t)arg2,(size_t)arg3);
#else
#define STAP_PROBE3(provider,probe,parm1,parm2,parm3) \
- {volatile typeof(parm1) arg1 = parm1; \
- volatile typeof(parm2) arg2 = parm2; \
- volatile typeof(parm3) arg3 = parm3; \
-_probe_ ## probe: \
+ {volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \
+ volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \
+ volatile typeof((parm3)) arg3 __attribute__ ((unused)) = parm3; \
+STAP_LABEL(probe,__LINE__): \
asm volatile ("nop" :: "r"(arg1), "r"(arg2), "r"(arg3)); \
- STAP_PROBE_STRUCT(probe,1,(size_t)&& _probe_ ## probe) \
+ STAP_PROBE_STRUCT(probe,1,(size_t)&& STAP_LABEL(probe,__LINE__)) \
if (__builtin_expect(_probe_ ## probe.probe_type < 0, 0)) \
- goto _probe_ ## probe;}
+ goto STAP_LABEL(probe,__LINE__);}
#endif
#ifdef USE_STAP_PROBE
@@ -92,15 +99,15 @@ _probe_ ## probe: \
_stap_probe_4 (_probe_ ## probe.probe_name,(size_t)arg1,(size_t)arg2,(size_t)arg3,(size_t)arg4);
#else
#define STAP_PROBE4(provider,probe,parm1,parm2,parm3,parm4) \
- {volatile typeof(parm1) arg1 = parm1; \
- volatile typeof(parm2) arg2 = parm2; \
- volatile typeof(parm3) arg3 = parm3; \
- volatile typeof(parm4) arg4 = parm4; \
-_probe_ ## probe: \
- asm volatile ("nop" "r"(arg1), "r"(arg2), "r"(arg3), "r"(arg4)); \
- STAP_PROBE_STRUCT(probe,1,(size_t)&& _probe_ ## probe) \
+ {volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \
+ volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \
+ volatile typeof((parm3)) arg3 __attribute__ ((unused)) = parm3; \
+ volatile typeof((parm4)) arg4 __attribute__ ((unused)) = parm4; \
+STAP_LABEL(probe,__LINE__): \
+ asm volatile ("nop" :: "r"(arg1), "r"(arg2), "r"(arg3), "r"(arg4)); \
+ STAP_PROBE_STRUCT(probe,1,(size_t)&& STAP_LABEL(probe,__LINE__)) \
if (__builtin_expect(_probe_ ## probe.probe_type < 0, 0)) \
- goto _probe_ ## probe;}
+ goto STAP_LABEL(probe,__LINE__);}
#endif
#ifdef USE_STAP_PROBE
@@ -109,16 +116,35 @@ _probe_ ## probe: \
_stap_probe_5 (_probe_ ## probe.probe_name,(size_t)arg1,(size_t)arg2,(size_t)arg3,(size_t)arg4,(size_t)arg5);
#else
#define STAP_PROBE5(provider,probe,parm1,parm2,parm3,parm4,parm5) \
- {volatile typeof(parm1) arg1 = parm1; \
- volatile typeof(parm2) arg2 = parm2; \
- volatile typeof(parm3) arg3 = parm3; \
- volatile typeof(parm4) arg4 = parm4; \
- volatile typeof(parm5) arg5 = parm5; \
-_probe_ ## probe: \
- asm volatile ("nop" "r"(arg1), "r"(arg2), "r"(arg3), "r"(arg4), "r"(arg5)); \
- STAP_PROBE_STRUCT(probe,1,(size_t)&& _probe_ ## probe) \
+ {volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \
+ volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \
+ volatile typeof((parm3)) arg3 __attribute__ ((unused)) = parm3; \
+ volatile typeof((parm4)) arg4 __attribute__ ((unused)) = parm4; \
+ volatile typeof((parm5)) arg5 __attribute__ ((unused)) = parm5; \
+STAP_LABEL(probe,__LINE__): \
+ asm volatile ("nop" :: "r"(arg1), "r"(arg2), "r"(arg3), "r"(arg4), "r"(arg5)); \
+ STAP_PROBE_STRUCT(probe,1,(size_t)&& STAP_LABEL(probe,__LINE__)) \
+ if (__builtin_expect(_probe_ ## probe.probe_type < 0, 0)) \
+ goto STAP_LABEL(probe,__LINE__);}
+#endif
+
+#ifdef USE_STAP_PROBE
+#define STAP_PROBE6(provider,probe,arg1,arg2,arg3,arg4,arg5,arg6) \
+ STAP_PROBE_STRUCT(probe,0,6) \
+ _stap_probe_6 (_probe_ ## probe.probe_name,(size_t)arg1,(size_t)arg2,(size_t)arg3,(size_t)arg4,(size_t)arg5,(size_t)arg6);
+#else
+#define STAP_PROBE6(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6) \
+ {volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \
+ volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \
+ volatile typeof((parm3)) arg3 __attribute__ ((unused)) = parm3; \
+ volatile typeof((parm4)) arg4 __attribute__ ((unused)) = parm4; \
+ volatile typeof((parm5)) arg5 __attribute__ ((unused)) = parm5; \
+ volatile typeof((parm6)) arg6 __attribute__ ((unused)) = parm6; \
+STAP_LABEL(probe,__LINE__): \
+ asm volatile ("nop" :: "r"(arg1), "r"(arg2), "r"(arg3), "r"(arg4), "r"(arg5), "r"(arg6)); \
+ STAP_PROBE_STRUCT(probe,1,(size_t)&& STAP_LABEL(probe,__LINE__)) \
if (__builtin_expect(_probe_ ## probe.probe_type < 0, 0)) \
- goto _probe_ ## probe;}
+ goto STAP_LABEL(probe,__LINE__);}
#endif
#define DTRACE_PROBE(provider,probe) \
@@ -131,3 +157,7 @@ STAP_PROBE2(provider,probe,parm1,parm2)
STAP_PROBE3(provider,probe,parm1,parm2,parm3)
#define DTRACE_PROBE4(provider,probe,parm1,parm2,parm3,parm4) \
STAP_PROBE4(provider,probe,parm1,parm2,parm3,parm4)
+#define DTRACE_PROBE5(provider,probe,parm1,parm2,parm3,parm4,parm5) \
+STAP_PROBE4(provider,probe,parm1,parm2,parm3,parm4,parm5)
+#define DTRACE_PROBE6(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6) \
+STAP_PROBE4(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6)
diff --git a/tapsets.cxx b/tapsets.cxx
index e109d4e8..90602e9a 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -5305,8 +5305,8 @@ dwarf_builder::build(systemtap_session & sess,
use_debuginfo = 1
};
- location->components[0]->arg = new literal_string(sess.cmd);
- ((literal_map_t&)parameters)[location->components[0]->functor] = location->components[0]->arg;
+// location->components[0]->arg = new literal_string(sess.cmd);
+// ((literal_map_t&)parameters)[location->components[0]->functor] = location->components[0]->arg;
Dwarf_Addr bias;
Elf* elf = dwfl_module_getelf (dw->module, &bias);
size_t shstrndx;
@@ -5328,22 +5328,33 @@ dwarf_builder::build(systemtap_session & sess,
Elf_Data *pdata = elf_getdata_rawchunk (elf, shdr->sh_offset, shdr->sh_size, ELF_T_BYTE);
assert (pdata != NULL);
size_t probe_scn_offset = 0;
+ size_t probe_scn_addr = shdr->sh_addr;
while (probe_scn_offset < pdata->d_size)
{
- probe_name = (char*)pdata->d_buf + probe_scn_offset;
- probe_scn_offset += strlen(probe_name) + 1;
- if (probe_scn_offset % (sizeof(int)))
- probe_scn_offset += sizeof(int) - (probe_scn_offset % sizeof(int));
+ const int stap_sentinel = 0x31425250;
probe_type = *((int*)((char*)pdata->d_buf + probe_scn_offset));
+ if (probe_type != stap_sentinel)
+ {
+ probe_scn_offset += sizeof(int);
+ continue;
+ }
probe_scn_offset += sizeof(int);
if (probe_scn_offset % (sizeof(__uint64_t)))
probe_scn_offset += sizeof(__uint64_t) - (probe_scn_offset % sizeof(__uint64_t));
+
+ // pdata->d_buf + *(long*)(pdata->d_buf + probe_scn_offset) - probe_scn_addr
+ probe_name = ((char*)((long)(pdata->d_buf) + (long)(*((int*)((long)pdata->d_buf + probe_scn_offset)) - probe_scn_addr)));
+ probe_scn_offset += sizeof(void*);
+ if (probe_scn_offset % (sizeof(__uint64_t)))
+ 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) == 0)
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));
}
+ if (probe_scn_offset < pdata->d_size)
+ break;
}
if (probe_type == no_debuginfo)
diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog
index 870148a1..322ddfbe 100644
--- a/testsuite/ChangeLog
+++ b/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2009-01-22 Stan Cox <scox@redhat.com>
+
+ * systemtap.base/static_uprobes.exp: Test dtrace.
+
2009-01-20 Stan Cox <scox@redhat.com>
* systemtap.base/static_uprobes.exp: Don't test -lsduprobes.
diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp
index a27ba2a7..eb0d1c6e 100644
--- a/testsuite/systemtap.base/static_uprobes.exp
+++ b/testsuite/systemtap.base/static_uprobes.exp
@@ -9,26 +9,26 @@ set fp [open $sup_srcpath "w"]
puts $fp "
#include <stdlib.h>
#define USE_STAP_PROBE 1
-#include \"sdt.h\"
+#include \"static_uprobes.h\"
foo ()
{
- STAP_PROBE(tstlabel,label1);
+ STAP_PROBE(static_uprobes,test_probe_1);
}
bar (int i)
{
if (i == 0)
i = 1000;
- STAP_PROBE1(tstlabel,label2,i);
+ STAP_PROBE1(static_uprobes,test_probe_2,i);
}
baz (int i, char* s)
{
- STAP_PROBE1(tstlabel,label0,i);
+ STAP_PROBE1(static_uprobes,test_probe_0,i);
if (i == 0)
i = 1000;
- STAP_PROBE2(tstlabel,label3,i,s);
+ STATIC_UPROBES_TEST_PROBE_3(i,s);
}
buz (int parm)
@@ -57,21 +57,21 @@ close $fp
set fp [open "[pwd]/static_uprobes.stp" "w"]
puts $fp "
-probe process(\"static_uprobes.x\").mark(\"label0\")
+probe process(\"static_uprobes.x\").mark(\"test_probe_0\")
{
- printf(\"In label0 probe %#x\\n\", \$arg1)
+ printf(\"In test_probe_0 probe %#x\\n\", \$arg1)
}
-probe process(\"static_uprobes.x\").mark(\"label1\")
+probe process(\"static_uprobes.x\").mark(\"test_probe_1\")
{
- printf(\"In label1 probe\\n\")
+ printf(\"In test_probe_1 probe\\n\")
}
-probe process(\"static_uprobes.x\").mark(\"label2\")
+probe process(\"static_uprobes.x\").mark(\"test_probe_2\")
{
- printf(\"In label2 probe %#x\\n\", \$arg1)
+ printf(\"In test_probe_2 probe %#x\\n\", \$arg1)
}
-probe process(\"static_uprobes.x\").mark(\"label3\")
+probe process(\"static_uprobes.x\").mark(\"test_probe_3\")
{
- printf(\"In label3 probe %#x %#x\\n\", \$arg1, \$arg2)
+ printf(\"In test_probe_3 probe %#x %#x\\n\", \$arg1, \$arg2)
}
"
close $fp
@@ -90,10 +90,10 @@ set ok 0
# spawn stap -c $sup_exepath [pwd]/static_uprobes.stp
# expect {
# -timeout 180
-# -re {In label1 probe} { incr ok; exp_continue }
-# -re {In label2 probe 0x2} { incr ok; exp_continue }
-# -re {In label0 probe 0x3} { incr ok; exp_continue }
-# -re {In label3 probe 0x3 0x[0-9a-f][0-9a-f]} { incr ok; exp_continue }
+# -re {In test_probe_1 probe} { incr ok; exp_continue }
+# -re {In test_probe_2 probe 0x2} { incr ok; exp_continue }
+# -re {In test_probe_0 probe 0x3} { incr ok; exp_continue }
+# -re {In test_probe_3 probe 0x3 0x[0-9a-f][0-9a-f]} { incr ok; exp_continue }
# timeout { fail "$test (timeout)" }
# eof { }
# }
@@ -109,7 +109,7 @@ ed $sup_srcpath <<HERE
/USE_STAP_PROBE/d
/buz/+1
a
- DTRACE_PROBE1(tstlabel,label4,parm);
+ DTRACE_PROBE1(static_uprobes,test_probe_4,parm);
.
w
q
@@ -119,30 +119,42 @@ spawn sh [pwd]/static_uprobes.sh
set fp [open "[pwd]/static_uprobes.stp" "w"]
puts $fp "
-probe process(\"static_uprobes.x\").mark(\"label0\")
+probe process(\"static_uprobes.x\").mark(\"test_probe_0\")
{
- printf(\"In label0 probe %#x\\n\", \$arg1)
+ printf(\"In test_probe_0 probe %#x\\n\", \$arg1)
}
-probe process(\"static_uprobes.x\").mark(\"label1\")
+probe process(\"static_uprobes.x\").mark(\"test_probe_1\")
{
- printf(\"In label1 probe\\n\")
+ printf(\"In test_probe_1 probe\\n\")
}
-probe process(\"static_uprobes.x\").mark(\"label2\")
+probe process(\"static_uprobes.x\").mark(\"test_probe_2\")
{
- printf(\"In label2 probe %#x\\n\", \$arg1)
+ printf(\"In test_probe_2 probe %#x\\n\", \$arg1)
}
-probe process(\"static_uprobes.x\").mark(\"label3\")
+probe process(\"static_uprobes.x\").mark(\"test_probe_3\")
{
- printf(\"In label3 probe %#x %#x\\n\", \$arg1, \$arg2)
+ printf(\"In test_probe_3 probe %#x %#x\\n\", \$arg1, \$arg2)
}
-probe process(\"static_uprobes.x\").mark(\"label4\")
+probe process(\"static_uprobes.x\").mark(\"test_probe_4\")
{
- printf(\"In label4 dtrace probe %#x\\n\", \$arg1)
+ printf(\"In test_probe_4 dtrace probe %#x\\n\", \$arg1)
}
"
close $fp
-set sup_flags "additional_flags=-iquote$env(SYSTEMTAP_RUNTIME) additional_flags=-g additional_flags=-O additional_flags=$env(SYSTEMTAP_RUNTIME)/sduprobes.c"
+set fp [open "[pwd]/static_uprobes.d" "w"]
+puts $fp "
+provider static_uprobes {
+ probe test_probe_1 ();
+ probe test_probe_2 (int i);
+ probe test_probe_3 (int i, char* x);
+ probe test_probe_4 (int i);
+};
+"
+close $fp
+spawn dtrace -h -s [pwd]/static_uprobes.d
+
+set sup_flags "additional_flags=-iquote$env(SYSTEMTAP_RUNTIME) additional_flags=-g additional_flags=-O additional_flags=-I."
set res [target_compile $sup_srcpath $sup_exepath executable $sup_flags]
if { $res != "" } {
verbose "target_compile failed: $res" 2
@@ -156,11 +168,11 @@ verbose -log "spawn stap -c $sup_exepath [pwd]/static_uprobes.stp"
spawn stap -c $sup_exepath [pwd]/static_uprobes.stp
expect {
-timeout 180
- -re {In label1 probe} { incr ok; exp_continue }
- -re {In label2 probe 0x2} { incr ok; exp_continue }
- -re {In label0 probe 0x3} { incr ok; exp_continue }
- -re {In label3 probe 0x3 0x[0-9a-f][0-9a-f]} { incr ok; exp_continue }
- -re {In label4 dtrace probe 0x4} { incr ok; exp_continue }
+ -re {In test_probe_1 probe} { incr ok; exp_continue }
+ -re {In test_probe_2 probe 0x2} { incr ok; exp_continue }
+ -re {In test_probe_0 probe 0x3} { incr ok; exp_continue }
+ -re {In test_probe_3 probe 0x3 0x[0-9a-f][0-9a-f]} { incr ok; exp_continue }
+ -re {In test_probe_4 dtrace probe 0x4} { incr ok; exp_continue }
timeout { fail "$test (timeout)" }
eof { }
}