-
Notifications
You must be signed in to change notification settings - Fork 143
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
[architecture] Rework assertions to make them more useful #351
Conversation
75b2514
to
c188ded
Compare
This is ready for review. This is a breaking change in API, but not much change in behavior. The handlers and Tested on AVR, Cortex-M and Hosted-Darwin. |
%% endif | ||
uintptr_t context; | ||
uint8_t behavior; | ||
} _modm_assertion_info; |
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.
I need to call this from C code too, hence the packed struct once in C here and once in C++ as modm::AssertionInfo
.
|
||
#include "assert.h" | ||
#include <modm/architecture/interface/register.hpp> | ||
/// @endcond |
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.
On purpose, there is an issue somewhere where a @code
hasn't been closed, but I couldn't find it in any of the header files. (at least none that were included here).
|
||
%% if with_assert |
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.
Only include this if it is necessary, this is good for tiny targets.
env.substitutions = { | ||
"with_logger": True, | ||
"with_assert": env.has_module(":architecture:assert") | ||
} |
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.
We really need to deduplicate at least all the nucleo boards. This is getting ridiculous.
|
||
KEEP(*(.assertion)) | ||
|
||
__assertion_table_end = . + SIZEOF(.data); | ||
__assertion_table_end = .; |
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.
This bug took me a day to find. I hate AVRs so much.
55c1788
to
15fe379
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.
Nice 👌
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.
Assert example tested on my F469 discovery board: Works 👍
15fe379
to
c35d52c
Compare
This adds a reworked (breaking) model of assertions, where
modm_assert()
forces abandonment, andmodm_assert_continue()
allows for handlers to ignore assertions.This makes it possible to distinguish between the two at the assertion site.
In addition the assertion can have a short string, that is choses completely by the user and behaves just like a normal string, not the abomination with
\0
as string delimiter before (I was being a little too smart lol). And a long description which is optionally included in the binary or placed in an ELF comment section to be looked up by the short name.Fixes #348.
TODO:
modm::ErrorReport
with assertions.vs Abort in libc. Abandon, since abort has slightly different semantics.Place descriptions into ELF comment section and integrate into build system.Better with a generic solution for logging.