From 51c5d5576485ccaab99ad62a87c5128e23997dd4 Mon Sep 17 00:00:00 2001 From: Stephen Freund Date: Wed, 1 May 2024 13:46:21 -0400 Subject: [PATCH 1/5] added clips to README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 95937e8..35c1b74 100644 --- a/README.md +++ b/README.md @@ -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) | +|:-------------------------:|:-------------------------:|:-------------------------:| +| | || + 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] From bebe59c218fc5846291466f4bc6fe6aa203b8721 Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 1 May 2024 17:50:47 +0000 Subject: [PATCH 2/5] cleanup prompt --- src/chatdbg/native_util/dbg_dialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chatdbg/native_util/dbg_dialog.py b/src/chatdbg/native_util/dbg_dialog.py index 5e7b048..3ba520d 100644 --- a/src/chatdbg/native_util/dbg_dialog.py +++ b/src/chatdbg/native_util/dbg_dialog.py @@ -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"]: From 222a573d3a34d0ded0ebdb104d53f25c32fde324 Mon Sep 17 00:00:00 2001 From: Kyla Levin <62115756+ravenblood000@users.noreply.github.com> Date: Wed, 1 May 2024 18:23:38 +0000 Subject: [PATCH 3/5] bug fixes --- src/chatdbg/chatdbg_gdb.py | 35 +++++++++++++++++++++------ src/chatdbg/chatdbg_lldb.py | 20 +++++++++++++++ src/chatdbg/native_util/dbg_dialog.py | 19 +-------------- 3 files changed, 49 insertions(+), 25 deletions(-) diff --git a/src/chatdbg/chatdbg_gdb.py b/src/chatdbg/chatdbg_gdb.py index 1a92f1f..d45f05b 100644 --- a/src/chatdbg/chatdbg_gdb.py +++ b/src/chatdbg/chatdbg_gdb.py @@ -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 @@ -234,12 +237,11 @@ 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): """ @@ -247,3 +249,22 @@ def _prompt_stack(self): 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) diff --git a/src/chatdbg/chatdbg_lldb.py b/src/chatdbg/chatdbg_lldb.py index d9981c9..570f129 100644 --- a/src/chatdbg/chatdbg_lldb.py +++ b/src/chatdbg/chatdbg_lldb.py @@ -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) + diff --git a/src/chatdbg/native_util/dbg_dialog.py b/src/chatdbg/native_util/dbg_dialog.py index 3ba520d..6504386 100644 --- a/src/chatdbg/native_util/dbg_dialog.py +++ b/src/chatdbg/native_util/dbg_dialog.py @@ -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: """ From 48a2e035a81034ad2e5f9eb938221ee8d3f1a28d Mon Sep 17 00:00:00 2001 From: Kyla Levin <62115756+ravenblood000@users.noreply.github.com> Date: Wed, 1 May 2024 18:31:01 +0000 Subject: [PATCH 4/5] more bug fix --- src/chatdbg/native_util/dbg_dialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chatdbg/native_util/dbg_dialog.py b/src/chatdbg/native_util/dbg_dialog.py index 6504386..ee604b1 100644 --- a/src/chatdbg/native_util/dbg_dialog.py +++ b/src/chatdbg/native_util/dbg_dialog.py @@ -129,7 +129,7 @@ def build_prompt(self, arg, conversing): ) def llm_debug(self, command: str) -> str: - pass + return "" def llm_get_code_surrounding(self, filename: str, line_number: int) -> str: """ From d6e2856c9b9ad8e97f1a22b33e9d172deef115e4 Mon Sep 17 00:00:00 2001 From: Kyla Levin <62115756+ravenblood000@users.noreply.github.com> Date: Wed, 1 May 2024 18:35:38 +0000 Subject: [PATCH 5/5] remove dissenters --- src/chatdbg/native_util/dbg_dialog.py | 2 +- test/test_coverup_98.py | 28 --------------------------- 2 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 test/test_coverup_98.py diff --git a/src/chatdbg/native_util/dbg_dialog.py b/src/chatdbg/native_util/dbg_dialog.py index ee604b1..6504386 100644 --- a/src/chatdbg/native_util/dbg_dialog.py +++ b/src/chatdbg/native_util/dbg_dialog.py @@ -129,7 +129,7 @@ def build_prompt(self, arg, conversing): ) def llm_debug(self, command: str) -> str: - return "" + pass def llm_get_code_surrounding(self, filename: str, line_number: int) -> str: """ diff --git a/test/test_coverup_98.py b/test/test_coverup_98.py deleted file mode 100644 index e55930c..0000000 --- a/test/test_coverup_98.py +++ /dev/null @@ -1,28 +0,0 @@ -# file src/chatdbg/native_util/dbg_dialog.py:132-149 -# lines [132, 149] -# branches [] - -import pytest -from unittest.mock import MagicMock, create_autospec - -# Assuming DBGDialog is part of a module named dbg_dialog under chatdbg/native_util -from chatdbg.native_util.dbg_dialog import DBGDialog - -# Test function to cover llm_debug method -def test_llm_debug(): - # Mock dependencies - prompt_mock = MagicMock() - - # Create an instance of DBGDialog with a mocked prompt - dbg_dialog_instance = DBGDialog(prompt_mock) - dbg_dialog_instance._run_one_command = create_autospec(dbg_dialog_instance._run_one_command, return_value='mocked response') - - # Call llm_debug with a test command - command = 'test_command' - result = dbg_dialog_instance.llm_debug(command) - - # Assert the return value is correct - assert result == (command, 'mocked response') - - # Assert that _run_one_command was called with the correct arguments - dbg_dialog_instance._run_one_command.assert_called_once_with(command)