Re: Getting a stack trace
From: Alexei A. Frounze (alexfru_at_chat.ru)
Date: 09/07/05
- Next message: Walter Bright: "Re: Getting a stack trace"
- Previous message: Andy Fraser: "Re: Grub, default boot question."
- In reply to: milkyway: "Getting a stack trace"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 7 Sep 2005 03:07:30 +0400
"milkyway" <d0mufasa@hotmail.com> wrote in message
news:1126040958.938914.75700@o13g2000cwo.googlegroups.com...
> Hello out there,
>
> When one gets an error, they can use
> fprintf (Stdout, "File %s Line %d\n", __FILE__, __LINE__);
>
> Is there a similar way where on can print out the stack trace?
>
> Any help, hints or advice is appreciated ;-)
If all you want to know is the function call sequence (not the whole stack
contents) that has led to this situation, then there's a solution: you
create your own stack-like structure, into which you can push either a
number or a string (i.e. char*) and then pop it off. Upon entry to each
function you push that function's ID (number or string) to the stack, upon
return you pop it off. At error you just dump the contents of the stack to
stdout, stderr or elsewhere. The dump will contain the exact call
sequence...
Alex
- Next message: Walter Bright: "Re: Getting a stack trace"
- Previous message: Andy Fraser: "Re: Grub, default boot question."
- In reply to: milkyway: "Getting a stack trace"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|