backward-cpp icon indicating copy to clipboard operation
backward-cpp copied to clipboard

Improvement to examples for correctness

Open TrianglesPCT opened this issue 5 years ago • 0 comments

This is with VS2019, latest version.

I noticed that the first time I attempted to print a stack trace it was always empty, but on subsequent prints it did work.

After investigating I discovered it was because I was using the example code as is-- and this code is not really correct.

using namespace backward;
StackTrace st; st.load_here(32);
Printer p; p.print(st);

This does not work because the symbols are not loaded until Printer is constructed, but it generates the stacktrace prior to that.

Simply rearranging this code fixes this bug

Printer p;
StackTrace st; st.load_here(32);
 p.print(st);

Maybe update the examples ? Thanks

TrianglesPCT avatar Sep 04 '20 03:09 TrianglesPCT