Skip to content

Commit

Permalink
Added Rust support (reading the panic info log).
Browse files Browse the repository at this point in the history
  • Loading branch information
emeryberger committed Oct 1, 2023
1 parent d7bd405 commit 83146d5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/chatdbg/chatdbg_lldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import pathlib
the_path = pathlib.Path(__file__).parent.resolve()

# The file produced by the panic handler if the Rust program is using the chatdbg crate.
rust_panic_log_filename = "panic_log.txt"

sys.path.append(os.path.abspath(the_path))

import chatdbg_utils
Expand Down Expand Up @@ -168,6 +171,13 @@ def buildPrompt(debugger: any) -> Tuple[str, str, str]:
continue
index += 1
error_reason = thread.GetStopDescription(255)
# If the Rust panic log exists, append it to the error reason.
try:
with open(rust_panic_log_filename, "r") as log:
panic_log = log.read()
error_reason = panic_log + "\n" + error_reason
except:
pass
return (source_code, stack_trace, error_reason)

@lldb.command("why")
Expand Down

0 comments on commit 83146d5

Please sign in to comment.