Visual Studio代码-C ++调试器无法启动 [英] Visual Studio Code - C++ Debugger doesn't start

查看:212
本文介绍了Visual Studio代码-C ++调试器无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我一直在使用Visual Studio Code在Linux上调试C ++.

I've been using Visual Studio Code to debug C++ on Linux for a while now.

在一个示例项目中,我有以下 launch.json :

In a sample project I've got the following launch.json:

{
    "name": "(gdb) Launch",
    "type": "cppdbg",
    "request": "launch",
    "program": "${workspaceFolder}/main",
    "args": [],
    "stopAtEntry": false,
    "cwd": "${workspaceFolder}",
    "environment": [],
    "externalConsole": true,
    "MIMode": "gdb",
    "setupCommands": [
        {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true
        }
    ]
}

我已经成功编译并运行了main.c,因此调试应该可以正常进行.

I've successfully compiled and run main.c, so debugging should work fine.

当我启动调试器时,箭头下方会出现一个蓝色的加载栏,什么也没发生.在我的笔记本电脑上,使用完全相同的配置,几秒钟后,加载栏将消失,调试器将启动.

When I start the debugger, a blue loading bar appears under the arrow and nothing happens. On my laptop, with the exact same configuration, the loading bar would disappear after a couple of seconds and the debugger would start.

看看 ps aux ,我可以看到两个新过程:

Looking at ps aux I can see two new processes:

    使用命令/home/guyyst/.vscode/extensions/ms-vscode.cpptools-0.20.1/debugAdapters/mono.linux-
  1. mono.linux-x86_640 x86_64 --config/home/guyyst/.vscode/extensions/ms-vscode.cpptools-0.20.1/debugAdapters/framework/config.linux/home/guyyst/.vscode/extensions/ms-vscode.cpptools-0.20.1/debugAdapters/bin/OpenDebugAD7.exe

  1. mono.linux-x86_640 with the command /home/guyyst/.vscode/extensions/ms-vscode.cpptools-0.20.1/debugAdapters/mono.linux-x86_64 --config /home/guyyst/.vscode/extensions/ms-vscode.cpptools-0.20.1/debugAdapters/framework/config.linux /home/guyyst/.vscode/extensions/ms-vscode.cpptools-0.20.1/debugAdapters/bin/OpenDebugAD7.exe

bash ,使用命令 bash/home/guyyst/.vscode/extensions/ms-vscode.cpptools-0.20.1/debugAdapters/OpenDebugAD7

在笔记本电脑上进行调试会产生相同的过程,但是在调试实际开始时它们会消失.即使关闭VSCode,PC上的两个进程仍然存在.当我第一次注意到这一点时,我有超过15份来自先前尝试的副本.

Debugging on my laptop spawns the same processes, but they disappear when the debugging actually starts. The two processes on my PC stick around even after closing VSCode. When I first noticed this I had 15+ copies running from previous attempts.

昨天所有这些工作都很好,从那时起,我不记得对我的配置进行任何更改.

All of this worked fine yesterday, and I don't remember making any changes to my configuration since then.

我已经尝试通过AUR版本 visual-studio-code-bin 或开源软件包 code 重新安装VSCode.

I've tried reinstalling VSCode several times through either the AUR version visual-studio-code-bin or the open source package code.

调试一些Python代码就可以了.

Debugging some Python code worked just fine.

推荐答案

结果就像在 launch.json 中将 externalConsole 设置为 false .本应该考虑过尝试过的.

Turns out it was as easy as setting externalConsole in launch.json to false. Should've probably thought of trying that before.

我受制于VSCode控制台,这没什么大不了的.

I'm constrained to the VSCode console, which isn't that big a deal.

我仍然无法解释为什么它不能与外部控制台一起使用,因为那是我仍然在笔记本电脑上并且过去也在PC上使用的方式.

I still can't explain why it won't work with an external console, since that's how I'm still doing it on my laptop and used to do it on my PC too.

这篇关于Visual Studio代码-C ++调试器无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