Fix for filename capture not working

pull/7050/head
Senthil Ramakrishnan 2018-05-31 10:39:58 -05:00
parent dbc42f696a
commit 07a6ab0864
1 changed files with 8 additions and 16 deletions

View File

@ -129,16 +129,10 @@ mbed_error_status_t handle_error(mbed_error_status_t error_status, const char *e
#ifdef MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED #ifdef MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED
//Capture filename/linenumber if provided //Capture filename/linenumber if provided
//Index for tracking error_filename //Index for tracking error_filename
int idx = 0; memset(&current_error_ctx.error_filename, 0, MBED_CONF_MAX_ERROR_FILENAME_LEN);
strncpy(current_error_ctx.error_filename, filename, MBED_CONF_MAX_ERROR_FILENAME_LEN);
if(NULL != filename) { current_error_ctx.error_line_number = line_number;
while(idx < MBED_CONF_MAX_ERROR_FILENAME_LEN && (filename[idx] != '\0')) {
current_error_ctx.error_filename[idx] = filename[idx];
idx++;
}
current_error_ctx.error_line_number = line_number;
}
#endif #endif
//Capture the fist system error and store it //Capture the fist system error and store it
@ -359,7 +353,7 @@ static void print_error_report(mbed_error_ctx *ctx, const char *error_msg)
uint32_t error_code = MBED_GET_ERROR_CODE(ctx->error_status); uint32_t error_code = MBED_GET_ERROR_CODE(ctx->error_status);
uint32_t error_module = MBED_GET_ERROR_MODULE(ctx->error_status); uint32_t error_module = MBED_GET_ERROR_MODULE(ctx->error_status);
mbed_error_printf("\n\n++ MbedOS Error Info ++\nError Status: 0x%x Code: %d Entity: %d\nError Message: ", ctx->error_status, error_code, error_module); mbed_error_printf("\n\n++ MbedOS Error Info ++\nError Status: 0x%x Code: %d Module: %d\nError Message: ", ctx->error_status, error_code, error_module);
//Report error info based on error code, some errors require different //Report error info based on error code, some errors require different
//error_vals[1] contains the error code //error_vals[1] contains the error code
@ -410,12 +404,10 @@ static void print_error_report(mbed_error_ctx *ctx, const char *error_msg)
} }
mbed_error_printf(error_msg, NULL); mbed_error_printf(error_msg, NULL);
mbed_error_printf("\nLocation: 0x%x", ctx->error_address); mbed_error_printf("\nLocation: 0x%x", ctx->error_address);
#ifdef MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED #if defined(MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED) && !defined(NDEBUG)
if(NULL != error_ctx->error_filename) { if(NULL != ctx->error_filename) {
//for string, we must pass address of a ptr which has the address of the string //for string, we must pass address of a ptr which has the address of the string
uint32_t *file_name = (uint32_t *)&error_ctx->error_filename[0]; mbed_error_printf("\nFile:%s+%d", ctx->error_filename, ctx->error_line_number);
mbed_error_printf("\nFile:%s", &file_name);
mbed_error_printf("+0x%x", ctx->error_line_number);
} }
#endif #endif