-
Notifications
You must be signed in to change notification settings - Fork 3k
Do not print error reports in release builds #7404
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
Do not print error reports in release builds #7404
Conversation
/morph build |
Build : SUCCESSBuild number : 2501 Triggering tests/morph test |
Exporter Build : FAILUREBuild number : 2150 |
Fixes #7387 |
/morph export-build |
Exporter Build : FAILUREBuild number : 2160 |
platform/mbed_error.c
Outdated
@@ -78,7 +78,9 @@ WEAK void error(const char *format, ...) | |||
|
|||
//Call handle_error/print_error_report permanently setting error_in_progress flag | |||
handle_error(MBED_ERROR_UNKNOWN, 0, NULL, 0); | |||
#ifndef NDEBUG | |||
print_error_report(&last_error_ctx, "Fatal Run-time error"); |
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.
Shouldn't we guard everything in error
function with NDEBUG? Should handle_error
be called in case of NDEBUG?
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 should not guard everything. We still need handle_error to be called because we need to record if its first/last error which is always tracked and we will report it externally(using devicehealth apis for example) when required.
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.
But you could guard everything in print_error_report()
with NDEBUG
or have a dummy print_error_report()
macro - neater than having multiple callers do ifdefs.
You should also watch out for "unused static function" warnings, which I think you'll get from the current version on some compilers.
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.
Implementation of print_error_report
should be guarded by NDEBUG
https://github.com/SenRamakri/mbed-os/blob/6d6db5e3c8edcdae02282f1f25c98675fd17344d/platform/mbed_error.c#L309
6d6db5e
to
61458d5
Compare
@deepikabhavnani Are changes still needed after the current updated commits? |
platform/mbed_error.c
Outdated
#define ERROR_REPORT print_error_report | ||
#else | ||
#define ERROR_REPORT | ||
#endif |
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.
Shall we not add an additional macro and instead just update the code as below:
#ifdef NDEBUG
#define print_error_report
#endif
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.
That would be confusing and may affect the readability to have actual function name to be nulled out. The macro bound to NDEBUG or not name clearly indicates the issue being addressed. Also its not a public macro, should not be a concern.
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.
Would kind of expect this version to generate a lot of warnings for release, as it expands to just
(&last_error_ctx, error_msg);
Which is legal, but a compiler is going to rightly think looks weird.
It's more conventional to define a function-like macro:
#ifdef NDEBUG
#define print_error_report(ctx, error_msg) ((void) 0)
#endif
or
#ifndef NDEBUG
#define ERROR_REPORT(ctx, error_msg) print_error_report(ctx, error_msg)
#else
#define ERROR_REPORT(ctx, error_msg) ((void) 0)
#endif
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.
@kjbracey-arm - Ok, I can change it to include args. And I would go with second version, I have found the first version to be confusing and affects readability.
/morph build |
Build : SUCCESSBuild number : 2540 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2185 |
61458d5
to
b6179d2
Compare
@kjbracey-arm @deepikabhavnani Mind re-reviewing? |
/morph build |
Build : SUCCESSBuild number : 2558 Triggering tests/morph test |
/morph export-build |
Exporter Build : SUCCESSBuild number : 2204 |
…kForRelease Do not print error reports in release builds
Description
This avoids printing error reports in release builds.
Pull request type