0

I'm trying to save the details from the callstack that is contained within the binary file crash.dmp that is created by Dr. Watson upon the crash of an application.

The dmp files exist so I just want to read one in (c#) and save the callstack if that's possible. Has anyone ever done anything like this, indeed, is it even possible?

I can look at the crash.dmp file manually using Visual Studio and copy the stack manually, but I would like this process to be automated within the original program.

Any help would be appreciated.

Cheers

Steve

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
  • You cannot hope that a crashed program is capable of reading its own minidump and survive the exercise. You already get a good stack trace out of AppDomain.UnhandledException, very few good reasons to look for an alternative. If you do need one then use the DebugDiag utility. – Hans Passant Mar 18 '14 at 12:02
  • How about reading it from a different program, i.e. writing some code which is designed to read the crash.dmp file and extract the call stack from that.. –  Mar 18 '14 at 12:55
  • Digging managed stack traces out of a minidump requires the SOS debugger extension, !EEStack command. Which requires a debugger, not just a "different program". – Hans Passant Mar 18 '14 at 13:06

2 Answers2

0

(Should be a comment, but is too long)

Since your also asking that question I have the strong feeling that this is a XY problem. You probably don't want to read a dump as stated in this question and you probably don't want to write a debugger yourself as in the other question. My guess: your actual problem is that your program crashes and you want to avoid that.

Your first choice should be to run the program in Debug mode under the debugger (Visual Studio) by pressing the play button, then wait until the crash occurs and find out the real reason why it crashes. Change your code in a way so that the crash does not occur at all, e.g. by checking whether all preconditions are met.

If, for whatever reason, you cannot fix the problem, there's a way to prevent crashes. A crash is caused by an exception and you can use exception handling to work with it. In C# it looks like this:

try
{
    // force a crash for demo purposes
    throw new InvalidOperationException();
}
catch (InvalidOperationException ex)
{
    // do something instead of crashing here
}

For more information on the exception handling topic, read Exception handling in C# or do some internet search for the terms try, catch or exception handling.

Community
  • 1
  • 1
Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
0

You can read the dump file by using Debug Diagnostic tool.

The Codeproject article explains how to use it.

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
Bura Chuhadar
  • 3,653
  • 1
  • 14
  • 17