From 08b22cd52aad1023c91341a1fd9bdb821cf4c90f Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 18 Aug 2009 23:03:00 +0200 Subject: 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. --- testsuite/systemtap.base/cxxclass.cxx | 59 +++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 testsuite/systemtap.base/cxxclass.cxx (limited to 'testsuite/systemtap.base/cxxclass.cxx') 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 , but pick current source version. */ + +#include + +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; +} -- cgit