我是Visual Code的新手。我想在Visual Code中使用Debbuging功能。 但这样做有一个问题。它可能由错误的launch.json设置(在我的opnion中)
发生我正在使用 mac os 最新版本。
我参考了一些页面来自己做。
https://code.visualstudio.com/docs/languages/cpp
https://github.com/Microsoft/vscode-cpptools/blob/master/launch.md
https://code.visualstudio.com/docs/python/debugging
但是我看到同样的错误。它说“启动:程序'$ {/ Users / bpk / Documents / Study / C / Study} / study'不存在”
这是下面的 launch.json 文件
{
"version": "0.2.0",
"configurations": [
{
"name": "Python3",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${/Users/bpk/Documents/Study/Python3/study.py}",
"cwd": "${/Users/bpk/Documents/Study/Python3}",
"env": {},
"envFile": "${/Users/bpk/Documents/Study/Python3}/.env",
"debugOptions": [
"RedirectOutput"
]
},
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${/Users/bpk/Documents/Study/C/Study}/study",
"args": [],
"stopAtEntry": false,
"cwd": "${/Users/bpk/Documents/Study/C/Study}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "${/Users/bpk/Documents/Study/C/Study}/study",
"processId": "${command:pickProcess}",
"MIMode": "gdb"
}
],
"compounds": []
}
=cmd-param-changed,param="pagination",value="off"
[New Thread 0x1803 of process 16326]
[New Thread 0x1a03 of process 16326]
[New Thread 0x2703 of process 16326]
ERROR: Unable to start debugging. Unexpected GDB output from command "-exec-run". Warning:
Cannot insert breakpoint -1.
Cannot access memory at address 0xf782
The program '/Users/jaekwangkim/Documents/Workspace/Project/C/PE_File_Assembler/a.out' has exited with code 42 (0x0000002a).
上层消息是来自可视代码的调试控制台日志
感谢您阅读我的第一个问题!
答案 0 :(得分:0)
我认为你混合变量和字符串 ${...}
表示可视代码中使用的变量。目录路径不需要包含${}
。
您的Python3配置应如下所示:
{
"name": "Python3",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "/Users/bpk/Documents/Study/Python3/study.py",
"cwd": "/Users/bpk/Documents/Study/Python3",
"env": {},
"envFile": "/Users/bpk/Documents/Study/Python3/.env",
"debugOptions": [
"RedirectOutput"
]
},
对C调试配置的更改与Python非常相似,应该如下所示:
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "/Users/bpk/Documents/Study/C/Study/study",
"args": [],
"stopAtEntry": false,
"cwd": "/Users/bpk/Documents/Study/C/Study",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},