Services - tools - models - for embedded software development
Embecosm divider strip
Prev  Next

2.4.2.  Specifying a New Target

Some targets (sets of target operations in a struct target_ops) are set up automatically by GDB—these include the operations to drive simulators (see Section 2.6 and the operations to drive the GDB Remote Serial Protocol (RSP) (see Section 2.7).

Other targets must be set up explicitly by the implementer, using the add_target function. By far the most common is the native target for native debugging of the host. Less common is to set up a non-native target, such as the JTAG target used with the OpenRISC 1000[1].

2.4.2.1.  Native Targets

A new native target is created by defining a function _initialize_arch_os_nat for the architecture, arch and operating system os, in the source file arch-os-nat.c. A fragment of a makefile to create the binary from the source is created in the file config/arch/os.mh with a header giving any macro definitions etc in config/arch/nm-os.h (which will be linked to nm.h at build time).

The _initialize_ function should create a new struct target_ops and call add_target to add this target to the list of available targets.

For new native targets there are standard implementations which can be reused, with just one or two changes. For example the function linux_trad_target returns a struct target_ops suitable for most Linux native targets. It may prove necessary only to alter the description field and the functions to fetch and store registers.

2.4.2.2.  Remote Targets

For a new remote target, the procedure is a little simpler. The source files should be added to configure.tgt, just as for the architectural description (see Section 2.3). Within the source file, define a new function _initialize_remote_arch to implement a new remote target, arch.

For new remote targets, the definitions in remote.c used to implement the RSP provide a good starting point.



[1] For a new remote target of any kind, the recommended approach is to use the standard GDB Remote Serial Protocol (RSP) and have the target implement the server side of this interface. The only remote targets remaining are historic legacy interfaces, such as the OpenRISC 1000 Remote JTAG Protocol.

Embecosm divider strip