The Assembly Programming Master Book

Overview

Borland Turbo Debugger is a powerful tool for debugging programs. It was developed in the time of MS-DOS and mainly is oriented toward Borland's implementations of most programming languages. The most important point is that this debugger allows program debugging both at the level of disassembled microprocessor commands and at the symbolic level (i.e., using the source code of the program being debugged ). In the latter case, for successful debugging it is necessary to include the debug information in the executable module at compile time.

For example, consider the program from Listing 17.1 in Chapter 17. This program displays the window containing the list of available disks and drives (both local and network, if there are any). To include the debug information in this module, add the /zi command-line option when assembling the program with TASM32. At build time, add the -v option to the TLINK32.EXE command-line options. In this case, all information required for symbolic debugging will be saved in the executable module.

It is important to bear in mind that more than the executable module and the debug information that it contains are required for symbolic debugging. In addition to this, you'll need the program's source code. The executable module stores the information that allows you to compare machine codes and the source code of the program. Fig. 23.1 shows the debugger window with the loaded debug information of the DRIV.ASM program (see Listing 17.1 in Chapter 17). The debugger allows you to execute the program step by step (more details on the modes of program execution are provided later in this chapter), simultaneously viewing the source code of the program being debugged and its disassembled listing. By walking through the program, you'll be able to view the results of executing each step.

Fig. 23.1 shows the three most frequently used debugger windows : the window containing the source code, the Central Processing Unit (CPU) window that displays the disassembled text, and even the current information about registers and flags, which is especially important when debugging GUI applications.

Figure 23.1: Turbo Debugger windows

Consider the debugger commands and its functional capabilities:

When executing any of the previously listed commands, it is also possible to specify command-line options. This can be achieved by choosing the Run Arguments commands.

Now, consider the most important windows of this debugger, some of which I have already mentioned. To display a specific debugger window, choose an appropriate command from the View menu.

To display the program text, choose the Module command of the View menu. The program must be translated with the options ensuring that the debug information is saved in the executable module. Unfortunately, this is only true for the modules compiled using Borland products: C++, Delphi, and Turbo Assembler. Debugging information of other developers cannot be recognized by Turbo Debugger. Later in this chapter, I provide an example illustrating the debugging of a program written in Borland C++.

If Turbo Debugger doesn't recognize the debug information in the executable module, you will have to use the CPU window in the course of debugging. This window is divided into five parts (these are shown in Fig. 23.2):

Figure 23.2: Turbo Debugger CPU window

Other windows of Turbo Debugger are as follows :

Категории