Better fix for esp32_exception_decoder missing space (#831)
Recent versions of ESP-IDF have a bug in which the Backtrace: line is malformed. Old/Good: Backtrace: 0xN:0xM 0xN:0xM 0xN:0xM ... New/Bad: Backtrace:0xN:0xM0xN:0xM 0xN:0xM ... I issued https://github.com/espressif/esp-idf/pull/9138 against ESP-IDF to fix the underlying problem, but it is unclear when or if that PR will be accepted, especially since the monitor program in ESP-IDF is immune to the problem. By using a decoding technique similar to the one in ESP-IDF's monitor, either backtrace format can be accepted. Supersedes #687 , which does not quite work, in that it misses one of the entries.
This commit is contained in:
@@ -32,11 +32,11 @@ IS_WINDOWS = sys.platform.startswith("win")
|
||||
class Esp32ExceptionDecoder(DeviceMonitorFilterBase):
|
||||
NAME = "esp32_exception_decoder"
|
||||
|
||||
BACKTRACE_PATTERN = re.compile(r"^Backtrace:(((\s?0x[0-9a-fA-F]{8}:0x[0-9a-fA-F]{8}))+)")
|
||||
BACKTRACE_ADDRESS_PATTERN = re.compile(r'0x[0-9a-f]{8}:0x[0-9a-f]{8}')
|
||||
|
||||
def __call__(self):
|
||||
self.buffer = ""
|
||||
self.backtrace_re = re.compile(
|
||||
r"^Backtrace: ?((0x[0-9a-fA-F]+:0x[0-9a-fA-F]+ ?)+)\s*"
|
||||
)
|
||||
|
||||
self.firmware_path = None
|
||||
self.addr2line_path = None
|
||||
@@ -100,7 +100,7 @@ See https://docs.platformio.org/page/projectconf/build_configurations.html
|
||||
self.buffer = ""
|
||||
last = idx + 1
|
||||
|
||||
m = self.backtrace_re.match(line)
|
||||
m = self.BACKTRACE_PATTERN.match(line)
|
||||
if m is None:
|
||||
continue
|
||||
|
||||
@@ -111,11 +111,11 @@ See https://docs.platformio.org/page/projectconf/build_configurations.html
|
||||
return text
|
||||
|
||||
def get_backtrace(self, match):
|
||||
trace = ""
|
||||
trace = "\n"
|
||||
enc = "mbcs" if IS_WINDOWS else "utf-8"
|
||||
args = [self.addr2line_path, u"-fipC", u"-e", self.firmware_path]
|
||||
try:
|
||||
for i, addr in enumerate(match.group(1).split()):
|
||||
for i, addr in enumerate(self.BACKTRACE_ADDRESS_PATTERN.findall(match.group(1))):
|
||||
output = (
|
||||
subprocess.check_output(args + [addr])
|
||||
.decode(enc)
|
||||
|
||||
Reference in New Issue
Block a user