These functions control the connection to the target. For remote targets this involves setting up and closing down a TCP/IP socket link to the server driving the hardware. For local targets it involves opening and closing the device.
or1k_open
. This is passed the arguments
to the target jtag command and establishes
the connection to the target. The arguments are the address of
the target (either a local device, or a TCP/IP host/port
specification) and an optional second argument
reset indicating the target should be reset
on connection.
Any existing connections are tidied up by
target_preopen
and any instances of this
target are removed from the target stack by
unpush_target
.
Connection is then established through the low level interface
routine, or1k_jtag_init
, which resets the
target if requested.
With the connection established, the target's Unit Present SPR is checked to verify it has a debug unit available. Data about the number of GPRs and matchpoints is read from the CPU Configuration SPR and used to update struct gdbarch_tdep.
The target processor is then stalled, to prevent further execution, with a 1000μs wait to allow the stall to complete.
The debug cache is cleared, and the Debug Stop SPR set to trigger the JTAG interface on trap exceptions (which are used for debug breakpoints, watchpoints and single stepping). The cache will be written out to the SPRs before execution recommences.
Having established a connection, the target is pushed on to
the stack. It is marked running, which sets all the flags
associated with a running process and updates the choice of
current target (which depending on the stratum could be this
target). However, the OpenRISC connection is established with
the target processor stalled, so the
to_has_execution
flag is cleared by setting
the macro target_has_execution
to 0. It
will be set when or1k_resume
unstalls the
target.
As a matter of good housekeeping, any shared library symbols
are cleared using no_shared_libraries
.
GDB identifies all inferior executables by their process and
thread ID. This port of the OpenRISC 1000 is for bare metal debugging,
so there is no concept of different processes that may be
executing. Consequently the null_ptid
is used
as the process/thread ID for the target. This is set in the
GDB global variable inferior_pid
.
Note | |
---|---|
It is important that the inferior process/thread ID is established at this early stage, so that the target can always be uniquely identified. |
Finally the generic start_remote
is called
to set up the new target ready for execution. It is possible
this could fail, so the call is wrapped in a function,
or1k_start_remote
, which has the correct
prototype to run using catch_exception
. If
failure occurs, the target can be popped, before the exception
is thrown on to the top level.
or1k_close
. This closes the connection by
calling the low level interface function,
or1k_jtag_close
. The target will
already have been unpushed and the inferior mourned (see Section 4.3.6), so these
actions are not required.
or1k_detach
. This just detaches from the
target being debugged, which is achieved by calling
or1k_close
.
There is no explicit function to reattach to the target, but a
call to or1k_open
(by giving a
target jtag command in GDB) will
achieve the same effect.