microsoft / microsoft/vscode-cpptools
The debugger doesn't hit the breakpoints set in Editor
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
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:
- In the environment given above.
- With thie configurations given below.
- Just create a simple HelloWorld C++ code and push
F5. - 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported tasks.json and launch.json configurations and reproduce the issue using the supplied test.cpp example and debugger logs, first with only the C/C++ extension enabled. Compare the grey breakpoint state and debug-console behavior with the configured GDB and launch settings; done means the reported breakpoints are resolved and execution stops on them.
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