Visual Studio debug C code in the .dll library from C#. How to load symbols on program load

huangapple go评论74阅读模式
英文:

Visual Studio debug C code in the .dll library from C#. How to load symbols on program load

问题

我有一个.dll库,我在C#代码中使用它。我已成功配置了VS以调试.dll中的C代码。但是有一个小问题。符号文件在第一次调用.dll库中的代码时加载。即使我想进入第一个函数,这在这个时候是不可能的,因为此时没有符号。第二次函数调用可以正确调试。如何强制VS调试器在应用程序启动时加载符号?

另外,我有一个变通方法 - 我在一个虚拟函数上中断C#代码 - 尝试进入(虽然不会发生,但会强制加载符号)。

英文:

I have a .dll library which I use in C# code. I have successfully configured VS to debug the C code in the .dll. But there is a small problem. The symbol file is loaded on the first call to the code from the .dll library. Even if I want to step into the first function it does not happen as it has no symbols at this point of time. The second function call can be debugged correctly. How can I force the VS debugger to load symbols on the application startup?


PS I have a workaround - dummy function I break C# code on - step into (it does not happen, but forces the symbols load).

答案1

得分: 2

答案是我们无法这样做。

这个dll文件是动态加载的。因此,只有在调用C函数时才会加载dll的pdb。

在设置断点后,在C#项目的属性设置中启用“启用本机代码调试”,当触发断点时,符号将被加载。

英文:

> Visual Studio debug C code in the .dll library from C#. How to load
> symbols on program load

The answer is we can't.

The dll file is dynamic load. So the pdb of dll will only be loaded when the c function be called.

After setting the breakpoints, turn on the "Enable native code debugging" on C# Project side property settings, the symbol will be load when hitting the breakpoints.

huangapple
  • 本文由 发表于 2023年7月3日 03:50:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76600535.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定