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

Aperta
#14,357 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
cmake, cpp, vscode

Direzione di ricerca

Inizia con i file launch.json e tasks.json forniti e con il CMakeLists.txt di livello superiore, quindi riproduci il breakpoint in sospeso per Arithmetic.cpp:299 usando GDB e i flag -Og. Confronta i log del debugger durante la compilazione dei target Console e DataStructuresAlgorithms.Core; il lavoro è completato quando il breakpoint viene risolto nel codice compilato e viene raggiunto all’interno della libreria collegata staticamente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/vscode-cpptools

Tutte le issue di microsoft/vscode-cpptools

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.