3.5. Using the Debugger

Before we can make full use of the debugger, we must recompile hello.c using the debug option. This option tells the compiler to include information about the source code, and the mapping of source code to generated code. Then the debugger can operate at source code level rather than at machine code level.

The debug information does not alter the generated code in any way but it does make object code files much bigger. Normally this is not a problem, but if you wish to remove the debug information from a file, then use the object code utility m1750-coff-strip.

This is how we recompile hello.c with the -g option. There are other debug options too. See the User's Guide for more information on debug options.

$ m1750-coff-gcc hello.c -o hello -g

The debugger is m1750-coff-gdb. By default the debugger will run a 1750 program on the 1750 simulator. If you prefer to run on a real 1750 then you must arrange for your target to communicate with the host using the gdb protocol. The debugger is configured to use either an RS-232 serial interface or TCP/IP.

$ m1750-coff-gdb hello
XGC Debugger Version 4.17.gnat.3.11 for m1750-coff
Copyright (c) 1998 Free Software Foundation, Inc...
(gdb) br main
Breakpoint 1 at 0x14e: file hello.c, line 6.
(gdb) r
Starting program: /home/xgc/gcc-1750/examples/hello 
Connected to the simulator.
Loading section .text, size 0x12b4 address 0x80
Loading section .rdata, size 0x44c address 0x1334
Start address 0x80
Transfer rate: 47104 bits in <1 sec.

Breakpoint 1, main () at hello.c:6
6         printf ("Hello world\n");
(gdb)