Call Stack Logger uses function instrumentation to facilitate logging of every function call. Each nesting adds an ident, whereas returning from a function removes it. As the result call stack tree is produced at the runtime giving knowledge of the actual program's flow of execution.
Here is the article on dev.to describing the details of the project, its aim and motivation
behind it:
Call Stack Logger - Function instrumentation as a way to trace program’s flow of execution
- Linux (the library reads
/proc/self/mapsand/proc/self/exeand usesdladdr) - CMake 3.14 or newer
- GCC or Clang with C++17 support, and glibc
Nothing else has to be installed. Addresses are resolved with
libbacktrace (BSD-3-Clause), whose
sources CMake downloads at configure time from a pinned commit and compiles into the
library; THIRD_PARTY.md lists it with its license. For a build
without network access, unpack that commit somewhere and pass
-DFETCHCONTENT_SOURCE_DIR_CSLG_LIBBACKTRACE=<directory>. The commit is
0b9b49cf4a2c9229fc052d6716e1528b2f23e91a; its archive is
https://github.com/ianlancetaylor/libbacktrace/archive/0b9b49cf4a2c9229fc052d6716e1528b2f23e91a.tar.gz.
Configure checks that the files it compiles are that commit's, however they
arrived. Two of them, dwarf.c and elf.c, are compiled from corrected copies
(complete paths in DWARF 5 line tables, and the last bytes of a zlib-compressed
debug section; THIRD_PARTY.md has the details).
Optional: the debug symbols of the C library (libc6-dbg on Debian and Ubuntu,
glibc-debuginfo on Fedora) give the frames inside libc — the caller of main, for
example — a file and a line instead of :???. The test suite also uses objcopy and
strip, which come with the compiler.
git clone https://github.com/TomaszAugustyn/call-stack-logger.git
cd call-stack-logger
# Create build folder and go there
mkdir build && cd build
# Configure cmake with default logging (GCC is the default compiler)
cmake ..
# or to build with Clang instead of GCC (both compilers: the bundled libbacktrace is C)
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..
# or to log the execution time of each function entry
cmake -DLOG_ELAPSED=ON ..
# or to include each callee's address in the output
cmake -DLOG_ADDR=ON ..
# or to see every throw, rethrow, catch and terminate in the tree (see "Exceptions in the trace tree")
cmake -DLOG_EXCEPTIONS=ON ..
# or to compile your application with disabled instrumentation (no logging)
cmake -DDISABLE_INSTRUMENTATION=ON ..
# or to build with tests and code coverage
cmake -DBUILD_TESTS=ON -DCOVERAGE=ON ..
# Build
make
# Build and Run (as the result trace.out file will be generated)
make runEach run appends to the trace output file with a timestamped separator header, so consecutive
runs are easy to distinguish. Output is line-buffered for crash safety without per-call overhead.
If the trace file cannot be opened, or the executable has neither a symbol table nor debug
information so that none of its functions can be named, a warning is printed to stderr.
Both GCC and Clang use -finstrument-functions for user code. The callstacklogger library
itself is compiled without instrumentation flags (all its functions have the NO_INSTRUMENT
attribute). Standard library exclusion differs by compiler:
| GCC | Clang | |
|---|---|---|
| Std library exclusion | Compile-time (-finstrument-functions-exclude-file-list) |
Runtime (mangled name filter in resolve_function_name()) |
| Exit hooks on exception unwind | Emitted — the unwound frames' exits are traced | Not emitted — the tracer reclaims the unwound frames at the next hook (see below) |
GCC auto-discovers std library header paths and excludes them at compile time. Clang does
not support the exclude-file-list flag, so std library functions are filtered at runtime by
checking the Itanium C++ ABI mangled name for known std::, __gnu_cxx::, and
__cxxabiv1:: prefixes.
The two mechanisms draw the line in different places, so the traces are the same for ordinary user code but can differ at the edges:
- Your own code in namespace
std(astd::hash<MyKey>specialization, a customstd::swapoverload) lives in your source file, so GCC traces it. Clang's filter only sees the mangled name, which starts withstd::, and drops it. - Third-party header-only code installed under
/usr/include(fmt, Boost, nlohmann json, ...) sits inside a directory on GCC's exclude list — the list is built from the compiler's system include paths, and/usr/includeis one of them — so GCC never instruments it. Clang instruments it and, because the names are notstd::, traces it.
Exceptions under Clang, longjmp on both compilers. Clang's
-finstrument-functions does not call __cyg_profile_func_exit for frames unwound by a
thrown exception, while GCC emits the exit call on the exceptional path too (like a
cleanup). longjmp restores the stack without running any cleanups, so the exit hooks of
the jumped-over instrumented frames never fire on either compiler. Neither affects the
tree: the tracer keys every frame record by its stack level and reclaims the records of
frames that are gone at the next hook, in every build, so the calls that follow a catch or
a jump sit at their true depth; the mechanism is described under
Keeping the tree exact after non-local exits.
What the unwound frames' own lines show differs by compiler: on GCC their exit hooks ran,
so with LOG_ELAPSED they carry measured durations, while on Clang they keep
[ pending ]. LOG_EXCEPTIONS marks such lines on both compilers (!_, ~_,
[! unwound ], [~ unwound ], see the section linked above).
The hooks are compiled into every function, but they only write while the tracer is
running: from the library's own startup constructor (trace_begin, which runs before
main()) until the main thread's per-thread tracer state is torn down at the start of
exit(). Calls outside that window are silently dropped:
- Global constructors in your program that run before
trace_begin— the order of constructors across translation units and libraries is not defined, so a constructor in your code may run first. Instrumented functions it calls leave no trace line. - After
main()returns, the only traced code on the main thread is the body ofthread_localdestructors that run before the tracer's own (glibc runs them in reverse order of first use, and the tracer's state is used from the very first hook, so anythread_localobject first touched duringmain()qualifies).atexithandlers — including ones registered duringmain()— destructors of function-local statics and destructors of global objects are never traced. They may still call instrumented code safely; it just produces no lines. Worker threads are simpler: a thread's tracing stops when its ownthread_localstate is destroyed at thread exit. - Frames still active when
exit()is called.exit()never returns, so the exit hooks ofmainand everything below it on the stack never fire. WithLOG_ELAPSEDthose lines keep[ pending ]exactly as they would after a crash (see Crash diagnostics) — a[ pending ]onmainmeans the program left throughexit(),_exit(),abort()or a signal, not throughreturn. WithLOG_EXCEPTIONS, an exception that nobody caught leaves aterminateline naming it as the last line of the trace.
Call Stack Logger ships a CMake target (callstacklogger::instrumented) that carries
every flag needed for tracing — -finstrument-functions, -g, the exported hook
symbols, the GCC std-library exclude-file-list, and the library itself (with the symbol
resolver inside, plus -ldl). A user project only needs to link against it; no
per-target target_compile_options boilerplate.
Consuming the project this way stays side-effect free: the demo executable and the
test tree are built only for a standalone (top-level) build, so your own
BUILD_TESTS option never pulls in Call Stack Logger's tests or its Google Test
download; every test target the project does define carries a cslg_ prefix
(cslg_unit_tests, ...), so it cannot clash with a unit_tests target of yours; and
the LOG_ADDR / LOG_ELAPSED macros stay private to the
library — they are never defined in your translation units.
Same as building Call Stack Logger standalone:
- Linux, CMake 3.14 or newer, GCC or Clang with C++17 support
- network access at configure time for the pinned libbacktrace download, or
FETCHCONTENT_SOURCE_DIR_CSLG_LIBBACKTRACEpointing at a local copy (see Requirements) libc6-dbgrecommended (file and line for the frames inside libc)
No manual checkout required. CMake downloads Call Stack Logger on first configure.
In your project's CMakeLists.txt:
cmake_minimum_required(VERSION 3.14)
project(my_app LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(FetchContent)
FetchContent_Declare(
call-stack-logger
GIT_REPOSITORY https://github.com/TomaszAugustyn/call-stack-logger.git
GIT_TAG master # or pin to a specific tag/commit
)
FetchContent_MakeAvailable(call-stack-logger)
add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE callstacklogger::instrumented)For projects that prefer to vendor the source (pinned version; for offline builds add
FETCHCONTENT_SOURCE_DIR_CSLG_LIBBACKTRACE, see Requirements):
git submodule add https://github.com/TomaszAugustyn/call-stack-logger.git third_party/call-stack-logger
git submodule update --init --recursiveThen in your CMakeLists.txt:
cmake_minimum_required(VERSION 3.14)
project(my_app LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_subdirectory(third_party/call-stack-logger)
add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE callstacklogger::instrumented)No changes to your source code are required — the compiler's -finstrument-functions
flag inserts hooks into every function automatically.
cmake -B build
cmake --build build -j$(nproc)
./build/my_app # runs your app and writes ./trace.out
cat trace.outTo redirect the trace somewhere else, set CSLG_OUTPUT_FILE:
CSLG_OUTPUT_FILE=/tmp/my_app_trace.out ./build/my_appSee Environment Variables for multi-threaded output naming.
Each trace line ends with (called from: <file>:<line>). Call Stack Logger resolves this
from the DWARF debug info (-g) in the CALLER's object file. The
callstacklogger::instrumented target adds -g to targets that link against it, but
third-party libraries you depend on (e.g. spdlog, fmt, boost) are compiled by their own
CMake rules — and most C++ libraries default to CMAKE_BUILD_TYPE=Release, which omits
-g. When a function inside such a library calls another function, both sides lack
debug info, and the trace shows (called from: SomeFunc:???).
To avoid this, configure your build with a type that preserves debug info:
cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo # -O2 -g -DNDEBUG
# or
cmake -B build -DCMAKE_BUILD_TYPE=Debug # -O0 -gIn practice this drops the unresolved-caller rate from ~20 % down to ~2–3 %. (Measured
against a spdlog 1.14 integration: 20.1 % :??? in Release, 2.7 % in RelWithDebInfo.)
The residual ~2 % is mostly inlined helpers where the compiler dropped line info.
One caveat at optimized levels (-O2 and up): when the compiler inlines an
instrumented function into its caller, the enter/exit hooks still fire (the call
tree stays complete, durations and nesting are unaffected), but the inlined call
has no physical stack frame — the return address the hook receives belongs to
the enclosing physical frame, so (called from: ...) reports that frame's
call site, one level up. Functions the compiler keeps out-of-line get exact
caller locations at every optimization level.
The resolver reads names from the symbol table and lines from the DWARF data of each
loaded object file. A binary stripped with strip --strip-all (which is what a plain
strip and cmake --install --strip do) has neither left, so none of its functions can
be named and its trace stays empty; the library then prints one warning on stderr at
the first traced call. (A binary stripped the way Fedora's packages are keeps its
function names in a compressed MiniDebugInfo section, .gnu_debugdata, which the
resolver reads: no warning then, names without lines.) The remedy is the one
distributions use: keep the debug information in a separate file and leave a link to
it in the binary. Call the helper on your executable target:
add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE callstacklogger::instrumented)
cslg_keep_debug_info(my_app INSTALL_DESTINATION bin) # INSTALL_DESTINATION is optionalAfter every link it writes my_app.debug next to the binary (objcopy --only-keep-debug) and adds a .gnu_debuglink to the binary (objcopy --add-gnu-debuglink); the binary itself is not stripped. Strip it whenever you like
afterwards — the link survives a full strip — and ship or install my_app.debug next to
it (or under /usr/lib/debug): the resolver follows the link and the trace is complete.
Two costs to know: the .debug file is as large as the
binary's debug information, and once the link exists the resolver reads the debug file
(checking its CRC over its whole length) instead of the binary's own sections, a one-time
cost per object file at its first traced call. Shared libraries without debug
information still show their function names, with :??? for the line.
| Target | What it adds to your executable |
|---|---|
callstacklogger::instrumented |
-finstrument-functions (with GCC's exclude-file-list), -g, the exported hook symbols, the library (symbol resolver included), -ldl, include path. Use this for per-call tracing (the common case). |
callstacklogger::callstacklogger |
Library only: -g, the exported hook symbols, the library, -ldl, include path — no -finstrument-functions. Use this when you want just the on-demand get_call_stack() API without per-call hooks. |
The exported symbols are the two hooks, __cyg_profile_func_enter and
__cyg_profile_func_exit (plugins loaded with dlopen() bind to them, see below),
plus the five interposed runtime entry points with LOG_EXCEPTIONS. They are exported
one by one with --export-dynamic-symbol; with a linker that lacks the option (GNU ld
before binutils 2.35) or with -DCSLG_EXPORT_ALL_SYMBOLS=ON, -rdynamic exports every
symbol instead, as releases before v1.0 did.
Trace files are opened lazily on each thread's first traced call, so a program
that links the plain library only for get_call_stack() never creates a trace
file as a side effect. (With LOG_EXCEPTIONS the exception events are traced
in every program that links the library, so such a program's first throw
does create the file, holding the event lines only.)
To compile your project without any instrumentation hooks (e.g. for release builds):
cmake -B build -DDISABLE_INSTRUMENTATION=ONWith the option on, callstacklogger::instrumented contributes nothing to your
executable: no -finstrument-functions, no -g, no exported symbols and no library — a
release build with the target in its link line is the same binary as one that never knew
the library (the test suite compares the two). The __cyg_profile_func_enter/exit hooks
compile out entirely. A program that calls the on-demand
get_call_stack() API in such a build links
callstacklogger::callstacklogger for it explicitly. cslg_keep_debug_info() is not
tied to the option: called on a target, it still writes the .debug file and adds the
.gnu_debuglink, which such a program needs once its binary is stripped. Leave the call
out of a build that must stay byte-identical to one without the library.
If you want per-target control — e.g., trace only one executable in a multi-target
project — link callstacklogger::instrumented only on the targets you want traced,
and link callstacklogger::callstacklogger (or nothing) on the others. Because
-finstrument-functions is on the instrumented target's INTERFACE, it only reaches
the consumers you choose.
Shared libraries loaded at runtime can be traced too: compile them with
-finstrument-functions (the callstacklogger::instrumented compile flags) and do
NOT link the library into them — their hooks bind at load time to the host
executable's exported __cyg_profile_func_* symbols.
The host must keep those symbols exported. A link that hides the symbols of static
libraries (-Wl,--exclude-libs,ALL, or a version script that exports only some names)
leaves the plugins' hook calls bound to glibc's own __cyg_profile_func_enter/exit,
which do nothing: the plugins' functions are then missing from the trace without any
error. With LOG_EXCEPTIONS the library warns at startup when the interposers are
hidden that way.
The object file behind each address is located through /proc/self/maps, so a plugin
loaded by a relative path (dlopen("./plugin.so")) resolves correctly even if the
program chdir()s
before the first traced call into it. A plugin whose file was deleted or replaced
on disk after loading reports <could not open object file> instead of symbols
from the wrong file, and so does an object without a file of its own (the vdso):
the resolver only opens absolute paths it got from the kernel, never a bare name
that would be looked up in the current directory. Separate debug files are opened
only if they are regular files, so a FIFO under a debug file's name cannot block
the program. Replace a plugin on disk with a new file (install, mv) rather than
overwriting it in place (cp onto it): a loaded object file that is truncated or
rewritten in place can crash the program, through the loader's mappings of its
code and through the resolver's mappings of its debug information alike.
| Option | Default | Description |
|---|---|---|
LOG_ADDR |
OFF |
Include function addresses in trace output |
LOG_ELAPSED |
OFF |
Record per-function duration in trace output. See Per-function timing. |
LOG_EXCEPTIONS |
OFF |
Trace every throw, rethrow, catch and terminate in the call tree and mark the lines of the frames an exception or a longjmp left. Needs the shared libstdc++. See Exceptions in the trace tree. |
DISABLE_INSTRUMENTATION |
OFF |
Compile without any instrumentation hooks; callstacklogger::instrumented then contributes nothing to a program (see Disabling tracing in a build) |
CSLG_EXPORT_ALL_SYMBOLS |
OFF |
Link tracing programs with -rdynamic (every symbol exported) instead of exporting only the hooks and, with LOG_EXCEPTIONS, the interposers |
BUILD_BENCH |
OFF |
Build the cost benchmark in bench/ and its bench target (top-level builds only) |
BUILD_TESTS |
OFF |
Build unit and integration tests (fetches Google Test). Honored only when Call Stack Logger is the top-level project, never when consumed via add_subdirectory / FetchContent. |
COVERAGE |
OFF |
Enable code coverage via GCC --coverage flag |
SANITIZE |
(empty) | Enable a sanitizer for all cslg-owned targets: address, undefined, address+undefined, or thread. See Sanitizers. |
| Variable | Default | Description |
|---|---|---|
CSLG_OUTPUT_FILE |
trace.out |
Path to the trace output file for the main thread. Worker threads append _tid_<gettid> to this path (e.g., /tmp/my_trace.out_tid_12345). A relative path is resolved against the working directory at program start, so a later chdir() never splits one run's per-thread files across directories. |
Example:
CSLG_OUTPUT_FILE=/tmp/my_trace.out ./build/runDemo
# Single-threaded program → /tmp/my_trace.out
# Multi-threaded program → /tmp/my_trace.out + /tmp/my_trace.out_tid_<N> per workerSecurity note: trace files are created with 0600 permissions and opened
with O_CLOEXEC (subprocesses spawned by the traced program do not inherit the
trace file descriptors) and O_NOFOLLOW, which rejects a symlink as the
final path component but
does not protect against symlinked intermediate directories. Point
CSLG_OUTPUT_FILE only at directories you trust (avoid world-writable
locations shared with untrusted users), and do not link the tracer into
setuid/setgid binaries — the output path is taken from the environment.
Build with -DLOG_ELAPSED=ON to record how long every traced function takes
to execute, displayed inline alongside the call. Useful for spotting bottlenecks
in unfamiliar code without leaving the trace-driven debugging workflow.
cmake -B build -DLOG_ELAPSED=ON
cmake --build build
./build/runDemoA 12-byte fixed-width duration field is spliced between the timestamp and the
tree column, so it never disturbs tree alignment and is independent of
LOG_ADDR:
[21-04-2026 15:00:00.123] [ 105.323ms] |_ main (called from: …libc-start.c:310)
[21-04-2026 15:00:00.123] [ 123.000ns] | |_ A::foo() (called from: .../main.cpp:28)
[21-04-2026 15:00:00.123] [ 45.678ms] | |_ B::foo() (called from: .../main.cpp:33)
[21-04-2026 15:00:00.124] [ 1.234us] | | |_ A::foo() (called from: .../main.cpp:18)
Combined with LOG_ADDR=ON the address column simply follows the duration:
[21-04-2026 15:00:00.123] [ 105.323ms] addr: [0x00007fff12345678] |_ main (called from: …)
| Range | Example | Notes |
|---|---|---|
< 1 µs |
[ 123.000ns] |
ns unit |
< 1 ms |
[ 123.456us] |
us unit |
< 1 s |
[ 123.456ms] |
ms unit |
< 1000 s |
[ 1.234s ] |
s unit (trailing space pads the field) |
≥ 1000 s |
[ >999.9s ] |
saturation sentinel |
Auto-scales to keep the output readable. The placeholder while a function is
still executing is [ pending ]. The second byte of the field is blank in
every rendering; with LOG_EXCEPTIONS it carries a flag telling how the frame
ended (see Exceptions in the trace tree).
The duration is written on function exit by patching the line in place
(pwrite() over a 12-byte placeholder). If the program crashes while a
function is still running, that line stays on disk with [ pending ]
intact — this is a feature, not a bug. Every line carrying [ pending ]
in the tail of a post-crash trace file identifies a frame that was active
at the crash site:
[21-04-2026 15:00:01.500] [ pending ] |_ main (called from: …)
[21-04-2026 15:00:01.500] [ pending ] | |_ process_request() (called from: server.cpp:42)
[21-04-2026 15:00:01.501] [ pending ] | | |_ parse_header() (called from: server.cpp:120)
*** SIGSEGV ***
Reading from the bottom up gives the call chain at the crash. Combined with the timestamps you also see roughly when each frame had been entered relative to the crash — additional signal that's hard to get from a stack trace alone.
The same degraded mode protects against I/O failures: if a trace line write
fails (disk full, I/O error), the logger stops patching from that point on for
the affected thread — later lines keep [ pending ] rather than risking
duration bytes being written at stale offsets into the middle of other lines.
Likewise, if the second (patching) file descriptor cannot be opened at all —
e.g. /proc is not mounted in a minimal container, or the process ran out of
descriptors — tracing itself continues normally and every line simply keeps
[ pending ]; a warning on stderr explains why.
The reported span covers the instrumented function itself: the enter hook reads
the clock as its last step (after symbol resolution, formatting, and the
line write) and the exit hook reads it first (before its own formatting and
pwrite), so the tracer's per-call work is not billed to the function it
traces. Tracing overhead of calls nested inside a function does remain part
of that function's span — a parent's duration always contains its children's
full spans, hooks included.
Adds two steady_clock::now() reads (~20 ns each with a TSC clocksource; over
1 µs per read on VMs that fall back to hpet/acpi_pm) and one pwrite() syscall
(~0.5–1 µs) per traced function call. Trace file size grows by ~13 bytes per
line (the placeholder + separator space). For a debug-time tool this is
small next to the resolver's first lookup of each address. With
LOG_ELAPSED=OFF the produced binary is byte-identical to a build without
the option — the entire feature is gated behind compile-time #ifdefs.
LOG_ELAPSED works alongside the multi-threaded per-thread-file design;
each thread keeps its own pair of file descriptors and patches durations
independently with no cross-thread synchronization on the write path.
One limitation: do not point two processes at the same CSLG_OUTPUT_FILE
concurrently when LOG_ELAPSED is on. Each process tracks its own byte cursor
from the position it observed at startup; a second process appending to the
same file shifts the real offsets and the in-place duration patches would land
inside the other process's lines. (Concurrent threads are fine — they write
to separate per-thread files. Sequential runs are fine too — each run re-reads
the file size on start.)
Build with -DLOG_EXCEPTIONS=ON to see every exception in the call tree, at the
point where it was thrown, rethrown and caught, and to mark the lines of the
frames it left. The tree itself stays exact after exceptions and longjmp in
every build; the option adds the events and the marks.
cmake -B build -DLOG_EXCEPTIONS=ON
cmake --build build
./build/runDemoEvery throw, every throw;, every std::rethrow_exception() and every
catch in the process becomes a line in the tree, as a child of the innermost
traced frame at that moment, ending in the !! glyph instead of |_ :
[25-09-2026 04:07:02.325] |_ exc_catcher() (called from: main.cpp:233)
[25-09-2026 04:07:02.325] | !_ exc_mid() (called from: main.cpp:71)
[25-09-2026 04:07:02.325] | | !_ exc_thrower() (called from: main.cpp:66)
[25-09-2026 04:07:02.325] | | | !! throw std::runtime_error "bad header" (thrown at: main.cpp:61)
[25-09-2026 04:07:02.325] | | |_ ExcGuard::~ExcGuard() (called from: main.cpp:67)
[25-09-2026 04:07:02.325] | | | |_ exc_helper() (called from: main.cpp:57)
[25-09-2026 04:07:02.325] | !! catch std::runtime_error "bad header" (caught at: main.cpp:72)
[25-09-2026 04:07:02.325] |_ exc_marker_a() (called from: main.cpp:234)
Read it top down: exc_thrower threw, the exception left exc_thrower and
exc_mid (their glyphs are patched to !_, see below), a destructor ran a
traced helper on the way out, and exc_catcher caught it on its line 72. The
frames that returned normally keep |_.
-
Type and message. The line names the dynamic type of the thrown object and, when that type derives from
std::exception, itswhat()text. Control characters in the text become spaces and a text longer than 127 bytes is cut with..., so one event stays on one line. Athrow 42;showsthrow intwith no text. The tracer's own calls towhat()leave no trace lines, even whenwhat()is an override compiled with instrumentation; only the program's calls to it are traced. -
Site.
thrown at,rethrown atandcaught atare resolved exactly likecalled from: file and line of the statement (thecatchclause's line for a catch). A throw born inside libstdc++ (vector::at,newfailing) or inside a library you did not instrument is seen too; its site resolves as far as that object's debug info allows, with the same fallbacks as call sites. One compiler quirk is handled: GCC 13 at-O2gives the entry of acatchlanding pad no source location, so the line of whatever code precedes it would be reported (a line of the previous function); the tracer notices the leaked line and reports the handler's first statement instead. -
Rethrows.
throw;gives!! rethrow std::logic_error (rethrown at: ...).std::rethrow_exception(), the mechanism behind futures, coroutines and stored exception pointers, gives the same line withvia std::rethrow_exceptionappended and the exact statement that rethrew. -
An exception nobody catches, and every other road to
std::terminate. The runtime finds no handler, so it calls the catch entry point itself and terminates. The tracer turns that into aterminateline, the last line of the trace, and leaves every active frame[ pending ]:[25-09-2026 04:07:02.325] [ pending ] |_ uncaught_outer() (called from: main.cpp:58) [25-09-2026 04:07:02.325] [ pending ] | |_ uncaught_leaf() (called from: main.cpp:47) [25-09-2026 04:07:02.325] [ throw ] | | !! throw std::logic_error "nobody catches this" (thrown at: main.cpp:42) [25-09-2026 04:07:02.325] [ terminate] | | !! terminate std::logic_error "nobody catches this" (no handler found)The parenthesis says which road it was.
(no handler found)is athrow, athrow;or astd::rethrow_exception()that nothing catches. The other roads render the same line with a different ending:!! terminate std::logic_error "nobody catches this" (thrown across a noexcept boundary) !! terminate std::logic_error "nobody catches this" (std::terminate called at: main.cpp:71) !! terminate (no active exception) (std::terminate called at: main.cpp:75)The first is an exception that could not leave a
noexceptfunction, or a destructor running during unwinding, on both compilers. The second is the program callingstd::terminate()itself, in a handler or anywhere else, or the runtime calling it, for instance for astd::threadwhose function threw; the site is that call. The third is the same call with no exception being handled; it reads(exception in flight)instead when an exception is on its way but was not caught first, which older compilers do fornoexceptviolations. The terminate handler's own rethrow and catch, which the default one does to print its message, are not traced. -
Cancellation and foreign exceptions.
pthread_cancelandpthread_exitunwind the thread with a forced unwind, which acatch (...)handler sees like an exception and must rethrow; the C++ runtime never threw it and has no type for it, so its lines read!! catch (forced unwind)and!! rethrow (forced unwind). An exception of another language runtime passing through C++ frames reads(foreign exception). The frames such an unwind leaves show as left by an exception where their exit hooks ran (GCC) and stay unmarked on Clang, whose thread ends before another hook runs. -
With
LOG_ELAPSEDthe duration column of an event line holds a word instead of a duration:[ throw ],[ rethrow ],[ catch ],[ terminate]. WithLOG_ADDRthe address column holds the event's site (a terminate line has one only for astd::terminate()call). -
How it works. The tracer defines
__cxa_throw,__cxa_rethrow,__cxa_begin_catch,std::rethrow_exceptionandstd::terminatein your executable and forwards every call to the C++ runtime's own implementation, found withdlsym(RTLD_NEXT). The dynamic linker resolves those names to the executable first, so the tracer sees throws from your code, fromlibstdc++.soitself and from every shared library. The definitions are weak: a program that defines its own__cxa_throw(some backtrace-on-throw helpers do) still links, its definition wins, and the tracer prints one warning at startup saying which events it will not see. The one exception is an AddressSanitizer build, where the definitions are strong so they beat the sanitizer runtime's own weak__cxa_throw; such a program then fails to link withLOG_EXCEPTIONS, with a duplicate-definition error.-static-libstdc++and fully static executables are not supported with this option: there is no runtime definition to forward to, so CMake warns at configure time and the program stops at startup with a FATAL message instead of failing at its first throw. Exceptions thrown and caught inside the tracer itself are never traced. AddressSanitizer's own interception of__cxa_throwkeeps working with either compiler.
This part is on in every build; LOG_EXCEPTIONS only adds the marks below.
The tracer pairs enters and exits positionally: every enter pushes a record on a
per-thread stack, every exit pops one. Two things would break that pairing
silently if records were popped blindly. Clang emits no exit hook for frames an
exception unwinds through, and longjmp skips the exit hooks of every frame it
jumps over on both compilers. A stale record would then make each later exit pop
the wrong record: the tree would drift one level deeper per skipped frame for
the rest of the thread, and with LOG_ELAPSED durations would land on the wrong
lines.
So every record also carries the frame's level, its canonical frame address: the stack pointer's value just before the call that created the frame. Stacks grow downward, so a frame deeper than the one running now always has a lower level, and a deeper frame cannot still be alive under a running shallower one. The hooks use that to reclaim what is gone:
- At every enter, records whose level lies below the entering frame's are
dead (deeper frames that never ran their exit hook), and so is a record at the
same level that was called from a different place (the frame's stack slot is
being reused after a
longjmp). They are popped before the new line is written, so the line lands at its true depth. - At every exit, the hook looks for the record carrying its own callee,
caller and level instead of blindly taking the top one; whatever sits above it
is dead and is popped along. When no record carries the callee and the
caller, the record of the callee at or above the hook's level is the frame:
GCC splits some functions at
-O2, and the two hooks of such a frame pass different callers. When there is none of those either, the frame has no record left, and the hook pops nothing: the record on top belongs to another frame, and taking it would pass the mistake on to that frame and to every frame below it.
The level is the canonical frame address and not the hook's own frame address on
purpose: the latter also depends on the callee's frame size, so two functions
called from the same place would not compare equal. How the one derives from the
other is a constant of each hook call site, measured once per site with a
two-frame unwind and cached per thread; afterwards each hook pays one hash
lookup and an addition. For a frame that keeps a frame pointer the level derives
from that pointer rather than from the hook's frame address (on x86; the two
sit a fixed two words apart), which stays exact when the frame's size differs
from call to call — alloca(), variable-length arrays — where the distance to
the hook's frame changes with every call. A catch measures the catcher's level
afresh instead of trusting the cache: a stale distance there could reclaim the
catcher's own record.
Inlined frames. A function the optimizer inlined still fires its hooks, but
it runs inside its host's physical frame: same level, same caller. The level
rules alone cannot tell a dead inlined frame (unwound by an exception under
Clang, skipped by longjmp) from a live inline host, so the tracer asks DWARF.
The inline chain at a site, the list of functions inlined into each other
there, comes from the same debug information the resolver already reads for line
numbers: at a catch, its innermost entry is the function that caught, and every
record above that function's record at the same level is dead; at an enter,
the function that follows the entering one in the chain is its host, with the
same rule; and the function containing a call site names a normal call's parent,
so dead inlined frames above the parent's record are reclaimed before the call's
line is written. The chains are resolved once per site and cached, from DWARF 4
and DWARF 5 alike, so Clang's default debug format needs no option.
At an enter the chain is read twice, inside the hook's call instruction and at the first instruction after it, and both are searched for the entering function under the name the debug information has for it at its own address. A hook call is not always counted as part of the function it belongs to: GCC gives the call no scope of its own, so when the optimizer moves an instruction of the host between the function's entry and its hook call — a constructor that sets a few members and then constructs one — the chain at the call starts at the host. A record is reclaimed only on what the chains that name the entering function agree on, and when none names it, nothing is reclaimed there.
One more case needs care. GCC's debug information knows a function with
internal linkage (static, anonymous namespace, a lambda) by its bare name
only, so two such functions of one name look the same in a chain. When one is
inlined into the other and both chains start at the outer one, the outer
function is taken for the one that is entering, and its own record would be
reclaimed while it runs. An inner constructor with nothing to do, behind an
outer one that sets a few members, is enough for that. What tells the outer
function's record from a dead one of the same name is which inlined copy it
is: the debug information records for every copy the file and line it was
called from. So when the entering function was found by its name alone, a
record that has this name, belongs to another function and was called from
the very place the chain entry was called from is kept, and the records
around it with it. A dead frame of the same name was called from somewhere
else and goes. The exception is a retry loop: when an earlier frame of the
entering function itself is among the records to reclaim, all of them are
dead, and all go.
A record is found by its function's name, so a frame that writes no line keeps
one too. Under Clang the functions of the standard library that are inlined
into your code run the hooks without being logged, and each is the host of
whatever is inlined into it. With no name on its record, the search for the
host std::queue::empty() would go past it and stop at the function of yours
that called it, if that is called empty() as well. The names on the records
are the debug information's, like those of the chains, not the ones a line
prints: for a function with internal linkage GCC prints the symbol table's
name, which spells a template differently.
With LOG_EXCEPTIONS, a reclaimed frame does not just disappear from the
bookkeeping: its line is patched in place, the same way LOG_ELAPSED patches
durations. The | of the
line's |_ glyph becomes a marker, so the tree keeps its shape and its
alignment while telling you how each frame ended:
| Glyph | Meaning |
|---|---|
|_ |
Returned normally |
!_ |
An exception left the frame (GCC runs the exit hook while the exception is in flight and sees it) |
~_ |
The frame left without running its exit hook and no exception was in flight: longjmp |
[25-09-2026 10:41:07.118] |_ exc_jump_root() (called from: main.cpp:236)
[25-09-2026 10:41:07.118] | ~_ exc_jump_mid() (called from: main.cpp:160)
[25-09-2026 10:41:07.118] | | ~_ exc_jump_leaf() (called from: main.cpp:151)
[25-09-2026 10:41:07.118] | |_ exc_jump_after() (called from: main.cpp:162)
With LOG_ELAPSED the duration field carries the same mark in its second byte,
which every rendering of the field leaves blank otherwise, so the field keeps
its width and its columns:
| Field | Meaning |
|---|---|
[ 1.234ms] |
Returned normally after 1.234 ms |
[! 1.234ms] |
Left by an exception after 1.234 ms (GCC measured it on the unwind path) |
[! unwound ] |
Left by an exception; no exit hook ran, so no duration exists (Clang, reclaimed at the catch) |
[~ unwound ] |
Skipped by longjmp; no exit hook ran, so no duration exists |
[ pending ] |
Still running: the program crashed, called exit(), or the line was never patched |
[ throw ] [ rethrow ] [ catch ] [ terminate] |
An event line, see above |
A line at depth 0 has no glyph, so only its duration field can carry the mark.
Measured with the benchmark in bench/ on the reference host: a Fedora 44 machine
(AMD Ryzen 7 5700G, hpet clocksource, GCC 16.2, binutils 2.46), the library
compiled by bench/run_bench.sh with the given build type and options, the trace
written to /dev/null, median of three runs on 24 October 2026. The benchmark
program calls 2000 small instrumented functions in each of two shared libraries,
every one from its own call site, so that every address is new on the first pass.
"Traced call" is the warm cost of one instrumented call once its callee and call
site are in the caches; "new function" is the cold cost of the first call of a
function (one new callee, one new call site: the symbol and line lookups plus the
line write); "first call into a library" also registers the library's symbol
table and debug information with the resolver (once per object file).
| Build type | Options | Traced call (warm) | New function (cold) | First call into a library | RSS after tracing |
|---|---|---|---|---|---|
| default (-O0) | none | 3.15 µs | 21.9 µs | 2.6 ms | 10.2 MB |
| default (-O0) | LOG_EXCEPTIONS |
3.14 µs | 22.1 µs | 2.7 ms | 10.3 MB |
| default (-O0) | LOG_ELAPSED |
6.69 µs | 25.7 µs | 2.6 ms | 10.2 MB |
| default (-O0) | LOG_EXCEPTIONS + LOG_ELAPSED |
6.67 µs | 26.2 µs | 2.5 ms | 10.2 MB |
| RelWithDebInfo | none | 2.12 µs | 15.1 µs | 4.2 ms | 11.1 MB |
| RelWithDebInfo | LOG_EXCEPTIONS |
2.17 µs | 15.8 µs | 4.4 ms | 11.2 MB |
| RelWithDebInfo | LOG_ELAPSED |
5.48 µs | 18.5 µs | 4.2 ms | 11.2 MB |
| RelWithDebInfo | LOG_EXCEPTIONS + LOG_ELAPSED |
5.51 µs | 18.8 µs | 4.2 ms | 11.3 MB |
To reproduce, from a checkout:
bench/run_bench.sh . mine # builds the eight configurations, prints the tableKeeping the tree exact after non-local exits runs in every build and is part
of what the "none" rows measure: one level lookup in each hook (a direct-mapped
cache in front of a per-thread hash map) and a handful of compares; the first
hook at each call site also pays one two-frame unwind to measure how that
site's level derives from its frame. LOG_EXCEPTIONS adds nothing measurable
per call; a throw or catch adds the event line itself: a memoized site
resolution, a memoized type name, the formatting and the write, plus a
std::uncaught_exceptions() read at each exit an exception passes through.
The LOG_ELAPSED rows carry that option's own cost (two clock reads and a
pwrite() per call, expensive on an hpet clock). The cold numbers depend
on the amount of debug information the object files carry; the warm numbers
do not, because a warm call never reaches the resolver.
Several threads tracing at once pay the same per call as one thread: a warm call takes no lock, because each thread keeps a cache in front of the shared lookup tables (see Thread Safety). Measured with a probe of N threads, each making 300,000 traced calls to a tiny function, on the same host with the library at -O0 and per-thread trace files on tmpfs: 3.0 µs per call with 1, 4 and 8 threads. Before the per-thread cache, the shared mutex — held for two hash lookups per call — made the threads sleep on it from four threads up: 4.0 µs at 4 and 5.3 µs at 8 threads, and a thread's first lookup in a large library (about 20 ms) stalled the other threads' calls for as long. The benchmark table above does not show this: it sweeps 4,000 distinct functions, more than the cache holds (1,024 entries per table), so it measures the locked lookup. Re-measured on 26 October 2026 with the cache in place, every column of the table is within the run-to-run spread of the numbers shown.
What this does not cover, and what happens instead:
- A frame that
longjmps out and is then called again from the very same call site at the same level is reclaimed on re-entry, DWARF permitting: the inline chain shows whether the re-entered function is a recursive inlined copy of the stale record (kept) or a fresh activation (the stale record is dead). Where the site has no DWARF location, or no chain read there names the function, the record is kept until the frame containing the loop returns, with one extra indentation level per iteration meanwhile. - Two functions of one name with internal linkage, compiled by GCC, both
inlined into the same function and called on the same source line
there: when the first is left by
longjmpand the second is entered right after it, the second is drawn under the first until the function they are inlined into makes its next traced call or returns. GCC's debug information has one bare name for both and records no column for an inlined call, and a running host of that name, which must be kept, looks the same. On different lines the two are told apart. Clang's debug information has a signature for every C++ function, so there it takes a function with C linkage among the two. - A retry loop in which one overload does nothing but call another of the same name, both with internal linkage and compiled by GCC, is drawn as a staircase, each try under the one before: the chain read after the hook call starts inside the callee and reads as if the function were inlined into itself.
- Fibers and stackful coroutines switch stacks within one thread. The
tracer's frame stack interleaves their frames, and the level rules never
touch them: they only ever compare frames on the thread's own stack (found
with
pthread_getattr_np), so a frame running off it gets the plain positional pairing. - Code compiled without unwind tables cannot be measured by the unwinder; such a hook site gets the smallest distance any frame can have, which keeps its level at or below the true one and the ordering rules sound.
Call Stack Logger has full multi-threaded support: each thread writes to its own
independent trace file. The main thread writes to CSLG_OUTPUT_FILE (or trace.out
fallback), and every worker thread writes to <base>_tid_<gettid> — e.g., if
CSLG_OUTPUT_FILE=/tmp/prog.out, a worker with kernel TID 12345 writes to
/tmp/prog.out_tid_12345. The numeric TID matches what ps -L, top -H, and
/proc/<pid>/task/<tid> show, making it easy to correlate a trace file with a specific
thread.
Each file starts with a header that includes the owning thread's ID:
================================================================
=== New trace run: 17-04-2026 15:18:12.255, thread ID: 12345 ===
================================================================
Per-thread state (thread_local call stack, re-entrancy guard) and per-thread FILE*
mean the hot write path has zero cross-thread synchronization — each thread writes
to its own file descriptor, and a warm traced call — one whose callee and call site the
thread has seen before — takes no lock at all: each thread keeps a small cache (32 KB) in
front of the shared lookup tables. Symbol resolution — the first sight of each address — is still
serialized by a mutex (libbacktrace parses a compilation unit lazily, and two threads doing
so at once would both parse it), but file I/O is fully parallel, and dynamic-linker lookups (dladdr)
run outside that mutex — so a plugin whose constructors are instrumented can be
dlopen()ed while other threads are tracing without deadlocking on the loader lock.
Shutdown race (documented trade-off): at program exit, the main thread flushes
each worker's trace file but deliberately does NOT close other threads' file
descriptors — closing a stdio FILE* while another thread holds a pointer to it
would be a use-after-free, and releasing a raw fd number lets a subsequent
open() reuse it for an unrelated file. Per-thread destructors close their own
descriptors at thread exit (race-free — only the owning thread accesses its own
FILE*), and any fds still open at process exit are closed by the kernel.
Worst case for a worker mid-fprintf at shutdown is therefore a torn final
line, bounded by line-buffered mode to at most one per thread.
fork() is not supported — the child process inherits the parent's thread_local
state including FILE* pointers pointing to inherited file descriptors.
Thread cancellation. The hooks run with cancellation disabled
(pthread_setcancelstate), so a pthread_cancel() request never lands inside the
tracer: it is honored at the next cancellation point of the traced program itself,
exactly as it would be without instrumentation. This is required, not optional — both
compilers emit the call to the hook as non-throwing, so an unwind that started inside
a hook (glibc implements cancellation as a forced unwind) would terminate the process.
Asynchronous cancellation (PTHREAD_CANCEL_ASYNCHRONOUS) is not supported.
Process start and exit are covered in What is not traced.
Signal handlers are not safe to trace. The instrumentation hooks allocate
memory, take a mutex, and use stdio — none of which is async-signal-safe. If a
signal interrupts a thread mid-malloc (or mid-resolution) and the handler runs
instrumented functions, the enter hook re-enters the allocator on the same
thread and can deadlock. Keep signal handlers non-instrumented: define them in a
translation unit compiled without -finstrument-functions, or mark them (and
everything they call) with __attribute__((no_instrument_function)).
The project includes unit tests (for the pure helpers: line and event formatting, timestamps, the duration field, the std-library filter, the trace path helpers and the frame reconciliation rules) and integration tests (that compile an instrumented program, execute it, and verify the trace output). Tests use the Google Test framework, fetched automatically via CMake FetchContent on first build.
mkdir build && cd build
cmake -DBUILD_TESTS=ON ..
make
ctest --output-on-failurectest registers two tests, cslg_unit_tests and cslg_integration_tests (each a
Google Test binary of the same name under build/tests/). BUILD_TESTS is honored
only for a top-level build of this repository — see
Integrating into your own project.
To generate a code coverage report (requires lcov 2.0+):
cmake -B build -DBUILD_TESTS=ON -DCOVERAGE=ON
cmake --build build
cd build && ctest --output-on-failure && cd ..
lcov --capture --directory build --output-file coverage.info --ignore-errors mismatch,negative,inconsistent,inconsistent
lcov --remove coverage.info '/usr/*' '*/tests/*' '*/_deps/*' --output-file coverage.info
genhtml coverage.info --output-directory coverage-report
# Open coverage-report/index.html in a browserWith FETCHCONTENT_SOURCE_DIR_CSLG_LIBBACKTRACE pointing at sources outside the build
tree, add that directory to the --remove patterns: the C sources are compiled with
coverage too, and libbacktrace's files would otherwise stay in the report.
-DCOVERAGE=ON compiles with -fprofile-update=atomic so gcov's counters stay
thread-safe under the multi-threaded tests (otherwise racing counter updates can
go negative and make geninfo fail). The negative entry in --ignore-errors
is an extra tolerance for any residual counter artifact. The inconsistent entry
is for gcov 15 and newer with Google Test: a TEST() macro puts a test's class and
its functions on one source line, gcov reports different end lines for them, and
lcov would otherwise stop with "mismatched end line"; the records concern the test
files, which the --remove step drops from the report. Listed twice, the warnings
stay out of the output as well.
In addition to the automatic per-call tracing driven by -finstrument-functions, the
library exposes a public API for capturing the current call stack on demand:
#include "callStack.h"
void my_function() {
auto frames = instrumentation::get_call_stack();
for (const auto& frame : frames) {
if (frame.has_value()) {
std::cout << frame->callee_function_name << "\n";
}
}
}get_call_stack() returns a std::vector<std::optional<ResolvedFrame>> (innermost
frame first). Unlike the automatic instrumentation, this does NOT require
-finstrument-functions — it uses backtrace() plus the same symbol resolution at the point of call.
Useful for logging a stack snapshot from an error handler or logging site.
Optimized builds: backtrace() only sees physical stack frames. At -O2
and above the compiler may inline a function into its caller, or turn a call in
tail position into a jump (sibling-call optimization) — such frames silently
disappear from the captured stack. If you need complete stacks from optimized,
non-instrumented code, compile the relevant translation units with
-fno-optimize-sibling-calls and mark must-appear functions
__attribute__((noinline)). (Code traced via -finstrument-functions is not
affected by the tail-call part — the exit hook after every call keeps calls out
of tail position.)
Naming of captured frames: each frame is named after the function that owns it, the
outermost function of the inline chain at the frame's return address. At -O2 the
instruction a call returns to often belongs to a helper inlined right after the call,
such as a vector's iterator constructor after get_call_stack() itself; naming by the
innermost function there, as releases before v1.0 did, called the frame after that helper.
For debugging, the build supports AddressSanitizer (ASan), UndefinedBehaviorSanitizer
(UBSan), and ThreadSanitizer (TSan) via the SANITIZE CMake option. Flags are applied
PRIVATE to every cslg-owned target (library, runDemo, test programs) — external
users who integrate via add_subdirectory / FetchContent never inherit sanitizer
flags, so your production integrations are unaffected.
# ASan + UBSan (combined; catches memory errors + UB)
cmake -B build-asan -DBUILD_TESTS=ON -DSANITIZE=address+undefined
cmake --build build-asan && cd build-asan && ctest --output-on-failure
# TSan (mutually exclusive with ASan)
cmake -B build-tsan -DBUILD_TESTS=ON -DSANITIZE=thread
cmake --build build-tsan && cd build-tsan && ctest --output-on-failureOr via Docker (these services also switch every LOG_* option on, so the
exception interposers, the in-place patching and the address column run
sanitized in the shipped library as well as in the per-flag test variants):
docker compose run sanitize-asan # GCC — ASan + UBSan + LSan
docker compose run sanitize-tsan # GCC — TSan
docker compose run sanitize-asan-clang # Clang — ASan + UBSan + LSan
docker compose run sanitize-tsan-clang # Clang — TSanThe GCC sanitizer services are also run in CI on every push and pull request so regressions in memory safety, UB, or thread safety fail the build automatically. The Clang services exist for local spot-checks — Clang's LSan is stricter than GCC's, so running them periodically is worth it as toolchain versions drift.
LeakSanitizer runs without a suppression file: the symbol resolver allocates through
mmap and keeps what it reads for the lifetime of the process, which LSan does not
report, and the library's own caches are reachable from static storage. Any allocation
the library loses is reported.
MSan is intentionally unsupported — it requires an MSan-instrumented libstdc++/libc, which is impractical without a full toolchain rebuild, and produces enormous noise otherwise.
Docker provides a reproducible build/test environment and is the recommended way to develop on non-Linux platforms (macOS, Windows).
# Build the project (GCC, default)
docker compose run build
# Run all tests (unit + integration) with GCC
docker compose run test
# Run all tests with Clang
docker compose run test-clang
# Run all tests under the optimized build type (RelWithDebInfo, -O2 -g), with GCC or Clang
docker compose run test-optimized
docker compose run test-clang-optimized
# Build with the instrumentation compiled out and every LOG_* option on, run the unit tests
docker compose run test-disabled
# Link every program with -rdynamic (the fallback for old linkers) and every LOG_* option on, run all tests
docker compose run test-export-all
# Generate code coverage report (output in coverage-report/index.html)
docker compose run coverage
# Run under AddressSanitizer + UndefinedBehaviorSanitizer + LeakSanitizer (GCC)
docker compose run sanitize-asan
# Run under ThreadSanitizer (GCC)
docker compose run sanitize-tsan
# Same, but with Clang (for occasional cross-checking — not run in CI)
docker compose run sanitize-asan-clang
docker compose run sanitize-tsan-clangThe Docker image is based on Ubuntu 24.04 with GCC, Clang, and all required dependencies,
including libc6-dbg (debug symbols for libc, which give the frames inside libc a file and a line).
GitHub Actions runs on every push and pull request to master:
- GCC (build, test, coverage): Builds, runs unit and integration tests, generates lcov HTML report (uploaded as an artifact).
- GCC RelWithDebInfo (optimized build, test): Builds with
-DCMAKE_BUILD_TYPE=RelWithDebInfo(the build type recommended to integrators) and runs the full suite — pins caller resolution and the documented inlining semantics under optimization. - Clang (build, test): Builds and runs unit and integration tests.
- Clang RelWithDebInfo (optimized build, test): The same suite with Clang at
-O2 -g. Clang at -O2 lays the instrumented code out differently from GCC at -O2 and from Clang at -O0 (tail-called exit hooks, its own inlining and landing pads, and no exit hook on the exception-unwind path), so the frame reconciliation and the exception paths meet that combination only here. - Instrumentation disabled (build, unit tests): Configures with
-DDISABLE_INSTRUMENTATION=ONand everyLOG_*option on, builds, and runs the unit tests (the integration tests are skipped at configure time by design). Keeps the#ifdefseams between the options and the kill switch building; nothing else exercises that configuration. - GCC, every symbol exported (-rdynamic): Builds with
-DCSLG_EXPORT_ALL_SYMBOLS=ONand everyLOG_*option on, and runs the full suite. This is the link every release before v1.0 used, and the one CMake falls back to with a linker that lacks--export-dynamic-symbol(GNU ld before binutils 2.35);StrippedExecutableTesthas a branch only this configuration runs. - Sanitize (GCC, ASan + UBSan + LSan): Builds with
SANITIZE=address+undefinedand everyLOG_*option on (LOG_EXCEPTIONS,LOG_ELAPSED,LOG_ADDR), and runs the full test suite under AddressSanitizer, UndefinedBehaviorSanitizer, and LeakSanitizer, so the exception interposers, the in-place patching and the address column run sanitized in the shipped library too, not only in the per-flag test variants. Fails on any memory error, UB, or leak. - Sanitize (GCC, TSan): Builds with
SANITIZE=threadand the same options, and runs the full test suite under ThreadSanitizer.
Clang sanitizer runs are intentionally NOT part of CI — GCC covers the core sweep, and Clang's LSan behaviour drifts across toolchain versions which would add maintenance noise. They remain available locally via docker compose run sanitize-asan-clang / sanitize-tsan-clang.
Call Stack Logger is a single-copyright project: all the source code in this Call Stack Logger repository is Copyright © Tomasz Augustyn.
As copyright owner, I dual license Call Stack Logger under different license terms, and offers the following licenses for Call Stack Logger:
- GNU AGPLv3, a popular open-source license with strong copyleft conditions (the default license)
- Commercial or closed-source licenses
If you license Call Stack Logger under AGPLv3, there is no license fee or signed license agreement: you just need to comply with the AGPLv3 terms and conditions. See LICENSE_COMMERCIAL and LICENSE for further information. The third-party code a program built with Call Stack Logger contains, with each license and what it asks of a distributor, is listed in THIRD_PARTY.md.
If you purchase a commercial or closed-source license for Call Stack Logger, you must comply with the terms and conditions listed in the associated license agreement; the AGPLv3 terms and conditions do not apply. To purchase commercial license please contact me via email at t.augustyn@poczta.fm in order to discuss requirements and formulate a commercial license that best suits your needs.
The Call Stack Logger software itself remains the same: the only difference between an open-source Call Stack Logger and a commercial Call Stack Logger are the license terms.
