This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Patch: add systemtap-style marker to _Unwind_DebugHook
- From: Tom Tromey <tromey at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: systemtap at sources dot redhat dot com
- Date: Fri, 14 Jan 2011 12:30:00 -0700
- Subject: Patch: add systemtap-style marker to _Unwind_DebugHook
This patch adds a systemtap-style static marker to the existing
_Unwind_DebugHook function in the unwinder. The benefit of doing this
is that it will enable GDB's exception-handling code to work even in the
absence of debuginfo.
The cost of this probe is very small. I believe that with the "v3"
probes it expands to a nop in the code, plus an extra note section in
the .o.
Some more info on static markers is here:
http://sourceware.org/systemtap/wiki/AddingUserSpaceProbingToApps
I tested this by building it two ways (once with sdt.h installed and
once without) on x86 F13, and then examining the resulting libgcc.so
using stap and readelf.
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..ca5e95c 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__)))
{
+#ifdef HAVE_SYS_SDT_H
+ STAP_PROBE2 (libgcc, unwind, cfa, handler);
+#else
asm ("");
+#endif
}
/* Install TARGET into CURRENT so that we can return to it. This is a