Debugging Library Code with Visual Studio's Linux support

半城伤御伤魂 提交于 2019-12-02 02:25:59

问题


I'm using Visual Studio 2017's integration to build and debug a CMake Linux application locally in the Windows Subsystem for Linux.

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.

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.

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:

Note that

  • 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.

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.

I'm relatively certain that libhypro.so.17.09 does include debug symbols as nm -gC libhypro.so prints a lot of output.

My case appears to be similar to this question but I'm not specifying the library's path manually, it's discovered by CMake.

Why are gdb and, in turn, Visual Studio failing to debug the library's code?


回答1:


If you are debugging in gdbserver mode, the default, try switching to gdb mode in the project properties / debugging page.

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.



来源:https://stackoverflow.com/questions/46890920/debugging-library-code-with-visual-studios-linux-support

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!