ChatGDB is a tool that integrates ChatGPT into the GDB or LLDB debugger, designed specifically for debugging compiled languages. It leverages ChatGPT's capabilities to assist with debugging, allowing developers to describe their intent in natural language and then automatically execute the corresponding debugging commands, thereby speeding up the debugging process.
Main Capabilities
- Natural language-driven command execution: When the user enters queries such as "chat list all breakpoints that I created", the tool automatically executes the relevant debugging commands.
- Command explanation and Q&A: Provides the
explaincommand. With no arguments, it can explain the last executed command (for example, after runningbreak 7, it explains how breakpoints work). It can also take a query to ask GPT (for example, "explain how input formatting works in gdb"). - Help command: Running
chat helpprints a short usage tutorial.
How to Use
- Installation: Make sure pip is installed and the Python version is 3.3 or above. Run
pip3 install chatgdb. - Configure the API key: After installation, an executable file
chatgdbis generated. Runchatgdb -k <API KEY>to set the key. - Choose a model: You can choose
gpt-3.5-turbo(default) orgpt-4, set viachatgdb -m <MODEL>. - Custom API address (non-official API providers): Set via
chatgdb -u <api-url>. The above configuration information is stored as text in the same directory as the installed script (that is, in the Python site-packages folder), and its location can be found viapython -m site --user-site. - Optional installation: You can also download the compressed file from the releases page, enter the chatgdb folder, and run
pip3 install .to install. - Update: Run
pip3 install chatgdb --upgrade. - GDB integration: It is recommended to edit
$HOME/.gdbinitto automatically load the main script, and runecho "source $(python -m site --user-site)/chatgdb/gdb.py" > $HOME/.gdbinit. - LLDB integration: Edit
$HOME/.lldbinit, and runecho "command script import $(python -m site --user-site)/chatgdb/lldb.py" > $HOME/.lldbinit. - Use within the debugger: Within the debugger, run
chatfollowed by a query (such aschat list all breakpoints that I created), or use theexplaincommand.
Applicable Scenarios
Suitable for developers using GDB or LLDB to debug compiled languages, helping reduce the burden of memorizing and looking up debugging commands so they can focus on locating and fixing bugs.
Limitations
- Requires an OpenAI API key and may incur API usage fees (specific costs are not provided).
- Depends on a network connection to access the ChatGPT API.
- Current functionality is limited to assisting with the use of GDB/LLDB commands and explanations; full context awareness (such as helping fix the code itself) is still under development.
- Configuration information is stored in plain text, so security should be taken into consideration.
- The specific supported platforms are not provided.