![](/img/trans.png)
[英]xperf WinDBG C# .NET 4.5.2 Application - Understanding process dump
[英]Debugging a c# application in WinDbg
我试图在我没有Visual Studio的系统上调试用C#编写的应用程序。 应用程序没有崩溃......但是我需要根据在Visual Studio所在的同一位置无法访问的驱动程序来确定某些变量的值,以及代码的某些部分是否被访问。
我在虚拟机中运行此测试环境,无法访问Internet。 我一直无法安装符号文件......但到目前为止这无关紧要。
我一直在使用附加到此应用程序的WinDbg对驱动程序(c / c ++)进行故障排除。 我希望能够从C#向WinDbg发送调试消息。
System.Diagnostics.Debug.Write("hello world\n");
没有出现......我不知道是否相关,但是在添加Debug.Write时我注意到的唯一不同的事情是一个新的异常,我没有看到没有调试调用...(试图显示非常无辜的变数)
(c78.808): C++ EH exception - code e06d7363 (first chance)
(c78.808): C++ EH exception - code e06d7363 (first chance)
(c78.808): Access violation - code c0000005 (first chance)
如何将这些消息发送到C#中附加到此应用程序的WinDbg输出?
尝试使用DebugView ,它应显示您的调试消息并且它没有依赖关系,请确保捕获全局win32事件并且Visual Studio没有自己附加。
在您的项目属性中选中标记BOTH DEFINE TRACE constant and DEFINE DEBUG constant
Debug.WriteLIne以及广告Trace.Writeline输出将在windbg中可见
码
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
Console.WriteLine("we should see both Debug and Trace .WriteLine\n");
System.Diagnostics.Trace.WriteLine("This is From Debug.WriteLine\n");
System.Diagnostics.Debug.WriteLine("This is From Trace.WriteLine\n");
System.Diagnostics.Trace.WriteLine("This is From Debug.WriteLine\n");
System.Diagnostics.Debug.WriteLine("This is From Trace.WriteLine\n");
Console.WriteLine("watched 2 Dbg and 2 Trace WriteLine in windbg\n");
System.Diagnostics.Trace.WriteLine("This is From Debug.WriteLine\n");
System.Diagnostics.Debug.WriteLine("This is From Trace.WriteLine\n");
System.Diagnostics.Trace.WriteLine("This is From Debug.WriteLine\n");
System.Diagnostics.Debug.WriteLine("This is From Trace.WriteLine\n");
}
}
}
产量
:cdb -c "g;q" helloWorld.exe | grep -i WriteLine
we should see both Debug and Trace .WriteLine
This is From Debug.WriteLine
This is From Trace.WriteLine
This is From Debug.WriteLine
This is From Trace.WriteLine
watched 2 Dbg and 2 Trace WriteLine in windbg
This is From Debug.WriteLine
This is From Trace.WriteLine
This is From Debug.WriteLine
This is From Trace.WriteLine
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.