Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When function calls are nested, the stack grows downwards and builds a chain of stack frames. At any given point in a program it is theoretically possible to backtrace the sequence of stack frames to the original calling point. The <code>backtrace()</code> function navigates the stack frames from the calling point to the beginning of the program and provides an array of return addresses. The implementation of <code>backtrace()</code> in the glibc library contains platform-specific code for each platform. </p> <p>In the case of an x86 platform, the contents of the ebp (base pointer) and esp (stack pointer) CPU registers, which hold the address of the current stack frame and of the stack pointer for any given function, are used to follow the chain of pointers and move up to the initial stack frame. This allows the sequence of return addresses to be gathered to build the backtrace.</p> <p>If you would like to know more information on how <code>backtrace()</code> works and how to use it, I would recommend reading <strong><em><a href="http://www.linuxjournal.com/article/6391" rel="nofollow noreferrer">Stack Backtracing Inside Your Program</a></em></strong> (LINUX Journal).</p> <hr> <p>Since you mentioned executing a backtrace from a signal handler for an x86 platform, I would like to add to <a href="https://stackoverflow.com/questions/167927/is-there-a-function-to-invoke-a-stack-dump-in-c/167959#167959">Adam's answer</a> and direct you to <strong><a href="https://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes/1925461#1925461">my response</a></strong> to the question he linked to for details on how to ensure a backtrace from a signal handler points to the actual location of the fault. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload