【问题标题】:VSCode: How to debugging (launch.json) when tasks (tasks.json) running?VSCode:任务(tasks.json)运行时如何调试(launch.json)?
【发布时间】:2021-11-18 20:33:29
【问题描述】:

我想在 launch.json

中运行这个调试程序
        {
            // Must be running before launching: out/Debug/bin/chrome_public_apk gdb --ide
            "name": "Attach Android Webview",
            "type": "cppdbg", // "cppdbg" for GDB/LLDB, "cppvsdbg" for Windows Visual Studio debugger
            "request": "launch",
            "targetArchitecture": "arm64",
            "program": "/tmp/adb-gdb-support-${env:USER}/app_process",
            "miDebuggerPath": "/tmp/adb-gdb-support-${env:USER}/gdb",
            "miDebuggerServerAddress": "ignored",
            "cwd": "${workspaceFolder}",
            "sourceFileMap": {
                "./../../": "${workspaceFolder}",
                "../../": "${workspaceFolder}",
                "././../../": "${workspaceFolder}"
            },
            // "miDebuggerArgs": " -x /tmp/adb-gdb-support-${env:USER}/gdbinit",
            // "args":["--package-name=com.bytedance.shell --output-directory=out/debug --adb=adb --device=914baf8f --pull-libs-dir=/tmp/adb-gdb-libs-914baf8f --verbose --target-arch=arm64"],
            "customLaunchSetupCommands": [
                {
                    "text": "-interpreter-exec console \"source -v /tmp/adb-gdb-support-${env:USER}/gdbinit\""
                }
            ],
            "launchCompleteCommand": "None",
            "preLaunchTask": "preReadyForWebView"
        }

还有一个名为 preReadyForWebView 的任务,它将开始运行一个 gdb 服务器并监听 gdb 客户端。 现在启动任务后,总是在等待任务结束,但我想在任务运行大约 5s 或正在侦听时开始调试,有人能帮帮我吗?

下面是我的tasks.json的详细信息

        {
            "label": "preReadyForWebView",
            "type": "shell",
            "command": "${workspaceFolder}/build/android/adb_gdb",
            "args": [
                "--package-name=com.bytedance.shell",
                "--output-directory=out/release",
                "--adb=adb",
                "--device=0C111FDD4006XG",
                "--pull-libs-dir=/tmp/adb-gdb-libs-0C111FDD4006XG",
                "--verbose",
                "--target-arch=arm64",
                "--ide"
            ]
        }

【问题讨论】:

标签: c++ debugging visual-studio-code gdb


【解决方案1】:

我找到了!
只需在 tasks.json 中添加 "isBackground": true 并启动它!然后在弹出的对话框中选择debug Anyway,gdb客户端就会开始调试。

【讨论】: