Skip to content

Commit 6b942d9

Browse files
authored
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 espressif/esp-idf#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.
1 parent 98aef9b commit 6b942d9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

monitor/filter_exception_decoder.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
class Esp32ExceptionDecoder(DeviceMonitorFilterBase):
3333
NAME = "esp32_exception_decoder"
3434

35+
BACKTRACE_PATTERN = re.compile(r"^Backtrace:(((\s?0x[0-9a-fA-F]{8}:0x[0-9a-fA-F]{8}))+)")
36+
BACKTRACE_ADDRESS_PATTERN = re.compile(r'0x[0-9a-f]{8}:0x[0-9a-f]{8}')
37+
3538
def __call__(self):
3639
self.buffer = ""
37-
self.backtrace_re = re.compile(
38-
r"^Backtrace: ?((0x[0-9a-fA-F]+:0x[0-9a-fA-F]+ ?)+)\s*"
39-
)
4040

4141
self.firmware_path = None
4242
self.addr2line_path = None
@@ -100,7 +100,7 @@ def rx(self, text):
100100
self.buffer = ""
101101
last = idx + 1
102102

103-
m = self.backtrace_re.match(line)
103+
m = self.BACKTRACE_PATTERN.match(line)
104104
if m is None:
105105
continue
106106

@@ -111,11 +111,11 @@ def rx(self, text):
111111
return text
112112

113113
def get_backtrace(self, match):
114-
trace = ""
114+
trace = "\n"
115115
enc = "mbcs" if IS_WINDOWS else "utf-8"
116116
args = [self.addr2line_path, u"-fipC", u"-e", self.firmware_path]
117117
try:
118-
for i, addr in enumerate(match.group(1).split()):
118+
for i, addr in enumerate(self.BACKTRACE_ADDRESS_PATTERN.findall(match.group(1))):
119119
output = (
120120
subprocess.check_output(args + [addr])
121121
.decode(enc)

0 commit comments

Comments
 (0)