Chapter 6. WinDBG, SOS, and ADPlus


In this chapter:

 

Before You Begin

252

Basics

254

The Command Window

260

SOS

291

ADPlus

340

Summary

352


After all those pages on Microsoft Visual Studio, you are probably thinking that there can't be any more I could write about debuggers. Judging by the length of this chapter, there's obviously quite a bit more to say as Microsoft produces a second debugger, WinDBG. WinDBG is sometimes affectionately referred to as Windbagthe Microsoft Office Word spelling checker suggests Windbag when encountering WinDBG in documents. The Developer Division at Microsoft produces Visual Studio, but WinDBG development comes from the Microsoft Windows Team. That's because WinDBG is designed to debug the operating system itself, whereas Visual Studio is the commercial product for application developers.

You might be wondering why I'm bothering to cover WinDBG in a book that focuses on .NET debugging. Especially when I tell you that WinDBG does not do any .NET debugging at all; it supports only straight native debugging. There's no way with WinDBG to single-step your C# source code, look at objects, or perform any other of the niceties available in Visual Studio. In fact, as you'll find out, whereas Visual Studio has a well-thought-out user interface, WinDBG's UI comes straight out of the 1980s PC development model. Although it technically does have a graphical user interface, it's a wrapper on a console. Don't let the lack of a hand-holding UI scare you though; it's the ultimate power debugger, and when it comes to the toughest of .NET bugs, it is the only tool that will save the day. To give you an idea of the power, in our consulting work at Wintellect, which as you know works only on the toughest bugs, we use WinDBG nearly 70 percent of the time.

The chapter title gives you a hint that there's more than WinDBG involved for .NET debugging. WinDBG acts as the debugger, but it's the SOS (Son of Strike) extension loaded into WinDBG with the smarts about .NET internals to let you see nearly everything going on in a process. ADPlus, also known as Autodump+, is the world's largest VBScript program, which can take snapshots of your .NET applications, called minidumps, that you'll use on your production servers.

If that last hint about getting minidumps on your production servers doesn't seem that exciting, and you're still not convinced that WinDBG and friends are worth dealing with, I have a few more morsels to drop that should definitely convince you. As all .NET developers should know, the .NET runtime is a garbage-collected system with three heaps. The big question everyone wants answered is, "what heap is this particular object in?" That's exactly what you can see with these tools. If that's not enough to convince you, think about how many times you wish you could see your application at the exact instance it goes down in a production environment. Again, these tools will make that dream a complete reality.

Be prepared: using WinDBG and friends is not always a pleasant experience. I'll do my best to help you over as many hurdles as possible. However, it will take practice using real-world problems. I can't stress enough that these tools are the real secret to hard-core .NET debugging. If you master them, I guarantee you'll be the complete Alpha Geek in your development shop. How's that for motivation?

Some of you may have heard that SOS can be loaded into Visual Studio. That's true, and I'll show you how in this chapter. However, there are some limitations to that support. In my opinion, WinDBG is a far superior platform for minidump analysis, so I've never used SOS inside Visual Studio.

For this chapter, I'll assume that you've never used WinDBG before. WinDBG is extremely powerful, but I'll concentrate solely on using it for .NET applications. Because WinDBG is strictly a native debugger, I'll first cover the native debugging parts that you'll need in order to look at your .NET applications, no matter the type. Once you have a handle on looking at the native side, we'll turn to using SOS to dig all the way through the .NET pieces of your applications. Using ADPlus is straightforward, but I'll show you the ropes there.

My goal for the chapter is to get you fully prepared to start debugging your applications with WinDBG, SOS, and ADPlus. There are some excellent advanced resources, which I will point you to in the Summary section at the end of the chapter. Sadly, much of what you find on WinDBG, SOS, and ADPlus already assume that you know all the basics. I want to spend this chapter getting you sufficiently conversant in the language of WinDBG, SOS, and ADPlus so you can use those resources even more effectively. Between this chapter and the resources I'll cite for you to continue your studies, you'll be a super expert in .NET internals.




Debugging Microsoft  .NET 2.0 Applications
Debugging Microsoft .NET 2.0 Applications
ISBN: 0735622027
EAN: 2147483647
Year: 2006
Pages: 99
Authors: John Robbins

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net