Getting Started with M68K Ada: Ada 95 Compilation System for the Motorola M68000 Family | ||
---|---|---|
Prev | Chapter 2. Advanced Techniques | Next |
Before we can make full use of the debugger, we must recompile hello.adb using the compiler's 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 m68k-coff-strip.
This is how we recompile hello.adb with the
-g
option. There are other debug options too. See the
M68K Ada User's Guide for more information on debug
options.
Example 2-12. Recompiling with the Debug Option
bash$ m68k-coff-gnatmake -f -g hello m68k-coff-gcc -c -g hello.adb m68k-coff-gnatbind -x hello.ali m68k-coff-gnatlink -g hello.ali
The debugger is m68k-coff-gdb. By default the debugger will run a M68K program on the M68K simulator. If you prefer to run and debug on a real M68K then you must arrange for your target to communicate with the host using the debugger's remote debug protocol. This is described in Section 2.7.
Example 2-13. Running under the Debugger
$ m68k-coff-gdb hello XGC m68k-ada Version 1.7 (debugger) Copyright (c) 1996, 2002, XGC Software. Based on gdb version 5.1.1 Copyright (c) 1998 Free Software Foundation... (gdb) br main Breakpoint 1 at 0x644: file b~hello.adb, line 39. (gdb)run Starting program: .../examples/hello Connected to the simulator. Loading sections: Idx Name Size VMA LMA File off Algn 0 .ivec 00000100 00000000 00000000 00002000 2**2 CONTENTS, ALLOC, LOAD 1 .init 00000004 00000100 00000100 00002100 2**2 CONTENTS, ALLOC, LOAD, CODE 2 .text 00001908 00000104 00000104 00002104 2**2 CONTENTS, ALLOC, LOAD, CODE 3 .rdata 000000ec 00001a0c 00001a0c 00003a0c 2**2 CONTENTS, ALLOC, LOAD 4 .data 000001fc 00100000 00001af8 00004000 2**2 CONTENTS, ALLOC, LOAD, DATA Start address 0x104 Transfer rate: 59296 bits in <1 sec. Breakpoint 1, main () at b~hello.adb:39 39 adainit; (gdb)c Continuing. Hello World Program exited normally. [Switching to process 0] (gdb)quit
You can view the debug information using the object dump utility, as follows:
Example 2-14. Dump of Debug Information
bash$ m68k-coff-objdump -G hello hello: file format coff-m68k Contents of .stab section: Symnum n_type n_othr n_desc n_value n_strx String -1 HdrSym 0 1598 00004b7d 1 0 SO 0 0 00000608 13 ../examples/ 1 SO 0 0 00000608 1 b~hello.adb 2 LSYM 0 0 00000000 58 long int:t(0,1)=r(0 3 LSYM 0 0 00000000 105 unsigned char:t(0,2 ...