使用Visual Studio的Linux支持调试库代码 [英] Debugging Library Code with Visual Studio's Linux support

查看:306
本文介绍了使用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使用与localhost的ssh连接运行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-Time compiled 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(正确)断言该断点当前不会被击中".另外,Debug输出打印Loaded '/mnt/c/Users/felix/git/hypro/build/libhypro.so.17.09'. Cannot find or open the symbol file.

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.

我的情况似乎类似于此问题,但我不是手动指定库的路径,而是由以下人员发现的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支持调试库代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