How does this work with the upcoming stacktrace API?

1. Revision History

1.1. Revision 0

Initial Release 🎉

2. Motivation

Setting breakpoints inside of a debugger can be difficult and confusing for newcomers to C++. Rather than having to learn C++, they have to learn a special syntax just to place a breakpoint in the exact spot they want, or rely on the interface of an IDE. At the end of the day, a simple programmer just wants to place a breakpoint so that their program stops when under the watchful eye of a debugger.

This paper proposes a new function, std :: breakpoint , that causes a program to stop or "break" execution when it is being debugged.

3. Design

The goal of the std :: breakpoint function is to "break" when being debugged but to act as though it is a no-op when it is executing normally. This might seem difficult in practice, but nearly every platform and various debuggers supports something to this effect. However, some platforms have caveats that make implementing this "break when being debugged" behavior hard to implement correctly.

The std :: breakpoint function is intended to go into the < utility > header.

4. FAQ

4.1. Couldn’t this be implemented via contracts?

Possibly. However, a std :: breakpoint function gives more fine grained control than "break on all contract violations".

4.2. How does this work with the upcoming stacktrace API?

It is not intended to interoperate with the stacktrace API at this time. Both the stacktrace API and std :: breakpoint are essentially orthogonal in their focus and use. Whereas the former is for getting more information in the event of an error, std :: breakpoint is intended to help programmers inspect the current state of a program at a breakpoint.

5. Wording

Wording is relative to [N4762]