esp-who/components/modules/trace/who_trace.c

41 lines
1.0 KiB
C
Raw Normal View History

#include "who_trace.h"
2022-03-03 11:59:22 +08:00
#include <stdio.h>
#include <stdlib.h>
2022-03-03 11:29:56 +08:00
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "esp_system.h"
static void task_trace(void *arg)
{
while (true)
{
2022-03-03 11:29:56 +08:00
int task_num = uxTaskGetNumberOfTasks();
char *buffer = (char *)malloc(task_num * 40 * sizeof(char));
#if CONFIG_FREERTOS_USE_TRACE_FACILITY
printf("TaskList-------------------------------------------------------------------------\n");
vTaskList(buffer);
printf("%s", buffer);
#endif
#if CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
printf("TimeStats------------------------------------------------------------------------\n");
vTaskGetRunTimeStats(buffer);
printf("%s", buffer);
#endif
vTaskDelay(1000 / portTICK_PERIOD_MS);
2022-03-03 11:29:56 +08:00
free(buffer);
}
2022-03-03 11:29:56 +08:00
vTaskDelete(NULL);
}
void register_trace()
{
2022-03-03 11:29:56 +08:00
xTaskCreate(task_trace, "trace", 3 * 1024, NULL, 5, NULL);
}