Skip to content

Commit

Permalink
Esp8266ExceptionDecoder compatibility fixes (#211)
Browse files Browse the repository at this point in the history
* Esp8266ExceptionDecoder: handle CRLF

* Esp8266ExceptionDecoder: decouple stack from exception reason

(cherry picked from commit 1748637)
  • Loading branch information
Tasssadar authored and valeros committed Jun 10, 2020
1 parent a12dcb5 commit 1faba85
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions monitor/filter_exception_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ class Esp8266ExceptionDecoder(
ADDR_MAX = 0x40300000

STATE_DEFAULT = 0
STATE_READ_EXCEPTION = 1
STATE_IN_STACK = 2
STATE_IN_STACK = 1

EXCEPTION_MARKER = "Exception ("

Expand Down Expand Up @@ -157,6 +156,9 @@ def rx(self, text):
self.buffer = ""
last = idx + 1

if line[-1] == "\r":
line = line[:-1]

extra = self.process_line(line)
self.previous_line = line
if extra is not None:
Expand All @@ -177,19 +179,18 @@ def is_addr_ok(self, hex_addr):

def process_line(self, line): # pylint: disable=too-many-return-statements
if self.state == self.STATE_DEFAULT:
extra = None
if self.previous_line.startswith(self.EXCEPTION_MARKER):
two_lines = (
self.previous_line[len(self.EXCEPTION_MARKER) :] + "\n" + line
)
match = self.exception_re.match(two_lines)
if match is not None:
self.advance_state()
return self.process_exception_match(match)
return None
elif self.state == self.STATE_READ_EXCEPTION:
extra = self.process_exception_match(match)

if line == ">>>stack>>>":
self.advance_state()
return None
return extra
elif self.state == self.STATE_IN_STACK:
if line == "<<<stack<<<":
self.state = self.STATE_DEFAULT
Expand Down

0 comments on commit 1faba85

Please sign in to comment.