From 3900dd04ca305f774b628380f2dfacf0ce5e41e7 Mon Sep 17 00:00:00 2001 From: Erhan Kurubas Date: Tue, 30 Jun 2026 14:29:09 +0200 Subject: [PATCH] change(sysview_heap_log): use esp sysview_mcore command for the JTAG capture --- .../system/sysview_tracing_heap_log/README.md | 13 ++++-------- .../system/sysview_tracing_heap_log/gdbinit | 6 ++---- .../pytest_sysview_tracing_heap_log.py | 21 ++++++++----------- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/examples/system/sysview_tracing_heap_log/README.md b/examples/system/sysview_tracing_heap_log/README.md index d0cce54afc7..4e9813a718a 100644 --- a/examples/system/sysview_tracing_heap_log/README.md +++ b/examples/system/sysview_tracing_heap_log/README.md @@ -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: ``` - mon esp sysview 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 + mon esp sysview_mcore start file:///tmp/heap_log.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`. 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. -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. @@ -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 ``` -And in dual core mode -``` -$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 -``` +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. Below is the sample scripts output. diff --git a/examples/system/sysview_tracing_heap_log/gdbinit b/examples/system/sysview_tracing_heap_log/gdbinit index 049b60c1bb9..09c36b8a341 100644 --- a/examples/system/sysview_tracing_heap_log/gdbinit +++ b/examples/system/sysview_tracing_heap_log/gdbinit @@ -6,15 +6,13 @@ maintenance flush register-cache tb heap_trace_start commands -mon esp sysview 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 +mon esp sysview_mcore start file:///tmp/heap_log.svdat c end tb heap_trace_stop commands -mon esp sysview stop +mon esp sysview_mcore stop end c diff --git a/examples/system/sysview_tracing_heap_log/pytest_sysview_tracing_heap_log.py b/examples/system/sysview_tracing_heap_log/pytest_sysview_tracing_heap_log.py index 1ee4ebcfd86..7cea65a7784 100644 --- a/examples/system/sysview_tracing_heap_log/pytest_sysview_tracing_heap_log.py +++ b/examples/system/sysview_tracing_heap_log/pytest_sysview_tracing_heap_log.py @@ -15,22 +15,18 @@ if typing.TYPE_CHECKING: def _test_examples_sysview_tracing_heap_log(openocd_dut: 'OpenOCD', idf_path: str, dut: IdfDut) -> None: - # Construct trace log paths - trace_log = [ - os.path.join(dut.logdir, 'heap_log0.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]) + # Single multi-core capture file (esp sysview_mcore): one file is enough for + # both single- and dual-core targets. + trace_log = os.path.join(dut.logdir, 'heap_log.svdat') # pylint: disable=protected-access - # Prepare gdbinit file + # Prepare gdbinit file pointing at this run's capture file gdb_logfile = os.path.join(dut.logdir, 'gdb.txt') gdbinit_orig = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'gdbinit') gdbinit = os.path.join(dut.logdir, 'gdbinit') with open(gdbinit_orig) as f_r, open(gdbinit, 'w') as f_w: for line in f_r: - if line.startswith('mon esp sysview start'): - f_w.write(f'mon esp sysview start {trace_files}\n') + if line.startswith('mon esp sysview_mcore start'): + f_w.write(f'mon esp sysview_mcore start file://{trace_log}\n') else: 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 p.expect_exact('Tracing is STOPPED') - # Process sysview trace logs - command = [os.path.join(idf_path, 'tools', 'esp_app_trace', 'sysviewtrace_proc.py'), '-p'] + trace_log + # Process sysview trace log (sysviewtrace_proc.py auto-detects and splits the + # 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: sysviewtrace.expect(r'Found \d+ leaked bytes in \d+ blocks.', timeout=120)