Re: stack trace without core
- From: Andrei Voropaev <avorop@xxxxxxx>
- Date: Tue, 26 Jun 2007 13:52:23 +0000 (UTC)
On 2007-06-23, Bin Chen <binary.chen@xxxxxxxxx> wrote:
On Jun 23, 2:33 am, RezaRob <Reza...@xxxxxxxxx> wrote:[...]
On Jun 22, 7:04 am, Jasen <j...@xxxxxxxxxxx> wrote:It is an option because you can attach gdb to yourself when some
On 2007-06-22, RezaRob <Reza...@xxxxxxxxx> wrote:
Is there a way to generate a brief view of the stack without dumping
entire core?
attach gdb to the process?
This isn't an option because it's in "production mode" and only in the
event of an exception I need a stack trace.
exception occurs.
sprintf(buf, "/usr/bin/gdbserver :9988 --attach %d", pid);
pid = fork();
if (pid == 0) {
system(buf);
Well. I've never used the gdbserver, but using regular gdb the whole
thing is possible. Generally you want to install signal handler that
does
echo "bt\ndetach\nquit\n" | gdb -batch -x /dev/stdin path_to_file pid
Then you need to catch the output from gdb.
One can use this simple piece of code for that
void
write_stack(int no)
{
char path[4096];
char str[256];
path[readlink("/proc/self/exe", path, -1 + sizeof(path))] = 0;
sprintf(str,
"echo 'bt\ndetach\nquit\n' | gdb -batch -x /dev/stdin %s %d",
path, getpid());
system(str);
}
If you catch stdout in some file already, then you'll get it right
there.
There's a catch here though. At least in my case. Somehow I was getting
only first line of the stack trace and nothing else. So I had to get rid
of "system" call and arrange piping of the input and output thru pipes
between processes.
--
Minds, like parachutes, function best when open
.
- References:
- stack trace without core
- From: RezaRob
- Re: stack trace without core
- From: Jasen
- Re: stack trace without core
- From: RezaRob
- Re: stack trace without core
- From: Bin Chen
- stack trace without core
- Prev by Date: Re: My way to check if a progam is already running
- Next by Date: "Default" value for close on exec flag
- Previous by thread: Re: stack trace without core
- Next by thread: NASA releases parts of mars robots sotware package as open source.
- Index(es):
Relevant Pages
|