Debugging Library Code with Visual Studio#39;s Linux support(使用 Visual Studio 的 Linux 支持调试库代码)
问题描述
我正在使用 Visual Studio 2017 的集成在适用于 Linux 的 Windows 子系统中本地构建和调试 CMake Linux 应用程序.
I'm using Visual Studio 2017's integration to build and debug a CMake Linux application locally in the Windows Subsystem for Linux.
运行应用程序时,Visual Studio 使用 ssh 连接到 localhost 来运行 cmake -DCMAKE_BUILD_TYPE="Debug" ..
和 make
,然后使用 gdbserver
来调试应用程序.这适用于我的应用程序自己的代码,包括断点和逐行调试.
When running the application, Visual Studio uses an ssh connection to localhost to run cmake -DCMAKE_BUILD_TYPE="Debug" ..
and make
, then uses gdbserver
to debug the application. This works fine for my application's own code, including breakpoints and line-by-line debugging.
此应用程序链接到库文件 libhypro.so.17.09
,它也是 CMake 项目的一部分.这个库也是在本地构建的(存储在我的 Windows 文件系统中,通过 /mnt/c/
挂载在 Linux 中构建,就像主应用程序一样)在调试模式下.CMake 确实自动发现了这种依赖关系.
This application links to a library file, libhypro.so.17.09
, which is also part of a CMake project. This library is also built locally (stored in my Windows file system, built within Linux through the /mnt/c/
mount, just as the main application) in debug mode. CMake did discover that dependency automatically.
我在调试对该库的调用时遇到问题.例如,如果我在调用库代码之前中断并选择Step Into,这就是我结束的地方:
I'm having trouble debugging my calls to this library. For example, if I break just before a call to library code and choose to Step Into, this is where I end up:
注意
- 调用堆栈消失了,改为显示
[Unknown/Just-In-Timecompiled code]
, - 我处于一个未处理的异常中(我希望最终会遇到该异常,但肯定不会在 Step Into 之后立即发生)并且
- 模块窗口显示没有可用的符号.
- the Call Stack has disappeared, showing
[Unknown/Just-In-Time compiled code]
instead, - I'm inside an unhandled exception (which I'd expect to hit eventually, but certainly not immediately after a Step Into) and
- the Modules window indicates that no symbols are available.
此外,我确实在库的代码中设置了断点,Visual Studio(正确地)断言断点当前不会被命中".此外,调试输出打印 Loaded '/mnt/c/Users/felix/git/hypro/build/libhypro.so.17.09'.无法找到或打开符号文件.
In addition, I did set a breakpoint in the library's code, and Visual Studio (correctly) asserts that "the breakpoint will not currently be hit". Also, Debug output prints Loaded '/mnt/c/Users/felix/git/hypro/build/libhypro.so.17.09'. Cannot find or open the symbol file.
我比较确定 libhypro.so.17.09
确实 包含调试符号,因为 nm -gC libhypro.so
打印 大量的输出.
I'm relatively certain that libhypro.so.17.09
does include debug symbols as nm -gC libhypro.so
prints a lot of output.
我的情况似乎类似于 this question 但我没有手动指定库的路径,它是由CMake.
My case appears to be similar to this question but I'm not specifying the library's path manually, it's discovered by CMake.
为什么 gdb
以及 Visual Studio 无法调试库的代码?
Why are gdb
and, in turn, Visual Studio failing to debug the library's code?
推荐答案
如果你在gdbserver
模式下调试,默认,在项目中尝试切换到gdb
模式属性/调试页面.
If you are debugging in gdbserver
mode, the default, try switching to gdb
mode in the project properties / debugging page.
基本上,gdbserver
模式是一个不错的想法,但从未完全交付.这是 VCLinux GitHub 站点上关于它的讨论.如您所见,一旦他们解决了控制台应用程序的问题,gdb
将成为默认调试模式.
Basically, gdbserver
mode is a nice idea that never quite delivered. Here's one discussion about it on the VCLinux GitHub site. As you'll see, gdb
will become the default debugging mode once they've fixed the problems with console applications.
这篇关于使用 Visual Studio 的 Linux 支持调试库代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Visual Studio 的 Linux 支持调试库代码
基础教程推荐
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 从 std::cin 读取密码 2021-01-01