From ddfb3a193c86704d4b7f30068c5f2aaa15a2ef4c Mon Sep 17 00:00:00 2001 From: Lauren Murphy Date: Mon, 6 Dec 2021 20:40:07 -0600 Subject: [PATCH] debug: coredump: dummy window registers, assign an to arn GDB server dummies WINDOWBASE to 0 and WINDOWSTART to 1 for both arches and sends An as corresponding ARn for ESP32 to get around packet size limitation. Fixes backtrace and other issues causing GDB client to crash. Signed-off-by: Lauren Murphy --- scripts/coredump/gdbstubs/arch/xtensa.py | 74 ++++++++++++++---------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/scripts/coredump/gdbstubs/arch/xtensa.py b/scripts/coredump/gdbstubs/arch/xtensa.py index 1e8821b1cb..0ddcf85de2 100644 --- a/scripts/coredump/gdbstubs/arch/xtensa.py +++ b/scripts/coredump/gdbstubs/arch/xtensa.py @@ -117,10 +117,18 @@ class GdbStub_Xtensa(GdbStub): def map_registers(self, tu): i = 2 for r in self.xtensaSoc.RegNum: - if r == self.xtensaSoc.RegNum.EXCCAUSE: - self.exception_code = tu[i] regNum = r.value - self.registers[regNum] = tu[i] + # Dummy WINDOWBASE and WINDOWSTART to enable GDB + # without dumping them and all AR registers; + # avoids interfering with interrupts / exceptions + if r == self.xtensaSoc.RegNum.WINDOWBASE: + self.registers[regNum] = 0 + elif r == self.xtensaSoc.RegNum.WINDOWSTART: + self.registers[regNum] = 1 + else: + if r == self.xtensaSoc.RegNum.EXCCAUSE: + self.exception_code = tu[i] + self.registers[regNum] = tu[i] i += 1 @@ -166,15 +174,9 @@ class GdbStub_Xtensa(GdbStub): def handle_register_single_read_packet(self, pkt): - # TODO: TEST FOR ESP32 - idx = int(pkt[1:].decode('ascii'), 16) - - if idx in self.registers: - bval = struct.pack(self.reg_fmt, self.registers[idx]) - reply_pkt = binascii.hexlify(bval) - self.put_gdb_packet(reply_pkt) - else: - self.put_gdb_packet(b'x' * 8) + # Mark registers as "". 'p' packets are not sent for the registers + # currently handled in this file so we can safely reply "xxxxxxxx" here. + self.put_gdb_packet(b'x' * 8) # The following classes map registers to their index (idx) on # a specific SOC. Since SOCs can have different numbers of @@ -184,7 +186,11 @@ class GdbStub_Xtensa(GdbStub): # WARNING: IF YOU CHANGE THE ORDER OF THE REGISTERS IN ONE # SOC's MAPPING, YOU MUST CHANGE THE ORDER TO MATCH IN THE OTHERS # AND IN arch/xtensa/core/coredump.c's xtensa_arch_block.r. -# See this file's map_registers function. +# See map_registers. + +# For the same reason, even though the WINDOWBASE and WINDOWSTART +# values are dummied by this script, they have to be last in the +# mapping below. # sdk-ng -> overlays/xtensa_sample_controller/gdb/gdb/xtensa-config.c class XtensaSoc_SampleController: @@ -219,12 +225,18 @@ class XtensaSoc_SampleController: A14 = 103 A15 = 104 # LBEG, LEND, and LCOUNT not on sample_controller + WINDOWBASE = 34 + WINDOWSTART = 35 # espressif xtensa-overlays -> xtensa_esp32/gdb/gdb/xtensa-config.c class XtensaSoc_ESP32: ARCH_DATA_BLK_STRUCT = '