Skip to content
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

Add modm_abort() as a non-recoverable modm_assert() #348

Closed
salkinium opened this issue Mar 13, 2020 · 2 comments · Fixed by #351
Closed

Add modm_abort() as a non-recoverable modm_assert() #348

salkinium opened this issue Mar 13, 2020 · 2 comments · Fixed by #351

Comments

@salkinium
Copy link
Member

salkinium commented Mar 13, 2020

Assertions were intended as a low-cost alternative to C++ exceptions, see https://blog.salkinium.com/xpccs-error-model/.

However, there are three issues:

  • modm_assert_debug() resolves into a no-op for release mode, which isn't useful.
  • modm_assert() is recoverable by the user by returing Ignore from the assertion handler.
  • modm_abort() or similar should be added that ignores the assertion handlers and always abandons. Or should there be a way to call modm_abandon() directly?
  • the failure string is too costly and too restrictive:
    • there isn't always a clear module, location and failure, leading to duplicated module and location strings.
    • there should only be one string passed as the reason, and the library developer is responsible for creating namespaced, unique failure strings. A naming convention inspired by reverse-domain notation (ie. separation by . dots) could be encouraged.
    • strings should optionally be placed into a GNU comment section and only their index is passed to the assertion handlers (there needs to be a way to reverse lookup this).
@salkinium
Copy link
Member Author

There should be a short error location string given, and also a full text reason that is placed only in the ELF file. In addition the call location (PC?) should be recorded, with an optional stack backtrace printer for the abandon handler.

@salkinium
Copy link
Member Author

Another thing is to replace modm::ErrorReport with assertion or similiar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

1 participant