This is an instrumentation library to capture function exection traces on an ESP32. It is meant to be used together with the visualization tool on the frontend, which can be found here
To get the tracer working:
- Initialize the logging module (we currently only have Serial available, but we aim to add UDP in the future)
SerialLogger logger("\r\n");- Initialize the tracer module
Tracer tracer(logger, QUEUE_SIZE);- During
setup()capture restart information and sync the tracer with the backend. Also initialize a logging task which will collect the logs and send them over UART.
void setup() {
Serial.begin(460800);
delay(100);
if (!logger.begin()) {
Serial.printf("Welp!");
}
TRACER_SYNC_AND_INIT();
// ...
xTaskCreatePinnedToCore(
Tracer::static_log_traces,
"logging task",
4096,
&tracer,
1,
NULL,
0
);
}- Wrap all functions you want to trace in the
TRACE_BLOCKmacro
int try_fib(int a) {
return TRACE_BLOCK({
if (a <= 1) {
return a;
}
return try_fib(a - 2) + try_fib(a - 1);
}, a);
}- Even though the full program in
example.inois dedicated to tracing, the queue still overflows and drops packets, leading to reading issues on the backend. I think it might be because UART communication is too slow.
- Add support for streaming data over UDP
- Consider other structures besides FreeRTOS queue, since that locks on reads and writes