From patchwork Tue Jul 2 00:01:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Butcher X-Patchwork-Id: 256253 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 333AC2C00A7 for ; Tue, 2 Jul 2013 10:01:59 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=wCvmc2w3ygf72uHHmE1KegXTzrjIrZ0LH9ruD5LiIUGYP6gGcnUiq qm1ADOT4Lz5rW9u33gup4rlMvng6j60wzCzyvFVWQrH4D+wig+d6upACM8kUyiA+ c2poDGeosK2F0s5M6LKq3lIFFZ9uwN6lmLy8QqWcLApJbDeAzxq42s= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=BmNYpLhoJcFPSZbzUdjN5h59JnM=; b=n6xsS7FNLgo6L+VD4O9q 1bbRgKOzMs4T55TKzohPE4nSnG0kLl1Fb6vuBJYCdgTewDiuZk1es0fiTE2AhDM+ ZPrU7kwghhWogmiXdutOpiLYXK7VjLKxtp/dI35tAVuRHpGcixnQ85V3rMwAhlOB HAS0TeKN7h8AMiddq61kE3s= Received: (qmail 8206 invoked by alias); 2 Jul 2013 00:01:52 -0000 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 Received: (qmail 8194 invoked by uid 89); 2 Jul 2013 00:01:52 -0000 X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, SPF_PASS autolearn=ham version=3.3.1 Received: from mail-we0-f174.google.com (HELO mail-we0-f174.google.com) (74.125.82.174) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 02 Jul 2013 00:01:51 +0000 Received: by mail-we0-f174.google.com with SMTP id q58so3719685wes.5 for ; Mon, 01 Jul 2013 17:01:49 -0700 (PDT) X-Received: by 10.194.103.226 with SMTP id fz2mr21486209wjb.75.1372723309133; Mon, 01 Jul 2013 17:01:49 -0700 (PDT) Received: from localhost.localdomain (munkyhouse.force9.co.uk. [84.92.244.81]) by mx.google.com with ESMTPSA id ez3sm9062649wib.3.2013.07.01.17.01.47 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Jul 2013 17:01:48 -0700 (PDT) From: Adam Butcher To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Adam Butcher Subject: [PATCH] [debug] Added DEBUG_FUNCTION void dump_backtrace. Date: Tue, 2 Jul 2013 01:01:34 +0100 Message-Id: <1372723294-6712-1-git-send-email-adam@jessamine.co.uk> In-Reply-To: <1372721221-6201-1-git-send-email-adam@jessamine.co.uk> References: <1372721221-6201-1-git-send-email-adam@jessamine.co.uk> * diagnostic-core.h: Declare dump_backtrace (void). * diagnostic.c: Define it. --- Just realized that I've submitted an unintended hunk in [PATCH 3/4] (http://gcc.gnu.org/ml/gcc-patches/2013-07/msg00042.html). I didn't notice that I'd left a tracing line in 'gcc/cp/decl.c'. This patch resolves the missing function. Or you can just skip that change. I've found this a useful tool when hacking on GCC before I found out about '-wrapper gdb,--args'. I cherry-pick it whenever I want to find out where something is called without stopping the compiler. Don't know if any one else would find use in it. Cheers, Adam gcc/diagnostic-core.h | 1 + gcc/diagnostic.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/gcc/diagnostic-core.h b/gcc/diagnostic-core.h index a210782..e204340 100644 --- a/gcc/diagnostic-core.h +++ b/gcc/diagnostic-core.h @@ -78,6 +78,7 @@ extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2); extern bool emit_diagnostic (diagnostic_t, location_t, int, const char *, ...) ATTRIBUTE_GCC_DIAG(4,5); extern bool seen_error (void); +extern void dump_backtrace (void); #ifdef BUFSIZ /* N.B. Unlike all the others, fnotice is just gettext+fprintf, and diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 2ec9620..0f12a38 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -1111,6 +1111,19 @@ fatal_error (const char *gmsgid, ...) gcc_unreachable (); } +/* Intended for compiler developers to trace the compiler's call stack + to stderr without affecting compilation state. The trace generated + here is the same as would occur with an ICE. */ +DEBUG_FUNCTION void +dump_backtrace (void) +{ + struct backtrace_state *state = + backtrace_create_state (NULL, 0, bt_err_callback, NULL); + int count = 0; + if (state != NULL) + backtrace_full (state, 2, bt_callback, bt_err_callback, (void *) &count); +} + /* An internal consistency check has failed. We make no attempt to continue. Note that unless there is debugging value to be had from a more specific message, or some other good reason, you should use