-
Notifications
You must be signed in to change notification settings - Fork 64
Enhance address decoding and backtrace handling #319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Refactor Esp32ExceptionDecoder to improve address pattern matching and backtrace context detection.
WalkthroughThe decoder now detects backtrace contexts and processes only relevant lines (bounded by a max context length), adds clang addr2line discovery, corrects a filter_addresses parameter name, and exposes is_backtrace_context() and should_process_line() methods. Changes
Sequence Diagram(s)sequenceDiagram
participant Console as Console lines
participant Decoder as Esp32ExceptionDecoder
participant AddrParser as Addr extraction
participant Addr2Line as addr2line tool
Console->>Decoder: send line
Decoder->>Decoder: is_backtrace_context(line)?
alt starts/inside backtrace
Decoder->>Decoder: should_process_line(line)?
alt should process
Decoder->>AddrParser: extract addresses (PC:SP)
AddrParser->>Addr2Line: translate addresses
Addr2Line-->>AddrParser: resolved symbols
AddrParser-->>Decoder: symbolized output
Decoder-->>Console: emit decoded line
else skip line
Decoder-->>Console: emit raw/ignored
end
else outside backtrace
Decoder-->>Console: skip line (no addr parsing)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
monitor/filter_exception_decoder.py (2)
53-55
: Consider clarifying the max_context_lines comment.The comment states "Maximum lines to process after context keyword", but the implementation processes the keyword line (lines_since_context=0) plus up to 50 additional lines, for a total of 51 lines. Consider updating the comment to: "Maximum lines to process within backtrace context (including the keyword line)" or renaming the variable to
max_lines_after_keyword
and adjusting the logic accordingly.
91-96
: LGTM! Clang toolchain support added.The clang support correctly mirrors the gcc logic for locating addr2line. As an optional improvement, you could refactor to reduce duplication:
cc_path = data.get("cc_path", "") - if "-gcc" in cc_path: - path = cc_path.replace("-gcc", "-addr2line") - if os.path.isfile(path): - self.addr2line_path = path - return True - elif "-clang" in cc_path: - # Support for Clang toolchain - path = cc_path.replace("-clang", "-addr2line") - if os.path.isfile(path): - self.addr2line_path = path - return True + for compiler in ["-gcc", "-clang"]: + if compiler in cc_path: + path = cc_path.replace(compiler, "-addr2line") + if os.path.isfile(path): + self.addr2line_path = path + return True
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
monitor/filter_exception_decoder.py
(5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: build (macos-15, examples/espidf-arduino-C6-ULP-blink)
- GitHub Check: build (macos-15, examples/arduino-NimBLE-ext_client)
- GitHub Check: build (ubuntu-latest, examples/espidf-arduino-littlefs)
- GitHub Check: build (ubuntu-latest, examples/arduino-wifiscan)
- GitHub Check: build (ubuntu-latest, examples/arduino-zigbee-switch)
- GitHub Check: build (ubuntu-latest, examples/arduino-blink)
🔇 Additional comments (6)
monitor/filter_exception_decoder.py (6)
31-32
: LGTM! Clearer pattern documentation.The comment update improves clarity by explicitly stating the pattern matches PC:SP pairs in backtraces.
37-49
: LGTM! Comprehensive exception keyword detection.The BACKTRACE_KEYWORDS pattern covers a wide range of ESP32 exception types (Guru Meditation errors, panics, heap corruption, assertions, etc.) with appropriate case-insensitive matching.
108-110
: LGTM! Clean abstraction.The helper method provides a clear, well-documented interface for backtrace keyword detection.
156-158
: LGTM! Context gating correctly integrated.The context check is properly integrated into the rx method. Lines outside backtrace contexts are preserved in the output but skip address decoding, which is the intended behavior.
173-173
: LGTM! Typo fixed in parameter name.The parameter name correction from
adresses_str
toaddresses_str
improves code quality.
112-136
: Code behavior is correct; original concerns appear based on misunderstanding the design.The two implementation details flagged in the original review are intentional design choices, not bugs:
Multiple keywords resetting the counter: ESP32 exception dumps contain sequential sections (e.g., "Guru Meditation Error:" → "register dump:" → "Backtrace:"). Each keyword marks a new section. Resetting allows processing all sections of a complete dump, not just the first 50 lines. The 50-line limit applies per section, not globally. This is correct.
Blank line exits context: The blank line check explicitly marks the end of the exception dump, which is the natural terminator in ESP32 output. Mid-traceback blank lines are not typical in ESP32 exception format. Code comment directly states this: "Exit context after max_context_lines or if we see an empty line."
Both behaviors are documented in code comments and appear well-reasoned for the ESP32 exception format.
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
monitor/filter_exception_decoder.py (2)
54-56
: Context tracking variables are well-initialized.The state variables properly support the context-aware processing. The
max_context_lines = 50
limit is reasonable for typical backtraces.Consider making
max_context_lines
configurable via project configuration if users need to adjust it:self.max_context_lines = self.config.get( "env:" + self.environment, "monitor_decoder_context_lines", 50 # default )
92-97
: Good addition of Clang toolchain support.The implementation correctly mirrors the GCC logic and handles Clang-based toolchains.
The GCC and Clang logic could be refactored to reduce duplication:
for compiler_suffix in ["-gcc", "-clang"]: if compiler_suffix in cc_path: path = cc_path.replace(compiler_suffix, "-addr2line") if os.path.isfile(path): self.addr2line_path = path return True
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
monitor/filter_exception_decoder.py
(5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: build (windows-latest, examples/arduino-blink)
- GitHub Check: build (ubuntu-latest, examples/espidf-arduino-blink)
- GitHub Check: build (ubuntu-latest, examples/arduino-wifiscan)
- GitHub Check: build (ubuntu-latest, examples/arduino-rmt-blink)
- GitHub Check: build (ubuntu-latest, examples/arduino-blink)
🔇 Additional comments (6)
monitor/filter_exception_decoder.py (6)
31-32
: LGTM! More specific pattern for ESP32 backtraces.The updated pattern correctly matches PC:SP address pairs in the format
0xXXXXXXXX:0xXXXXXXXX
, which is the standard ESP32 backtrace format.
109-111
: LGTM! Clean separation of concern.The method provides a clear, single-purpose check for backtrace context detection.
157-159
: LGTM! Context filtering optimizes processing.The context check correctly gates address pattern matching while preserving all original output. This improves performance by skipping pattern matching on irrelevant lines.
174-174
: Good catch on the typo fix!Correcting
adresses_str
toaddresses_str
improves code quality and consistency.
113-137
: Code is correct; no issues identified.After examining the complete implementation, the context detection logic is sound and appropriately handles ESP32 backtrace output.
The method's side effects (modifying
in_backtrace_context
andlines_since_context
) are intentional and necessary for stateful line filtering—already documented in the docstring mentioning "backtrace context." This is standard for device monitor filters.The empty line detection (
line.strip() == ""
) is appropriate because:
- ESP32 backtraces are dense machine-generated output (address pairs) without internal blank lines
- Blank lines naturally mark backtrace end, which is the intended exit condition
- The
max_context_lines = 50
limit provides an additional safety boundary- The method correctly returns False for empty lines (doesn't attempt processing)
37-50
: Verify BACKTRACE_KEYWORDS regex covers all relevant exception types for your ESP-IDF version.The regex patterns are syntactically correct and align with documented ESP32 exception types (Guru Meditation Error, panic, stack smashing, corrupt heap, assertions, etc.). However, without test cases in the repository showing coverage validation, verify that all exception types for your specific ESP-IDF version are included. If you encounter undetected exception messages during device monitoring, patterns may need expansion.
Refactor Esp32ExceptionDecoder to improve address pattern matching and backtrace context detection.
Description:
Related issue (if applicable): fixes #
Checklist:
Summary by CodeRabbit
Bug Fixes
New Features