mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-12-10 13:45:07 -05:00
Enable profiling for the linux port
This commit is contained in:
parent
784fb8c157
commit
a2029c781c
3 changed files with 174 additions and 55 deletions
|
|
@ -55,6 +55,8 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* FreeRTOS kernel includes. */
|
||||
#include "FreeRTOS.h"
|
||||
|
|
@ -68,6 +70,12 @@
|
|||
|
||||
#define mainSELECTED_APPLICATION BLINKY_DEMO
|
||||
|
||||
#ifdef BUILD_DIR
|
||||
#define BUILD BUILD_DIR
|
||||
#else
|
||||
#define BUILD "./"
|
||||
#endif
|
||||
|
||||
/* This demo uses heap_3.c (the libc provided malloc() and free()). */
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
@ -103,6 +111,12 @@ void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer,
|
|||
*/
|
||||
static void prvSaveTraceFile( void );
|
||||
|
||||
/*
|
||||
* Signal handler for Ctrl_C to cause the program to exit, and generate the
|
||||
* profiling info.
|
||||
*/
|
||||
static void handle_sigint(int signal);
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* When configSUPPORT_STATIC_ALLOCATION is set to 1 the application writer can
|
||||
|
|
@ -117,8 +131,13 @@ static BaseType_t xTraceRunning = pdTRUE;
|
|||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
int main( void )
|
||||
{
|
||||
/* SIGINT is not blocked by the posix port */
|
||||
signal( SIGINT, handle_sigint );
|
||||
|
||||
/* Do not include trace code when performing a code coverage analysis. */
|
||||
#if ( projCOVERAGE_TEST != 1 )
|
||||
{
|
||||
|
|
@ -231,13 +250,13 @@ void vApplicationTickHook( void )
|
|||
|
||||
void traceOnEnter()
|
||||
{
|
||||
int ret;
|
||||
int xReturn;
|
||||
struct timeval tv = { 0L, 0L };
|
||||
fd_set fds;
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(0, &fds);
|
||||
ret = select(1, &fds, NULL, NULL, &tv);
|
||||
if ( ret > 0 )
|
||||
xReturn = select(1, &fds, NULL, NULL, &tv);
|
||||
if ( xReturn > 0 )
|
||||
{
|
||||
if( xTraceRunning == pdTRUE )
|
||||
{
|
||||
|
|
@ -386,3 +405,14 @@ the stack and so not exists after this function exits. */
|
|||
configMINIMAL_STACK_SIZE is specified in words, not bytes. */
|
||||
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
||||
}
|
||||
|
||||
void handle_sigint( int signal )
|
||||
{
|
||||
int xReturn;
|
||||
xReturn = chdir( BUILD ); /* changing dir to place gmon.out inside build */
|
||||
if( xReturn == -1 )
|
||||
{
|
||||
printf( "chdir into %s error is %d\n", BUILD, errno );
|
||||
}
|
||||
exit( 1 );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue