{"id":19902982,"url":"https://github.com/airob0t/gdbai","last_synced_at":"2025-07-27T04:36:33.386Z","repository":{"id":186496912,"uuid":"674907857","full_name":"airob0t/gdbai","owner":"airob0t","description":"GDB AI debug assistant plugin/ GDB AI调试助手插件","archived":false,"fork":false,"pushed_at":"2023-08-07T15:58:47.000Z","size":70,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-03T00:36:03.478Z","etag":null,"topics":["ai","chat","chatglm","debug","gdb","glm","gpt"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/airob0t.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-05T06:04:54.000Z","updated_at":"2024-12-15T23:03:09.000Z","dependencies_parsed_at":"2023-11-09T13:06:34.576Z","dependency_job_id":"164e374b-50c2-48de-8890-63b30775760d","html_url":"https://github.com/airob0t/gdbai","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":0.07692307692307687,"last_synced_commit":"c16f30ca94f300bcf857d99f70fa47bfa5dbfe18"},"previous_names":["airob0t/gdbai"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/airob0t/gdbai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airob0t%2Fgdbai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airob0t%2Fgdbai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airob0t%2Fgdbai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airob0t%2Fgdbai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/airob0t","download_url":"https://codeload.github.com/airob0t/gdbai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airob0t%2Fgdbai/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267300058,"owners_count":24066094,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","chat","chatglm","debug","gdb","glm","gpt"],"created_at":"2024-11-12T20:20:38.468Z","updated_at":"2025-07-27T04:36:33.341Z","avatar_url":"https://github.com/airob0t.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GDBAI\nGDB AI assistant plugin. Debug with GPT.\n\nGDB AI助手插件,和GPT一起debug.\n\n# Usage\n\n## set your openai api key,proxy, language\n设置你的openai api key\n\n(可选)设置你的代理,回答语言\n```\nexport OPENAI_API_KEY=\"your key\"\n# [optional]\nexport http_proxy=http://username:password@proxy_host:proxy_port\nexport https_proxy=http://username:password@proxy_host:proxy_port\nexport GDBAI_LANG=zh\nexport GDBAI_MODEL=\"gpt-3.5-turbo\"\nexport CHATGLM_API=\"http://localhost:8000\"\n```\n\n## example\n\n## command\n- ai - Answer questions based on current stack information\n- chat - Chat with GPT\n- trans - Translate natural language into a GDB command\n- explain - Explain the meaning of a GDB command\n- llm - Select the language model to use [gpt|glm]  default gpt\n## 命令\n- ai - 根据当前堆栈信息回答问题\n- chat - 和GPT聊天\n- trans - 将自然语言翻译称一条GDB命令\n- explain - 解释GDB命令的含义\n- llm - 选择语言模型 [gpt|glm]  默认gpt\n\n## load\n`pip install -U gdbai`\n\n`(gdb) source /path/to/gdbai/gdbai.py ` every time\n\nor add it to `.gdbinit`\n\n`echo \"source $(python -m site --user-site)/gdbai.py\" \u003e $HOME/.gdbinit`\n\n```\n(gdb) source /path/to/gdbai/gdbai.py\nusage:\n        ai\n        ai Explain what the root cause of this error is.Give me Suggestions\n        ai 用中文回答无效指针是哪个\n        chat how to use gdb\n        trans show the instructions at the current location\n        explain handle SIGINT stop\n(gdb) r\nStarting program: /path/to/gdbai/debug_demo\n[Thread debugging using libthread_db enabled]\nUsing host libthread_db library \"/lib/x86_64-linux-gnu/libthread_db.so.1\".\n\nProgram received signal SIGSEGV, Segmentation fault.\n0x0000555555555236 in print (p=0x0) at debug_demo.cpp:9\nwarning: Source file is more recent than executable.\n9         std::cout\u003c\u003c *p \u003c\u003c std::endl;\n(gdb) ai\nBased on the provided GDB debug information, the error seems to occur in the \"print\" function at line 9 of the \"debug_demo.cpp\" file. The error is caused by accessing a null pointer (p=0x0).\n\nThe root cause of this error is that the \"print\" function is receiving a null pointer (p) as an argument. Trying to access the memory location pointed to by a null pointer will result in a segmentation fault or other similar error.\n\nTo resolve this issue, you should ensure that the pointer being passed to the \"print\" function is not null before attempting to access its value. You can add a null check at the beginning of the function to handle such cases gracefully:\n\nvoid print(int* p) {\n    if (p == nullptr) {\n        // Handle the case when p is null\n        std::cout \u003c\u003c \"Error: Null pointer passed to print function\\n\";\n        return;\n    }\n\n    // Rest of your code to print the value pointed by p\n    // ...\n}\n\nBy adding this null check, you can avoid the segmentation fault and handle the null pointer case in a more controlled manner.\n(gdb) ai 用中文回答无效指针是哪个,是谁调用这个函数的\n根据给出的GDB调试信息，我们可以看到位于print函数中的NULL指针。\n\n当前函数是print函数，它在debug_demo.cpp文件的第9行被调用。\n调用print函数的是main函数，它位于debug_demo.cpp文件的第15行。\n\n希望这能帮到你！\n(gdb) trans show the instructions at the current location\nx/8i $pc\n\n=\u003e 0x555555555236 \u003c_Z5printPi+20\u003e:      mov    (%rax),%eax\n   0x555555555238 \u003c_Z5printPi+22\u003e:      mov    %eax,%esi\n   0x55555555523a \u003c_Z5printPi+24\u003e:      lea    0x2dff(%rip),%rdi        # 0x555555558040 \u003c_ZSt4cout@GLIBCXX_3.4\u003e\n   0x555555555241 \u003c_Z5printPi+31\u003e:      call   0x5555555550d0 \u003c_ZNSolsEi@plt\u003e\n   0x555555555246 \u003c_Z5printPi+36\u003e:      mov    %rax,%rdx\n   0x555555555249 \u003c_Z5printPi+39\u003e:      mov    0x2d80(%rip),%rax        # 0x555555557fd0\n   0x555555555250 \u003c_Z5printPi+46\u003e:      mov    %rax,%rsi\n   0x555555555253 \u003c_Z5printPi+49\u003e:      mov    %rdx,%rdi\n(gdb) explain x/8i $pc\nThe GDB command \"x/8i $pc\" is used to display the next 8 instructions of the program being debugged starting from the current value of the program counter ($pc).\n\nThe \"x\" command is used in GDB to examine memory. In this case, we are using it to examine the instructions in memory. The \"8i\" argument specifies that we want to examine 8 instructions, and the \"$pc\" specifies that we want to start examining from the current value of the program counter.\n\nThe program counter ($pc) keeps track of the memory address of the next instruction to be executed by the processor. By using the \"x/8i\" command with the $pc register, we can see the assembly instructions that are about to be executed.\n\nThe output of this command will show the memory addresses and corresponding assembly instructions for the next 8 instructions in the program. This can be useful for understanding program flow and debugging issues at the instruction level.\n(gdb) chat what's gdb\nGDB (GNU Debugger) is a powerful and widely used debugger for various programming languages, including C, C++, and assembly. It allows developers to trace and debug their programs by providing features such as breakpoints, stepping through code, examining variables and memory, and controlling program execution. GDB is a command-line tool that is commonly used in development environments for finding and fixing software bugs and errors.\n```\n# ToDo\nWelcome to raise an issue. If there are more stars, it will speed up development.\n- [ ] The information provided to AI includes source code, balancing token length limitations and the issue of necessary information.\n- [ ] Add task decomposition for debugging, automate calling functions to obtain the required additional information to complete debugging.\n\n欢迎提issue,如果星星多的话,会加快开发\n- [ ] 提供给AI的信息包含source code,平衡token长度限制和必要信息的问题\n- [ ] 增加debug任务拆解,自动化调用函数获取需要的补充信息完成debug","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairob0t%2Fgdbai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fairob0t%2Fgdbai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairob0t%2Fgdbai/lists"}