标签: vscode-debugger

VS Code:如何从扩展内访问调试变量?

我正在为 Visual Studio 代码编写一个扩展,我想在其中评估 javascript 调试会话的当前变量。当打开该部分下的调试窗格时,通常会显示这些变量VARIABLES。请参阅随附的屏幕截图。

Visual Studio 代码中的调试变量窗格

我想在用户右键单击编辑器时访问这些变量,但我不知道如何操作。

我当前的扩展设置是这样的:在package.json我已经注册了一个菜单贡献和一个命令:

"contributes": {
    "menus": {
        "editor/context": [{
            "command": "extension.showVariables",
            "group": "navigation"
        }]
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的 extension.ts 中,我注册了这样的命令:

export function activate(context: vscode.ExtensionContext) {

    let disposable = vscode.commands.registerCommand('extension.showVariables', () => {

        // TODO: let variables = vscode.debug.activeDebugSession.variables.toString();

        vscode.window.showInformationMessage(variables);
    });
}
Run Code Online (Sandbox Code Playgroud)

我试图让它们通过,vscode.debug.activeDebugSession但这里没有变量的 API。我还尝试注册一个事件处理程序,vscode.debug.onDidReceiveDebugSessionCustomEvent但我不知道在哪里搜索调试变量。

是否可以在 vs 扩展中访问这些变量,或者我是否需要实现自己的调试器?

visual-studio-code vscode-extensions vscode-debugger

6
推荐指数
1
解决办法
6285
查看次数

使用 VS Code 和 MSVC 工具链调试 Rust 程序时,如何在“panic”处设置断点?

我可以手动设置断点,并使用调试器运行,但我无法在 Rust 程序出现紧急情况时设置断点。如何在恐慌时设置断点,就像在 C++ 中设置异常一样?

我正在使用 Rust 1.29.0-nightly、VS Code 1.25.1 和 MSVC 2017 工具链。

debugging breakpoints rust visual-studio-code vscode-debugger

6
推荐指数
1
解决办法
3501
查看次数

如何在使用 bazel 构建的项目中使用 vscode python 调试器?

我想调试一个 python 文件,该文件有一些仅出现在runfilesfrom bazel 中的依赖项。如何使用 vscode 调试器调试 bazel 构建?

python bazel visual-studio-code vscode-debugger

6
推荐指数
1
解决办法
3688
查看次数

如何使用 VSCode 远程调试 Go 代码

我在需要调试的 docker 容器内运行一个进程。该进程在 docker 的入口点 via 启动 dlv debug /go/src/path/to/package --headless --listen=:2345 --log,以便稍后在 VSCode 中启用调试。

docker 容器通过 启动 docker run --rm -it -p 2345:2345 my_image:tag。注意 delve 的端口是暴露的。

在VSCode中我定义launch.json如下:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach remote",
            "type": "go",
            "request": "attach",
            "mode": "remote",
            "port": 2345,
            "host": "127.0.0.1",
            "apiVersion": 1
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

启动“附加远程”VSCode 调试配置后,我得到 在此输入图像描述

虽然不是很清楚,但该 UI 让我相信我现在已连接到远程无头调试器并准备好进行调试。我定义了一个断点,我知道该断点会被我可以发送远程进程的请求击中。我发送该请求,得到结果,并且该断点从未命中,表明我尚未实现远程调试。

我的 VSCode“附加远程”配置有问题吗?我可以进行命令行调试,dlv connect :2345并且实际上可以很好地调试远程进程,这表明无头服务器功能正常。我宁愿在 VSCode 中使用源代码进行调试。

go visual-studio-code delve vscode-debugger

6
推荐指数
1
解决办法
8201
查看次数

使用 launch.json 中的“输入”选择在 Visual Studio Code 中的 preLaunchTask 中使用

In a project there are a number of helper utilities. In the launch and tasks json files they are configured to allow the user to select the particular utility to build or debug. What I would like to do is have the selection from launch to be passed to the tasks and the task use that selection. The launch.json configuration file looks like:

launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug: <Utility App>",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/apps/${input:utility}/${input:utility}", …
Run Code Online (Sandbox Code Playgroud)

visual-studio-code vscode-debugger

6
推荐指数
1
解决办法
1814
查看次数

VS Code 的 launch.json 中不允许使用 outFiles 属性

我正在尝试在 vs code 中调试打字稿。据我研究,您需要在 vs code 的 launch.config 中设置 outfiles 属性,以映射您在已编译的 .js 文件中在 TypeScript 文件中设置的断点,如此处指定

当我尝试设置我的时,出现以下错误:

在此输入图像描述

我在谷歌中没有发现任何关于此错误的信息,因为打字稿调试器需要此设置才能工作,正如VS Code 文档中所示。

预先感谢您的任何帮助。

编辑:

启动.json:

"configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Chrome",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceFolder}",
            "preLaunchTask": "tsc",
            "sourceMaps": true
        }
    ]
