microsoft / microsoft/vscode-cpptools
VS Code when debugging with gdb can't find source file.
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 6.2k
- Fork
- 1.7k
- Merge medio
- 14h 46m
- PR unite (30g)
- 61
Descrizione
Environment
- OS and version:
Edition Windows 10 Pro
Version 22H2
Installed on 11/7/2020
OS build 19045.3996
Experience Windows Feature Experience Pack 1000.19053.1000.0 - VS Code:
Version: 1.86.0 (user setup)
Commit: 05047486b6df5eb8d44b2ecd70ea3bdf775fd937
Date: 2024-01-31T10:28:19.990Z
Electron: 27.2.3
ElectronBuildId: 26495564
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Windows_NT x64 10.0.19045 - C/C++ extension:
C/C++ v1.18.5
C/C++ Extension Pack v1.3.0
C/C++ Themes v2.0.0
Microsoft microsoft.com - OS and version of remote machine (if applicable):
- GDB / LLDB version:
GNU gdb (GDB) (Cygwin 13.2-1) 13.2
Bug Summary and Steps to Reproduce
Bug Summary:
Cannot debug C/C++ code on Windows.
Steps to reproduce:
- Follow instructions to create new Hello World app from https://code.visualstudio.com/docs/languages/cpp
- Run the file as in the instructions and confirm that it produces the output "Hello World"
- Set breakpoint at line 5 of the example code "std::cout << "Hello World" << std::endl;"
- From the drop down at the top right of the helloworld.cpp file select "Debug C/C++ File"
- The debugger runs but does not break at the breakpoint.
So I created a "Launch" configuration to see if I could get it to break via "stopAtEntry": true.
I switch to the "Run and Debug" interface on the left, make helloworld.cpp the active file and click the green arrow play button to the left of "(gdb) Launch" the app will launch and break, however the helloworld.cpp does not show the break point as active and I can't step through it. If I open the CALL STACK and click on "main()" it attempts to open the helloworld.cpp file but the path to the file is incorrect. It says "The editor could not be opened because the file was not found." I have attached an image of this. Notice the path at the top of the file.
If I click "Create File" there is a helloworld.cpp file created at "C:\Users\myaccount\Documents\CProjects\HelloWorld\C☐\Users\myaccount\Documents\CProjects\HelloWorld\helloworld.cpp" and it is blank. If I paste my code into that file VSCode shows the code with the debug marker but I can't set additional breakpoints by clicking in the file.
I have tried using "sourceFileMap" to map the folder C:\cygwin\bin to \cygdrive but that only affects the path to the left of C☐>Users>... The problem seems to lie with the fact that VS Code wants to use the full Windows path to the cpp file name but gdb isn't interpreting the c:\ part correctly.
I also have VS Code running on a Linux installation and the debugger works just fine.
Debugger Configurations
tasks.json
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\cygwin\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/helloworld.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\cygwin\\bin\\gdb.exe",
"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
}
]
}
]
}
Debugger Logs
The debugger log was too long so I included it as an attachment under "Additional Information"
Other Extensions
The only other extensions that are installed are:
CMake Tools v1.16.32 by Microsoft
CMake v0.0.17 twxs (CMake language support)
Additional Information
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con i percorsi e le configurazioni Cygwin in tasks.json e launch.json, quindi riproduci il flusso di debug di Hello World descritto nell’issue ed esamina il file Debugging Log.txt allegato. Confronta il percorso sorgente indicato da GDB con il percorso del workspace e con il sourceFileMap tentato. Il lavoro è completato quando il breakpoint si associa a helloworld.cpp e il call stack apre il file sorgente esistente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cpp, vscode
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100