Skip to content

Commit

Permalink
testing/esp: fix breakpoint count in test_gdb_detach
Browse files Browse the repository at this point in the history
  • Loading branch information
sobuch committed Jan 16, 2025
1 parent 6cc0879 commit 43df26a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
7 changes: 7 additions & 0 deletions testing/esp/debug_backend_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
ESP32_PT_FLASH_OFF = 0x8000
# TODO: get from partition table
ESP32_APP_FLASH_OFF = 0x10000
ESP_XTENSA_HW_BP_CNT = 2

test_apps_dir = ''

Expand Down Expand Up @@ -567,6 +568,12 @@ def prepare_app_for_debugging(self, app_flash_off):
self.assertEqual(frame['func'], self.test_app_cfg.entry_point)
self.gdb.delete_bp(bp)

def get_hw_bp_count(self):
if testee_info.arch == 'riscv32':
info = self.oocd.cmd_exec('riscv info')
match = re.search(r'hart.trigger_count *([0-9]+)', info)
return int(match.group(1))
return ESP_XTENSA_HW_BP_CNT

def add_bp(self, loc, ignore_count=0, cond='', hw=False, tmp=False):
self.bpns.append(self.gdb.add_bp(loc, ignore_count=ignore_count, cond=cond, hw=hw, tmp=tmp))
Expand Down
11 changes: 4 additions & 7 deletions testing/esp/test_bp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ class BreakpointTestsImpl:
"""

def setUp(self):
self.dummy_bp_count = 0
if testee_info.arch == 'riscv32':
info = self.oocd.cmd_exec('riscv info')
hw_bps = int(info.split('\n')[1].split()[-1])
self.assertTrue(hw_bps <= 8 and hw_bps >= 2)
self.dummy_bp_count = hw_bps - 2
# dummy HW breaks to fill in HW breaks slots and make OpenOCD using SW breakpoints in flash (seen as HW ones by GDB)
self.dummy_bps = ['unused_func0', 'unused_func1', 'unused_func2', 'unused_func3', 'unused_func4', 'unused_func5'][:self.dummy_bp_count]
self.dummy_bp_count = self.get_hw_bp_count() - 2
dummy_bps = ['unused_func0', 'unused_func1', 'unused_func2', 'unused_func3', 'unused_func4', 'unused_func5']
self.assertTrue(self.dummy_bp_count <= len(dummy_bps) and self.dummy_bp_count >= 0)
self.dummy_bps = dummy_bps[:self.dummy_bp_count]
self.bps = self.dummy_bps + ['app_main', 'gpio_set_direction', 'gpio_set_level', 'vTaskDelay']

def test_multi_reset_break(self):
Expand Down
20 changes: 7 additions & 13 deletions testing/esp/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,13 @@ def test_gdb_detach(self):
7) Run the test and check that will chip hit to the SW breakpoints. If it will, detach command is not working properly.
"""
# Filling HW breakpoints to test SW breakpoints
bps = ['unused_func0', 'unused_func1']
if testee_info.chip == "esp32c3":
# esp32c3 has 8 HW breakpoint slots
# 6 dummy HW breaks to fill in HW breaks slots and make OpenOCD using SW breakpoints in flash (seen as HW ones by GDB)
bps += ['unused_func2', 'unused_func3', 'unused_func4', 'unused_func5', 'unused_func6', 'unused_func7']
elif testee_info.chip == "esp32c6" or testee_info.chip == "esp32h2":
# esp32c6 and esp32h2 has 4 HW breakpoint slots
# 2 dummy HW breaks to fill in HW breaks slots and make OpenOCD using SW breakpoints in flash (seen as HW ones by GDB)
bps += ['unused_func0', 'unused_func1']
elif testee_info.chip == "esp32c5":
# esp32c5 has 3 HW breakpoint slots
# 1 dummy HW break to fill in HW breaks slots and make OpenOCD using SW breakpoints in flash (seen as HW ones by GDB)
bps += ['unused_func0']
dummy_bp_count = self.get_hw_bp_count()
dummy_bps = [
'unused_func0', 'unused_func1', 'unused_func2', 'unused_func3',
'unused_func4', 'unused_func5', 'unused_func6', 'unused_func7'
]
self.assertTrue(dummy_bp_count <= len(dummy_bps) and dummy_bp_count >= 0)
bps = dummy_bps[:dummy_bp_count]
# flash SW breakpoints
bps += ['gdb_detach0', 'gdb_detach1', 'gdb_detach2']

Expand Down

0 comments on commit 43df26a

Please sign in to comment.