Skip to content

Commit 1faba85

Browse files
Tasssadarvaleros
authored andcommitted
Esp8266ExceptionDecoder compatibility fixes (#211)
* Esp8266ExceptionDecoder: handle CRLF * Esp8266ExceptionDecoder: decouple stack from exception reason (cherry picked from commit 1748637)
1 parent a12dcb5 commit 1faba85

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

monitor/filter_exception_decoder.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ class Esp8266ExceptionDecoder(
3737
ADDR_MAX = 0x40300000
3838

3939
STATE_DEFAULT = 0
40-
STATE_READ_EXCEPTION = 1
41-
STATE_IN_STACK = 2
40+
STATE_IN_STACK = 1
4241

4342
EXCEPTION_MARKER = "Exception ("
4443

@@ -157,6 +156,9 @@ def rx(self, text):
157156
self.buffer = ""
158157
last = idx + 1
159158

159+
if line[-1] == "\r":
160+
line = line[:-1]
161+
160162
extra = self.process_line(line)
161163
self.previous_line = line
162164
if extra is not None:
@@ -177,19 +179,18 @@ def is_addr_ok(self, hex_addr):
177179

178180
def process_line(self, line): # pylint: disable=too-many-return-statements
179181
if self.state == self.STATE_DEFAULT:
182+
extra = None
180183
if self.previous_line.startswith(self.EXCEPTION_MARKER):
181184
two_lines = (
182185
self.previous_line[len(self.EXCEPTION_MARKER) :] + "\n" + line
183186
)
184187
match = self.exception_re.match(two_lines)
185188
if match is not None:
186-
self.advance_state()
187-
return self.process_exception_match(match)
188-
return None
189-
elif self.state == self.STATE_READ_EXCEPTION:
189+
extra = self.process_exception_match(match)
190+
190191
if line == ">>>stack>>>":
191192
self.advance_state()
192-
return None
193+
return extra
193194
elif self.state == self.STATE_IN_STACK:
194195
if line == "<<<stack<<<":
195196
self.state = self.STATE_DEFAULT

0 commit comments

Comments
 (0)