diff --git a/README.md b/README.md index d454897..e79a366 100644 --- a/README.md +++ b/README.md @@ -245,14 +245,6 @@ namespace cpptrace { `cpptrace::demangle` provides a helper function for name demangling, since it has to implement that helper internally anyways. -The library makes an attempt to fail silently and continue during trace generation if any errors are encountered. -`cpptrace::absorb_trace_exceptions` can be used to configure whether these exceptions are absorbed silently internally -or wether they're rethrown to the caller. - -`cpptrace::experimental::set_cache_mode` can be used to control time-memory tradeoffs within the library. By default -speed is prioritized. If using this function, set the cache mode at the very start of your program before any traces are -performed. - `cpptrace::isatty` and the fileno definitions are useful for deciding whether to use color when printing stack taces. `cpptrace::register_terminate_handler()` is a helper function to set a custom `std::terminate` handler that prints a @@ -261,7 +253,6 @@ stack trace from a cpptrace exception (more info below) and otherwise behaves li ```cpp namespace cpptrace { std::string demangle(const std::string& name); - void absorb_trace_exceptions(bool absorb); bool isatty(int fd); extern const int stdin_fileno; @@ -269,6 +260,25 @@ namespace cpptrace { extern const int stdout_fileno; void register_terminate_handler(); +} +``` + +### Configuration + +`cpptrace::absorb_trace_exceptions`: Configure whether the library silently absorbs internal exceptions and continues. +Default is true. + +`cpptrace::enable_inlined_call_resolution`: Configure whether the library will attempt to resolve inlined call +information for release builds. Default is true. + +`cpptrace::experimental::set_cache_mode`: Control time-memory tradeoffs within the library. By default speed is +prioritized. If using this function, set the cache mode at the very start of your program before any traces are +performed. + +```cpp +namespace cpptrace { + void absorb_trace_exceptions(bool absorb); + void enable_inlined_call_resolution(bool enable); enum class cache_mode { // Only minimal lookup tables diff --git a/include/cpptrace/cpptrace.hpp b/include/cpptrace/cpptrace.hpp index c8caed9..8cf1b5c 100644 --- a/include/cpptrace/cpptrace.hpp +++ b/include/cpptrace/cpptrace.hpp @@ -248,6 +248,7 @@ namespace cpptrace { // configuration: CPPTRACE_EXPORT void absorb_trace_exceptions(bool absorb); + CPPTRACE_EXPORT void enable_inlined_call_resolution(bool enable); enum class cache_mode { // Only minimal lookup tables diff --git a/src/cpptrace.cpp b/src/cpptrace.cpp index 91972f9..c632df3 100644 --- a/src/cpptrace.cpp +++ b/src/cpptrace.cpp @@ -411,25 +411,34 @@ namespace cpptrace { namespace detail { std::atomic_bool absorb_trace_exceptions(true); // NOSONAR + std::atomic_bool resolve_inlined_calls(true); // NOSONAR std::atomic cache_mode(cache_mode::prioritize_speed); // NOSONAR } - void absorb_trace_exceptions(bool absorb) { + void absorb_trace_exceptions(bool absorb) { detail::absorb_trace_exceptions = absorb; } + void enable_inlined_call_resolution(bool enable) { + detail::resolve_inlined_calls = enable; + } + namespace experimental { - void set_cache_mode(cache_mode mode) { + void set_cache_mode(cache_mode mode) { detail::cache_mode = mode; } } namespace detail { - bool should_absorb_trace_exceptions() { + bool should_absorb_trace_exceptions() { return absorb_trace_exceptions; } - enum cache_mode get_cache_mode() { + bool should_resolve_inlined_calls() { + return resolve_inlined_calls; + } + + enum cache_mode get_cache_mode() { return cache_mode; } diff --git a/src/symbols/symbols_with_libdwarf.cpp b/src/symbols/symbols_with_libdwarf.cpp index ca423d6..20d691b 100644 --- a/src/symbols/symbols_with_libdwarf.cpp +++ b/src/symbols/symbols_with_libdwarf.cpp @@ -406,7 +406,9 @@ namespace libdwarf { ) { ASSERT(die.get_tag() == DW_TAG_subprogram); const auto name = subprogram_symbol(die, dwversion); - get_inlines_info(cu_die, die, pc, dwversion, inlines); + if(detail::should_resolve_inlined_calls()) { + get_inlines_info(cu_die, die, pc, dwversion, inlines); + } return name; } diff --git a/src/utils/common.hpp b/src/utils/common.hpp index ccc7461..5f79f59 100644 --- a/src/utils/common.hpp +++ b/src/utils/common.hpp @@ -58,6 +58,7 @@ namespace detail { static const stacktrace_frame null_frame {0, nullable::null(), nullable::null(), "", "", false}; bool should_absorb_trace_exceptions(); + bool should_resolve_inlined_calls(); enum cache_mode get_cache_mode(); } }