Patch: add systemtap-style marker to _Unwind_DebugHook

Message ID
State New
Headers show

Commit Message

Tom Tromey Jan. 14, 2011, 9:17 p.m.
Tom> I think I will make it check for the existence of STAP_PROBE2, unless
Tom> there is some better plan.  I don't know anything about dtrace and have

Rainer> For the moment, that should do.

Here is an updated version.

Tom> no way to test it, so if we want to use the DTRACE_* macro, somebody
Tom> will have to help.

Rainer> Adding DTrace probes to the unwinder sounds like an excellent idea: I
Rainer> recently had to debug lots of unwinder issues on Solaris, and such
Rainer> probes would certainly have helped.  I'll add this to my agenda.

From reading on the web it was unclear to me whether Solaris+DTrace
requires a .d file, an invocation of dtrace, and a new .o file in order
to make this work.

If so then it is further unclear what should be done when building a
cross compiler.

The below ought to work ok in cross scenarios.  I think it would be
mildly nicer if we did not use a .d file on Linux, though the cost is
very small (one global variable for the semaphore).


2011-01-14  Tom Tromey  <>

	* unwind-dw2.c: Include sys/sdt.h if it exists.
	(_Unwind_DebugHook): Use STAP_PROBE2.
	*, configure: Rebuild.
	* Check for sys/sdt.h.


Richard Henderson Jan. 14, 2011, 9:31 p.m. | #1
On 01/14/2011 01:17 PM, Tom Tromey wrote:
> 	* unwind-dw2.c: Include sys/sdt.h if it exists.
> 	(_Unwind_DebugHook): Use STAP_PROBE2.
> 	*, configure: Rebuild.
> 	* Check for sys/sdt.h.

Ok by me.



diff --git a/gcc/ b/gcc/
index 776c71f..44a963d 100644
--- a/gcc/
+++ b/gcc/
@@ -4313,6 +4313,16 @@  if test x$gcc_cv_libc_provides_ssp = xyes; then
 	    [Define if your target C library provides stack protector support])
+# Test for <sys/sdt.h> on the target.
+AC_MSG_CHECKING(sys/sdt.h in the target C library)
+if test -f $target_header_dir/sys/sdt.h; then
+            [Define if your target C library provides 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..6f9b224 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>
@@ -1493,7 +1497,11 @@  static void
 _Unwind_DebugHook (void *cfa __attribute__ ((__unused__)),
 		   void *handler __attribute__ ((__unused__)))
+#if defined (HAVE_SYS_SDT_H) && defined (STAP_PROBE2)
+  STAP_PROBE2 (libgcc, unwind, cfa, handler);
   asm ("");
 /* Install TARGET into CURRENT so that we can return to it.  This is a