正在寻找如何在 VS 9 中调试导出的 dll 函数。可能吗?
有一个大型 MFC C++ 项目。我们的 VS 版本是 2008。它加载一个常规 dll(用于某些可选功能)并从中调用导出的函数。当通过 MFC 应用程序进行调试并到达调用导出函数的位置时,您无法单步执行 dll 函数。有没有办法在 dll 函数内部进行调试。即使我已经将 dll 项目包含在 C++ 解决方案中,它似乎也没有“看到”dll 代码。
编辑:我们有许多扩展 dll,并且对它们进行调试工作得很好。这是一个直接的 dll,没有 mfc、/clr 选项集,因此我们可以调用一些托管代码。使用该 dll 的类加载它,然后使用 GetProcAddress 查找指向导出函数的指针。以下是示例。
typedef void (*FP_OnEditOptions) ();
对该函数进行原型设计。 然后
m_fpOnEditOptions = (FP_OnEditOptions) GetProcAddress(hInstance, "Direct_Edit_Options");
获取 proc 指针,然后
static void OnEditOptions()
{(*m_fpOnEditOptions)();}
调用它。
调试时,找到对它的调用,按 F11,它会调用它,但不会介入。 是的,dll 有调试选项,加载模块时,将从相应的 pdb 文件加载符号。
谢谢,
安迪
Got a big MFC C++ project. Our VS version is 2008. It loads a regular dll (for some optional functionality) and calls exported functions from it. When debug through the MFC app and get to the point where we call the exported function you can't step into the dll function. Is there a way to get debugging inside the dll functions. Even if I've got the dll project included in the C++ solution, it doesn't seem to "see" the dll code.
Edit: We've got a number of extension dlls and debugging into them works just fine. This is a straight dll, no mfc, /clr option set so we can call into some managed code. The class that consumes this dll, loads it, then uses GetProcAddress to find pointers to the exported functions. Here are examples.
typedef void (*FP_OnEditOptions) ();
to prototype the function.
then
m_fpOnEditOptions = (FP_OnEditOptions) GetProcAddress(hInstance, "Direct_Edit_Options");
to get the proc pointer, then
static void OnEditOptions()
{(*m_fpOnEditOptions)();}
to call it.
When debugging, get to the call to it, hit F11, and it calls it, but doesn't step in.
Yes, the dll has debug option, and when the module is loaded, the symbols are loaded from the appropriate pdb file.
Thx,
Andy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
调试+Windows+模块。在列表中找到 DLL 并右键单击它。符号加载信息告诉您调试器在哪里查找 .pdb 文件。确保你把它拿到那里。
更新后:很可能在启用 /clr 的情况下,您实际上正在运行编译为 IL 并即时编译的代码。就像托管代码一样。您需要将调试器切换到混合模式调试。项目 + 属性、调试、调试器类型 = 混合。
Debug + Windows + Modules. Locate the DLL in the list and right-click it. Symbol Load Information tells you where the debugger looked for the .pdb file. Make sure you get it there.
After update: it is very likely that with /clr enabled that you are actually running code that was compiled to IL and just-in-time compiled. Just like managed code. You'll need to switch the debugger to Mixed mode debugging. Project + Properties, Debugging, Debugger Type = Mixed.
查看“工具”->“选项”->“调试”->“常规”,
有几个选项可能会有所帮助 - 我不确定您到底需要哪一个。两个明显的问题是:
您还可以尝试在要跳过的函数内放置一个断点。这应该会强制调试器在该代码处停止。
Look under Tools->Options->Debugging->General
There are a couple of options which may help - I'm not sure which one exactly you'll need. The 2 obvious ones are:
You might also try putting a breakpoint inside the function that's being jumped over. That should force the debugger to stop at that code.