Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / September 2006

Tip: Looking for answers? Try searching our database.

JIT debugging - How to get the managed exception details?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Loy - 27 Sep 2006 12:44 GMT
JIT debugging - How to get the managed exception details?

Problem: managed application is crashing on startup with unhandled
exception - need to understand the exception

I've set windbg to be my JIT debugger for managed code
 HKLM\Software\Microsoft\.NetFramework\DbgJITDebugLaunchSetting =
(DWORD)2
 HKLM\Software\Microsoft\.NetFramework\DbgManagedDebugger = (string)
c:\DebuggingTools\windbg.exe -p %ld

My test app throws new ApplicationException right from the main

WinDbg does attach to the process and break

So far - so good

Now I expect to be able to understand the exception type and location

!analyze -v  is telling that the exception is 80000003 - break
instruction exception
 Which is not what I expected - any idea why?

!sos.CurrenExceptionName is telling that: "This is not a managed
exception or not in KERNEL32!RaiseException"

How could I get the details of the ApplicationException?

Loy
Oleg Starodumov - 28 Sep 2006 08:10 GMT
> !analyze -v  is telling that the exception is 80000003 - break
> instruction exception
[quoted text clipped - 4 lines]
>
> How could I get the details of the ApplicationException?

When WinDbg have attached via .NET JIT debugging and with
such command line parameters, it will be in the context of the "break" thread,
not in the context of the thread that raised the exception. Therefore
you need to switch to the thread that raised the exception.
If the exception happens at application startup, it usually will be thread 0,
so you should do

> ~0 s

to switch to that thread. (Otherwise, print call stacks of all threads to see which
one raised the exception). (Alternatve approach is to add -pv option to WinDbg
command line - it will cause non-invasive attach and thread 0 will usually be
the current one)

After you have switched to the right thread, you can use SOS e.g. to
print the managed call stack (!clrstack, etc.).

If you want to use !currentexceptionname, you need one more step -
lookup the exception context on the thread stack and use .cxr command
to switch to it. There are two most typical approaches to it:
http://blogs.msdn.com/jmstall/archive/2005/01/18/355697.aspx
http://www.debuginfo.com/articles/easywindbg2.html#crashdumpanalysis
(in the second link, see at the end of the topic)

--
Oleg
[VC++ MVP http://www.debuginfo.com/]
Loy - 28 Sep 2006 13:47 GMT
Thanks Oleg - It works!

1. I've added the -pv to the command line
2. Need to load sos.dll before !analyze - in order for analyze to
understand managed exceptions

A problem with .net framework 1.1 is that unhandled exception in thread
other than the main thread does not (always) crash the application

Loy

> > !analyze -v  is telling that the exception is 80000003 - break
> > instruction exception
[quoted text clipped - 32 lines]
> Oleg
> [VC++ MVP http://www.debuginfo.com/]

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.