From patchwork Fri Jan 14 21:17:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 79013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 072E1B70A3 for ; Sat, 15 Jan 2011 08:17:53 +1100 (EST) Received: (qmail 9547 invoked by alias); 14 Jan 2011 21:17:47 -0000 Received: (qmail 9536 invoked by uid 22791); 14 Jan 2011 21:17:46 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 14 Jan 2011 21:17:44 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0ELHexo026506 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 14 Jan 2011 16:17:40 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0ELHdsx025575; Fri, 14 Jan 2011 16:17:39 -0500 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p0ELHc1p000505; Fri, 14 Jan 2011 16:17:38 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id D49A0379883; Fri, 14 Jan 2011 14:17:37 -0700 (MST) From: Tom Tromey To: Rainer Orth Cc: gcc-patches@gcc.gnu.org, systemtap@sources.redhat.com Subject: Re: Patch: add systemtap-style marker to _Unwind_DebugHook References: Date: Fri, 14 Jan 2011 14:17:37 -0700 In-Reply-To: (Rainer Orth's message of "Fri, 14 Jan 2011 20:46:40 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 * 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 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 +#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