summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2009-08-18 23:03:00 +0200
committerMark Wielaard <mjw@redhat.com>2009-08-18 23:03:00 +0200
commit08b22cd52aad1023c91341a1fd9bdb821cf4c90f (patch)
treed4d18c21a32b002872af24e5e3089d13ba992334
parenta80a54cb804d0df40e064a72bd8c6bf7c1258e02 (diff)
downloadsystemtap-steved-08b22cd52aad1023c91341a1fd9bdb821cf4c90f.tar.gz
systemtap-steved-08b22cd52aad1023c91341a1fd9bdb821cf4c90f.tar.xz
systemtap-steved-08b22cd52aad1023c91341a1fd9bdb821cf4c90f.zip
PR10512 STAP_PROBES don't work in c++ constructors/destructors testcase.
* testsuite/systemtap.base/cxxclass.exp: New file. * testsuite/systemtap.base/cxxclass.stp: Likewise. * testsuite/systemtap.base/cxxclass.cxx: Likewise.
-rw-r--r--testsuite/systemtap.base/cxxclass.cxx59
-rw-r--r--testsuite/systemtap.base/cxxclass.exp33
-rw-r--r--testsuite/systemtap.base/cxxclass.stp34
3 files changed, 126 insertions, 0 deletions
diff --git a/testsuite/systemtap.base/cxxclass.cxx b/testsuite/systemtap.base/cxxclass.cxx
new file mode 100644
index 00000000..85f31c4e
--- /dev/null
+++ b/testsuite/systemtap.base/cxxclass.cxx
@@ -0,0 +1,59 @@
+#include "sdt.h" /* Really <sys/sdt.h>, but pick current source version. */
+
+#include <stdio.h>
+
+class ProbeClass
+{
+private:
+ int& ref;
+ const char *name;
+
+public:
+ ProbeClass(int& v, const char *n) : ref(v), name(n)
+ {
+ STAP_PROBE2(_test_, cons, name, ref);
+ }
+
+ void method(int min)
+ {
+ STAP_PROBE3(_test_, meth, name, ref, min);
+ ref -= min;
+ }
+
+ ~ProbeClass()
+ {
+ STAP_PROBE2(_test_, dest, name, ref);
+ }
+};
+
+static void
+call()
+{
+ int i = 64;
+ STAP_PROBE1(_test_, call, i);
+ ProbeClass inst = ProbeClass(i, "call");
+ inst.method(24);
+ i += 2;
+ // Here the destructor goes out of scope and uses i as ref one last time.
+}
+
+static void
+call2()
+{
+ int j = 24;
+ STAP_PROBE1(_test_, call2, j);
+ ProbeClass inst = ProbeClass(j, "call2");
+ inst.method(40);
+ j += 58;
+ // Here the destructor goes out of scope and uses i as ref one last time.
+}
+
+int
+main (int argc, char **argv)
+{
+ STAP_PROBE(_test_, main_enter);
+ call();
+ call2();
+ STAP_PROBE(_test_, main_exit);
+ return 0;
+}
diff --git a/testsuite/systemtap.base/cxxclass.exp b/testsuite/systemtap.base/cxxclass.exp
new file mode 100644
index 00000000..f9ce3668
--- /dev/null
+++ b/testsuite/systemtap.base/cxxclass.exp
@@ -0,0 +1,33 @@
+set test "cxxclass"
+set ::result_string {main_enter
+call: 64
+cons call: 64
+meth call: 64 24
+dest call: 42
+call2: 24
+cons call2: 24
+meth call2: 24 40
+dest call2: 42
+main_exit}
+
+set test_flags "additional_flags=-g"
+set test_flags "$test_flags additional_flags=-O2"
+set test_flags "$test_flags additional_flags=-I$srcdir/../includes/sys"
+set test_flags "$test_flags compiler=g++"
+
+set res [target_compile $srcdir/$subdir/$test.cxx $test.exe executable "$test_flags"]
+if { $res != "" } {
+ verbose "target_compile failed: $res" 2
+ fail "compiling $test.c"
+ untested "$test.c compile"
+ continue
+} else {
+ pass "$test.c compile"
+}
+
+if {[installtest_p] && [uprobes_p]} {
+ stap_run3 "$test" $srcdir/$subdir/$test.stp $test.exe -c ./$test.exe
+} else {
+ untested "$test"
+}
+catch {exec rm -f $test.exe}
diff --git a/testsuite/systemtap.base/cxxclass.stp b/testsuite/systemtap.base/cxxclass.stp
new file mode 100644
index 00000000..f36be72b
--- /dev/null
+++ b/testsuite/systemtap.base/cxxclass.stp
@@ -0,0 +1,34 @@
+probe process("cxxclass.exe").mark("main_enter")
+{
+ log("main_enter");
+}
+
+probe process("cxxclass.exe").mark("main_exit")
+{
+ log("main_exit");
+}
+
+probe process("cxxclass.exe").mark("call")
+{
+ printf("call: %d\n", $arg1);
+}
+
+probe process("cxxclass.exe").mark("call2")
+{
+ printf("call2: %d\n", $arg1);
+}
+
+probe process("cxxclass.exe").mark("cons")
+{
+ printf("cons %s: %d\n", user_string($arg1), $arg2);
+}
+
+probe process("cxxclass.exe").mark("meth")
+{
+ printf("meth %s: %d %d\n", user_string($arg1), $arg2, $arg3);
+}
+
+probe process("cxxclass.exe").mark("dest")
+{
+ printf("dest %s: %d\n", user_string($arg1), $arg2);
+}