Porting a new architecture to GDB can be broken into a number of steps.
Ensure a BFD exists for executables of the target architecture
in the bfd
directory. If one does not exist,
create one by modifying an existing similar one.
Implement a disassembler for the target architecture in the
opcodes
directory.
Define the target architecture in the gdb
directory. Add the pattern for the new target to
configure.tgt
with the names of the files
that contain the code. By convention the target architecture
definition for an architecture arch is placed
in arch-tdep.c
.
Within arch-tdep.c
define the function
_initialize_arch_tdep
which calls
gdbarch_register
to create the new struct gdbarch
for the architecture.
If a new remote target is needed, consider adding a new remote
target by defining a function
_initialize_remote_arch
.
However if at all possible use the Remote Serial
Protocol for this and implement the server side
protocol independently with the target.
If desired implement a simulator in the sim
directory. This should create the library
libsim.a
implementing the interface in
remote-sim.h
(found in the
include
directory).
Build and test. If desired, lobby the GDB steering group to have the new port included in the main distribution!
Add a description of the new architecture to the "Configuration
Specific Information" section in the main GDB user guide
(gdb/doc/gdb.texinfo
[3]).
The remainder of this document shows how this process was used to port GDB to the OpenRISC 1000 architecture.