Skip to content

Commit a9d92be

Browse files
committed
Slightly improve the docs and make more debug data available in test
1 parent b931f50 commit a9d92be

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

example/terminate_handler.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,15 @@ int test_inplace() {
199199
const bool is_noop = !boost::stacktrace::stacktrace();
200200

201201
{
202-
boost::stacktrace::safe_dump_to("./backtrace2.dump");
202+
const std::size_t frames_ss1 = boost::stacktrace::safe_dump_to("./backtrace2.dump");
203203
boost::stacktrace::stacktrace ss2;
204204
std::ifstream ifs("./backtrace2.dump");
205205
boost::stacktrace::stacktrace ss1 = boost::stacktrace::stacktrace::from_dump(ifs);
206206
ifs.close();
207207
boost::filesystem::remove("./backtrace2.dump");
208208

209-
if (ss1.size() != ss2.size()) {
210-
std::cerr << "Stacktraces differ:\n" << ss1 << "\n vs \n" << ss2 << '\n';
209+
if (ss2.size() != ss1.size()) {
210+
std::cerr << "Stacktraces differ. Dumped size == " << frames_ss1 << ".\n" << ss1 << "\n vs \n" << ss2 << '\n';
211211
return 51;
212212
}
213213

@@ -224,12 +224,12 @@ int test_inplace() {
224224

225225
{
226226
void* data[1024];
227-
boost::stacktrace::safe_dump_to(data, sizeof(data));
227+
const std::size_t frames_ss1 = boost::stacktrace::safe_dump_to(data, sizeof(data));
228228
boost::stacktrace::stacktrace ss2;
229229
boost::stacktrace::stacktrace ss1 = boost::stacktrace::stacktrace::from_dump(data, sizeof(data));
230230

231-
if (ss1.size() != ss2.size()) {
232-
std::cerr << "Stacktraces differ:\n" << ss1 << "\n vs \n" << ss2 << '\n';
231+
if (ss1.size() + 1 != frames_ss1 || ss1.size() != ss2.size()) {
232+
std::cerr << "Stacktraces differ. Dumped size == " << frames_ss1 << ".\n" << ss1 << "\n vs \n" << ss2 << '\n';
233233
return 53;
234234
}
235235

include/boost/stacktrace/safe_dump_to.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct this_thread_frames { // struct is required to avoid warning about usage o
7676
///
7777
/// @b Async-Handler-Safety: Safe.
7878
///
79-
/// @returns Stored call sequence depth.
79+
/// @returns Stored call sequence depth including terminating zero frame.
8080
///
8181
/// @param memory Preallocated buffer to store current function call sequence into.
8282
///
@@ -91,7 +91,7 @@ BOOST_FORCEINLINE std::size_t safe_dump_to(void* memory, std::size_t size) BOOST
9191
///
9292
/// @b Async-Handler-Safety: Safe.
9393
///
94-
/// @returns Stored call sequence depth.
94+
/// @returns Stored call sequence depth including terminating zero frame.
9595
///
9696
/// @param skip How many top calls to skip and do not store.
9797
///
@@ -109,7 +109,7 @@ BOOST_FORCEINLINE std::size_t safe_dump_to(std::size_t skip, void* memory, std::
109109
///
110110
/// @b Async-Handler-Safety: Safe.
111111
///
112-
/// @returns Stored call sequence depth.
112+
/// @returns Stored call sequence depth including terminating zero frame.
113113
///
114114
/// @param file File to store current function call sequence.
115115
BOOST_FORCEINLINE std::size_t safe_dump_to(const char* file) BOOST_NOEXCEPT {
@@ -122,7 +122,7 @@ BOOST_FORCEINLINE std::size_t safe_dump_to(const char* file) BOOST_NOEXCEPT {
122122
///
123123
/// @b Async-Handler-Safety: Safe.
124124
///
125-
/// @returns Stored call sequence depth.
125+
/// @returns Stored call sequence depth including terminating zero frame.
126126
///
127127
/// @param skip How many top calls to skip and do not store.
128128
///
@@ -141,7 +141,7 @@ BOOST_FORCEINLINE std::size_t safe_dump_to(std::size_t skip, std::size_t max_dep
141141
///
142142
/// @b Async-Handler-Safety: Safe.
143143
///
144-
/// @returns Stored call sequence depth.
144+
/// @returns Stored call sequence depth including terminating zero frame.
145145
///
146146
/// @param file File to store current function call sequence.
147147
BOOST_FORCEINLINE std::size_t safe_dump_to(platform_specific_descriptor fd) BOOST_NOEXCEPT;
@@ -152,7 +152,7 @@ BOOST_FORCEINLINE std::size_t safe_dump_to(platform_specific_descriptor fd) BOOS
152152
///
153153
/// @b Async-Handler-Safety: Safe.
154154
///
155-
/// @returns Stored call sequence depth.
155+
/// @returns Stored call sequence depth including terminating zero frame.
156156
///
157157
/// @param skip How many top calls to skip and do not store.
158158
///

include/boost/stacktrace/stacktrace.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ class basic_stacktrace {
288288
return impl_;
289289
}
290290

291-
/// Constructs stacktrace from basic_istreamable that references the dumped stacktrace.
291+
/// Constructs stacktrace from basic_istreamable that references the dumped stacktrace. Terminating zero frame is discarded.
292292
///
293293
/// @b Complexity: O(N)
294294
template <class Char, class Trait>
@@ -319,13 +319,13 @@ class basic_stacktrace {
319319
return ret;
320320
}
321321

322-
/// Constructs stacktrace from raw memory dump.
322+
/// Constructs stacktrace from raw memory dump. Terminating zero frame is discarded.
323323
///
324324
/// @b Complexity: O(size) in worst case
325-
static basic_stacktrace from_dump(const void* begin, std::size_t size, const allocator_type& a = allocator_type()) {
325+
static basic_stacktrace from_dump(const void* begin, std::size_t buffer_size_in_bytes, const allocator_type& a = allocator_type()) {
326326
basic_stacktrace ret(0, 0, a);
327327
const native_frame_ptr_t* first = static_cast<const native_frame_ptr_t*>(begin);
328-
const std::size_t frames_count = frames_count_from_buffer_size(size);
328+
const std::size_t frames_count = frames_count_from_buffer_size(buffer_size_in_bytes);
329329
if (!frames_count) {
330330
return ret;
331331
}

0 commit comments

Comments
 (0)