# c-plus-plus-callstack **Repository Path**: tjopenlab/c-plus-plus-callstack ## Basic Information - **Project Name**: c-plus-plus-callstack - **Description**: C++ program tracing tool https://github.com/goblinhack/c-plus-plus-callstack - **Primary Language**: C++ - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-04-25 - **Last Updated**: 2024-04-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README C++ program tracing tool ======================== Uses a constructor to maintain a callstack that can be dumped at any time. This is a portable approach that does not rely on backtrace() and c++ demangling which is very unportable. The only change you need is to include callstack.h and add an underscore at the beginning of a function (a bit of sedding can do this - reach out to me if you cannot do this). ```C++ void my_function (void) {_ // <<---- yes, add "_" to trace this function // rest of code } ``` you can even trace inside functions ```C++ void my_function (void) {_ // rest of code _ // more code _ } ``` Call the following anytime to dump the current stack: ```C++ CALLSTACK_DUMP(); ``` To build:
make ./callstackExample output:
Stack dump: (stack) 1 main.cpp void foo3(int, int), line 7 (stack) 2 main.cpp void foo2(int), line 12 (stack) 3 main.cpp void foo1(), line 17 (stack) 4 main.cpp int main(int32_t, char **), line 22NOTE: It should be thread safe as thread local storage is maintained for the callstack.