From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21162 invoked by alias); 8 Jan 2007 00:17:09 -0000 Received: (qmail 21152 invoked by uid 22791); 8 Jan 2007 00:17:08 -0000 X-Spam-Check-By: sourceware.org Received: from 211-255-32-57.rev.krline.net (HELO suresofttech.com) (211.255.32.57) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 08 Jan 2007 00:17:02 +0000 Received: from black ([222.106.18.236]) by suresofttech.com with MailEnable ESMTP; Mon, 08 Jan 2007 09:23:51 +0900 Message-ID: <008801c732ba$502534f0$aae074d3@black> Reply-To: "Hyun Seop Bae" From: "Hyun Seop Bae" To: Subject: How to retrieve the caller information from call stack Date: Mon, 08 Jan 2007 00:17:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: base64 X-Mailer: Microsoft Outlook Express 6.00.2900.3028 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-01/txt/msg00113.txt.bz2 SGkgdGhlcmUsDQoNCkknbSBsb29raW5nIGZvciBhIHdheSB0byByZXRyaWV2 ZSBjYWxsZXIgaW5mb3JtYXRpb24gZHVyaW5nIHJ1bi10aW1lLg0KT2YgY291 cnNlLCBJIGNhbiBmaW5kIHRoZSBuYW1lIG9mIGNhbGxlciBmdW5jdGlvbiBp ZiBJIHVzZSBnZGIgYW5kIHNldCBicmVha3BvaW50Lg0KDQpCdXQsIGhvdyBj YW4gSSBrbm93IHRoZSBuYW1lIG9mIGNhbGxlciBmdW5jdGlvbiB3aXRob3V0 IGdkYj8NCldoZW4gSSBpbnNlcnQgdGhlIF9fRlVOQ19fIG1hY3JvIGludG8g c291cmNlIGNvZGVzLCBJIGNhbiByZXRyaWV2ZSB0aGUgbmFtZSBvZiBjdXJy ZW50IHJ1bm5pbmcgZnVuY3Rpb24uDQpJcyB0aGVyZSBhbnkgbWFjcm8gb3Ig c29tZXRoaW5nIGxpa2UgdGhhdCB0byByZXRyaWV2ZSB0aGUgbmFtZSBvZiBj YWxsZXIgZnVuY3Rpb24/DQoNClRoYW5rcyBpbiBhZHZhbmNlLA0KDQotLQ0K SHl1biBCYWU= >From gdb-return-27366-listarch-gdb=sources.redhat.com@sourceware.org Mon Jan 08 05:06:36 2007 Return-Path: Delivered-To: listarch-gdb@sources.redhat.com Received: (qmail 29105 invoked by alias); 8 Jan 2007 05:06:32 -0000 Received: (qmail 29052 invoked from network); 8 Jan 2007 05:06:14 -0000 Received: from unknown (72.22.69.69) by sourceware.org with QMTP; 8 Jan 2007 05:06:14 -0000 Received: (qmail 788 invoked by uid 3521); 8 Jan 2007 05:01:13 -0000 Received: from 220.225.33.101 by rs384.securehostserver.com (envelope-from , uid 1002) with qmail-scanner-1.25st (clamdscan: 0.88/1245. spamassassin: 3.1.0. perlscan: 1.25st. Clear:RC:1(220.225.33.101):. Processed in 0.541898 secs); 08 Jan 2007 05:01:13 -0000 Received: from unknown (HELO ?192.168.100.106?) (220.225.33.101) by rs384.securehostserver.com with SMTP; 8 Jan 2007 05:01:12 -0000 Subject: Re: How to retrieve the caller information from call stack From: Ramana Radhakrishnan Reply-To: ramana.radhakrishnan@celunite.com To: Hyun Seop Bae Cc: gdb@sourceware.org In-Reply-To: <008801c732ba$502534f0$aae074d3@black> References: <008801c732ba$502534f0$aae074d3@black> Content-Type: text/plain Date: Mon, 08 Jan 2007 05:06:00 -0000 Message-Id: <1168232708.29620.14.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Delivered-To: mailing list gdb@sourceware.org X-SW-Source: 2007-01/txt/msg00114.txt.bz2 Content-length: 910 On Mon, 2007-01-08 at 09:16 +0900, Hyun Seop Bae wrote: > Hi there, > > I'm looking for a way to retrieve caller information during run-time. > Of course, I can find the name of caller function if I use gdb and set breakpoint. > > But, how can I know the name of caller function without gdb? You can use __builtin_return_address if you were using gcc to get to the address of the calling function . Getting to the name is a simple matter of using a script to identify the function in which the address is located, you can use an intelligent script using objdump / readelf to get to it. Ofcourse you'll have to do some more hackery if this were in a shared library :) . cheers Ramana -- cheers Ramana Ramana Radhakrishnan GNU Tools Celunite Inc (www.celunite.com) 3rd Floor, Business Avenue Lane 6 North Main Road Koregaon Park Pune 411001 Phone (work) - +912026051367 (mobile) - +919890040009