【问题标题】:Mediapipe: How to configure debugger? (using VS Code and Bazel)Mediapipe:如何配置调试器? (使用 VS Code 和 Bazel)
【发布时间】:2022-06-13 18:14:46
【问题描述】:

有人知道如何有效地调试媒体管道吗?

到目前为止,我将打印语句放在每一行中,并继续编译 + 运行代码,直到找到我的错误。

有没有办法使用断点和调试器来调试它,比如从 VS 代码?

我已经看到 vs code 具有 Bazel 扩展,但是我不确定如何正确配置扩展。

这就是我平时在终端运行的根目录下编译运行

bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 mediapipe/examples/desktop/hand_tracking:hand_tracking_cpu

bazel run --define MEDIAPIPE_DISABLE_GPU=1 mediapipe/examples/desktop/hand_tracking:hand_tracking_cpu --calculator_graph_config_file=mediapipe/graphs/hand_tracking/hand_tracking_desktop_signn.pbtxt

更多信息:
显然已经在 vs 代码中安装了一个 bazel 插件。这就是 vs code bazel 插件设置的样子。虽然我可以为我的可执行文件找到一个潜在的候选者,但我不确定“构建器”。这是一个普通的 bazel 编译器吗?我目前正在使用 bazelisk,它应该会自动找出所需的 bazel 版本。我可以在这里使用 bazelisk 可执行文件吗?

【问题讨论】:

    标签: mediapipe


    【解决方案1】:

    快速回答:将此内容添加到 .vscode/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": [
          {
            "preLaunchTask": "Bazel Build (Debug)",
            "name": "CodeLLDB",
            "type": "lldb",
            "request": "launch",
            "console": "internalConsole", 
            "program": "${workspaceFolder}/bazel-out/k8-dbg/bin/mediapipe/examples/desktop/hand_tracking/hand_tracking_cpu",
            "args": ["--calculator_graph_config_file=mediapipe/graphs/hand_tracking/hand_tracking_desktop_signn.pbtxt"],
            "env": {"GLOG_logtostderr":"1"},
            "sourceMap": {
              "/proc/self/cwd/": "${workspaceFolder}"
            },
          }
        ]
      }
    

    注意事项

    • 我仍在通过命令行构建,使用 -c dbg 作为附加参数来编译适合与调试器一起使用的二进制文件
    • CodeLLDB 是一个必须预先安装的扩展程序(请参阅 vscode 扩展程序)。
    • "env": {"GLOG_logtostderr":"1"} 是一个系统变量(类似于 linux 中的 $PATH),它告诉调试器将 Google logger 输出写入控制台
    • /bazel-out/k8-dbg/bin/ 是使用调试标志 (-c dbg) 使用 bazel 编译后二进制文件的位置
    • 其他命令行参数进入"args",通过与原始启动命令的比较可以看到
    • "/proc/self/cwd/": "${workspaceFolder}" 是必需的,因此调试器会在正确的文件中中断(默认情况下,调试器会打开与您实际放置断点的源文件不同的源文件

    【讨论】:

      猜你喜欢
      • 2020-09-11
      • 2018-08-16
      • 2021-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-25
      相关资源
      最近更新 更多