Debugging Programs Written in High-Level Languages

Now, it is time describe debugging programs written using high-level languages. If the debug information was saved in the executable module at compile time, Turbo Debugger will be able to work with high-level language. Consider, for example, a simple console program demonstrating the bubble sort algorithm. The program is presented in Listing 23.1.

Listing 23.1: A simple console application
image from book
 #include <windows.h> #include <stdio.h> void sort(DWORD a[], DWORD ); void main() {       DWORD a [10];       DWORD j, p, k, r;       randomize () ;       for(j=0; j<10; j++) a[j]=random(10); // Sorting       {       for(k=9; k>l; k--)             {             r=0;                  for(j=0; j<k; j++)                        {                              if(a[j]>a[j+l]){p=a[j+l];                              a[j+l]=a[j];                              a[j]=p;                              r=l; };                        }                        if (r==0) break;             }             for(j=0; j<10; j++) printf("%lu\n", a[j]);             ExitProcess(0); } 
image from book
 

Fig. 23.5 shows the Turbo Debugger window with the program from Listing 23.1 loaded. In the lower part of the main window, the Watches window resides. This window traces the values of elements of the array a [ ] . If you switch to the CPU window, you'll see how the bubble sort algorithm implemented in C language is converted into Assembly code.

image from book
Figure 23.5: Program from Listing 23.1 in the debugger window


The Assembly Programming Master Book
The Assembly Programming Master Book
ISBN: 8170088178
EAN: 2147483647
Year: 2004
Pages: 140
Authors: Vlad Pirogov

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