Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new load_saved function #344

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

1 participant