Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get a stacktrace from a CLR exception without attaching the VS debugger?

I have a website running on a remote server, and want to get some information from an exception that is occurring. I can't install VS or use remote debugging, and have been trying to use various versions of WinDbg with little success. In my local tests, I can get WinDbg to break on a C++ exception, or a CLR exception that I threw, but can't get much more information than 'something was thrown'.

Is WinDbg the way to go, or is there another way, or am I screwed for not having adequate logging?

like image 235
MStodd Avatar asked Aug 03 '12 21:08

MStodd


1 Answers

Attach WinDbg to the process, then enter these commands:

.symfix
sxe clr
sxd av
.loadby sos clr
g

The execution will continue (after go command) and will break whenever CLR exception is thrown (or any other unhandled exception). Whenever it breaks on CLR exception you see:

(xxxx.xxxx): CLR exception - code e0434352 (first chance)

Then you can use SOS commands like !pe to print out exception type, !ClrStack to dump stack, !dso to dump managed objects in the stack, etc.

EDIT: I had typos in sxe and sxd commands. Thanks to @MStodd for noticing that.

like image 119
seva titov Avatar answered Sep 28 '22 05:09

seva titov