Skip to content

Commit 5db0034

Browse files
committed
Added stack address support for the C++ wrapper
1 parent 059612b commit 5db0034

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

include/callstack.hpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,36 @@ namespace lcs {
6969
*
7070
* Zero-initializes the underlying C struct. If the given bool value is true,
7171
* it is initialized using the function callstack_emplace().
72-
* Throws an runtime_error or a system_error if compiled using C++11 or newer if
72+
* Throws a runtime_error or a system_error if compiled using C++11 or newer if
7373
* emplace is set to true and the backtrace could not be created.
7474
*
7575
* @param emplace Whether to call callstack_emplace().
7676
*/
7777
explicit callstack(bool emplace = true) {
7878
if (emplace) {
79-
if (!callstack_emplace(*this)) {
79+
if (!callstack_emplaceWithAddress(*this, __builtin_return_address(0))) {
8080
error();
8181
}
8282
} else {
8383
callstack_create(*this);
8484
}
8585
}
8686

87+
/**
88+
* @brief Constructs this object using the given stack address.
89+
*
90+
* Initializes the underlying C struct using the function callstack_emplaceWithAddress().
91+
* Throws a runtime_error or a system_error if compiled using C++11 or newer if
92+
* the backtrace could not be created.
93+
*
94+
* @param address The stack address after which frames are ignored.
95+
*/
96+
explicit callstack(void * address) {
97+
if (!callstack_emplaceWithAddress(*this, address)) {
98+
error();
99+
}
100+
}
101+
87102
/**
88103
* @brief Constructs the underlying C struct with the given backtrace.
89104
*

0 commit comments

Comments
 (0)