调试本机代码 [英] Debugging of native code

查看:152
本文介绍了调试本机代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#服务,调用最初用VC6编写的C DLL。



我正在尝试检查的DLL中有一个错误。



在噩梦试图让调试工作后,我最终将dll添加到包含C#服务的VS2005解决方案中,并添加了必要的 _CRT_SECURE_NO_WARNINGS



该服务的调试版本使用installutil.exe工具注册。



我可以通过调用 System.Diagnostics.Debugger.Break();

来调用调试器来打破dll输入的行。 >

我在网上发现了一些关于进入调试非托管代码的指令,并启用了启用非托管代码调试复选框,我也尝试打开Options-> Debugging - > Native'加载DLL导出'和'启用RPC调试'(即使它不是COM)。我也将debug dll和.pdb复制到与服务相同的bin目录。



然而,非托管代码没有进入我真正需要的。



更新:我在DLL属性中找到了调试类型,并根据多个站点的建议将其设置为混合可用。



UPDATE2 :我的项目现在将调试dll和pdb发送到与调试服务相同的目录。仍然无法调试dll。

解决方案

最后我创建了一个控制台应用程序,并重新创建了所有以前的电话,以确保该通话将按照实际服务中的实际参数进行一次。



我记录了我的修复,结果代码在我的网站


I have a C# Service that is calling a C DLL that was originally written in VC6.

There is a bug in the DLL which I am trying to inspect.

After having a nightmare trying to get debug to work I eventually added the dll to the VS2005 solution containing the C# Service and added the necessary _CRT_SECURE_NO_WARNINGS.

The debug version of the service is registered using 'installutil.exe' tool.

I can get the debugger to break just before the line where the dll is entered via a call to System.Diagnostics.Debugger.Break();.

I found some instruction on the net regarding stepping into debugging unmanaged code, and enabled the 'Enable unmanaged code debugging' check box, I've also tried turning on the Options->Debugging->Native 'Load DLL exports' and 'Enable RPC Debugging' (even though it's not COM). I've also copied the debug dll and .pdb to the same bin directory as the service.

However the unmanaged code is not being stepped into which is what I really need.

UPDATE: I found the Debugging Type in the DLL properties and set it to 'Mixed' as per suggestion on several sites but to no avail.

UPDATE2: My project now emits the debug dll and the pdb to the same directory as the debug service. Still unable to debug the dll.

解决方案

In the end I created a console app and recreated all the prior calls just to make sure the call would act as it did in the actual service with the actual parameters once it got there.

I chronicled my fix and the resultant code at my site.

这篇关于调试本机代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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