diff mbox

RFC: add some static probes to libstdc++

Message ID 87a9qozc7h.fsf@fleche.redhat.com
State New
Headers show

Commit Message

Tom Tromey Feb. 28, 2013, 3:32 p.m. UTC
Dave>   How did it build in the without sys/sdt.h case?

Sorry about that again.
I must have made some change after testing it.

Here is an updated version.

One thing I found out while fixing this up is that changes to
unwind-cxx.h do not cause anything to rebuild if I just run "make".  I
have to "make clean" each time.

On the plus side, while digging around after being confused by this, I
found that I didn't actually need "../config.h" -- the code now checks
_GLIBCXX_HAVE_SYS_SDT_H instead.

Tom

2013-02-27  Tom Tromey  <tromey@redhat.com>

	* libsupc++/unwind-cxx.h: Include sys/sdt.h if detected.
	(PROBE2): New macro.
	* libsupc++/eh_throw.cc (__cxa_throw, __cxa_rethrow): Add probe.
	* libsupc++/eh_catch.cc (__cxa_begin_catch): Add probe.
	* configure.ac: Check for sys/sdt.h.
	* configure, config.h.in: Rebuild.

Comments

Tom Tromey March 14, 2013, 6:43 p.m. UTC | #1
Tom> 2013-02-27  Tom Tromey  <tromey@redhat.com>
Tom> 	* libsupc++/unwind-cxx.h: Include sys/sdt.h if detected.
Tom> 	(PROBE2): New macro.
Tom> 	* libsupc++/eh_throw.cc (__cxa_throw, __cxa_rethrow): Add probe.
Tom> 	* libsupc++/eh_catch.cc (__cxa_begin_catch): Add probe.
Tom> 	* configure.ac: Check for sys/sdt.h.
Tom> 	* configure, config.h.in: Rebuild.

FWIW the gdb patches relying on this have all been submitted.
They are pending comments, but also this patch going in.

In particular:

Using the probes in gdb:
    http://sourceware.org/ml/gdb-patches/2013-03/msg00242.html

Using the probes to implement the $_exception convenience variable:
    http://sourceware.org/ml/gdb-patches/2013-03/msg00243.html

Using the probes to implement filtering for exception catchpoints:
    http://sourceware.org/ml/gdb-patches/2013-03/msg00245.html

Tom
Jakub Jelinek March 15, 2013, 8:55 a.m. UTC | #2
On Thu, Feb 28, 2013 at 08:32:02AM -0700, Tom Tromey wrote:
> 2013-02-27  Tom Tromey  <tromey@redhat.com>
> 
> 	* libsupc++/unwind-cxx.h: Include sys/sdt.h if detected.
> 	(PROBE2): New macro.
> 	* libsupc++/eh_throw.cc (__cxa_throw, __cxa_rethrow): Add probe.
> 	* libsupc++/eh_catch.cc (__cxa_begin_catch): Add probe.
> 	* configure.ac: Check for sys/sdt.h.
> 	* configure, config.h.in: Rebuild.

This is ok.  As we are close to 4.8.0-rc1, I went ahead and committed it for
you.

	Jakub
Jonathan Wakely April 2, 2013, 3:19 p.m. UTC | #3
On 15 March 2013 08:55, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Feb 28, 2013 at 08:32:02AM -0700, Tom Tromey wrote:
>> 2013-02-27  Tom Tromey  <tromey@redhat.com>
>>
>>       * libsupc++/unwind-cxx.h: Include sys/sdt.h if detected.
>>       (PROBE2): New macro.
>>       * libsupc++/eh_throw.cc (__cxa_throw, __cxa_rethrow): Add probe.
>>       * libsupc++/eh_catch.cc (__cxa_begin_catch): Add probe.
>>       * configure.ac: Check for sys/sdt.h.
>>       * configure, config.h.in: Rebuild.
>
> This is ok.  As we are close to 4.8.0-rc1, I went ahead and committed it for
> you.
>
>         Jakub

This change is causing a few problems, it looks as though older
versions of Systemtap headers are incompatible with C++11 due to the
UDL/whitespace issues described at
http://gcc.gnu.org/gcc-4.7/porting_to.html

e.g. http://gcc.gnu.org/ml/gcc-help/2013-04/msg00011.html

Should we update the prerequisites documentation to say that if
Systemtap is installed it needs to be at least version X?
Marc Glisse April 2, 2013, 3:39 p.m. UTC | #4
On Tue, 2 Apr 2013, Jonathan Wakely wrote:

> On 15 March 2013 08:55, Jakub Jelinek <jakub@redhat.com> wrote:
>> On Thu, Feb 28, 2013 at 08:32:02AM -0700, Tom Tromey wrote:
>>> 2013-02-27  Tom Tromey  <tromey@redhat.com>
>>>
>>>       * libsupc++/unwind-cxx.h: Include sys/sdt.h if detected.
>>>       (PROBE2): New macro.
>>>       * libsupc++/eh_throw.cc (__cxa_throw, __cxa_rethrow): Add probe.
>>>       * libsupc++/eh_catch.cc (__cxa_begin_catch): Add probe.
>>>       * configure.ac: Check for sys/sdt.h.
>>>       * configure, config.h.in: Rebuild.
>>
>> This is ok.  As we are close to 4.8.0-rc1, I went ahead and committed it for
>> you.
>>
>>         Jakub
>
> This change is causing a few problems, it looks as though older
> versions of Systemtap headers are incompatible with C++11 due to the
> UDL/whitespace issues described at
> http://gcc.gnu.org/gcc-4.7/porting_to.html
>
> e.g. http://gcc.gnu.org/ml/gcc-help/2013-04/msg00011.html
>
> Should we update the prerequisites documentation to say that if
> Systemtap is installed it needs to be at least version X?

