Stack: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
m Spelling & Grammar..
Moved Stack Trace to its own topic
Line 184: Line 184:
== Stack trace ==
== Stack trace ==


When debugging a stack trace is often shown and can be helpful. It analyzes the stack, finding the stack frames. Then it can extract the addresses of the routines called (calling each other) and display the names for them. The names has to be provided in a debug section of the object file being executed. Normally the debug section is removed in a kernel object file.
When debugging a stack trace is often shown and can be helpful. [[Stack Trace]] describes how this can be done and provides sample code for X86 CDECL using the stack layout above.

A stack trace is easily implemented. You have to know the structure of the stack frames, which is shown above for X86 CDECL. Then you need a table of routine addresses and their names. When looking up a routine you have to find the biggest address smaller than the value you are looking for. This is because the calls are performed inside a routine. The return values are the routine address and some more (the position of the instruction). It's not exactly the routine's address.


== Unwinding the stack ==
== Unwinding the stack ==