Getting Started with GCC-ERC32: C/C++ Compilation System for Mission Critical Spacecraft Applications | ||
---|---|---|
Prev | Next |
Once you have mastered writing and running a small program, you'll want to check out some of the more advanced techniques required to write and run real application programs. In this chapter, we cover the following topics:
Customizing the start-file and linker script file
Generating PROM programming files
Using the debugger
Interrupt handling
POSIX Multi Tasking
Using optimizations
Working on the target
The boot PROM
Temic revisions CBA and CCA
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 erc-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.
The debugger is erc-coff-gdb. By default the debugger will run an ERC32 program on the ERC32 simulator. If you prefer to run and debug on a real ERC32 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-2. Running Under the Debugger
$ erc-coff-gdb hello XGC gcc-erc32 Version 1.7e (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 0x2001500: file hello.c, line 6. (gdb) r Starting program: ../examples/hello Connected to the simulator. Loading sections: Idx Name Size VMA LMA File off Algn 1 .text 00002c88 02000000 02000000 00002000 2**2 CONTENTS, ALLOC, LOAD, CODE 2 .rodata 000003c8 02002c88 02002c88 00004c88 2**3 CONTENTS, ALLOC, LOAD, READONLY 3 .data 00000008 02100000 02003050 00006000 2**3 CONTENTS, ALLOC, LOAD, DATA Start address 0x2000a00 Transfer rate: 99008 bits in <1 sec. Breakpoint 1, main () at hello.c:6 6 printf ("Hello world\n"); a(gdb)