I thought you were going to suggest enhancing the configure test so it 
fails on old systemtap (detects it as absent).
Jonathan Wakely April 2, 2013, 7:27 p.m. UTC | #5
On 2 April 2013 16:39, Marc Glisse wrote:
> On Tue, 2 Apr 2013, Jonathan Wakely wrote:
>> Should we update the prerequisites documentation to say that if
>> Systemtap is installed it needs to be at least version X?
>
>
> I thought you were going to suggest enhancing the configure test so it fails
> on old systemtap (detects it as absent).

Ah yes, that's a much better idea!
Tom Tromey April 8, 2013, 8:54 p.m. UTC | #6
>>>>> "Jonathan" == Jonathan Wakely <jwakely.gcc@gmail.com> writes:

Jonathan> On 2 April 2013 16:39, Marc Glisse wrote:
>> On Tue, 2 Apr 2013, Jonathan Wakely wrote:
>>> Should we update the prerequisites documentation to say that if
>>> Systemtap is installed it needs to be at least version X?
>> 
>> 
>> I thought you were going to suggest enhancing the configure test so it fails
>> on old systemtap (detects it as absent).

Jonathan> Ah yes, that's a much better idea!

Sorry about the delay on this.  I've been away.
I will try to write a fix this week.

Tom
diff mbox

Patch

diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index a64fee2..de66406 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -216,7 +216,7 @@  GLIBCXX_CHECK_SYSCTL_HW_NCPU
 AC_CHECK_HEADERS([endian.h execinfo.h float.h fp.h ieeefp.h inttypes.h \
 locale.h machine/endian.h machine/param.h nan.h stdint.h stdlib.h string.h \
 strings.h sys/ipc.h sys/isa_defs.h sys/machine.h sys/param.h \
-sys/resource.h sys/sem.h sys/stat.h sys/time.h sys/types.h unistd.h \
+sys/resource.h sys/sdt.h sys/sem.h sys/stat.h sys/time.h sys/types.h unistd.h \
 wchar.h wctype.h])
 
 # Only do link tests if native. Else, hardcode.
diff --git a/libstdc++-v3/libsupc++/eh_catch.cc b/libstdc++-v3/libsupc++/eh_catch.cc
index 779f5a3..43e875a 100644
--- a/libstdc++-v3/libsupc++/eh_catch.cc
+++ b/libstdc++-v3/libsupc++/eh_catch.cc
@@ -80,6 +80,9 @@  __cxxabiv1::__cxa_begin_catch (void *exc_obj_in) _GLIBCXX_NOTHROW
     }
 
   objectp = __gxx_caught_object(exceptionObject);
+
+  PROBE2 (catch, objectp, header->exceptionType);
+
 #ifdef __ARM_EABI_UNWINDER__
   _Unwind_Complete(exceptionObject);
 #endif
diff --git a/libstdc++-v3/libsupc++/eh_throw.cc b/libstdc++-v3/libsupc++/eh_throw.cc
index 297aa04..a79a025 100644
--- a/libstdc++-v3/libsupc++/eh_throw.cc
+++ b/libstdc++-v3/libsupc++/eh_throw.cc
@@ -60,6 +60,8 @@  extern "C" void
 __cxxabiv1::__cxa_throw (void *obj, std::type_info *tinfo,
 			 void (_GLIBCXX_CDTOR_CALLABI *dest) (void *))
 {
+  PROBE2 (throw, obj, tinfo);
+
   // Definitely a primary.
   __cxa_refcounted_exception *header
     = __get_refcounted_exception_header_from_obj (obj);
@@ -97,7 +99,12 @@  __cxxabiv1::__cxa_rethrow ()
       if (!__is_gxx_exception_class(header->unwindHeader.exception_class))
 	globals->caughtExceptions = 0;
       else
-	header->handlerCount = -header->handlerCount;
+	{
+	  header->handlerCount = -header->handlerCount;
+	  // Only notify probe for C++ exceptions.
+	  PROBE2 (rethrow, __get_object_from_ambiguous_exception(header),
+		  header->exceptionType);
+	}
 
 #ifdef _GLIBCXX_SJLJ_EXCEPTIONS
       _Unwind_SjLj_Resume_or_Rethrow (&header->unwindHeader);
diff --git a/libstdc++-v3/libsupc++/unwind-cxx.h b/libstdc++-v3/libsupc++/unwind-cxx.h
index e2b945d..ed4eea5 100644
--- a/libstdc++-v3/libsupc++/unwind-cxx.h
+++ b/libstdc++-v3/libsupc++/unwind-cxx.h
@@ -37,6 +37,19 @@ 
 #include <bits/atomic_word.h>
 #include <cxxabi.h>
 
+#ifdef _GLIBCXX_HAVE_SYS_SDT_H
+#include <sys/sdt.h>
+/* We only want to use stap probes starting with v3.  Earlier versions
+   added too much startup cost.  */
+#if defined (STAP_PROBE2) && _SDT_NOTE_TYPE >= 3
+#define PROBE2(name, arg1, arg2) STAP_PROBE2 (libstdcxx, name, arg1, arg2)
+#endif
+#endif
+
+#ifndef PROBE2
+#define PROBE2(name, arg1, arg2)
+#endif
+
 #pragma GCC visibility push(default)
 
 namespace __cxxabiv1