Can a GDB breakpoint be set programmatically?
Can a GDB breakpoint be set programmatically?
I’d like to emulate the behavior of assert() in IAR. If the debugger is connected, then a breakpoint is automatically “generated” when an assert() fails, and you can inspect code and/or call stacks. This probably requires setting up an exception, but I’m not sure how to proceed.
Hello,
Thank you for reaching out to us!
It depends on the target, but usually a failed assert will call the abort function. GDB users can create a breakpoint in the abort function to catch failed asserts by executing the following GDB command while debugging:
br abort
Developers can also use target specific instructions to cause GDB to suspend execution and allow the inspection of the program state. For example, the RL78 uses the brk instruction for this:
foo.c : __asm("brk");
Please let us know if we can be of further assistance.
__
Best regards,
The Open Source Tools Team