eclipse-threadx / threadx

Eclipse ThreadX is an advanced real-time operating system (RTOS) designed specifically for deeply embedded applications.
https://github.com/eclipse-threadx/rtos-docs/blob/main/rtos-docs/threadx/index.md
MIT License
2.82k stars 773 forks source link

Compile Error when define TX_ENABLE_EVENT_TRACE #295

Closed ZhijieLei closed 8 months ago

ZhijieLei commented 11 months ago

Describe the bug Compile error when I define _TX_ENABLE_EVENTTRACE in "tx_user.h". My system is AARCH64 architecture.

When I define _TX_ENABLE_EVENTTRACE in "tx_user.h" and then compile code, the compiler show me the below error info:

mypath/threadx/tx_misra.c: In function ‘_tx_misra_trace_event_insert’:
mypath/threadx/tx_misra.c:341:31: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  341 |         trace_system_state =  (UINT32) _tx_thread_system_state;
      |                               ^
mypath/threadx/tx_misra.c:342:26: error: assignment to ‘TX_THREAD *’ {aka ‘struct TX_THREAD_STRUCT *’} from incompatible pointer type ‘TX_THREAD **’ {aka ‘struct TX_THREAD_STRUCT **’} [-Werror=incompatible-pointer-types]
  342 |         trace_thread_ptr =    _tx_thread_current_ptr;
      |                          ^
mypath/threadx/tx_misra.c:348:33: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  348 |             trace_priority =    (UINT32) trace_thread_ptr;
      |                                 ^
mypath/threadx/tx_misra.c:354:73: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  354 |         trace_event_ptr -> tx_trace_buffer_entry_thread_pointer =       (UINT32) trace_thread_ptr;
      |                                                                         ^
mypath/threadx/tx_misra.c:359:73: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  359 |         trace_event_ptr -> tx_trace_buffer_entry_info_1 =               (UINT32) (info_field_1);
      |                                                                         ^
mypath/threadx/tx_misra.c:373:79: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  373 |             _tx_trace_header_ptr -> tx_trace_header_buffer_current_pointer =  (UINT32) trace_event_ptr;
      |                                                                               ^
mypath/threadx/tx_misra.c:378:79: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  378 |             _tx_trace_header_ptr -> tx_trace_header_buffer_current_pointer =  (UINT32) trace_event_ptr;

The reason is that __tx_thread_systemstate is defined as a array, but is used as a function here.

If I delete the below code in "tx_api_SMP_A64.h" and delete the function implementation of __tx_misra_trace_eventinsert.In this case, the _TX_TRACE_IN_LINEINSERT will be defined as a macro in "tx_trace_A64.h". It still doesn't work well.

#ifdef TX_ENABLE_EVENT_TRACE
#define TX_TRACE_IN_LINE_INSERT(i,a,b,c,d,e)            _tx_misra_trace_event_insert((UINT32) (i), (VOID *) (a), (UINT32) (b), (UINT32) (c), (UINT32) (d), (UINT32) (e), ((UINT32) TX_TRACE_TIME_SOURCE));
#endif
mypath/threadx/tx_trace.h:506:41: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  506 |                     trace_priority =    (UINT32) trace_thread_ptr; \
      |                                         ^
mypath/threadx/tx_block_allocate.c:170:5: note: in expansion of macro ‘TX_TRACE_IN_LINE_INSERT’
  170 |     TX_TRACE_IN_LINE_INSERT(TX_TRACE_BLOCK_ALLOCATE, pool_ptr, 0, wait_option, pool_ptr -> tx_block_pool_available, TX_TRACE_BLOCK_POOL_EVENTS)
      |     ^~~~~~~~~~~~~~~~~~~~~~~
mypath/threadx/tx_trace.h:514:81: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  514 |                 trace_event_ptr -> tx_trace_buffer_entry_thread_pointer =       (UINT32) trace_thread_ptr; \
      |                                                                                 ^
mypath/threadx/tx_block_allocate.c:170:5: note: in expansion of macro ‘TX_TRACE_IN_LINE_INSERT’
  170 |     TX_TRACE_IN_LINE_INSERT(TX_TRACE_BLOCK_ALLOCATE, pool_ptr, 0, wait_option, pool_ptr -> tx_block_pool_available, TX_TRACE_BLOCK_POOL_EVENTS)
      |     ^~~~~~~~~~~~~~~~~~~~~~~
In file included from mypath/threadx/tx_block_allocate.c:30:
mypath/threadx/tx_trace.h:475:101: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  475 | #define TX_TRACE_INFO_FIELD_ASSIGNMENT(a,b,c,d)  trace_event_ptr -> tx_trace_buffer_entry_info_1 =  (UINT32) (a); trace_event_ptr -> tx_trace_buffer_entry_info_2 =  (UINT32) (b); trace_event_ptr -> tx_trace_buffer_entry_info_3 =  (UINT32) (c); trace_event_ptr -> tx_trace_buffer_entry_info_4 =  (UINT32) (d);
      |                                                                                                     ^
mypath/threadx/tx_trace.h:519:17: note: in expansion of macro ‘TX_TRACE_INFO_FIELD_ASSIGNMENT’
  519 |                 TX_TRACE_INFO_FIELD_ASSIGNMENT((a),(b),(c),(d)) \
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mypath/threadx/tx_block_allocate.c:170:5: note: in expansion of macro ‘TX_TRACE_IN_LINE_INSERT’
  170 |     TX_TRACE_IN_LINE_INSERT(TX_TRACE_BLOCK_ALLOCATE, pool_ptr, 0, wait_option, pool_ptr -> tx_block_pool_available, TX_TRACE_BLOCK_POOL_EVENTS)
      |     ^~~~~~~~~~~~~~~~~~~~~~~
In file included from mypath/threadx/tx_block_allocate.c:30:
mypath/threadx/tx_trace.h:525:87: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  525 |                     _tx_trace_header_ptr -> tx_trace_header_buffer_current_pointer =  (UINT32) trace_event_ptr; \
      |                                                                                       ^
mypath/threadx/tx_block_allocate.c:170:5: note: in expansion of macro ‘TX_TRACE_IN_LINE_INSERT’
  170 |     TX_TRACE_IN_LINE_INSERT(TX_TRACE_BLOCK_ALLOCATE, pool_ptr, 0, wait_option, pool_ptr -> tx_block_pool_available, TX_TRACE_BLOCK_POOL_EVENTS)
      |     ^~~~~~~~~~~~~~~~~~~~~~~
mypath/threadx/tx_trace.h:532:87: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  532 |                     _tx_trace_header_ptr -> tx_trace_header_buffer_current_pointer =  (UINT32) trace_event_ptr; \

Expected behavior I expect "_tx_misra_trace_event_insert" can works well. And I want to know whether i can ignore the Werror or not.

TiejunMS commented 10 months ago

In case you have defined TX_MISRA_ENABLE, tx_misra.c should not be used directly in your project. Follow the instructions here to convert C file to assembly file.

TiejunMS commented 8 months ago

Closing