From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32078 invoked by alias); 8 Jan 2008 10:52:41 -0000 Received: (qmail 32069 invoked by uid 22791); 8 Jan 2008 10:52:41 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 08 Jan 2008 10:52:24 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m08AqLG8032224 for ; Tue, 8 Jan 2008 05:52:22 -0500 Received: from zebedee.littlepinkcloud.COM (vpn-14-83.rdu.redhat.com [10.11.14.83]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m08AqLJR012590; Tue, 8 Jan 2008 05:52:21 -0500 Received: from littlepinkcloud.COM (localhost.localdomain [127.0.0.1]) by zebedee.littlepinkcloud.COM (8.13.8/8.13.5) with ESMTP id m08AqI4v011786; Tue, 8 Jan 2008 10:52:20 GMT Received: (from aph@localhost) by littlepinkcloud.COM (8.13.8/8.13.5/Submit) id m08AqHLF011783; Tue, 8 Jan 2008 10:52:17 GMT MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18307.21985.888303.875264@zebedee.pink> Date: Tue, 08 Jan 2008 21:25:00 -0000 From: Andrew Haley To: "PRC" Cc: gcc-help Subject: Re: How to traceback call stack on MIPS arch? In-Reply-To: <200801081007106802280@gmail.com> References: <200801081007106802280@gmail.com> X-Mailer: VM 7.19 under Emacs 22.0.93.1 X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-01/txt/msg00071.txt.bz2 PRC writes: > Gcc saves the frame pointer to fp(s8) register at the beginning of > each function if compiling source with -O0. But it won't do so if > compiling source with -O2. Without frame pointers, can I trace back > call stacks in current function context? Or is there any option > which forces gcc to save frame pointers for MIPS arch? You need to use the unwinder. #include #include static _Unwind_Reason_Code backtrace_helper (struct _Unwind_Context *ctx, void *a) { void *ip = (void*)_Unwind_GetIP (ctx); fprintf (stdout, " %p\n", ip); return _URC_NO_REASON; } void print_backtrace (void) { _Unwind_Backtrace (backtrace_helper, NULL); } int main (int argc, char **argv) { print_backtrace (); return 0; } -- Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK Registered in England and Wales No. 3798903