标签: vscode-debugger

如何使用 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
查看次数

VS-Code Python调试 - ConnectionRefusedError: [WinError 10061] 由于目标机器主动拒绝而无法建立连接

我想像Python往常一样通过按VS-Code下来调试我的本地代码:Windows 10F5

调试设置 VS-Code 侧栏

我一年多前就开始出现这个错误,但最近它变得持续存在。

整个错误回溯:

$  /usr/bin/env 'DEBUGPY_LOG_DIR=c:\Users\username\.vscode\extensions\ms-python.python-2021.8.1105858891' c:\\Users\\username\\Projects\\project-venv\\Scripts\\python.exe c:\\Users\\username\\.vscode\\extensions\\ms-python.python-2021.8.1105858891\\pythonFiles\\lib\\python\\debugpy\\launcher 56721 -- c:\\Users\\username\\Projects\\project\\test_files\\prediction_performance_monitoring\\modified_app_for_docker_testing.py
Traceback (most recent call last):
  File "C:\Users\username\.pyenv\pyenv-win\versions\3.8.9\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\username\.pyenv\pyenv-win\versions\3.8.9\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "c:\Users\username\.vscode\extensions\ms-python.python-2021.8.1105858891\pythonFiles\lib\python\debugpy\launcher\__main__.py", line 97, in
<module>
    main()
  File "c:\Users\username\.vscode\extensions\ms-python.python-2021.8.1105858891\pythonFiles\lib\python\debugpy\launcher\__main__.py", line 53, in
main
    launcher.connect(host, port)
  File "c:\Users\username\.vscode\extensions\ms-python.python-2021.8.1105858891\pythonFiles\lib\python\debugpy\launcher/../..\debugpy\launcher\__init__.py", line 34, in connect
    sock.connect((host, port))
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
Run Code Online (Sandbox Code Playgroud)

.vscode/launch.json …

python-3.x connection-refused visual-studio-code vscode-debugger

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

VS Code 中的调试错误:无法连接到 localhost:3000 处的目标:找不到任何可调试目标

我有一个前端有 React 、后端有 .Net Core 的应用程序,我正在尝试调试我的 React 前端,没有扩展和附加到进程,但我收到以下消息错误:

\n
\n

无法连接到 localhost:3000 处的目标:无法连接到 http:localhost:3000 处的调试目标:找不到任何可调试目标。

\n
\n

我正在使用这个launch.json

\n
{\n    "version": "0.2.0",\n    "configurations": [\n        {\n            "name": "Debug FrontEnd",\n            "port": 3000,\n            "request": "attach",\n            "type": "chrome",\n            "webRoot": "${workspaceFolder}"\n        },\n        {\n            "name": "Debug BackEnd",\n            "type": "coreclr",\n            "request": "attach"\n        }\n    ]\n}\n
Run Code Online (Sandbox Code Playgroud)\n

npm start基本上使用witch启动我的前端react-scripts start

\n

观察:I\xe1\xb8\xbf 使用 Opera 浏览器。

\n

launch javascript-debugger reactjs .net-core vscode-debugger

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

我的 vscode 关于 linting 的设置有问题,如何解决这个问题

打开 vscode 时,无法初始化 linting 设置

2023-11-02 21:04:46.011 [错误] 已弃用以下设置:“python.linting.flake8Enabled” 2023-11-02 21:04:46.011 [错误] 所有以“python.linting”开头的设置。已弃用,可以从设置中删除。2023-11-02 21:04:46.011 [错误] Linting 功能已移至单独的 linter 扩展。2023-11-02 21:04:46.011 [错误] 请参阅此处了解更多信息:https://code.visualstudio.com/docs/python/linting 2023-11-02 21:04:46.012 [错误] 请安装“ flake8”扩展名:https://marketplace.visualstudio.com/items? itemName=ms-python.flake8

在此输入图像描述

这是什么原因以及如何解决这个问题

visual-studio-code vscode-debugger

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