-
Notifications
You must be signed in to change notification settings - Fork 2k
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
debug: add DEBUG_BREAKPOINT() macro, set breakpoint on failed assertion #19368
Conversation
5978b84
to
fba4fdf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good & works on my machine.
However, debugging RIOT is poorly documented. I initially wanted to complain that the quick example from the PR description would be a nice addition to the How-To-RIOT-Debugging section on doc.riot-os.org. But we don't have that. 🤷
65e0858
to
b2d54b8
Compare
bors merge |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
19766: core/lib: make the use of DEBUG_BREAKPOINT on assert optional r=maribu a=gschorcht ### Contribution description This PR makes the use of `DEBUG_BREAKPOINT` on failed assertion optional. The behavior of `assert` has been changed with PR #19368. Instead of printing some useful information, either a breakpoint is inserted and the execution of the MCU stops in debugger or a endless while loop is executed. Before PR #19368 the user got on failed assertion: ``` Starting ESP32x with ID: 7cdfa1e36a34 ESP-IDF SDK Version v4.4.1-0-g1329b19fe49 ... *** RIOT kernel panic: FAILED ASSERTION. *** halted. ``` This was very helpful during development, especially to identify quickly the cause of problems with `DEBUG_ASSERT_VERBOSE` enabled, e.g. when misconfiguration led to failed assertions. With PR #19368 the user gets an address in best case (or even `0` on platforms like ESP32), in worst case the MCU seems to stuck, e.g. ``` Starting ESP32x with ID: 7cdfa1e36a34 ESP-IDF SDK Version v4.4.1-0-g1329b19fe49 ... 0 ``` The problem with the new behavior is that - a user doesn't get a quick indication of what happened - there is not always an easy way to attach a debugger This PR therefore makes the use of `DEBUG_BREAKPOINT` optional using `DEBUG_ASSERT_BREAKPOINT` define. ### Testing procedure Add `assert(0)` in `examples/hello-world/main.c` and compile with and w/o `CFLAGS='-DDEBUG_ASSERT_BREAKPOINT'`. With `DEBUG_ASSERT_BREAKPOINT` the execution should stop in `assert_failue`. Without `DEBUG_ASSERT_BREAKPOINT`, the information as generated before PR #19368 and the execution should stop in `panic_arch`. ### Issues/PRs references Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
19766: core/lib: make the use of DEBUG_BREAKPOINT on assert optional r=gschorcht a=gschorcht ### Contribution description This PR makes the use of `DEBUG_BREAKPOINT` on failed assertion optional. The behavior of `assert` has been changed with PR #19368. Instead of printing some useful information, either a breakpoint is inserted and the execution of the MCU stops in debugger or a endless while loop is executed. Before PR #19368 the user got on failed assertion: ``` Starting ESP32x with ID: 7cdfa1e36a34 ESP-IDF SDK Version v4.4.1-0-g1329b19fe49 ... *** RIOT kernel panic: FAILED ASSERTION. *** halted. ``` This was very helpful during development, especially to identify quickly the cause of problems with `DEBUG_ASSERT_VERBOSE` enabled, e.g. when misconfiguration led to failed assertions. With PR #19368 the user gets an address in best case (or even `0` on platforms like ESP32), in worst case the MCU seems to stuck, e.g. ``` Starting ESP32x with ID: 7cdfa1e36a34 ESP-IDF SDK Version v4.4.1-0-g1329b19fe49 ... 0 ``` The problem with the new behavior is that - a user doesn't get a quick indication of what happened - there is not always an easy way to attach a debugger This PR therefore makes the use of `DEBUG_BREAKPOINT` optional using `DEBUG_ASSERT_BREAKPOINT` define. ### Testing procedure Add `assert(0)` in `examples/hello-world/main.c` and compile with and w/o `CFLAGS='-DDEBUG_ASSERT_BREAKPOINT'`. With `DEBUG_ASSERT_BREAKPOINT` the execution should stop in `assert_failue`. Without `DEBUG_ASSERT_BREAKPOINT`, the information as generated before PR #19368 and the execution should stop in `panic_arch`. ### Issues/PRs references Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
Contribution description
This provides an architecture independent macro to set breakpoints. So far it has only been implemented for Cortex-M and native, but it degrades to a no-op if not defined, so the situation is the same as before.
To make use of this, I added a breakpoints to the
assert()
function in the case of failure.This makes debugging failed asserts much easier.
Testing procedure
I simply added a
assert(0)
tomain()
inexamples/hello-world
and ranmake debug
:master
this PR
Issues/PRs references