Buddhike's Weblog

cordbg fun

Debugging is an interesting topic which should be covered in more detail than just a blog post. However, I had to play ‘n figure-out something strange in one of the .NET Fx assemblies ;-). I used some cool tricks and thought about sharing them here. BTW: I spend a good part of my life with Reflector. But sometimes it’s very hard to track each and every function call and study the code until you get to where you wanna go (Sometimes I just do this for hours and hours for fun though ;-). Specially, reading through the SOAP stack (WCF) is one of my hobbies!!!).

Today I had a managed program which did not crash at all but did not provide the expected results. And that was just an optimized release build and no pdb was available. After going thorough it with the Reflector, I smelled something like a “first chance exception”. These exceptions are handled during the execution so that it won’t crash the app. However, this does not necessarily mean that all your troubles are gone. So take them serious when you debug something written by someone else ;-).
I started cordbg and instructed it to break whenever there is a first chance exception as follows.

>cordbg
>catch e on

Just as I expected it stopped at certain places… Then I wanted to observe my call stack to find out the exact method throwing the exception. So this was my next command.

>what

So when I found the actual method along with the parameters being passed, figuring out the rest was just a piece of cake with the Reflector ;-). In addition to that I used several other commands to see the locals, to step in through the code (assembler though) etc etc…

The reason I posted this here is: I think this is an easy way you can track the problems in the production system. Specially when your applications are live and you get limited access to the production machines and you cannot install anything in those boxes and when your client wants to find out what the hell is happening during their lunch break :D.

Finally, this post really compelled me to write an in-dept doc about hardcore debugging with various tools like cordbg windbg+sos etc… I’m really looking forward to that ;-).

Update: My friend Christian just pointed me this article. Simply priceless! And this is what exactly I wanted to do. So I just took it off from my list ;-).

Happy debugging!!!

Posted: Mar 22 2007, 01:03 PM by Buddhike | with no comments
Filed under:

Comments

No Comments