Add separate compile option for tracing functionality in Posix demo (#1194)

* Add compile option for enabling tracing in cmake file *
pull/1196/head
Rahul Kar 11 months ago committed by GitHub
parent 000c005cee
commit 7de1b5098d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -10,10 +10,19 @@ else()
add_compile_options( -DTRACE_ON_ENTER=0 ) add_compile_options( -DTRACE_ON_ENTER=0 )
endif() endif()
if( ( COVERAGE_TEST ) OR ( NO_TRACING ) ) if( COVERAGE_TEST )
set( COVERAGE_TEST 1 ) set( COVERAGE_TEST 1 )
set( NO_TRACING 1 )
add_compile_options( -DprojCOVERAGE_TEST=1 ) add_compile_options( -DprojCOVERAGE_TEST=1 )
add_compile_options( -DprojENABLE_TRACING=0 )
else() else()
if( NO_TRACING )
set( NO_TRACING 1 )
add_compile_options( -DprojENABLE_TRACING=0 )
else()
set( NO_TRACING 0 )
add_compile_options( -DprojENABLE_TRACING=1 )
endif()
set( COVERAGE_TEST 0 ) set( COVERAGE_TEST 0 )
add_compile_options( -DprojCOVERAGE_TEST=0 ) add_compile_options( -DprojCOVERAGE_TEST=0 )
endif() endif()
@ -58,7 +67,7 @@ add_subdirectory( ${FREERTOS_KERNEL_PATH} ${CMAKE_CURRENT_BINARY_DIR}/FreeRTOS-K
target_compile_options( freertos_kernel target_compile_options( freertos_kernel
PRIVATE PRIVATE
# Trace macro cast pointer to int to store memory management event # Trace macro cast pointer to int to store memory management event
$<IF:${COVERAGE_TEST},,-Wno-pointer-to-int-cast> $<IF:${NO_TRACING},,-Wno-pointer-to-int-cast>
) )
file( GLOB FREERTOS_PLUS_TRACE_SOURCES ${FREERTOS_PLUS_TRACE_PATH}/*.c ${FREERTOS_PLUS_TRACE_PATH}/kernelports/FreeRTOS/*.c ) file( GLOB FREERTOS_PLUS_TRACE_SOURCES ${FREERTOS_PLUS_TRACE_PATH}/*.c ${FREERTOS_PLUS_TRACE_PATH}/kernelports/FreeRTOS/*.c )
@ -70,7 +79,7 @@ add_executable( posix_demo
main_blinky.c main_blinky.c
main_full.c main_full.c
run-time-stats-utils.c run-time-stats-utils.c
$<$<NOT:${COVERAGE_TEST}>:${FREERTOS_PLUS_TRACE_SOURCES}> $<$<NOT:${NO_TRACING}>:${FREERTOS_PLUS_TRACE_SOURCES}>
${CMAKE_CURRENT_LIST_DIR}/../Common/Minimal/AbortDelay.c ${CMAKE_CURRENT_LIST_DIR}/../Common/Minimal/AbortDelay.c
${CMAKE_CURRENT_LIST_DIR}/../Common/Minimal/BlockQ.c ${CMAKE_CURRENT_LIST_DIR}/../Common/Minimal/BlockQ.c
${CMAKE_CURRENT_LIST_DIR}/../Common/Minimal/blocktim.c ${CMAKE_CURRENT_LIST_DIR}/../Common/Minimal/blocktim.c

@ -128,6 +128,10 @@ extern void vAssertCalled( const char * const pcFileName,
#error projCOVERAGE_TEST should be defined to 1 or 0 on the command line. #error projCOVERAGE_TEST should be defined to 1 or 0 on the command line.
#endif #endif
#ifndef projENABLE_TRACING
#error projENABLE_TRACING should be defined to 1 or 0 on the command line.
#endif
#if ( projCOVERAGE_TEST == 1 ) #if ( projCOVERAGE_TEST == 1 )
/* Insert NOPs in empty decision paths to ensure both true and false paths /* Insert NOPs in empty decision paths to ensure both true and false paths
@ -154,7 +158,9 @@ extern void vAssertCalled( const char * const pcFileName,
#define configUSE_MALLOC_FAILED_HOOK 1 #define configUSE_MALLOC_FAILED_HOOK 1
/* Include the FreeRTOS+Trace FreeRTOS trace macro definitions. */ /* Include the FreeRTOS+Trace FreeRTOS trace macro definitions. */
#include "trcRecorder.h" #if( projENABLE_TRACING == 1 )
#include "trcRecorder.h"
#endif /* if ( projENABLE_TRACING == 1 ) */
#endif /* if ( projCOVERAGE_TEST == 1 ) */ #endif /* if ( projCOVERAGE_TEST == 1 ) */
/* networking definitions */ /* networking definitions */

@ -75,8 +75,14 @@ endif
ifeq ($(COVERAGE_TEST),1) ifeq ($(COVERAGE_TEST),1)
CPPFLAGS += -DprojCOVERAGE_TEST=1 CPPFLAGS += -DprojCOVERAGE_TEST=1
CPPFLAGS += -DprojENABLE_TRACING=0
CFLAGS += -Werror CFLAGS += -Werror
else else
ifeq ($(NO_TRACING),1)
CPPFLAGS += -DprojENABLE_TRACING=0
else
CPPFLAGS += -DprojENABLE_TRACING=1
endif
CPPFLAGS += -DprojCOVERAGE_TEST=0 CPPFLAGS += -DprojCOVERAGE_TEST=0
# Trace library. # Trace library.
SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/kernelports/FreeRTOS/trcKernelPort.c SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/kernelports/FreeRTOS/trcKernelPort.c

@ -68,7 +68,7 @@
/* Local includes. */ /* Local includes. */
#include "console.h" #include "console.h"
#if ( projCOVERAGE_TEST != 1 ) #if ( projENABLE_TRACING == 1 )
#include <trcRecorder.h> #include <trcRecorder.h>
#endif #endif
@ -139,13 +139,6 @@ static void handle_sigint( int signal );
* in a different file. */ * in a different file. */
StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
/* Notes if the trace is running or not. */
#if ( projCOVERAGE_TEST == 1 )
static BaseType_t xTraceRunning = pdFALSE;
#else
static BaseType_t xTraceRunning = pdTRUE;
#endif
static clockid_t cid = CLOCK_THREAD_CPUTIME_ID; static clockid_t cid = CLOCK_THREAD_CPUTIME_ID;
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -155,8 +148,7 @@ int main( void )
/* SIGINT is not blocked by the posix port */ /* SIGINT is not blocked by the posix port */
signal( SIGINT, handle_sigint ); signal( SIGINT, handle_sigint );
/* Do not include trace code when performing a code coverage analysis. */ #if ( projENABLE_TRACING == 1 )
#if ( projCOVERAGE_TEST != 1 )
{ {
/* Initialise the trace recorder. Use of the trace recorder is optional. /* Initialise the trace recorder. Use of the trace recorder is optional.
* See http://www.FreeRTOS.org/trace for more information. */ * See http://www.FreeRTOS.org/trace for more information. */
@ -168,9 +160,9 @@ int main( void )
#if ( TRACE_ON_ENTER == 1 ) #if ( TRACE_ON_ENTER == 1 )
printf( "\r\nThe trace will be dumped to disk if Enter is hit.\r\n" ); printf( "\r\nThe trace will be dumped to disk if Enter is hit.\r\n" );
#endif #endif /* if ( TRACE_ON_ENTER == 1 ) */
} }
#endif /* if ( projCOVERAGE_TEST != 1 ) */ #endif /* if ( projENABLE_TRACING == 1 ) */
console_init(); console_init();
#if ( mainSELECTED_APPLICATION == BLINKY_DEMO ) #if ( mainSELECTED_APPLICATION == BLINKY_DEMO )
@ -281,10 +273,11 @@ void traceOnEnter()
if( xReturn > 0 ) if( xReturn > 0 )
{ {
if( xTraceRunning == pdTRUE ) #if ( projENABLE_TRACING == 1 )
{ {
prvSaveTraceFile(); prvSaveTraceFile();
} }
#endif /* if ( projENABLE_TRACING == 1 ) */
/* clear the buffer */ /* clear the buffer */
char buffer[ 1 ]; char buffer[ 1 ];
@ -334,10 +327,11 @@ void vAssertCalled( const char * const pcFileName,
{ {
xPrinted = pdTRUE; xPrinted = pdTRUE;
if( xTraceRunning == pdTRUE ) #if ( projENABLE_TRACING == 1 )
{ {
prvSaveTraceFile(); prvSaveTraceFile();
} }
#endif /* if ( projENABLE_TRACING == 0 ) */
} }
/* You can step out of this function to debug the assertion by using /* You can step out of this function to debug the assertion by using
@ -353,10 +347,8 @@ void vAssertCalled( const char * const pcFileName,
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
static void prvSaveTraceFile( void ) #if ( projENABLE_TRACING == 1 )
{ static void prvSaveTraceFile( void )
/* Tracing is not used when code coverage analysis is being performed. */
#if ( projCOVERAGE_TEST != 1 )
{ {
FILE * pxOutputFile; FILE * pxOutputFile;
@ -375,8 +367,7 @@ static void prvSaveTraceFile( void )
printf( "\r\nFailed to create trace dump file\r\n" ); printf( "\r\nFailed to create trace dump file\r\n" );
} }
} }
#endif /* if ( projCOVERAGE_TEST != 1 ) */ #endif /* if ( projENABLE_TRACING == 1 ) */
}
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an /* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an

Loading…
Cancel
Save