Skip to content

Compile-time override of defaultReportAssert/defaultPrintAssert #5057

Description

@Kronos3
F´ Version
Affected Component

Feature Description

I'd like to be able to override the default assertion hook at compile time rather than only allowing runtime override:

fprime/Fw/Types/Assert.cpp

Lines 123 to 132 in ebd2306

if (nullptr == registeredHook) {
CHAR assertMsg[FW_ASSERT_TEXT_SIZE];
defaultReportAssert(file, lineNo, numArgs, arg1, arg2, arg3, arg4, arg5, arg6, assertMsg,
static_cast<FwSizeType>(sizeof(assertMsg)));
defaultPrintAssert(assertMsg);
assert(0);
} else {
registeredHook->reportAssert(file, lineNo, numArgs, arg1, arg2, arg3, arg4, arg5, arg6);
registeredHook->doAssert();
}

These functions can be factored out into an F Prime implementation similar to Fw_StringFormat.

Rationale

Assert hooks are registered at runtime rather than compile causing a large amount of code bloat for tiny systems. When manually overriding this, my text size drops by around 10k due to not using fputs. For deeply embedded systems it is useful to provide custom compile time hooks for these lower level abstractions.

Activity

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

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions