Skip to content

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

Merged
merged 2 commits into from
Jul 11, 2018

Conversation

SenRamakri
Copy link
Contributor

Description

This avoids printing error reports in release builds.

Pull request type

[x] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change

cmonr
cmonr previously approved these changes Jul 3, 2018
@cmonr
Copy link
Contributor

cmonr commented Jul 3, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jul 3, 2018

Build : SUCCESS

Build number : 2501
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7404/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Jul 3, 2018

@mbed-ci
Copy link

mbed-ci commented Jul 3, 2018

@0xc0170 0xc0170 requested a review from a team July 3, 2018 07:03
@0xc0170
Copy link
Contributor

0xc0170 commented Jul 3, 2018

Fixes #7387

0xc0170
0xc0170 previously approved these changes Jul 3, 2018
@0xc0170
Copy link
Contributor

0xc0170 commented Jul 3, 2018

/morph export-build

@mbed-ci
Copy link

mbed-ci commented Jul 3, 2018

@@ -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");

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link

@deepikabhavnani deepikabhavnani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SenRamakri SenRamakri dismissed stale reviews from 0xc0170 and cmonr via 61458d5 July 5, 2018 16:55
@SenRamakri SenRamakri force-pushed the sen_FixErrorReportLinkForRelease branch from 6d6db5e to 61458d5 Compare July 5, 2018 16:55
cmonr
cmonr previously approved these changes Jul 5, 2018
@cmonr cmonr dismissed their stale review July 5, 2018 19:21

Changes still needed

@cmonr
Copy link
Contributor

cmonr commented Jul 5, 2018

@deepikabhavnani Are changes still needed after the current updated commits?

#define ERROR_REPORT print_error_report
#else
#define ERROR_REPORT
#endif

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

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

deepikabhavnani
deepikabhavnani previously approved these changes Jul 5, 2018
@cmonr
Copy link
Contributor

cmonr commented Jul 5, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jul 5, 2018

Build : SUCCESS

Build number : 2540
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7404/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Jul 5, 2018

@mbed-ci
Copy link

mbed-ci commented Jul 6, 2018

@cmonr
Copy link
Contributor

cmonr commented Jul 6, 2018

@kjbracey-arm @deepikabhavnani Mind re-reviewing?

@0xc0170
Copy link
Contributor

0xc0170 commented Jul 10, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jul 10, 2018

Build : SUCCESS

Build number : 2558
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7404/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Jul 10, 2018

@cmonr
Copy link
Contributor

cmonr commented Jul 11, 2018

/morph export-build

@mbed-ci
Copy link

mbed-ci commented Jul 11, 2018

@cmonr cmonr merged commit 6130744 into ARMmbed:master Jul 11, 2018
pan- pushed a commit to pan-/mbed that referenced this pull request Aug 22, 2018
…kForRelease

Do not print error reports in release builds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants