Mon*_*elf 5 c windows gdb visual-studio-code vscode-debugger
使用 GDB 在 VSCode 中调试 C 项目时,到 stdout 的输出(通过 printf())不会出现在调试控制台上。cppvsdebug然而,当使用 时,它可以工作。
这是我的 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": "Debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": false
}
],
"windows": {
"miDebuggerPath": "C:/raylib/mingw/bin/gdb.exe",
},
"osx": {
"MIMode": "lldb"
},
"linux": {
"miDebuggerPath": "/usr/bin/gdb",
},
"preLaunchTask": "build debug"
},
{
"name": "Run",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"program": "${workspaceFolder}/main",
"MIMode": "gdb",
"windows": {
"program": "${workspaceFolder}/main.exe",
"miDebuggerPath": "C:/raylib/mingw/bin/gdb.exe"
},
"osx": {
"MIMode": "lldb"
},
"linux": {
"miDebuggerPath": "/usr/bin/gdb"
},
"preLaunchTask": "build release",
}
]
}
Run Code Online (Sandbox Code Playgroud)
这是运行调试会话时执行的命令(根据终端窗口):
'c:\Users\...\.vscode\extensions\ms-vscode.cpptools-0.27.1\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-2dvbqvix.1cb' '--stdout=Microsoft-MIEngine-Out-1m5j1iy0.ufe' '--stderr=Microsoft-MIEngine-Error-oqyothgz.h5l' '--pid=Microsoft-MIEngine-Pid-hal3wx4b.uld' '--dbgExe=C:/raylib/mingw/bin/gdb.exe' '--interpreter=mi'
Run Code Online (Sandbox Code Playgroud)
调试控制台显示 GDB 的“启动屏幕”信息,但不显示我的代码中 printf() 语句的任何输出:
=thread-group-added,id="i1"
GNU gdb (GDB) 8.1
Copyright (C) 2018 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 "i686-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://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 9488.0x54dc]
[New Thread 9488.0x577c]
[New Thread 9488.0xff4]
[New Thread 9488.0x4918]
Run Code Online (Sandbox Code Playgroud)
当我从命令行(Git Bash)使用 GDB 运行 Exe 文件时,所有输出都正常显示。
设置externalConsole为 true 不起作用(它一开始也不会打开外部控制台)。
我使用的是 Windows 10。
我需要调整任何特定设置才能使其正常工作吗?
| 归档时间: |
|
| 查看次数: |
15043 次 |
| 最近记录: |