Skip to content

Conversation

BritBlaster
Copy link

Adding new load_saved function to allow loading a previously obtained stacktrace to be printed.

Currently, there does not appear to be any way to use a stacktrace that might have been obtained earlier (e.g. by backtrace).
This is particularly relevant if a signal handler has captured a stacktrace, which might want to be printed at a later time.

Example use:

constexpr int max_stackdepth_for_trace = 128;
void *saved_st[max_stackdepth_for_trace];
int SavedStacktraceDepth;

SavedStacktraceDepth = backtrace(saved_st, max_stackdepth_for_trace);

[later]
StackTrace st;
st.load_saved(saved_st, SavedStacktraceDepth);
TraceResolver tr;
tr.load_stacktrace(st);

backward::Printer p;
std::stringstream &ss
p.snippet    = EnableVerboseBackTraces;
p.object     = EnableVerboseBackTraces;
p.address    = true;
p.color_mode = backward::ColorMode::always;

p.print(st, ss);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants