【问题标题】:How to debug external library code in Visual Studio Code?如何在 Visual Studio Code 中调试外部库代码?
【发布时间】:2019-07-14 07:16:29
【问题描述】:

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

但是,当我想从该库中单步执行函数调用时,它无法进入。在 Visual Studio 中,How to debug external class library projects in visual studio? 可以解决问题,但我不知道如何在 Visual Studio Code 中执行此操作。可能应该在某处指定该库的源文件?但是我在哪里可以指定它们?

【问题讨论】:

    标签: debugging visual-studio-code shared-libraries


    【解决方案1】:

    调试 => 添加配置...

    这将打开一个 launch.json 文件。它应该是这样的:

    "version": ...,
    "configurations": [
        {
    
        ... bunch of stuff here
    
        "justMyCode":false          <==== add this line then save
        }
    ]
    

    现在您应该可以对外部文件使用断点了。

    【讨论】:

    • OP 要求使用 C++。此选项在 VS Code C++ 扩展中不可用。
    • 它肯定适用于 Python。 :) 以防万一有人需要。
    • “调试 => 添加配置...”是什么意思?没有“调试”菜单或具有该名称的命令。
    【解决方案2】:

    在您的launch.json 文件中,指定additionalSOLibSearchPath 的路径:

    "configurations": [
        {
            "name": "Debug C++",
            "type": "cppdbg",
            ...            
            "additionalSOLibSearchPath": "/path/to/some/dir/from/which/vscode/can/find/the/lib/**"
        },
    

    【讨论】:

      猜你喜欢
      • 2016-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-04
      • 2021-03-05
      • 2014-06-12
      相关资源
      最近更新 更多