Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

C++ Debug breakpoint doesn't work with linked libraries built with the application in VSCode when using `-Og` compilation flag/option.

未关闭
#14,357 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
cmake, cpp, vscode

调研方向

从提供的 launch.json、tasks.json 和顶层 CMakeLists.txt 开始,然后使用 GDB 和 -Og 标志重现 Arithmetic.cpp:299 的待处理断点。构建 Console 和 DataStructuresAlgorithms.Core 目标时比较调试器日志;当断点解析到已编译代码并在静态链接库内部命中时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

debugger help wanted
Environment
  • OS and version: Ubuntu 25.10
  • VS Code: 1.114.0
  • C/C++ extension: 1.5.1
  • OS and version of remote machine (if applicable):
  • GDB / LLDB version: 16.3
Bug Summary and Steps to Reproduce

Bug Summary:
Breakpoints set inside a statically linked library built with the same C++ application in the same source tree are greyed out and not hit.

Steps to reproduce:
Console.cpp CMakeLists.txt:

target_link_libraries(${PROJECT_NAME} PRIVATE
MyLibrary.Core
)

top-level CMakeLists.txt:

set(CMAKE_CXX_STANDARD 26)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_BUILD_TYPE "Debug")

# ###############################################################################
# Global compiler options
# https://stackoverflow.com/questions/79444534/vscode-cmake-configure-does-not-generate-cmakecache-txt-from-cmakelists-txt
# CMAKE_CXX_COMPILER_ID is set only at the project() call, when CMake actually detect compilers.
# ###############################################################################
if(MSVC)
    # remove default flags provided with CMake for MSVC
    set(CMAKE_CXX_FLAGS "")
    set(CMAKE_CXX_FLAGS_DEBUG "")
    set(CMAKE_CXX_FLAGS_RELEASE "")
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
    message("-- Setting GNU options from CMakeLists.txt")
    set(CMAKE_CXX_FLAGS "-std=gnu++26 -fdiagnostics-color=always" CACHE STRING "CXX build flags" FORCE)
    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -ggdb3 -Og -g3" CACHE STRING "Debug build flags" FORCE)
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG" CACHE STRING "Release build flags" FORCE)
endif()
Debugger Configurations

launch.json:

        {
            "name": "C++ Launch (Console)",
            "type": "cppdbg",
            "request": "launch",
            "preLaunchTask": "CMake: build all",
            "postDebugTask": "",
            "program": "${workspaceFolder}/Debug/Console",
            "cwd": "${workspaceFolder}/build",
            "stopAtEntry": false,
            "externalConsole": false,
            "launchCompleteCommand": "exec-run",
            "linux": {
              "MIMode": "gdb",
              "miDebuggerPath": "/usr/bin/gdb"
            },
            "osx": {
              "MIMode": "lldb"
            },
            "windows": {
              "MIMode": "gdb",
              "miDebuggerPath": "C:\\MinGw\\bin\\gdb.exe"
            },
            "args": [],
            "setupCommands": [
                {
                    "description": "Disable MI-async",
                    "text": "set mi-async off",
                    "ignoreFailures": true
                },
                {
                    "description": "Enable auto-load for all paths. Considered a security risk. See link for details: https://sourceware.org/gdb/current/onlinedocs/gdb.html/Auto_002dloading-safe-path.html",
                    "text": "set auto-load safe-path /",
                    "ignoreFailures": true
                },
                {
                    "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
                },                
                {
                    "description": "Do not display function arguments when printing a stack frame",
                    "text": "set print frame-arguments none",
                    "ignoreFailures": true
                }
            ]
        },          

tasks.json:

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "cmake",
			"label": "CMake: build all",
			"command": "build",
			"targets": [
				"all"
			],
			"group": {
				"kind": "build",
				"isDefault": true
			},
			"problemMatcher": ["$gcc"],
			"detail": "CMake build all"
		},
		{
			"type": "cmake",
			"label": "CMake: build Console",
			"command": "build",
			"targets": [
				"Console"
			],
			"group": {
				"kind": "build",
				"isDefault": false
			},
			"problemMatcher": ["$gcc"],
			"detail": "CMake build Console"
		},
		{
			"type": "cmake",
			"label": "CMake: build Core",
			"command": "build",
			"targets": [
				"DataStructuresAlgorithms.Core"
			],
			"group": {
				"kind": "build",
				"isDefault": false
			},
			"problemMatcher": ["$gcc"],
			"detail": "CMake build Core"
		},
		{
			"type": "cmake",
			"label": "CMake: build Tests",
			"command": "build",
			"targets": [
				"DataStructuresAlgorithms.Tests"
			],
			"group": {
				"kind": "build",
				"isDefault": false
			},
			"problemMatcher": ["$gcc"],
			"detail": "CMake build Tests"
		},
	]
}
Debugger Logs
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (590) DebuggerPid=583206\n"},"seq":185}
1: (590) DebuggerPid=583206
<--   C (setBreakpoints-4): {"command":"setBreakpoints","arguments":{"source":{"name":"Arithmetic.cpp","path":"/usr/src/DataStructuresAlgorithms/src/Arithmetic.cpp"},"lines":[299,323],"breakpoints":[{"line":299},{"line":323}],"sourceModified":false},"type":"request","seq":4}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (604) <-1016-break-insert -f Arithmetic.cpp:299\n"},"seq":188}
1: (604) <-1016-break-insert -f Arithmetic.cpp:299
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (701) ->&\"No compiled code for line 299 in file \\\"Arithmetic.cpp\\\".\\n\"\n"},"seq":190}
1: (701) ->&"No compiled code for line 299 in file \"Arithmetic.cpp\".\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (702) ->1016^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"<PENDING>\",pending=\"Arithmetic.cpp:299\",times=\"0\",original-location=\"Arithmetic.cpp:299\"}\n"},"seq":192}
1: (702) ->1016^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="<PENDING>",pending="Arithmetic.cpp:299",times="0",original-location="Arithmetic.cpp:299"}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (702) ->(gdb)\n"},"seq":194}
Other Extensions

No response

Additional Information

No response

主要语言
TypeScript
星标
6.2k
派生
1.7k
平均合并
1 天 4 小时
30 天内合并 PR
58

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/vscode-cpptools 的其他 Issue

查看 microsoft/vscode-cpptools 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。