Patchwork Patch: add systemtap-style marker to _Unwind_DebugHook

login
register
mail settings
Submitter Tom Tromey
Date Jan. 17, 2011, 5:23 p.m.
Message ID <m3k4i3jvfk.fsf@fleche.redhat.com>
Download mbox | patch
Permalink /patch/79198/
State New
Headers show

Comments

Tom Tromey - Jan. 17, 2011, 5:23 p.m.
>>>>> "Roland" == Roland McGrath <roland@redhat.com> writes:

Roland> That test would work.  (That macro is not defined at all in
Roland> earlier versions.)

Here is an updated version.

Tom

2011-01-14  Tom Tromey  <tromey@redhat.com>

	* unwind-dw2.c: Include sys/sdt.h if it exists.
	(_Unwind_DebugHook): Use STAP_PROBE2.
	* config.in, configure: Rebuild.
	* configure.ac: Check for sys/sdt.h.
Roland McGrath - Jan. 17, 2011, 5:26 p.m.
> Here is an updated version.

This looks good to me, modulo the question of going for Solaris/dtrace
compatibility (on which I have no opinion).


Thanks,
Roland
Rainer Orth - Jan. 20, 2011, 5:30 p.m.
Tom,

> Here is an updated version.

I'm fine with that version since it guarantees that it won't break
Solaris bootstrap, as the initial one would have done.

As for DTrace support proper, we can postpone that IMO.  To be honest,
from my experience getting the libgcc unwinder to work with dl_iterate_phdr
on Solaris 11, a single probe in _Unwind_DebugHook may not be enough,
but it's certainly a start.  Maybe we can get at a list of additional
probes to add to the unwinder, perhaps conditionally compiled if there is
unacceptable overhead in production.

Thanks, and sorry for letting the ball drop.

	Rainer
Tom Tromey - Jan. 28, 2011, 9:09 a.m.
>>>>> "Rainer" == Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

Tom> Here is an updated version.

Rainer> I'm fine with that version since it guarantees that it won't break
Rainer> Solaris bootstrap, as the initial one would have done.

Rainer> As for DTrace support proper, we can postpone that IMO.  To be
Rainer> honest, from my experience getting the libgcc unwinder to work
Rainer> with dl_iterate_phdr on Solaris 11, a single probe in
Rainer> _Unwind_DebugHook may not be enough, but it's certainly a start.

Yeah ... the motivation for this specific probe is that it lets gdb work
nicely in the presence of exceptions, nothing more.  If you want to look
more deeply into the unwinder itself, you may want more.

Rainer> Thanks, and sorry for letting the ball drop.

It is no trouble, this is waiting for Stage 1 anyhow :-)

Tom
Tom Tromey - March 14, 2011, 6:12 p.m.
Roland> That test would work.  (That macro is not defined at all in
Roland> earlier versions.)

Tom> Here is an updated version.

Tom> 2011-01-14  Tom Tromey  <tromey@redhat.com>
Tom> 	* unwind-dw2.c: Include sys/sdt.h if it exists.
Tom> 	(_Unwind_DebugHook): Use STAP_PROBE2.
Tom> 	* config.in, configure: Rebuild.
Tom> 	* configure.ac: Check for sys/sdt.h.

Now that Stage 1 is open, I am checking this in.

Tom

Patch

diff --git a/gcc/configure.ac b/gcc/configure.ac
index 776c71f..44a963d 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -4313,6 +4313,16 @@  if test x$gcc_cv_libc_provides_ssp = xyes; then
 	    [Define if your target C library provides stack protector support])
 fi
 
+# Test for <sys/sdt.h> on the target.
+GCC_TARGET_TEMPLATE([HAVE_SYS_SDT_H])
+AC_MSG_CHECKING(sys/sdt.h in the target C library)
+have_sys_sdt_h=no
+if test -f $target_header_dir/sys/sdt.h; then
+  AC_DEFINE(HAVE_SYS_SDT_H, 1,
+            [Define if your target C library provides sys/sdt.h])
+fi
+AC_MSG_RESULT($have_sys_sdt_h)
+
 # Check if TFmode long double should be used by default or not.
 # Some glibc targets used DFmode long double, but with glibc 2.4
 # and later they can use TFmode.
diff --git a/gcc/unwind-dw2.c b/gcc/unwind-dw2.c
index 2ea9adb..25990b4 100644
--- a/gcc/unwind-dw2.c
+++ b/gcc/unwind-dw2.c
@@ -1,6 +1,6 @@ 
 /* DWARF2 exception handling and frame unwind runtime interface routines.
    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2008, 2009, 2010  Free Software Foundation, Inc.
+   2008, 2009, 2010, 2011  Free Software Foundation, Inc.
 
    This file is part of GCC.
 
@@ -37,6 +37,10 @@ 
 #include "gthr.h"
 #include "unwind-dw2.h"
 
+#ifdef HAVE_SYS_SDT_H
+#include <sys/sdt.h>
+#endif
+
 #ifndef __USING_SJLJ_EXCEPTIONS__
 
 #ifndef STACK_GROWS_DOWNWARD
@@ -1493,7 +1497,13 @@  static void
 _Unwind_DebugHook (void *cfa __attribute__ ((__unused__)),
 		   void *handler __attribute__ ((__unused__)))
 {
+  /* We only want to use stap probes starting with v3.  Earlier
+     versions added too much startup cost.  */
+#if defined (HAVE_SYS_SDT_H) && defined (STAP_PROBE2) && _SDT_NOTE_TYPE >= 3
+  STAP_PROBE2 (libgcc, unwind, cfa, handler);
+#else
   asm ("");
+#endif
 }
 
 /* Install TARGET into CURRENT so that we can return to it.  This is a