@@ -129,16 +129,10 @@ mbed_error_status_t handle_error(mbed_error_status_t error_status, const char *e
129
129
130
130
#ifdef MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED
131
131
//Capture filename/linenumber if provided
132
- //Index for tracking error_filename
133
- int idx = 0 ;
134
-
135
- if (NULL != filename ) {
136
- while (idx < MBED_CONF_MAX_ERROR_FILENAME_LEN && (filename [idx ] != '\0' )) {
137
- current_error_ctx .error_filename [idx ] = filename [idx ];
138
- idx ++ ;
139
- }
140
- current_error_ctx .error_line_number = line_number ;
141
- }
132
+ //Index for tracking error_filename
133
+ memset (& current_error_ctx .error_filename , 0 , MBED_CONF_MAX_ERROR_FILENAME_LEN );
134
+ strncpy (current_error_ctx .error_filename , filename , MBED_CONF_MAX_ERROR_FILENAME_LEN );
135
+ current_error_ctx .error_line_number = line_number ;
142
136
#endif
143
137
144
138
//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)
359
353
uint32_t error_code = MBED_GET_ERROR_CODE (ctx -> error_status );
360
354
uint32_t error_module = MBED_GET_ERROR_MODULE (ctx -> error_status );
361
355
362
- 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 );
356
+ 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 );
363
357
364
358
//Report error info based on error code, some errors require different
365
359
//error_vals[1] contains the error code
@@ -410,12 +404,10 @@ static void print_error_report(mbed_error_ctx *ctx, const char *error_msg)
410
404
}
411
405
mbed_error_printf (error_msg , NULL );
412
406
mbed_error_printf ("\nLocation: 0x%x" , ctx -> error_address );
413
- #ifdef MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED
414
- if (NULL != error_ctx -> error_filename ) {
407
+ #if defined( MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED ) && !defined( NDEBUG )
408
+ if (NULL != ctx -> error_filename ) {
415
409
//for string, we must pass address of a ptr which has the address of the string
416
- uint32_t * file_name = (uint32_t * )& error_ctx -> error_filename [0 ];
417
- mbed_error_printf ("\nFile:%s" , & file_name );
418
- mbed_error_printf ("+0x%x" , ctx -> error_line_number );
410
+ mbed_error_printf ("\nFile:%s+%d" , ctx -> error_filename , ctx -> error_line_number );
419
411
}
420
412
#endif
421
413
0 commit comments