This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: Patch: add systemtap-style marker to _Unwind_DebugHook
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).
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.
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..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>
+#endif
+
#ifndef __USING_SJLJ_EXCEPTIONS__
#ifndef STACK_GROWS_DOWNWARD
@@ -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);
+#else
asm ("");
+#endif
}
/* Install TARGET into CURRENT so that we can return to it. This is a