Skip to content

Commit

Permalink
fix(sysview): add prefix to the module desc to avoid stuck in Segger …
Browse files Browse the repository at this point in the history
…SystemView app

Closes #10483
  • Loading branch information
erhankur committed Nov 26, 2024
1 parent 235168e commit e2db600
Show file tree
Hide file tree
Showing 18 changed files with 37,485 additions and 256,322 deletions.
2 changes: 1 addition & 1 deletion components/app_trace/sys_view/ext/heap_trace_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const static char *TAG = "sysview_heap_trace";
#endif

static SEGGER_SYSVIEW_MODULE s_esp_sysview_heap_module = {
.sModule = "ESP32 SystemView Heap Tracing Module",
.sModule = "M=ESP32 SystemView Heap Tracing Module",
.NumEvents = 2,
};

Expand Down
28 changes: 14 additions & 14 deletions tools/esp_app_trace/espytrace/sysview.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import copy
import json
Expand Down Expand Up @@ -87,7 +87,7 @@ def parse_trace(reader, parser, os_evt_map_file=''):
parser : SysViewTraceDataParser
Top level parser object.
os_evt_map_file : string
Path to file containg events format description.
Path to file containing events format description.
"""
global _os_events_map
# parse OS events formats file
Expand All @@ -106,12 +106,12 @@ def _read_events_map(os_evt_map_file):
Parameters
----------
os_evt_map_file : string
Path to file containg events format description.
Path to file containing events format description.
Returns
-------
dict
a dict with event IDs as keys and values as tuples containg event name and a list of parameters.
a dict with event IDs as keys and values as tuples containing event name and a list of parameters.
"""
os_evt_map = {}
with open(os_evt_map_file) as f:
Expand All @@ -130,7 +130,7 @@ def _read_events_map(os_evt_map_file):
elif sp[1] == 's':
params.append(SysViewEventParamSimple(sp[0], _decode_str))
elif sp[1] == 't' or sp[1] == 'T' or sp[1] == 'I' or sp[1] == 'p':
# TODO: handle shrinked task/queue ID and addresses
# TODO: handle shrunk task/queue ID and addresses
params.append(SysViewEventParamSimple(sp[0], _decode_u32))
os_evt_map[int(comps[0])] = (comps[1], params)
return os_evt_map
Expand Down Expand Up @@ -177,7 +177,7 @@ def _read_init_seq(reader):
sync_bytes = struct.unpack(SYNC_SEQ_FMT, reader.read(struct.calcsize(SYNC_SEQ_FMT)))
for b in sync_bytes:
if b != 0:
raise SysViewTraceParseError('Invalid sync sequense!')
raise SysViewTraceParseError('Invalid sync sequence!')


def _decode_u32(reader):
Expand All @@ -192,7 +192,7 @@ def _decode_u32(reader):
Returns
-------
tuple
a tuple containg number of read bytes and decoded value.
a tuple containing number of read bytes and decoded value.
"""
sz = 0
val = 0
Expand All @@ -219,7 +219,7 @@ def _decode_id(reader):
Returns
-------
tuple
a tuple containg number of read bytes and decoded value.
a tuple containing number of read bytes and decoded value.
"""
return _decode_u32(reader)

