microsoft / microsoft/vscode-cpptools

cannot set breakpoint in .gdbinit/DebuggerConsole

Open
#11,882 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

debugger help wanted
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and version: ubuntu22.04
  • VS Code: 1.85.1
  • C/C++ extension: 1.18.5
  • GDB / LLDB version: 12.1
Bug Summary and Steps to Reproduce

Bug Summary:

I can debug a c++ application as normal. When I try to set a breakpoint in .gdbinit or in the debug console, vscode shows that an exception occurred.

image image
Debugger Configurations
{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/build/linux/x86_64/debug/c++",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "BuildAndDebug",
            "postRemoteConnectCommands": [
                {
                    "description": "",
                    "text": "info file",
                    "ignoreFailures": false
                },
                {
                    "description": "",
                    "text": "source ${workspaceRoot}/.gdbinit",
                    "ignoreFailures": false
                }
            ]
        }

    ]
}

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "BuildAndDebug",
            "command": "make",
            "args": [
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                {
                    "pattern": [
                        {
                            "regexp": ".",
                            "file": 1,
                            "location": 2,
                            "message": 3
                        }
                    ],
                    "background": {
                        "activeOnStart": true,
                        "beginsPattern": ".",
                        "endsPattern": ".",
                    }
                }
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。",
            "isBackground": false,
        }
    ],
    "version": "2.0.0"
}
```json



### Debugger Logs

```shell
=thread-group-added,id="i1"
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"
Stopped due to shared library event (no libraries added or removed)
Loaded '/lib64/ld-linux-x86-64.so.2'. Symbols loaded.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, main (argc=1, argv=0x7fffffffd7c8) at src/main.cpp:14
14	    std::cout << add(1, 2) << std::endl;
Loaded '/lib/x86_64-linux-gnu/libstdc++.so.6'. Symbols loaded.
Loaded '/lib/x86_64-linux-gnu/libc.so.6'. Symbols loaded.
Loaded '/lib/x86_64-linux-gnu/libm.so.6'. Symbols loaded.
Loaded '/lib/x86_64-linux-gnu/libgcc_s.so.1'. Symbols loaded.
Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)
-exec b add
Breakpoint 3 at 0x5555555551d7: file src/main.cpp, line 9.

Breakpoint 3, add (a=1, b=2) at src/main.cpp:9
9	    return a + b;
Kill the program being debugged? (y or n) [answered Y; input not from terminal]
[Inferior 1 (process 37763) killed]
The program '/home/wang/Documents/test/c++/build/linux/x86_64/debug/c++' has exited with code 0 (0x00000000).
Other Extensions

No response

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the debugger console and the postRemoteConnectCommands that source .gdbinit in the provided launch configuration. Reproduce the breakpoint failure on Ubuntu 22.04 with VS Code 1.85.1, the C/C++ extension 1.18.5, and GDB 12.1, then compare the exception with the debugger logs. Done means breakpoints entered in .gdbinit or the debug console no longer trigger the exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.