Chapter 6 -- Power Debugging with x86 Assembly Language and the Visual C Debugger Disassembly Window

[Previous] [Next]

Chapter 6

In many cases when your application crashes, the real difference between solving the bug and screaming in frustration comes down to how well you can read a little assembly language. Although we'd all prefer our crashes to occur in a module with source code and a complete call stack, many crashes just don't happen that way. When you do crash, you're generally left looking at the Disassembly window in the Microsoft Visual C++ debugger and wondering how you're going to figure out where you are in the program, let alone why you crashed.

By no means am I saying that you need to know assembly language well enough to write all your programs using Microsoft Macro Assembler (MASM). The key is to learn enough assembly language to be comfortable reading it. My goal for this chapter is to present the information you need to have a working knowledge of assembly language. By the time you finish reading this chapter and practice for a couple of hours, you'll know more than enough assembly language to get by. That small investment of time can be the difference between flailing around in the debugger practicing your primal scream therapy and fixing your bugs.

Developers are sometimes wary of learning assembly language because they think some sort of black magic is involved. There's really nothing mysterious about assembly language, though; a single assembly language instruction does one thing and one thing only. Once you see the pattern and understand how the CPU carries out instructions, you'll realize that assembly language is actually quite elegant. If you want to look at black magic, take a single line in Microsoft Visual Basic, such as db.Connect ("Foo"). That single line can call 30 to 40 different functions and make an incredible number of assumptions. To me, Visual Basic is sometimes far more mystifying than assembly language.

After introducing you to assembly language, I'll turn back to the Visual C++ debugger and show you how to survive in the Disassembly window. For example, I'll show you how to look up parameters on the stack and navigate within the Disassembly window. I'll also explain the relationship between the Memory window and the Disassembly window as well as supply you with tips and tricks that will help you debug at the assembly-language level.



Debugging Applications
Debugging Applications for MicrosoftВ® .NET and Microsoft WindowsВ® (Pro-Developer)
ISBN: 0735615365
EAN: 2147483647
Year: 2000
Pages: 122
Authors: John Robbins

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