-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Here you can find all informations about the CallstackLibrary as well as the documentation of the source code.
This library can translate backtraces obtained by the function backtrace
into a human readable format.
It will use the debug symbols of the application, in case they are not available, the informations obtained
by the dynamic linker are used.
Additionally, the name demangler for C++ names can be enabled.
There is also a wrapper class for easy use with C++ code.
- Using the function
callstack_new()
a callstack can be generated. - The getter functions
callstack_toArray()
andcallstack_toString()
provide simple access to the translated callstack. - The callstack struct can also be placed anywhere and filled using the functions
callstack_emplace()
andcallstack_emplaceWithBacktrace()
.
Example:
#include <callstack.h> #include <stdio.h> int main() { struct callstack * callstack = callstack_new(); char ** frames = callstack_toArray(callstack); printf("The current callstack:\n"); for (size_t i = 0; i < callstack_getFrameCount(callstack); ++i) { printf("In: %s\n", frames[i]); } callstack_delete(callstack); }
Using the wrapper class, the integration into C++ is simplified.
To use it, you need to do nothing - it is automatically included if you compile your code with a C++ compiler.
The move semantic is also supported by the wrapper!
Example:
#include <callstack.h> #include <iostream> int main() { cs::callstack callstack; char ** frames = callstack_toArray(callstack); std::cout << "The current callstack:" << std::endl; for (size_t i = 0; i < callstack_getFrameCount(callstack); ++i) { std::cout << "In: " << frames[i] << std::endl; } }
Copyright (C) 2022, 2024 mhahnFr.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".