Merge pull request #7609 from bremoran/patch-2

Make location meaningful in print_error_report
pull/7620/head
Cruz Monrreal 2018-07-26 22:07:22 -05:00 committed by GitHub
commit 8292affb53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -57,7 +57,7 @@ static mbed_error_ctx first_error_ctx = {0};
static mbed_error_ctx last_error_ctx = {0}; static mbed_error_ctx last_error_ctx = {0};
static mbed_error_hook_t error_hook = NULL; static mbed_error_hook_t error_hook = NULL;
static void print_error_report(mbed_error_ctx *ctx, const char *); static void print_error_report(mbed_error_ctx *ctx, const char *);
static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsigned int error_value, const char *filename, int line_number); static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsigned int error_value, const char *filename, int line_number, void *caller);
//Helper function to halt the system //Helper function to halt the system
static void mbed_halt_system(void) static void mbed_halt_system(void)
@ -82,7 +82,7 @@ WEAK void error(const char *format, ...)
} }
//Call handle_error/print_error_report permanently setting error_in_progress flag //Call handle_error/print_error_report permanently setting error_in_progress flag
handle_error(MBED_ERROR_UNKNOWN, 0, NULL, 0); handle_error(MBED_ERROR_UNKNOWN, 0, NULL, 0, MBED_CALLER_ADDR());
ERROR_REPORT(&last_error_ctx, "Fatal Run-time error"); ERROR_REPORT(&last_error_ctx, "Fatal Run-time error");
error_in_progress = 1; error_in_progress = 1;
@ -96,7 +96,7 @@ WEAK void error(const char *format, ...)
} }
//Set an error status with the error handling system //Set an error status with the error handling system
static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsigned int error_value, const char *filename, int line_number) static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsigned int error_value, const char *filename, int line_number, void *caller)
{ {
mbed_error_ctx current_error_ctx; mbed_error_ctx current_error_ctx;
@ -123,7 +123,7 @@ static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsign
memset(&current_error_ctx, sizeof(mbed_error_ctx), 0); memset(&current_error_ctx, sizeof(mbed_error_ctx), 0);
//Capture error information //Capture error information
current_error_ctx.error_status = error_status; current_error_ctx.error_status = error_status;
current_error_ctx.error_address = (uint32_t)MBED_CALLER_ADDR(); current_error_ctx.error_address = (uint32_t)caller;
current_error_ctx.error_value = error_value; current_error_ctx.error_value = error_value;
#ifdef MBED_CONF_RTOS_PRESENT #ifdef MBED_CONF_RTOS_PRESENT
//Capture thread info //Capture thread info
@ -193,14 +193,14 @@ int mbed_get_error_count(void)
//Sets a fatal error //Sets a fatal error
mbed_error_status_t mbed_warning(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number) mbed_error_status_t mbed_warning(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number)
{ {
return handle_error(error_status, error_value, filename, line_number); return handle_error(error_status, error_value, filename, line_number, MBED_CALLER_ADDR());
} }
//Sets a fatal error, this function is marked WEAK to be able to override this for some tests //Sets a fatal error, this function is marked WEAK to be able to override this for some tests
WEAK mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number) WEAK mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number)
{ {
//set the error reported and then halt the system //set the error reported and then halt the system
if (MBED_SUCCESS != handle_error(error_status, error_value, filename, line_number)) { if (MBED_SUCCESS != handle_error(error_status, error_value, filename, line_number, MBED_CALLER_ADDR())) {
return MBED_ERROR_FAILED_OPERATION; return MBED_ERROR_FAILED_OPERATION;
} }