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

Error handling configuration updates and Optimization for exception handling #7214

Merged
merged 3 commits into from
Jun 25, 2018

Conversation

SenRamakri
Copy link
Contributor

@SenRamakri SenRamakri commented Jun 13, 2018

Description

This change is targeted towards optimizing Error handling and exception handling to save memory.
The PR contains following changes:

  1. Updates to configuration flags used in error handling implementation
  2. Make Error history tracking switched off by default and enabled by using the config flag MBED_CONF_PLATFORM_ERROR_HIST_ENABLED.
  3. Update exception handling code to remove dedicated fault safe printfs and to use mbed_error_printf.
    Dedicated safe printfs were originally developed to print data over serial with minimal resources. But this adds more code space, so we are switching to use mbed_error_printf. Although it uses more resources, but it saves on rom usage.
  4. Another change is to remove printing info on all threads always when generating exception report. This will be turned off by default and can be turned on using config flag MBED_CONF_PLATFORM_ERROR_ALL_THREADS_INFO if required.
    These optimizations should save around 800 bytes on Rom.

Pull request type

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

@kjbracey
Copy link
Contributor

Looking at this, I'm a teeny bit nervous some of the prints are getting a bit close to the 128-byte buffer limit in mbed_error_vfprintf. I've seen people hit that problem in mbed_assert, which can certainly blow the limit and fail to print the full filename + line as a result. (Doubly bad in Greentea, which will actually show none of the assert due to no line terminator.)

So mbed_assert_internal does need its mbed_error_printf broken up - not sure if this does, but watch out for anywhere you're printing a filename in %s. That can be rather long.

@@ -53,6 +53,6 @@ typedef struct {

//This is a handler function called from Fault handler to print the error information out.
//This runs in fault context and uses special functions(defined in mbed_rtx_fault_handler.c) to print the information without using C-lib support.
__NO_RETURN void mbed_fault_handler (uint32_t fault_type, void *mbed_fault_context_in, void *osRtxInfoIn);
void mbed_fault_handler (uint32_t fault_type, void *mbed_fault_context_in, void *osRtxInfoIn);
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we removing no_return here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@0xc0170 - With the new error handling implementation fault handler will call into error handler which will handle halting the system and thus no longer required here.

mbed_error_printf("\nLocation: 0x%X", ctx->error_address);

#if MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED && !defined(NDEBUG)
if((NULL != ctx->error_filename[0]) && (ctx->error_line_number != 0)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if ( space . Look at astyle failures for this changes in Travis

}

void print_context_info(void)
MBED_NOINLINE void print_context_info(void)
Copy link
Contributor

Choose a reason for hiding this comment

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

inlining was causing some problems for this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No specific problems with inlining. But sometimes debugging and also identifying the space required for individual functions becomes hard. So I removed inline as I was working on some optimizations.

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 15, 2018

The PR contains following changes:

That info should be part of the commit messages here

@SenRamakri
Copy link
Contributor Author

@0xc0170 - You mentioned my description should be part of commit messages? Are you meaning I should include the entire description?

@SenRamakri
Copy link
Contributor Author

@kjbracey-arm - Good point about the mbed_error_printf/%s. Currently we are using %s for printing filename. I'll change the implementation to limit the filename length to 64 chars max, by default its 16. That should take care of this as we have one printf which prints the filename+linenum but nothing else.

//We have to limit this to 64 bytes since we use mbed_error_printf for error reporting
//and mbed_error_vfprintf uses 128bytes internal buffer which may not be sufficient for anything
//longer that 64 bytes with the current implementation.
#error "Unsupported error filename buffer length detected, max supported length is 64 chars. Please change MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN or max-error-filename-len in configuration."
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 - Please see this change to limit the filename buffer to 64 chars. This should take care of 128 chars buffer limitation in mbed_error_printf implementation.

@SenRamakri SenRamakri force-pushed the sen_ErrorOptimAndConfig branch 2 times, most recently from 6057ccd to 28be10c Compare June 18, 2018 17:40
@0xc0170
Copy link
Contributor

0xc0170 commented Jun 19, 2018

@0xc0170 - You mentioned my description should be part of commit messages? Are you meaning I should include the entire description?

Yes, I dont see a reason why not.

This needs a rebase now

@SenRamakri
Copy link
Contributor Author

@0xc0170 - Commit message has been updated.

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 20, 2018

The last commit was amended. What I had in mind was reworked all 3 commits to provide details, this needs rebase interactive and edit each one of them . The last commit does not make much sense , or am I misreading the changes vs commit msg there (the last commit contains style changes that should be separate commit - this is making it hard to review).

The new configuration make Error history tracking switched off by default and enabled by using the config flag MBED_CONF_PLATFORM_ERROR_HIST_ENABLED.
Config flag MBED_CONF_PLATFORM_ERROR_ALL_THREADS_INFO enables printing info of all threads. This will be turned off by default.
… and use mbed_error_printf to optimize memory usage.

Dedicated safe printfs were originally developed to print data over serial with minimal resources. But this adds more code space, so we are switching to use mbed_error_printf.
@SenRamakri
Copy link
Contributor Author

@0xc0170 - Commit messages have been split/re-worked.

@0xc0170 0xc0170 requested a review from a team June 21, 2018 09:03
Copy link
Contributor

@cmonr cmonr left a comment

Choose a reason for hiding this comment

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

LGTM

@cmonr
Copy link
Contributor

cmonr commented Jun 21, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jun 21, 2018

Build : FAILURE

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

@cmonr
Copy link
Contributor

cmonr commented Jun 21, 2018

Looks like the K64F example mbed-os-example-error-handling failed on all compilers, but looks like a simple fix.

@SenRamakri
Copy link
Contributor Author

@cmonr - Thanks Cruz, I'll look into the failure and push a fix.

@SenRamakri
Copy link
Contributor Author

@cmonr - I have pushed a fix to the example app(on master branch).

@cmonr
Copy link
Contributor

cmonr commented Jun 25, 2018

/morph build

@cmonr
Copy link
Contributor

cmonr commented Jun 25, 2018

@SenRamakri Thansk for the quick direct commit to the example, but I'm thinking that once an example becomes public, fixes and the such should come into the example as PRs instead of direct commits.

@ARMmbed/mbed-os-maintainers Thoughts? I'm not sure ownership/process is clear/public for internal examples that become public.

@mbed-ci
Copy link

mbed-ci commented Jun 25, 2018

Build : SUCCESS

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

Triggering tests

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

@mbed-ci
Copy link

mbed-ci commented Jun 25, 2018

@mbed-ci
Copy link

mbed-ci commented Jun 25, 2018

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.

5 participants