Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Library for logging Call Stack at runtime (Windows/Linux)

I need a way to record the function stack trace in a debug log to help me diagnose a defect. The problem is that I need to implement this on Windows and Linux using C++.

After a little research, I have found that:

  • For the Windows implementation, I can use StackWalk64 API function and family.
  • Under Linux, I have found libunwind that sounds great.
  • Or, I can use glibc's backtrace

Before starting work, I want some advice if this is the right way and to ask if there is an already written multi-platform library that can help. I suspect that I'm not the first programmer who needs this. :)

like image 775
vlg789 Avatar asked Oct 03 '11 06:10

vlg789


People also ask

How do I get stack trace on Windows?

Each thread has its own call stack, representing the calls made in that thread. To get a stack trace, use the methods GetStackTrace and GetContextStackTrace. A stack trace can be printed using OutputStackTrace and OutputContextStackTrace.

How can I get call stack information?

View the call stack while in the debugger While debugging, in the Debug menu, select Windows > Call Stack or press ctrl + alt + C .

What is call stack stack trace?

a call stack is a stack data structure that stores information about the active subroutines of a computer program. A stack trace is a report of the active stack frames at a certain point in time during the execution of a program.


1 Answers

Google Breakpad handles all of this for you if you want to get crash dumps back from the field.

like image 100
Ana Betts Avatar answered Oct 21 '22 03:10

Ana Betts