boostorg / stacktrace

C++ library for storing and printing backtraces.
https://boost.org/libs/stacktrace
422 stars 70 forks source link

getting required size for `safe_dump_to` call #98

Closed Spongman closed 3 years ago

Spongman commented 4 years ago

how is one supposed to query for the required buffer size for a call to safe_dump_to(void*,size_t) ? the only way i can think of to do this right now is to keep calling it repeatedly with an increasing buffer size until the return value stops changing.

please don't say 'just choose some random constant value'...

apolukhin commented 3 years ago

Yep, there's no way to do that.

Compilers can inline, split or not inline functions. Compilers treat inline, force_inline and no_inline as hints and sometimes ignore them. There's no nice way to sync get_stacktrace_depth() and safe_dump_to.

I'm planning to less advertise safe_dump_to in next revisions of stacktrace library.