From 95e26cd461064715eff4549799d72cec5dd828bc Mon Sep 17 00:00:00 2001 From: Alexey Gerenkov Date: Mon, 2 Jul 2018 18:10:34 +0300 Subject: [PATCH 1/2] coredump: Fixes exception stack frame structure indicator Initializes exception stack frame EXIT field to indicate stack frame format for 'espcoredump'. --- components/esp32/core_dump.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/esp32/core_dump.c b/components/esp32/core_dump.c index 56ce08b64..078afe93b 100644 --- a/components/esp32/core_dump.c +++ b/components/esp32/core_dump.c @@ -127,6 +127,10 @@ static void esp_core_dump_write(XtExcFrame *frame, core_dump_write_config_t *wri if (tasks[i].pxTCB == xTaskGetCurrentTaskHandleForCPU(xPortGetCoreID())) { // set correct stack top for current task tasks[i].pxTopOfStack = (StackType_t *)frame; + // This field is not initialized for crashed task, but stack frame has the structure of interrupt one, + // so make workaround to allow espcoredump to parse it properly. + if (frame->exit == 0) + frame->exit = -1; ESP_COREDUMP_LOG_PROCESS("Current task EXIT/PC/PS/A0/SP %x %x %x %x %x", frame->exit, frame->pc, frame->ps, frame->a0, frame->a1); } From 8fe2a77c461fbf8d409c0a6bae576ea05cca9b66 Mon Sep 17 00:00:00 2001 From: Alexey Gerenkov Date: Fri, 29 Jun 2018 15:45:31 +0300 Subject: [PATCH 2/2] coredump: Adds support for ROM ELF file to 'espcoredump' script --- components/espcoredump/espcoredump.py | 99 +++++++++++++++++---------- docs/en/api-guides/core_dump.rst | 10 +++ 2 files changed, 71 insertions(+), 38 deletions(-) diff --git a/components/espcoredump/espcoredump.py b/components/espcoredump/espcoredump.py index a1091a006..321941fd1 100755 --- a/components/espcoredump/espcoredump.py +++ b/components/espcoredump/espcoredump.py @@ -22,7 +22,7 @@ except ImportError: print "Esptool is not found! Set proper $IDF_PATH in environment." sys.exit(2) -__version__ = "0.1-dev" +__version__ = "0.2-dev" if os.name == 'nt': CLOSE_FDS = False @@ -77,12 +77,6 @@ class BinStruct(object): keys = self.__class__.fields return struct.pack(self.__class__.format, *(self.__dict__[k] for k in keys)) -# def __str__(self): -# keys = self.__class__.fields -# return (self.__class__.__name__ + "({" + -# ", ".join("%s:%r" % (k, self.__dict__[k]) for k in keys) + -# "})") - class Elf32FileHeader(BinStruct): """ELF32 file header @@ -304,14 +298,12 @@ class ESPCoreDumpElfFile(esptool.ELFFile): raise ESPCoreDumpError("%s does not appear to be an Xtensa ELF file. e_machine=%04x" % (self.name, machine)) self.e_type = type self.e_machine = machine + self.sections = [] + self.program_segments = [] if shnum > 0: self._read_sections(f, shoff, shstrndx) - else: - self.sections = [] - if phnum > 0: - self._read_program_segments(f, phoff, phentsize, phnum) - else: - self.program_segments = [] + if phnum > 0: + self._read_program_segments(f, phoff, phentsize, phnum) def _read_sections(self, f, section_header_offs, shstrndx): """Reads core dump sections from ELF file @@ -373,17 +365,15 @@ class ESPCoreDumpElfFile(esptool.ELFFile): def read_program_header(offs): type,offset,vaddr,_paddr,filesz,_memsz,flags,_align = struct.unpack_from("