microsoft / microsoft/vscode-cpptools

sometimes cppdbg report an error and quit when run on a break point

Open
#13,198 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug 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: ubuntu x64 24.04
  • VS Code: 1.96.4
  • C/C++ extension: 1.23.4
  • OS and version of remote machine (if applicable): linux 4.9 on arm 32bit cortex-A9
  • GDB / LLDB version: gdb 7.12
Bug Summary and Steps to Reproduce

Bug Summary:
I run vs code on ubuntu 24.04 with a cross compiled gdb 7.12, to remote debug a program run on another embeded device( cpu is arm cortex-A9 32bit), a gdb server 7.12 run on device to execute the program, sometimes, cppdbg failed to enter an common break point, it report an error message: "ERROR: Error while trying to enter break state. Debugging will now stop. Unrecognized format of field "level" in result: {level=-1,addr=0x7603e3ac,func=??,args=[]}"
but when I use codeblock 20.03 with the same cross compiled gdb 7.12, that is ok to enter the same break point.

Steps to reproduce:

  1. In this environment...
  2. With this config...
  3. Do '...'
  4. See error...
Debugger Configurations
lauhcn.json
{
    "configurations": [
        {
            "name": "Remote GDB Debug",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/mdvr_mqtt",
            "args": [],
            "miDebuggerPath": "/opt/arm-ca9-linux-gnueabihf-6.5/bin/arm-ca9-linux-gnueabihf-gdb",  // 交叉GDB的路径,如 arm-none-eabi-gdb
            "miDebuggerArgs":"-nx -fullname -quiet",    // -nx: do not use init, -fullname: not stardard. -quiet: no gdb version info output
            //"stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false, // 是否使用外部控制台
            "MIMode": "gdb",
            "targetArchitecture": "arm",
            
            "miDebuggerServerAddress": "192.168.1.175:7720",
            "serverStarted": "Remote debugging from host 192.168.1.240",    // 通过搜索std output文本,取回输出信息在Debug Console显示
            "setupCommands": [
                 // 在这里添加你需要执行的其他GDB命令
                {
                    "description": "Set system root path",
                    "text": "set sysroot /home/gdb-sysroot/ca9/sysroot", // 替换为你的系统根路径
                    "ignoreFailures": false
                },
                // {
                //     "description": "delete old program",
                //     "text": "extended-remote delete /var/disk3/gdbca9/mdvr_mqtt",
                //     "ignoreFailures": false
                // },
                // {
                //     "description": "put file",
                //     "text": "extended-remote put '${workspaceFolder}/mdvr_mqtt' /var/disk3/gdbca9/mdvr_mqtt",                   
                //     "ignoreFailures": false
                // },
                {
                    "description": "set file",
                    "text": "set remote exec-file /mnt/user/test/mdvr_mqtt",                   
                    "ignoreFailures": false
                },
                {
                    "description": "Set a breakpoint at main",
                    "text": "break main",
                    "ignoreFailures": false
                },
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            //"postLaunchTask": "", // 可选,调试启动后的任务(如编译)
            //"preLaunchTask": "build", // 可选,调试启动前的任务(如编译)
            "logging": {
                "trace": false,
                "traceResponse": false,
                "engineLogging": false,
                "programOutput": true,
                "exceptions": true
            }
        },
        {
            "name": "C/C++: Novatek CA9 G++ build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            //"preLaunchTask": "C/C++: Novatek CA9 G++ build active file",
            "miDebuggerPath": "/opt/arm-ca9-linux-gnueabihf-6.5/bin/arm-ca9-linux-gnueabihf-gdb"
        }
    ],
    "version": "2.0.0"
}
tasks.json:
{
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "make",
            "args": [
                "-C",
                "${workspaceFolder}", // 指定工作目录为项目根目录"
                "-f",
                "Makefile.mqtt",
                "-j4",
                "-s"
            ],
            "options": {
                "cwd": "${workspaceFolder}",
                "env": {
                    "PATH": "/opt/arm-ca9-linux-gnueabihf-6.5/bin:${env:PATH}"
                },
            },
            "presentation": {
                "echo": true,    // 是否在终端中回显命令
                "reveal": "always", // 何时在终端中显示输出
                "focus": true,  // 是否在任务开始时聚焦终端
                "panel": "shared" // 输出面板的共享行为
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "make a build"
        },
        {
            "label": "clean",
            "type": "shell",
            "command": "make",
            "args": [
                "-f",
                "Makefile.mqtt",
                "clean"
            ],
            "options": {
                "cwd": "${workspaceFolder}",
                "env": {
                    "PATH": "/opt/arm-ca9-linux-gnueabihf-6.5/bin:${env:PATH}"
                },
            },
            "presentation": {
                "echo": true,    // 是否在终端中回显命令
                "reveal": "always", // 何时在终端中显示输出
                "focus": true,  // 是否在任务开始时聚焦终端
                "panel": "shared" // 输出面板的共享行为
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "make clean"    
        },
        {
            "label": "clean-and-build",
            "type": "shell",
            "dependsOn": [
                "clean",
                "build"
            ],
            "options": {
                //"cwd": "${fileDirname}",
                "env": {
                    "PATH": "/opt/arm-ca9-linux-gnueabihf-6.5/bin:${env:PATH}"
                },
            },
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": ["$gcc"],
            "presentation": {
                "echo": true,    // 是否在终端中回显命令
                "reveal": "always", // 何时在终端中显示输出
                "focus": true,  // 是否在任务开始时聚焦终端
                "panel": "shared" // 输出面板的共享行为
            },
            "detail": "make clean, build."
        },
        {
            "label": "C/C++: compile file",
            "type": "cppbuild",
            "command": "/opt/arm-ca9-linux-gnueabihf-6.5/bin/arm-ca9-linux-gnueabihf-g++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${workspaceFolder}",
                "env": {
                    "PATH": "/opt/arm-ca9-linux-gnueabihf-6.5/bin:${env:PATH}"
                },
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}
Debugger Logs
ERROR: Error while trying to enter break state. Debugging will now stop. Unrecognized format of field "level" in result: {level=-1,addr=0x7603e3ac,func=??,args=[]}
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 remote cppdbg configuration in lauhcn.json, tasks.json, and the recorded debugger log showing the unrecognized GDB/MI level field. Reproduce the intermittent breakpoint failure with the listed Ubuntu, ARM remote target, and GDB 7.12 versions, then compare the result with Code::Blocks; done means the same breakpoint can be entered without cppdbg stopping.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, typescript
Domain
devtools, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.