From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5490 invoked by alias); 22 Apr 2003 00:51:42 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 5432 invoked from network); 22 Apr 2003 00:51:41 -0000 Received: from unknown (HELO mail-out1.apple.com) (17.254.0.52) by sources.redhat.com with SMTP; 22 Apr 2003 00:51:41 -0000 Received: from mailgate2.apple.com (A17-129-100-225.apple.com [17.129.100.225]) by mail-out1.apple.com (8.12.9/8.12.9) with ESMTP id h3M0pe3h022846 for ; Mon, 21 Apr 2003 17:51:40 -0700 (PDT) Received: from scv2.apple.com (scv2.apple.com) by mailgate2.apple.com (Content Technologies SMTPRS 4.2.1) with ESMTP id ; Mon, 21 Apr 2003 17:51:40 -0700 Received: from apple.com (moleja.apple.com [17.201.22.21]) by scv2.apple.com (8.12.9/8.12.9) with ESMTP id h3M0pdbN018162; Mon, 21 Apr 2003 17:51:39 -0700 (PDT) Date: Tue, 22 Apr 2003 00:51:00 -0000 Subject: Re: backtrace C-API Content-Type: text/plain; charset=ISO-8859-1; format=flowed Mime-Version: 1.0 (Apple Message framework v552) Cc: Daniel Jacobowitz , =?ISO-8859-1?Q?Gerrit_Bruchh=E4user?= , gdb@sources.redhat.com To: Andrew Cagney From: Jason Molenda In-Reply-To: <3EA45CE2.9040500@redhat.com> Message-Id: <8ECA5848-745C-11D7-8838-000393D457E2@apple.com> Content-Transfer-Encoding: quoted-printable X-SW-Source: 2003-04/txt/msg00241.txt.bz2 On Monday, April 21, 2003, at 02:04 PM, Andrew Cagney wrote: >> On Fri, Apr 18, 2003 at 02:33:27PM +0200, Gerrit Bruchh=E4user wrote: >>> Hello, >>> is there any C-API function in libgdb.a (or some other library) which >>> returns a call stack (something 'bt' like)? >> No; but you might find backtrace() useful if you're on a >> glibc-supported platform. > > But there probably should. How hard is it to create a `target-self'=20 > that uses local memory, and a jump-buf for registers? The tricky bit,=20 > I see, is the symbol table assuming a single global structure. This falls into the category of Nasty Hack, but I helped someone on our=20 compiler group with a similar problem a long time ago. I had them add=20 a call at the site of interest which (a) got the current process' pid,=20 (b) wrote a little gdb command script into a /tmp file which would=20 attach to the process, bt, and detach, (c) ran system ("gdb=20 --command=3D/tmp...") in the function, and (d) removed the file from /tmp. I'm sure there are better ways to handle all this, but it took about=20 five minutes to do all this correctly -- for a one-off problem, it=20 wasn't a bad solution. They captured stdout, massaged the output a=20 bit, and had the info they needed. J