Subj : Re: call stack To : borland.public.cpp.borlandcpp From : Bob Gonder Date : Mon Dec 20 2004 02:00 pm Jeff Kish wrote: >Yes, I am running Borland 5.02 with OWL. > >Is there some way (easy I hope) to get the call stack if I build with >debug, and display it somewhere like a messagebox, or a log file? I don't see a function to help with that, but it shouldn't be hard. To help you see every function, turn on Standard Stack Frame option. The basic functionality (in 32bit Windows code) would be like this: (written off-the-cuff, so may be some tweaks needed) First, for reference: How a StackFrame is contructed: FunctionEntryPoint: push ebp mov ebp,esp sub esp,16 ;16 bytes local variables other code mov esp,ebp pop ebp ret How to walk the stack: DWORD * pointer; DWORD return_address; asm mov [pointer],ebp; Again: asm{ mov eax,[pointer] mov edx,[eax+4] mov [return_address],edx mov eax,[eax] mov [pointer],eax }; printf the return address if( you_want_more_data ) goto Again; .