Run Code Online (Sandbox Code Playgroud)

ts配置:

{
  "compilerOptions": {
    /* Visit https://aka.ms/tsconfig.json to read more about this file */

    /* Basic Options */
    // "incremental": true,                   /* Enable incremental compilation */
    "target": "es5",                          /* Specify ECMAScript target version: 'ES3' …
Run Code Online (Sandbox Code Playgroud)

typescript visual-studio-code vscode-debugger

6
推荐指数
1
解决办法
4454
查看次数

VS Code 调试器在停止调试器后不会终止节点进程

我正在开发一个 Node.js 应用程序,使用express.js 作为监听 PORT 3000 的 Web 框架。我使用的是 VS Code v1.46。

我的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": [
    {
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "program": "${workspaceFolder}\\WebApi\\index.js",
        "restart": true,
        "protocol": "inspector"
    }
   ]
  }
Run Code Online (Sandbox Code Playgroud)

我能够第一次启动调试会话,但第二次开始,我收到错误Error: Listen EADDRINUSE: 地址已在使用 :::3000

此错误是因为 VSCode 没有终止在第一个调试会话中创建的 node.exe 进程,因此在后续会话中,节点无法在端口 3000 上启动 Express 服务器,因为该服务器仍在使用中。

谁能帮我配置 VSCode 以在停止调试器后终止 node.exe 进程?

node.js visual-studio-code vscode-debugger

6
推荐指数
1
解决办法
4231
查看次数

自 1.47.0 更新以来,VSCode 会自动在内置终端中启动一些调试检查器

自从昨天更新到 以来1.47.0,当 VSCode 启动时,它会在终端中给出以下输出(没有随后的提示让我输入):

Debugger listening on ws://127.0.0.1:55430/f3f20387-0605-4a39-b807-77f02bea362f
For help, see: https://nodejs.org/en/docs/inspector
Run Code Online (Sandbox Code Playgroud)

我通常的程序是:

  1. 使用WSL导航到我要打开的项目目录,类型code .
  2. npm run serve然后,我将通过键入(package.json has )在 VSCode 终端 (bash) 中启动我的服务器"serve": "vue-cli-service serve"

但是,现在有一些调试器和检查器持续运行,我显然不能这样做?launch.json这是显示我的空白和终端的屏幕截图:

显示调试器而不是命令提示符

有人可以告诉我如何解决这个问题吗?我不知道出了什么问题,但它似乎只发生在我打开的这个特定项目中code .


更新

所以我尝试了更多的事情。

  1. cp -rf testsite testfrontend我在 WSL 内跑步
  2. 然后在我删除的复制目录package-lock.jsonnode_modules
  3. 我随后跑了npm install
  4. code .然后,我通过在 WSL 中复制的项目的目录中运行来启动 VSCode

当 vscode 出现时,终端没有显示。当我展示它时(ctrl+`),以下几行会自动运行:

vscode 终端启动

  1. 然后我跑了npm run serve,发生了以下情况: 卡住

  2. 调试器控制台选项卡中显示以下消息: 错误

我应该提到,当我直接从 WSL 运行时,我没有遇到此错误或任何其他上述问题npm run serveWSL: Ubuntu如果我单击左下角的绿色按钮,然后选择Remote-WSL: …

webpack vue.js visual-studio-code vscode-debugger

6
推荐指数
1
解决办法
1924
查看次数

VSCode extension debugging dont use the latest updated code

I try to edit a vscode extension, update and add some customization, but when I debug it by pressing F5, my changes seem like not being executed. Even when I try to remove a piece of code that I am sure will break the extension, but unfotunately it still run like there are no changes at all. Am I wrong debugging it or there's caches that we should remove?

Btw I am using VSCode 1.52.1 on Ubuntu 18.04.

My …

visual-studio-code vscode-extensions vscode-debugger

6
推荐指数
0
解决办法
563
查看次数

在 VSCode 中,如何在 bash shell 脚本中调试 python 程序

我写了一个shell脚本,它会在启动python程序之前先做一些配置。(例如,下载数据,pip安装一些包,设置环境变量等。然后在python程序内部完成繁重的工作(例如,深度学习训练任务)。现在我想调试python程序,(我'如果我必须同时调试 shell 和 python,我可以接受)。我应该如何修改文件launch.json来完成此操作?我应该添加一些 task.json 项吗?我还不熟悉该任务主题。

目前,我正在以一种丑陋的解决方法来做这件事。我把shell脚本中的语句注释掉python train.py,先运行shell脚本。python train.py然后在调试模式下单独运行 python scipt 。我认为这目前适用于我的简单情况,但如果在 shell 脚本内部,我们正在做一些诸如临时修改环境变量之类的事情,我无法将这两个步骤分开。所以我想知道是否有更直接、更体面的方法。非常感激。

visual-studio-code vscode-tasks vscode-debugger

6
推荐指数
1
解决办法
1036
查看次数