问题描述
我遵循的指示。安装了cpptools。创建 tasks.json
以下内容:
{
version:0.1.0,
command:g ++,
isShellCommand:true,
showOutput:always,
args :[-g,helloworld.c]
}
launch.json
以下内容:
{
版本:0.2.0,
配置:[
{
name:C ++ Launch(Windows),
type: cppvsdbg,
request:launch,
program:$ {workspaceRoot} /a.exe,
args:[],
stopAtEntry:false,
cwd:$ {workspaceRoot},
environment:[],
externalConsole:false,
windows: {
MIMode:gdb,
miDebuggerPath:C:\\ Mahesh\\Program Files\\\\\\\\\\\\\\\\\ MinGW \\\\\\\\\\\\\\\\\\\\\\\\'\\\\\\\\\\\\\\\'
program:$ {workspaceRoot} /a.exe,
type:cppvsdbg,
request:attach,
processId :$ {command.pickProcess},
windows:{
MIMode:gdb,
miDebuggerPath:C:\\Mahesh\\\ \\程序文件\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
当我执行 Ctrl + Shift + B
时, ,生成 a.exe
。当我运行调试时,它会提供以下输出:
---------------- -------------------------------------------------- --------------
您只能在Visual Studio
Code,Visual Studio或Xamarin Studio软件中使用Visual Studio代码的C / C ++扩展来帮助您开发并测试您的
应用程序。
---------------------------------------------- ----------------------------------
Loaded'C:\Mahesh\repos\ VSCodeC\polyaddition\a.exe。符号未加载。
加载'C:\ Windows \ System32 \\\
tdll.dll'。符号未加载。
加载'C:\ Windows \ System32 \kernel32.dll'。符号未加载。
加载'C:\ Windows \ System32 \KernelBase.dll'。符号未加载。
加载'C:\ Windows \ System32 \sysfer.dll'。符号未加载。
加载'C:\ Windows \ System32 \msvcr100.dll'。符号未加载。
加载'C:\ Windows \ System32 \ QIPCAP64.dll'。符号未加载。
加载'C:\ Windows \ System32 \ oleaut32.dll'。符号未加载。
加载'C:\Windows\System32\ole32.dll'。符号未加载。
加载'C:\ Windows \ System32 \msvcrt.dll'。符号未加载。
加载'C:\ Windows \ System32 \gdi32.dll'。符号未加载。
加载'C:\Windows\System32\user32.dll'。符号未加载。
加载'C:\ Windows \ System32 \lpk.dll'。符号未加载。
加载'C:\ Windows \ System32 \usp10.dll'。符号未加载。
加载'C:\ Windows \ System32 \rpcrt4.dll'。符号未加载。
加载'C:\Windows\System32\imm32.dll'。符号未加载。
加载'C:\ Windows \ System32 \msctf.dll'。符号未加载。
线程9524已退出,代码为0(0x0)。
Hello World !!!
程序'[7876] a.exe'已经用代码0(0x0)退出。
但是代码没有达到我在代码中设置的调试点。你可以看到,它正在打印Hello World !!!。如何配置,以便它能让我在调试时逐步完成代码?
环境:
- 程序'[7876] a.exe'已退出,代码为0(0x0),
为i686-pc-mingw32。 - gcc.exe(x86_64-win32-seh-rev201506,mingwpy build)4.9.2
- g ++ .exe(x86_64-win32-seh-rev201506,mingwpy build) li>
更新
- 在的讨论中,我被要求使用
m32 $运行gcc c $ c>标志,因为我的编译器是64位的,它可能会生成64位二进制文件。但是
gcc -m32 helloworld.c
给出了诸如的错误。 用-m32
选项解释它。它要求在编译时添加i686-w64-mingw32 / x86_64-w64-mingw32
标志。但是gcc -x86_64-w64-mingw32 helloworld.c
给出语言无法识别
错误,gcc -i686-w64-mingw32 helloworld.c
给出无法识别的命令行选项
。我做错了什么? - 还这篇文章说,调试目前只能用于Linux,而不能用于Windows。是这样吗?如果你想让command.PickProcess工作。 >
它应该是':'不是'。' - 因此:
{
name:.NET Core Attach,
type:coreclr,
request:attach,
processId: $ {command:pickProcess}
应该把你排序:)
I was following instructions from here. Installed cpptools. Created tasks.json
with following contents:
{
"version": "0.1.0",
"command": "g++",
"isShellCommand": true,
"showOutput": "always",
"args": ["-g", "helloworld.c"]
}
And launch.json
with following content:
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch (Windows)",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceRoot}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": false,
"windows": {
"MIMode" : "gdb",
"miDebuggerPath": "C:\\Mahesh\\Program Files\\mingw\\MinGW\\bin\\gdb.exe"
}
},
{
"name": "C++ Attach (Windows)",
"program": "${workspaceRoot}/a.exe",
"type": "cppvsdbg",
"request": "attach",
"processId": "${command.pickProcess}",
"windows": {
"MIMode" : "gdb",
"miDebuggerPath": "C:\\Mahesh\\Program Files\\mingw\\MinGW\\bin\\gdb.exe"
}
}
]
}
When I do Ctrl+Shift+B
, the code builds, generating a.exe
. When I run debug, it gives following output:
--------------------------------------------------------------------------------
You may only use the C/C++ Extension for Visual Studio Code with Visual Studio
Code, Visual Studio or Xamarin Studio software to help you develop and test your
applications.
--------------------------------------------------------------------------------
Loaded 'C:\Mahesh\repos\VSCodeC\polyaddition\a.exe'. Symbols are not loaded.
Loaded 'C:\Windows\System32\ntdll.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\kernel32.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\KernelBase.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\sysfer.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\msvcr100.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\QIPCAP64.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\oleaut32.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\ole32.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\msvcrt.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\gdi32.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\user32.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\lpk.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\usp10.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\rpcrt4.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\imm32.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\msctf.dll'. Symbols are not loaded.
The thread 9524 has exited with code 0 (0x0).
Hello World!!!
The program '[7876] a.exe' has exited with code 0 (0x0).
But the code is not hitting the debug point I set up in the code. You can see, it is printing "Hello World!!!". How can I configure so that it will allow me to step through the code while debugging?
Environment:
- The program '[7876] a.exe' has exited with code 0 (0x0),configured as "i686-pc-mingw32".
- gcc.exe (x86_64-win32-seh-rev201506, mingwpy build) 4.9.2
- g++.exe (x86_64-win32-seh-rev201506, mingwpy build) 4.9.2
Update
- In the discussion in the comments, I have been asked to run gcc with
m32
flag as my compiler is 64-bit, it may be generating 64-bit binaries. Butgcc -m32 helloworld.c
gave errors like this. The comment here explains it with-m32
option. It asks to addi686-w64-mingw32/x86_64-w64-mingw32
flags while compiling. Butgcc -x86_64-w64-mingw32 helloworld.c
giveslanguage not recognized
error,gcc -i686-w64-mingw32 helloworld.c
givesunrecognized command line option
. What I am doing wrong? - Also this article says that debugging is currently possible only with linux but not with Windows. Is it so?
If you want command.PickProcess to work..
It should be a ':' not a '.' - therefore:
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
Should sort you out :)
这篇关于使用gcc,g ++和gdb在Window 7上设置VSCode进行C / C ++调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!