From: "Steven" <sos22@cam.ac.uk>
To: "Singh, Umesh K (MED)" <Umesh.Singh@geind.ge.com>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: (F)stack trace
Date: Thu, 21 Aug 2003 08:57:04 +0100 [thread overview]
Message-ID: <20030821075704.GA598@archibold.chu.cam.ac.uk> (raw)
In-Reply-To: <DD9E117A8BE9F34FA4130376EC9C1F6A05E5136D@BANMLVEM01.e2k.ad.ge.com>
[-- Attachment #1: Type: text/plain, Size: 459 bytes --]
> is it possible to get the stack trace without attaching the process
> to debugger. For Ex. can i write a func let's say
> "print_stack_trace()" and call it anywhere in my program to print
> the stack trace at that point of time.
If you're using glibc, it's reasonably easy:
#include <execinfo.h>
void print_stack_trace(void)
{
void *buffer[100];
int x;
x = backtrace(buffer, 100);
backtrace_symbols_fd(buffer, x, 1);
}
Steven Smith,
sos22@cam.ac.uk.
[-- Attachment #2: Type: application/pgp-signature, Size: 187 bytes --]
next prev parent reply other threads:[~2003-08-21 7:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-21 3:59 stack trace Singh, Umesh K (MED)
2003-08-21 5:07 ` Glynn Clements
2003-08-21 6:12 ` Fekete Gabor
2003-08-21 7:57 ` Steven [this message]
2003-08-21 10:57 ` Luciano Miguel Ferreira Rocha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030821075704.GA598@archibold.chu.cam.ac.uk \
--to=sos22@cam.ac.uk \
--cc=Umesh.Singh@geind.ge.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).