28
28
#if DEVICE_STDIO_MESSAGES
29
29
#include <stdio.h>
30
30
#endif
31
+ #ifndef __STDC_FORMAT_MACROS
32
+ #define __STDC_FORMAT_MACROS
33
+ #endif
34
+ #include <inttypes.h>
31
35
32
36
#ifndef NDEBUG
33
37
#define ERROR_REPORT (ctx , error_msg , error_filename , error_line ) print_error_report(ctx, error_msg, error_filename, error_line)
@@ -278,7 +282,7 @@ static const char *name_or_unnamed(const char *name)
278
282
/* Prints info of a thread(using osRtxThread_t struct)*/
279
283
static void print_thread (const osRtxThread_t * thread )
280
284
{
281
- mbed_error_printf ("\n%s State: 0x%X Entry: 0x%08X Stack Size: 0x%08X Mem: 0x%08X SP: 0x%08X" , name_or_unnamed (thread -> name ), thread -> state , thread -> thread_addr , thread -> stack_size , (uint32_t )thread -> stack_mem , thread -> sp );
285
+ mbed_error_printf ("\n%s State: 0x%" PRIX8 " Entry: 0x%08" PRIX32 " Stack Size: 0x%08" PRIX32 " Mem: 0x%08" PRIX32 " SP: 0x%08" PRIX32 , name_or_unnamed (thread -> name ), thread -> state , thread -> thread_addr , thread -> stack_size , (uint32_t )thread -> stack_mem , thread -> sp );
282
286
}
283
287
284
288
/* Prints thread info from a list */
@@ -294,43 +298,43 @@ static void print_threads_info(const osRtxThread_t *threads)
294
298
#ifndef NDEBUG
295
299
static void print_error_report (const mbed_error_ctx * ctx , const char * error_msg , const char * error_filename , int error_line )
296
300
{
297
- uint32_t error_code = MBED_GET_ERROR_CODE (ctx -> error_status );
298
- uint32_t error_module = MBED_GET_ERROR_MODULE (ctx -> error_status );
301
+ int error_code = MBED_GET_ERROR_CODE (ctx -> error_status );
302
+ int error_module = MBED_GET_ERROR_MODULE (ctx -> error_status );
299
303
300
304
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 );
301
305
302
306
switch (error_code ) {
303
307
//These are errors reported by kernel handled from mbed_rtx_handlers
304
308
case MBED_ERROR_CODE_RTOS_EVENT :
305
- mbed_error_printf ("Kernel Error: 0x%X , " , ctx -> error_value );
309
+ mbed_error_printf ("Kernel Error: 0x%" PRIX32 " , " , ctx -> error_value );
306
310
break ;
307
311
308
312
case MBED_ERROR_CODE_RTOS_THREAD_EVENT :
309
- mbed_error_printf ("Thread: 0x%X , " , ctx -> error_value );
313
+ mbed_error_printf ("Thread: 0x%" PRIX32 " , " , ctx -> error_value );
310
314
break ;
311
315
312
316
case MBED_ERROR_CODE_RTOS_MUTEX_EVENT :
313
- mbed_error_printf ("Mutex: 0x%X , " , ctx -> error_value );
317
+ mbed_error_printf ("Mutex: 0x%" PRIX32 " , " , ctx -> error_value );
314
318
break ;
315
319
316
320
case MBED_ERROR_CODE_RTOS_SEMAPHORE_EVENT :
317
- mbed_error_printf ("Semaphore: 0x%X , " , ctx -> error_value );
321
+ mbed_error_printf ("Semaphore: 0x%" PRIX32 " , " , ctx -> error_value );
318
322
break ;
319
323
320
324
case MBED_ERROR_CODE_RTOS_MEMORY_POOL_EVENT :
321
- mbed_error_printf ("MemoryPool: 0x%X , " , ctx -> error_value );
325
+ mbed_error_printf ("MemoryPool: 0x%" PRIX32 " , " , ctx -> error_value );
322
326
break ;
323
327
324
328
case MBED_ERROR_CODE_RTOS_EVENT_FLAGS_EVENT :
325
- mbed_error_printf ("EventFlags: 0x%X , " , ctx -> error_value );
329
+ mbed_error_printf ("EventFlags: 0x%" PRIX32 " , " , ctx -> error_value );
326
330
break ;
327
331
328
332
case MBED_ERROR_CODE_RTOS_TIMER_EVENT :
329
- mbed_error_printf ("Timer: 0x%X , " , ctx -> error_value );
333
+ mbed_error_printf ("Timer: 0x%" PRIX32 " , " , ctx -> error_value );
330
334
break ;
331
335
332
336
case MBED_ERROR_CODE_RTOS_MESSAGE_QUEUE_EVENT :
333
- mbed_error_printf ("MessageQueue: 0x%X , " , ctx -> error_value );
337
+ mbed_error_printf ("MessageQueue: 0x%" PRIX32 " , " , ctx -> error_value );
334
338
break ;
335
339
336
340
case MBED_ERROR_CODE_ASSERTION_FAILED :
@@ -342,7 +346,7 @@ static void print_error_report(const mbed_error_ctx *ctx, const char *error_msg,
342
346
break ;
343
347
}
344
348
mbed_error_puts (error_msg );
345
- mbed_error_printf ("\nLocation: 0x%X" , ctx -> error_address );
349
+ mbed_error_printf ("\nLocation: 0x%" PRIX32 , ctx -> error_address );
346
350
347
351
/* We print the filename passed in, not any filename in the context. This
348
352
* avoids the console print for mbed_error being limited to the presence
@@ -357,9 +361,9 @@ static void print_error_report(const mbed_error_ctx *ctx, const char *error_msg,
357
361
mbed_error_printf ("+%d" , error_line );
358
362
}
359
363
360
- mbed_error_printf ("\nError Value: 0x%X" , ctx -> error_value );
364
+ mbed_error_printf ("\nError Value: 0x%" PRIX32 , ctx -> error_value );
361
365
#ifdef MBED_CONF_RTOS_PRESENT
362
- mbed_error_printf ("\nCurrent Thread: %s Id: 0x%X Entry: 0x%X StackSize: 0x%X StackMem: 0x%X SP: 0x%X " ,
366
+ mbed_error_printf ("\nCurrent Thread: %s Id: 0x%" PRIX32 " Entry: 0x%" PRIX32 " StackSize: 0x%" PRIX32 " StackMem: 0x%" PRIX32 " SP: 0x%" PRIX32 " " ,
363
367
name_or_unnamed (((osRtxThread_t * )ctx -> thread_id )-> name ),
364
368
ctx -> thread_id , ctx -> thread_entry_address , ctx -> thread_stack_size , ctx -> thread_stack_mem , ctx -> thread_current_sp );
365
369
#endif
0 commit comments