Expand All @@ -236,7 +236,7 @@ def _decode_u64(reader):
Returns
-------
tuple
a tuple containg number of read bytes and decoded value.
a tuple containing number of read bytes and decoded value.
"""
sz,val = _decode_u32(reader)
sz2,high = _decode_u32(reader)
Expand All @@ -256,7 +256,7 @@ def _decode_str(reader):
Returns
-------
tuple
a tuple containg number of read bytes and decoded value.
a tuple containing number of read bytes and decoded value.
"""
sz = 0
val = ''
Expand Down Expand Up @@ -411,7 +411,7 @@ def decode(self, reader, max_sz):
Returns
-------
tuple
a tuple containg number of read bytes and decoded value.
a tuple containing number of read bytes and decoded value.
"""
pass

Expand Down Expand Up @@ -963,13 +963,13 @@ def get_trace_stream(self, core_id, stream_id):

def event_supported(self, e):
"""
Should be overriden in child class.
Should be overridden in child class.
"""
return False

def handle_event(self, e):
"""
Should be overriden in child class.
Should be overridden in child class.
"""
pass

Expand Down Expand Up @@ -1263,7 +1263,7 @@ def on_new_event(self, event):
"""
if self.root_proc == self:
SysViewTraceDataParser.on_new_event(self, event)
if event.id == SYSVIEW_EVTID_MODULEDESC and event.params['desc'].value == 'ESP32 SystemView Heap Tracing Module':
if event.id == SYSVIEW_EVTID_MODULEDESC and event.params['desc'].value == 'M=ESP32 SystemView Heap Tracing Module':
self.events_off = event.params['evt_off'].value


Expand Down
66 changes: 66 additions & 0 deletions tools/esp_app_trace/test/sysview/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Steps to Generate Test Input Files

1. `sysview_tracing_heap_log.elf`

Build example `sysview_tracing_heap_log` project.

```
cd $IDF_PATH/examples/system/sysview_tracing_heap_log
idf.py set target esp32
idf.py build
cp build/sysview_tracing_heap_log.elf $IDF_PATH/tools/esp_app_trace/test/sysview/
cd $IDF_PATH/tools/esp_app_trace/test/sysview/
chmod -x sysview_tracing_heap_log.elf
```
2. `heap_log0.svdat` and `heap_log1.svdat`
Flash the example and run OpenOCD and GDB using the following command in a separate console
```
cd $IDF_PATH/examples/system/sysview_tracing_heap_log
idf.py openocd
```
```
cd $IDF_PATH/examples/system/sysview_tracing_heap_log
xtensa-esp32-elf-gdb -x gdbinit build/sysview_tracing_heap_log.elf
```
When program stops at `heap_trace_stop` quit GDB and OpenOCD
Copy generated svdat files
```
cp heap_log0.svdat $IDF_PATH/tools/esp_app_trace/test/sysview/
cp heap_log1.svdat $IDF_PATH/tools/esp_app_trace/test/sysview/
```
3. `heap_log_mcore.svdat`
Flash the example and run OpenOCD and GDB using the following command in a separate console
```
cd $IDF_PATH/examples/system/sysview_tracing_heap_log
idf.py openocd
```
```
cd $IDF_PATH/examples/system/sysview_tracing_heap_log
xtensa-esp32-elf-gdb -x gdbinit-mcore build/sysview_tracing_heap_log.elf
```
When program stops at `heap_trace_stop` quit GDB and OpenOCD
Copy generated svdat file
```
cp heap_log_mcore.svdat $IDF_PATH/tools/esp_app_trace/test/sysview/
```
4. `expected_output` and `expected_output_json` files
You can use the commands from the `test.sh` to generate expected result files
```
$IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -d -p -b sysview_tracing_heap_log.elf heap_log0.svdat heap_log1.svdat &> expected_output
$IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -j -b sysview_tracing_heap_log.elf heap_log0.svdat heap_log1.svdat &> expected_output.json
$IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -d -p -b sysview_tracing_heap_log.elf heap_log_mcore.svdat &> expected_output_mcore
$IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -j -b sysview_tracing_heap_log.elf heap_log_mcore.svdat &> expected_output_mcore.json
```
88 changes: 0 additions & 88 deletions tools/esp_app_trace/test/sysview/blink.c

This file was deleted.

Binary file removed tools/esp_app_trace/test/sysview/cpu0.svdat
Binary file not shown.
Binary file removed tools/esp_app_trace/test/sysview/cpu1.svdat
Binary file not shown.
Loading

0 comments on commit e2db600

Please sign in to comment.