Re: Getting a stack trace

From: Alexei A. Frounze (alexfru_at_chat.ru)
Date: 09/07/05


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



Relevant Pages

  • Re: HOWTO Implement LoadLibrary, GetProcAdress, and FreeLibrary.
    ... public static string Invoke(IntPtr IntPtr_Function, string csParam1, ... AssemblyName AssemblyName_This = new AssemblyName; ... // We must now push each paramter onto the stack. ... // We must now push the function pointer onto the stack. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: wide screen text mode?
    ... on the stack and perform a far call to the routine. ... update yx with cursor address/not 0008/0000 ... PUSH BP;save BP ... TEST AL,02H;00/01 CHAR OR 02/03 STRING? ...
    (comp.os.msdos.programmer)
  • Re: Stack
    ... character pointer once i exit the push function. ... So in case of *Strings* i cannot display the popped string or the ... members of the stack at any given time. ... struct stackelement item; ...
    (comp.lang.c)
  • Re: Quality of FastMM debug stack traces
    ... quickly filter out valid code addresses from the stack. ... A memory block has been leaked. ... Current memory dump of 256 bytes starting at pointer address BEADE8: ... see that the leaked string is "Hellow World". ...
    (borland.public.delphi.language.basm)
  • Re: Getting a stack trace
    ... If all you want to know is the function call sequence (not the whole stack ... number or a string and then pop it off. ... function you push that function's ID to the stack, ... At error you just dump the contents of the stack to ...
    (comp.unix.programmer)