如何在 Visual Studio Code 中调试外部库代码?

pad*_*009 13 debugging shared-libraries visual-studio-code

我在基本 C++ 项目中使用 Visual Studio Code。我链接使用 gcc -g 选项构建的库以包含调试符号信息。

但是,当我想从该库单步执行函数调用时,它无法进入。在 Visual Studio 中,如何在 Visual Studio 中调试外部类库项目?可以解决问题,但我不知道如何在 Visual Studio Code 中执行此操作。也许应该在某个地方指定该库的源文件?但我可以在哪里指定它们呢?

小智 9

调试 => 添加配置...

这将打开一个 launch.json 文件。它应该看起来像这样:

"version": ...,
"configurations": [
    {

    ... bunch of stuff here

    "justMyCode":false          <==== add this line then save
    }
]
Run Code Online (Sandbox Code Playgroud)

现在您应该能够对外部文件使用断点。

  • OP 要求 C++。此选项在 VS Code C++ 扩展中不可用。 (4认同)
  • 它肯定适用于 Python。:) 以防万一有人需要它。 (2认同)