开发者

How to get call stack of a dying process, i.e. to find out how the process is exiting

I'm in a unique predicament where my process is exiting without throwing any exception or such, just silently exiting.

I want to find out what the call stack is when the process is exiting, like, who is calling exit(0) on my process.

This is a native C++ application, that is millions of line, I couldn't possibly figure out where things were go开发者_运维问答ing wrong.

Is there such a faciliity, for example if I run under Windbg?


You can configure Process Dumper to dump a full image of the process on exit, for postmortem debugging. From the Overview:

Dump automatically when process being monitored exited


WinDbg is by default configured to break when a process exits, so all you have to do is attach to your process and wait. And of course type 'k' to have your callstack once your process has broken.


The Microsoft Debugging Toolkit from Microsoft comes with such a utility, called ADPlus.

ADPlus is a command line tool (It used to be a glorified vb script apparently) that does a bunch of things. But You and I care about is getting the callstack of a process that died. AdPlus can be configured to capture the callstack of an external process when it encounters an unhandled exception.

The syntax is like this:

ADPlus -p <process id> -crash -o <output path>

where

-p is the argument where you pass in the process ID. You can get this from process explorer to TList (I think). There are other arguments that allow you specify the process name, but you will have to look up that yourself.

-crash is to tell it to generate a minidump when it crashes, or encounters an unhandled exception.

-o is the path to a directory where you want the minidump to be saved. What ADPlus will do is then create a subdirectory there that incorporates the name of the process and a timestamp.

Then you can run your application, and when it crashes, ADPlus will create the minidump, and then your process will exit.

The microsoft Debugging toolkit is now a part of the Windows SDK install. You go here to find it:

http://www.microsoft.com/whdc/devtools/debugging/default.mspx

Click on the download link to download a small app that will install the whole thing from the web. The installer will give you lots of options for different components to install. You can ignore most of them and install just the debugging toolkit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