Add configuration to control resolution of inlined calls
This commit is contained in:
parent
589d87063a
commit
d7aac52f8b
28
README.md
28
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
|
`cpptrace::demangle` provides a helper function for name demangling, since it has to implement that helper internally
|
||||||
anyways.
|
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::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
|
`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
|
```cpp
|
||||||
namespace cpptrace {
|
namespace cpptrace {
|
||||||
std::string demangle(const std::string& name);
|
std::string demangle(const std::string& name);
|
||||||
void absorb_trace_exceptions(bool absorb);
|
|
||||||
bool isatty(int fd);
|
bool isatty(int fd);
|
||||||
|
|
||||||
extern const int stdin_fileno;
|
extern const int stdin_fileno;
|
||||||
@ -269,6 +260,25 @@ namespace cpptrace {
|
|||||||
extern const int stdout_fileno;
|
extern const int stdout_fileno;
|
||||||
|
|
||||||
void register_terminate_handler();
|
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 {
|
enum class cache_mode {
|
||||||
// Only minimal lookup tables
|
// Only minimal lookup tables
|
||||||
|
|||||||
@ -248,6 +248,7 @@ namespace cpptrace {
|
|||||||
|
|
||||||
// configuration:
|
// configuration:
|
||||||
CPPTRACE_EXPORT void absorb_trace_exceptions(bool absorb);
|
CPPTRACE_EXPORT void absorb_trace_exceptions(bool absorb);
|
||||||
|
CPPTRACE_EXPORT void enable_inlined_call_resolution(bool enable);
|
||||||
|
|
||||||
enum class cache_mode {
|
enum class cache_mode {
|
||||||
// Only minimal lookup tables
|
// Only minimal lookup tables
|
||||||
|
|||||||
@ -411,25 +411,34 @@ namespace cpptrace {
|
|||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
std::atomic_bool absorb_trace_exceptions(true); // NOSONAR
|
std::atomic_bool absorb_trace_exceptions(true); // NOSONAR
|
||||||
|
std::atomic_bool resolve_inlined_calls(true); // NOSONAR
|
||||||
std::atomic<enum cache_mode> cache_mode(cache_mode::prioritize_speed); // NOSONAR
|
std::atomic<enum cache_mode> cache_mode(cache_mode::prioritize_speed); // NOSONAR
|
||||||
}
|
}
|
||||||
|
|
||||||
void absorb_trace_exceptions(bool absorb) {
|
void absorb_trace_exceptions(bool absorb) {
|
||||||
detail::absorb_trace_exceptions = absorb;
|
detail::absorb_trace_exceptions = absorb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enable_inlined_call_resolution(bool enable) {
|
||||||
|
detail::resolve_inlined_calls = enable;
|
||||||
|
}
|
||||||
|
|
||||||
namespace experimental {
|
namespace experimental {
|
||||||
void set_cache_mode(cache_mode mode) {
|
void set_cache_mode(cache_mode mode) {
|
||||||
detail::cache_mode = mode;
|
detail::cache_mode = mode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
bool should_absorb_trace_exceptions() {
|
bool should_absorb_trace_exceptions() {
|
||||||
return 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;
|
return cache_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -406,7 +406,9 @@ namespace libdwarf {
|
|||||||
) {
|
) {
|
||||||
ASSERT(die.get_tag() == DW_TAG_subprogram);
|
ASSERT(die.get_tag() == DW_TAG_subprogram);
|
||||||
const auto name = subprogram_symbol(die, dwversion);
|
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;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -58,6 +58,7 @@ namespace detail {
|
|||||||
static const stacktrace_frame null_frame {0, nullable<uint32_t>::null(), nullable<uint32_t>::null(), "", "", false};
|
static const stacktrace_frame null_frame {0, nullable<uint32_t>::null(), nullable<uint32_t>::null(), "", "", false};
|
||||||
|
|
||||||
bool should_absorb_trace_exceptions();
|
bool should_absorb_trace_exceptions();
|
||||||
|
bool should_resolve_inlined_calls();
|
||||||
enum cache_mode get_cache_mode();
|
enum cache_mode get_cache_mode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user