How to Read This Book and What's New in the Second Edition
The first edition focused on Microsoft Visual Studio 6 and Microsoft Win32 debugging. As we now have a brand new development environment, Microsoft Visual Studio .NET 2003, and a whole new programming paradigm, .NET, there's quite a bit more to cover. In fact, the first edition was 512 pages and this edition is around 850 pages, so you can see that the information I need to cover has grown considerably. As several of the reviewers commented: "I don't know why you're calling this a second edition because this is a whole new book!" To give you another idea of how much larger the second edition is, the first edition had 2.5 MB of text source code. This edition has 6.9 MB! Remember, that's just text and supporting files, not compiled binaries (compiling everything adds up to over 1 GB). What's even more astounding is that I didn't even include two chapters from the first edition in the second edition. As you can see, this is a whole new book.
I divided the book into four distinct parts. You should read the first two
(Chapters 1 through 8) in order because I build the information in a logical progression.
In the first part of the book, "The Gestalt of Debugging" (Chapters 1 through 3), I define the different types of
and develop a process for debugging that all great developers follow. As
by readers of the first edition, I expanded and deepened the discussion. I also discuss the infrastructure requirements necessary for proper team debugging. I strongly suggest you pay particular attention to the discussion on setting up symbol servers in Chapter 2. Finally, because you can (and should) do a tremendous amount of debugging during the coding phase, I cover how you can proactively debug as you're writing your code. The discussion on assertions in Chapter 3 should be the final word on the subject for both .NET and Win32.
In the second part of the book, "Power Debugging" (Chapters 4 through 8), I start with an explanation of operating-system debugging support and how Win32
work, because Win32 debugging has more magic going on behind the scenes than .NET. The more you understand your tools, the better able you are to use them. I also cover the Visual Studio .NET debugger in considerable depth so that you can learn to maximize its usage for both .NET and Win32. One thing I learned while working with developers from across the industry—from the inexperienced to the very
—was that they were using only a tiny fraction of the power of the Visual Studio .NET debugger. Although this sentiment might sound odd coming from an author of a book about debugging, I want to keep you out of the debugger as much as possible. As you read this book, you'll see that much of my goal for you isn't just to learn how to fix bugs and crashes but how to avoid them in the first place. I also want to teach you to use the debuggers to their maximum effectiveness because there will be times when you're forced to use them.
In the third part of the book, "Power Tools and Techniques for .NET" (Chapters 9 through 11), I offer up some
utilities for .NET development. Chapter 9 covers the outstanding extensibility mode
with Visual Studio .NET. In that chapter, I build several great macros and add-ins that will help you speed up your development no matter whether you're working in .NET or Win32 exclusively. Chapter 10 and Chapter 11 cover the exciting .NET Profiling API and build two tools that will easily help you track exceptions and the flow through your .NET applications.
In the final part of the book, "Power Tools and Techniques for Native Code" (Chapters 12 through 19), offers solutions to common debugging problems you'll encounter when writing Windows-based applications. I cover topics
from finding the source file and line number with just a crash address to how to properly handle crashes in your application so that you can get the most information possible. Although Chapters 15 through 18 appeared in the first edition, I significantly updated the chapter text and completely rewrote some of the utilities (DeadlockDetection, Tester, and MemDumperValidator). Also, tools such as Tester work
well with both native as well as .NET code. Finally, I added two new Windows debugging tools, FastTrace (Chapter 18) and Smooth Working Set (Chapter 19).
The final part of the book, "Appendixes" (Appendix A and Appendix B), provides additional information you'll find useful in your debugging
. In Appendix A, I explain how to read and interpret a Dr. Watson log. In Appendix B, you'll find annotated lists of resources—books, tools, and Web sites—that have helped me hone my skills as a developer/debugger.
In the first edition, I offered a few sidebars about various debugging war stories I'd seen. The response was so overwhelming that in this edition, I greatly expanded the number of war stories. I hope that by sharing with you some of the really "good" bugs I've helped solve (and some I've helped write!), you'll see the practical application of the approaches and techniques I recommend. I also want to help you avoid the mistakes that I've made.
I also kept a list of all the questions I was asked in the first edition and made sure to answer them in the Common Debugging Question sidebars. The war stories and Common Debugging Questions are listed on pages xix to xx.