Subj : Re: call stack To : borland.public.cpp.borlandcpp From : Jeff Kish Date : Tue Dec 21 2004 08:50 am On Mon, 20 Dec 2004 14:00:30 -0800, Bob Gonder wrote: >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; > > Thanks. So Bob, I need to embed a small amount of assembly code into the c++ code? Does that mean I need the assembler product? I am fairly assembly illiterate. Thanks for any additional pointers, Jeff Kish .