tags:

views:

205

answers:

2

We're running an application, happens to be web server we've written, and we're saying some nasty issues only in production, so for about 12 hours we're going to put this under WinDBG and take callstacks every time it breaks.

Sometimes it'll break because of an unhandled exception, and sometimes we'll hit an assert, at which point our code says if running under a debugger, break.

Is it possible to hook into WinDBG in such a way that as soon it breaks, it takes a callstack, and moves on immediately?

A: 

Try

sxe -c "kb;g" -h wkd

and

sxe -c "kb;g" -h eh

Search Controlling Exceptions and Events in windbg's Help document for more related information.

whunmr
+1  A: 

Attaching a debugger to a production box can be disastrous, (a) performance (b) unexpected breaks into the debugger

As a safety, definately make sure you disable all exceptions you don't care about or will not want to break into the debugger.

sxd *

Then, choose the ones you'd like to handle in some fashion (take callstack, and move on)

sxe -c "kb;g" bpe
sxe -c "kb;g" asrt
sxe -c "kb;g" eh

The first one is a break point exception handler, assert failure, and C++ EH exception.

There's a huge list of what your debugger supports, for example if you load SOS.dll (the CLR extension to WinDBG) then you'll be able to

sxe -c "kb;g" clr

For authoritative information on types of exception/events you can potentially filter on, see the WinDbg help (search for sxe)

mjsabby