Skip to content

Commit

Permalink
common: Don't abort StackWalk when StackFrame.AddrFrame.Offset is zero.
Browse files Browse the repository at this point in the history
For code without frame pointer EBP might have any value, including zero.

This change allows to get at least the first entry of the stack when that
happens.

Fixes #29.
  • Loading branch information
jrfonseca committed Sep 7, 2016
1 parent 99e33c9 commit 58320fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

- https://github.com/gcc-mirror/gcc/tree/master/libbacktrace
- http://www.nongnu.org/libunwind/
- http://blog.reverberate.org/2013/05/deep-wizardry-stack-unwinding.html

- Generate gdb core dumps

Expand Down
12 changes: 3 additions & 9 deletions src/common/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,6 @@ dumpStack(HANDLE hProcess, HANDLE hThread,
)
break;

// Basic sanity check to make sure the frame is OK. Bail if not.
if (StackFrame.AddrFrame.Offset == 0)
break;

if (MachineType == IMAGE_FILE_MACHINE_I386) {
lprintf(
"%08lX %08lX %08lX %08lX",
Expand Down Expand Up @@ -309,11 +305,9 @@ dumpStack(HANDLE hProcess, HANDLE hThread,
dumpSourceCode(szFileName, dwLineNumber);
}

if (StackFrame.AddrStack.Offset < PrevFrameStackOffset) {
break;
}

if (StackFrame.AddrPC.Offset == 0xBAADF00D) {
// Basic sanity check to make sure the frame is OK. Bail if not.
if (StackFrame.AddrStack.Offset < PrevFrameStackOffset ||
StackFrame.AddrPC.Offset == 0xBAADF00D) {
break;
}

Expand Down

1 comment on commit 58320fa

@vit9696
Copy link

@vit9696 vit9696 commented on 58320fa Sep 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Please sign in to comment.