0

This question is just for understanding purpose.

What does _Unwind_Backtrace do internally to keep track of stack of function calls called.

Does some of unwind library code executes internally every time we call a function to keep track of the stack?

Or only when we call _Unwind_Backtrace, it collects the function stack and gives the information? If so, how does it collects the information.

I have googled for some time, but could not find any information on how unwinder works. If somebody knows, please explain.

Pendyala
  • 585
  • 1
  • 6
  • 17
  • I'd guess it simply knows the compilers format for the stack frame, and can simply check the stack (it should always contain a "pointer" to the calling function, at the very least the return address when the current function ends). – Some programmer dude Oct 19 '18 at 12:50
  • https://stackoverflow.com/a/2456882/1216776 – stark Oct 19 '18 at 12:55
  • "Does some of unwind library code executes internally every time we call a function to keep track of the stack?" No. When frame pointer is not omitted, it's easy to unwind the stack, as all the needed information is there. If frame pointer is omitted, then additional information is needed usually, which is stored in the ".eh_frame" section in the elf (but I don't know, how _Unwind_Backtrack works actually. With ".eh_frame", stack can be unwound easily. It's main purpose is to make stack unwind possible, when an exception is thrown). – geza Oct 19 '18 at 13:02

0 Answers0