Googles appar
Huvudmeny

Post a Comment On: cbloom rants

"01-30-09 - Stack Tracing on Windows"

3 Comments -

1 – 3 of 3
Blogger castano said...

I've been playing with that stuff today and I was not able to get StackWalk64 to work without frame pointers. I would get garbage, while RtlCaptureStackBackTrace simply returned 0.

Something that puzzled me for a while was that the compiler was removing the frame pointers even when the FPO optimization was disabled. I had to explicitly set the /Oy- option to prevent that from happening.

On the other side, both StackWalk64, and RtlCaptureStackBackTrace worked fine on win64 without frame pointers. Win64 embeds additional meta-data in the binaries to make that possible: http://www.nynaeve.net/?p=101

August 2, 2010 at 11:35 AM

Blogger cbloom said...

Hmm.. not sure what the problem was with StackWalk , maybe it wasn't finding your PDB for some reason.

In any case, Win64 definitely makes this all way nicer. It's because of the change of the exception model :

http://cbloomrants.blogspot.com/2010/06/06-07-10-exceptions.html

you now get gauranteed frames everywhere.

August 2, 2010 at 1:11 PM

Blogger castano said...

Turns out that the problem is that RtlCaptureContext does not fill the context properly when FPO is enabled, so on x86 you have to do it manually. The following code seems to work:

CONTEXT ctx = { 0 };
ctx.ContextFlags = CONTEXT_CONTROL;
_asm {
call x
x: pop eax
mov ctx.Eip, eax
mov ctx.Ebp, ebp
mov ctx.Esp, esp
}

One nice feature of the StackWalk64 API is that you can pass the context provided to the unhandled exception filter, trying that out is when I noticed what was causing the problem.

August 3, 2010 at 10:13 AM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.