Reputation: 24731
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:
Update
m32
flag as my compiler is 64-bit, it may be generating 64-bit binaries. But gcc -m32 helloworld.c
gave errors like this. The comment here explains it with -m32
option. It asks to add i686-w64-mingw32/x86_64-w64-mingw32
flags while compiling. But gcc -x86_64-w64-mingw32 helloworld.c
gives language not recognized
error, gcc -i686-w64-mingw32 helloworld.c
gives unrecognized command line option
. What I am doing wrong?Upvotes: 3
Views: 8489
Reputation: 257
This can appear if you execute visual studio normally and trying to debug a .exe marqued as 'execute as administrator'
Upvotes: 0
Reputation: 181
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 :)
Upvotes: 1
Reputation: 479
I have faced this issue before. In my case, the compiler generated a release application as default. It has no symbols for debugging.
So, please make sure that you are generated a debug app for debugging.
good luck!
Upvotes: 0
Reputation: 1074
I believe you are trying to use the VS Code debugger (cppvsdbg) instead of gdb (cppdbg.) This modified launch.json
works for me with TDM-GCC and gdb as the debugger:
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"linux": {
"program": "${workspaceRoot}/a.out",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"miDebuggerPath": "C:\\TDM-GCC-64\\bin\\gdb.exe",
"program": "${workspaceRoot}\\a.exe",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
},
{
"name": "C++ Attach",
"miDebuggerPath": "C:\\TDM-GCC-64\\bin\\gdb.exe",
"type": "cppdbg",
"request": "attach",
"program": "${workspaceRoot}/a.exe",
"processId": "${command:pickProcess}",
"linux": {
"MIMode": "gdb",
"program": "${workspaceRoot}/a.out",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb",
"miDebuggerPath": "C:\\TDM-GCC-64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
}
]
}
Upvotes: 1