Stack Trace

From OSDev.wiki
Revision as of 12:16, 14 March 2009 by osdev>Nathanjphillips (New page: The article Stack shows the layout of a stack and mentions the usefulness of a stack trace in debugging. Often a stack trace is written in assembly as it involves finding the current ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The article Stack shows the layout of a stack and mentions the usefulness of a stack trace in debugging.

Often a stack trace is written in assembly as it involves finding the current value of the ebp register. If you wish to write you stack trace routine in a higher-level language then you will need to find ebp. This can be done by finding the address of an object in a known location on the stack. One thing we always know is in a fixed location on the stack is the first argument to the current function. Taking the address of this argument gives us the value of the ebp plus 8 bytes. The following C++ code shows how this can be used to walk up the stack: