microsoft / microsoft/vscode-cpptools

The debugger doesn't hit the breakpoints set in Editor

Offen
#12,477 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug debugger help wanted
Vorherrschende Sprache
TypeScript
Sterne
6.2k
Forks
1.7k
Ø Merge
14 Std. 46 Min.
Gemergte PRs (30 T.)
61

Beschreibung

Environment
  • OS and version: WIndows 11
  • VS Code: 1.91.1 (system setup)
  • C/C++ extension: 1.20.5
  • OS and version of remote machine (if applicable):
  • GDB / LLDB version: GNU gdb (GDB) 14.2 (installed by msys2)
Bug Summary and Steps to Reproduce

Bug Summary:
Let's take the code below (test.cpp) as an example.

#include <iostream>

int main()
{
	std::cout << "Line 5" << std::endl;
	std::cout << "Line 6" << std::endl;
	return 0;
}

I marked all the 3 lines (line 5, 6, and 7) of main func as breakpoints. After that, I pushed F5. However, not only did the program print it's output in the "DEBUG CONSOLE" rather than either "TERMINAL" or a system terminal, but also it ran smoothly from the start to the end, without stopping at any one of the 3 breakpoints. Actually, in the output info in "DEBUG CONSOLE" there's a line saying "Thread 1 "test" hit Breakpoint 1, 0x000000010040108d in main ()", but the debugger didn't do this literally. It just skipped every breakpoints.

Steps to reproduce:

  1. In the environment given above.
  2. With thie configurations given below.
  3. Just create a simple HelloWorld C++ code and push F5.
  4. The breakpoints turn grey and say, "Module containing this breakpoint has not yet loaded or the breakpoint address could not be obtained."
Debugger Configurations

tasks.json

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "cppbuild",
			"label": "C/C++: g++.exe build active file",
			"command": "D:\\msys64\\usr\\bin\\g++.exe",
			"args": [
				"-fdiagnostics-color=always",
				"${file}",
				"-o",
				"${fileDirname}\\${fileBasenameNoExtension}.exe",
				"-std=c++14",
				"-Wall",
				"-Wextra",
				"-g"
			],
			"options": {
				"cwd": "${fileDirname}"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": {
				"kind": "build",
				"isDefault": true
			},
			"detail": "compiler: D:\\msys64\\usr\\bin\\g++.exe"
		}
	]
}

launch.json

{
    "configurations": [
        {
            "name": "C/C++: g++.exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": true,
            "internalConsoleOptions": "neverOpen",
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\msys64\\usr\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": false
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": false
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ],
    "version": "2.0.0"
}
Debugger Logs
=thread-group-added,id="i1"
GNU gdb (GDB) 14.2
Copyright (C) 2023 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-pc-msys".
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"
[New Thread 12480.0x1a18]
[New Thread 12480.0x1524]
[New Thread 12480.0x55c4]
[New Thread 12480.0x5b94]

Thread 1 "test" hit Breakpoint 1, 0x000000010040108d in main ()
Loaded '/c/Windows/SYSTEM32/ntdll.dll'. Symbols loaded.
Loaded '/c/Windows/System32/KERNEL32.DLL'. Symbols loaded.
Loaded '/c/Windows/System32/KERNELBASE.dll'. Symbols loaded.
Loaded '/usr/bin/msys-2.0.dll'. Symbols loaded.
Loaded '/usr/bin/msys-stdc++-6.dll'. Symbols loaded.
Loaded '/usr/bin/msys-gcc_s-seh-1.dll'. Symbols loaded.
Loaded '/c/Windows/System32/advapi32.dll'. Symbols loaded.
Loaded '/c/Windows/System32/msvcrt.dll'. Symbols loaded.
Loaded '/c/Windows/System32/sechost.dll'. Symbols loaded.
Loaded '/c/Windows/System32/bcrypt.dll'. Symbols loaded.
Loaded '/c/Windows/System32/RPCRT4.dll'. Symbols loaded.
Loaded '/c/Windows/SYSTEM32/CRYPTBASE.DLL'. Symbols loaded.
Loaded '/c/Windows/System32/bcryptPrimitives.dll'. Symbols loaded.
Loaded '/c/Windows/system32/netapi32.dll'. Symbols loaded.
Loaded '/c/Windows/SYSTEM32/SAMCLI.DLL'. Symbols loaded.
Loaded '/c/Windows/System32/ucrtbase.dll'. Symbols loaded.
Loaded '/c/Windows/SYSTEM32/SAMLIB.dll'. Symbols loaded.
Loaded '/c/Windows/SYSTEM32/NETUTILS.DLL'. Symbols loaded.
Loaded '/c/Windows/System32/ws2_32.dll'. Symbols loaded.
Loaded '/c/Windows/system32/mswsock.dll'. Symbols loaded.
Line 5
Line 6
[Thread 12480.0x3218 exited with code 0]
[Thread 12480.0x1524 exited with code 0]
[Thread 12480.0x1a18 exited with code 0]
[Thread 12480.0x55c4 exited with code 0]
[Inferior 1 (process 12480) exited normally]
The program 'e:\Coding\Programs\test.exe' has exited with code 0 (0x00000000).

The two lines of output would not be printed here when I disabled the extension "C/C++ Compile Run".

Other Extensions
  • Better C++ Syntax
  • C/C++ Compile Run
  • C/C++ Themes
  • GlassIt-VSC
  • One Dark Pro
  • Vim

Notably when I disabled "C/C++ Compile Run", the code would run in a system terminal. However, even if I leave only "C/C++" enabled, the debugger still did not hit the breakpoints literally.

Additional Information

No response

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit den gemeldeten tasks.json- und launch.json-Konfigurationen und reproduzieren Sie das Problem anhand des bereitgestellten test.cpp-Beispiels und der Debugger-Protokolle, zunächst mit ausschließlich aktivierter C/C++-Erweiterung. Vergleichen Sie den Status der grauen Breakpoints und das Verhalten der Debug-Konsole mit den konfigurierten GDB- und launch-Einstellungen; abgeschlossen ist die Aufgabe, wenn die gemeldeten Breakpoints aufgelöst werden und die Ausführung an ihnen anhält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp, vscode
Bereich
devtools
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.