bombela / backward-cpp

A beautiful stack trace pretty printer for C++
MIT License
3.73k stars 471 forks source link

New feature proposal: Callback from backward::Printer into user code #196

Closed no-more-secrets closed 3 years ago

no-more-secrets commented 3 years ago

Hi, I'd like to send a PR for an enhancement to the backward::Printer printer. It will optionally accept a user callback that, if specified, will be called on each stack frame to decide whether to print it. That is, in the Printer::print_trace function, if there is a filename, it will call the user callback with the file path name and the callback will return either true (display the stack frame) or false (skip displaying it).

One application of this is that the user callback can decide if it wants to show the stack frame in order to avoid showing stack frames from code outside of the user's project. In my project, I want to avoid showing stack frames from inside the C++ standard library, and this feature would allow me to do that.

By having a callback it allows the user the most flexibility. If you think this feature will be acceptable then I can submit a PR.

no-more-secrets commented 3 years ago

Actually I am going to close this because I realize now that it is relatively straightforward to just make my own printer class.