change(sysview_heap_log): use esp sysview_mcore command for the JTAG capture

This commit is contained in:
Erhan Kurubas
2026-07-08 12:59:44 +02:00
parent 4a5a50e95a
commit d22741aa12
3 changed files with 15 additions and 25 deletions
@@ -21,11 +21,9 @@ NOTE: In order to run this example you need OpenOCD version `v0.10.0-esp32-20190
The gdbinit file includes commands to start tracing: The gdbinit file includes commands to start tracing:
``` ```
mon esp sysview start file:///tmp/heap_log.svdat mon esp sysview_mcore start file:///tmp/heap_log.svdat
# For dual-core mode uncomment the line below and comment the line above
# mon esp sysview start file:///tmp/heap_log0.svdat file:///tmp/heap_log1.svdat
``` ```
When program hits breakpoint at `heap_trace_start`, in single core mode, trace data will be saved to `/tmp/heap_log.svdat`. In dual core mode, there will be two trace data files, one for each core. `/tmp/heap_log0.svdat` and `/tmp/heap_log1.svdat` When program hits breakpoint at `heap_trace_start`, trace data will be saved to `/tmp/heap_log.svdat`. The `esp sysview_mcore` command uses the SEGGER SystemView multi-core format, so a single file holds the trace for both single- and dual-core targets.
Tracing will be stopped when program hits breakpoint at `heap_trace_stop`. Tracing will be stopped when program hits breakpoint at `heap_trace_stop`.
3. [SEGGER SystemView tool](https://www.segger.com/products/development-tools/systemview/). By default SystemView shows only numeric values of IDs and parameters for IDF's heap messages in `Events` view. To make them pretty-looking you need to copy `SYSVIEW_FreeRTOS.txt` from the project's root directory to SystemView installation one. 3. [SEGGER SystemView tool](https://www.segger.com/products/development-tools/systemview/). By default SystemView shows only numeric values of IDs and parameters for IDF's heap messages in `Events` view. To make them pretty-looking you need to copy `SYSVIEW_FreeRTOS.txt` from the project's root directory to SystemView installation one.
@@ -54,7 +52,7 @@ To run the example and collect trace data:
2. When program stops at `heap_trace_stop` quit GDB. 2. When program stops at `heap_trace_stop` quit GDB.
3. Open trace data file in SystemView tool. 3. Open trace data file in SystemView tool. The multi-core format produced by `esp sysview_mcore` requires SEGGER SystemView v3.60 or later.
4. Now you can inspect all collected events. Log messages are shown in `Terminal` view. 4. Now you can inspect all collected events. Log messages are shown in `Terminal` view.
@@ -67,10 +65,7 @@ Since SystemView tool is mostly intended for OS level analysis. It allows just t
``` ```
$IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -p -b build/sysview_tracing_heap_log.elf /tmp/heap_log.svdat $IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -p -b build/sysview_tracing_heap_log.elf /tmp/heap_log.svdat
``` ```
And in dual core mode The script auto-detects the multi-core capture format and processes both cores from the single file, so the same command works for single- and dual-core targets.
```
$IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -p -b build/sysview_tracing_heap_log.elf /tmp/heap_log0.svdat /tmp/heap_log1.svdat
```
Below is the sample scripts output. Below is the sample scripts output.
@@ -6,15 +6,13 @@ maintenance flush register-cache
tb heap_trace_start tb heap_trace_start
commands commands
mon esp sysview start file:///tmp/heap_log.svdat mon esp sysview_mcore start file:///tmp/heap_log.svdat
# For dual-core mode uncomment the line below and comment the line above
# mon esp sysview start file:///tmp/heap_log0.svdat file:///tmp/heap_log1.svdat
c c
end end
tb heap_trace_stop tb heap_trace_stop
commands commands
mon esp sysview stop mon esp sysview_mcore stop
end end
c c
@@ -15,22 +15,18 @@ if typing.TYPE_CHECKING:
def _test_examples_sysview_tracing_heap_log(openocd_dut: 'OpenOCD', idf_path: str, dut: IdfDut) -> None: def _test_examples_sysview_tracing_heap_log(openocd_dut: 'OpenOCD', idf_path: str, dut: IdfDut) -> None:
# Construct trace log paths # Single multi-core capture file (esp sysview_mcore): one file is enough for
trace_log = [ # both single- and dual-core targets.
os.path.join(dut.logdir, 'heap_log0.svdat') # pylint: disable=protected-access trace_log = os.path.join(dut.logdir, 'heap_log.svdat') # pylint: disable=protected-access
]
if not dut.app.sdkconfig.get('ESP_SYSTEM_SINGLE_CORE_MODE') or dut.target == 'esp32s3':
trace_log.append(os.path.join(dut.logdir, 'heap_log1.svdat')) # pylint: disable=protected-access
trace_files = ' '.join([f'file://{log}' for log in trace_log])
# Prepare gdbinit file # Prepare gdbinit file pointing at this run's capture file
gdb_logfile = os.path.join(dut.logdir, 'gdb.txt') gdb_logfile = os.path.join(dut.logdir, 'gdb.txt')
gdbinit_orig = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'gdbinit') gdbinit_orig = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'gdbinit')
gdbinit = os.path.join(dut.logdir, 'gdbinit') gdbinit = os.path.join(dut.logdir, 'gdbinit')
with open(gdbinit_orig) as f_r, open(gdbinit, 'w') as f_w: with open(gdbinit_orig) as f_r, open(gdbinit, 'w') as f_w:
for line in f_r: for line in f_r:
if line.startswith('mon esp sysview start'): if line.startswith('mon esp sysview_mcore start'):
f_w.write(f'mon esp sysview start {trace_files}\n') f_w.write(f'mon esp sysview_mcore start file://{trace_log}\n')
else: else:
f_w.write(line) f_w.write(line)
@@ -52,8 +48,9 @@ def _test_examples_sysview_tracing_heap_log(openocd_dut: 'OpenOCD', idf_path: st
# Wait for sysview files to be generated # Wait for sysview files to be generated
p.expect_exact('Tracing is STOPPED') p.expect_exact('Tracing is STOPPED')
# Process sysview trace logs # Process sysview trace log (sysviewtrace_proc.py auto-detects and splits the
command = [os.path.join(idf_path, 'tools', 'esp_app_trace', 'sysviewtrace_proc.py'), '-p'] + trace_log # multi-core capture, so a single file works for single- and dual-core)
command = [os.path.join(idf_path, 'tools', 'esp_app_trace', 'sysviewtrace_proc.py'), '-p', trace_log]
with pexpect.spawn(' '.join(command)) as sysviewtrace: with pexpect.spawn(' '.join(command)) as sysviewtrace:
sysviewtrace.expect(r'Found \d+ leaked bytes in \d+ blocks.', timeout=120) sysviewtrace.expect(r'Found \d+ leaked bytes in \d+ blocks.', timeout=120)