Skip to content

Commit

Permalink
Merge branch 'main' of github.com:plasma-umass/ChatDBG
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenfreund committed May 1, 2024
2 parents 16b96b9 + d6e2856 commit 748ee16
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 54 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ ChatDBG is an AI-based debugging assistant for C/C++/Python/Rust code that integ

As far as we are aware, ChatDBG is the *first* debugger to automatically perform root cause analysis and to provide suggested fixes.

**Watch ChatDBG in action!**
| LLDB on [test-overflow.cpp](samples/cpp/test-overflow.cpp) | GDB on [test-overflow.cpp](samples/cpp/test-overflow.cpp) | Pdb on [bootstrap.py](samples/python/bootstrap.py) |
|:-------------------------:|:-------------------------:|:-------------------------:|
| <a href="https://asciinema.org/a/RsAGFFmsicIvMW8xgvPP6PW2f" target="_blank"><img src="https://asciinema.org/a/RsAGFFmsicIvMW8xgvPP6PW2f.svg" /></a>| <a href="https://asciinema.org/a/bMWOyyrh7WXWsTCFboyKpqwTq" target="_blank"><img src="https://asciinema.org/a/bMWOyyrh7WXWsTCFboyKpqwTq.svg" /></a>|<a href="https://asciinema.org/a/qulxiJTqwVRJPaMZ1hcBs6Clu" target="_blank"><img src="https://asciinema.org/a/qulxiJTqwVRJPaMZ1hcBs6Clu.svg" /></a>|

For technical details and a complete evaluation, see our arXiv paper, [_ChatDBG: An AI-Powered Debugging Assistant_](https://arxiv.org/abs/2403.16354) ([PDF](https://github.com/plasma-umass/ChatDBG/blob/main/ChatDBG-arxiv-2403.16354.pdf)).

> [!NOTE]
Expand Down
35 changes: 28 additions & 7 deletions src/chatdbg/chatdbg_gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ def _message_is_a_bad_command_error(self, message):
return message.strip().startswith("Undefined command:")

def _run_one_command(self, command):
return gdb.execute(command, to_string=True)
try:
return gdb.execute(command, to_string=True)
except Exception as e:
return str(e)

def check_debugger_state(self):
global last_error_type
Expand Down Expand Up @@ -234,16 +237,34 @@ def _initial_prompt_input(self):
input_pipe = args.find('<')
if input_pipe != -1:
input_file = args[input_pipe + 1:].strip()

try:
content = open(input_file, 'r').read()
return content
except Exception:
self.fail(f"The detected input file {input_file} could not be read.")
try:
content = open(input_file, 'r').read()
return content
except Exception:
self.fail(f"The detected input file {input_file} could not be read.")

def _prompt_stack(self):
"""
Return a simple backtrace to show the LLM where we are on the stack
in followup prompts.
"""
return None

def llm_debug(self, command: str) -> str:
"""
{
"name": "debug",
"description": "The `debug` function runs a GDB command on the stopped program and gets the response.",
"parameters": {
"type": "object",
"properties": {
"command": {
"type": "string",
"description": "The GDB command to run, possibly with arguments."
}
},
"required": [ "command" ]
}
}
"""
return command, self._run_one_command(command)
20 changes: 20 additions & 0 deletions src/chatdbg/chatdbg_lldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,23 @@ def _prompt_stack(self):
in followup prompts.
"""
return None

def llm_debug(self, command: str) -> str:
"""
{
"name": "debug",
"description": "The `debug` function runs an LLDB command on the stopped program and gets the response.",
"parameters": {
"type": "object",
"properties": {
"command": {
"type": "string",
"description": "The LLDB command to run, possibly with arguments."
}
},
"required": [ "command" ]
}
}
"""
return command, self._run_one_command(command)

21 changes: 2 additions & 19 deletions src/chatdbg/native_util/dbg_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def dialog(self, user_text):
self.query_and_print(assistant, user_text, False)
while True:
try:
command = input("\u001b[35m(ChatDBG chatting)\u001b[0m").strip()
command = input("(ChatDBG chatting) ").strip()
if command in ["exit", "quit"]:
break
if command in ["chat", "why"]:
Expand Down Expand Up @@ -128,25 +128,8 @@ def build_prompt(self, arg, conversing):
self._prompt_history(), self._prompt_stack(), arg
)

# TODO: Factor out the name of the debugger that's embedded in the doc string...
def llm_debug(self, command: str) -> str:
"""
{
"name": "debug",
"description": "The `debug` function runs an LLDB command on the stopped program and gets the response.",
"parameters": {
"type": "object",
"properties": {
"command": {
"type": "string",
"description": "The LLDB command to run, possibly with arguments."
}
},
"required": [ "command" ]
}
}
"""
return command, self._run_one_command(command)
pass

def llm_get_code_surrounding(self, filename: str, line_number: int) -> str:
"""
Expand Down
28 changes: 0 additions & 28 deletions test/test_coverup_98.py

This file was deleted.

0 comments on commit 748ee16

Please sign in to comment.