RE: [GD-Windows] Call stack
Brought to you by:
vexxed72
From: Grills, J. <jg...@so...> - 2005-02-09 17:47:59
|
I have very similar code for walking the stack. My code works on many versions of windows, but it has stopped working as of Windows XP SP2. I even did a test on a machine where my test program worked, I upgraded to SP2, and the test program stopped working, so I know it had something to do with the SP2 upgrade. StackWalk won't walk the whole stack - it just gives up after returning 2 call stack frames. I've ended up having to rewrite StackWalk myself (which isn't very hard, if you disable the "Frame pointer omission" optimization, since you can use the EBP register to walk up the stack). I've complained to Microsoft about this, but they haven't been very quick to try and fix it. Anyone else run into the same problem on XP SP2? If it's just me, then I'll start comparing my code against other implementations (like the one below) to see what I may doing wrong. If it's not just me, I'd be happy to share my stack walking code so that others can work around the issue.. =20 One thing I do differently than most other implementations I've seen is that I don't do any symbol lookup while walking the stack. I have plenty of cases in the engine where I capture a call stack for debugging later if something else goes wrong, and the symbol lookup may not be necessary. For instance, our memory manager can grab a stack for every allocation, and at application exit time we can report the call stack for any memory leaks. Typically all allocations are properly freed, so looking up the symbols when capturing the call stack during an allocation is unnecessary and also seriously impacts performance. In the rare case of a memory leak (most often discovered in new code that hasn't been submitted), very few addresses need to be translated into symbols. =20 Jeff Grills=20 Senior Technical Director, Austin Studio=20 Sony Online Entertainment=20 -----Original Message----- From: gam...@li... [mailto:gam...@li...] On Behalf Of Simon O'Connor Sent: Wednesday, February 09, 2005 7:58 AM To: gam...@li... Subject: Re: [GD-Windows] Call stack =09 =09 =09 I wrote some code a while back that sounds like what you're after - or at least should point you in the right direction: =09 http://www.sc3d.com/thought/snippets/debugging/GetFunctionCaller/ NB: It's not quite what I'd class as "production" quality - it was written for debugging purposes only :o) Cheers, =09 Simon O'Connor Programmer @ Reflections Interactive & Microsoft DirectX MVP =09 =09 |