A target vector can be completely inactive (not pushed on the target stack), active but not running (pushed, but not connected to a fully manifested inferior), or completely active (pushed, with an accessible inferior). Most targets are only completely inactive or completely active, but some support persistent connections to a target even when the target has exited or not yet started.
For example, connecting to the simulator using
target sim does
not create a running program. Neither registers nor memory are
run. Similarly, after
program can not continue executing. But in both cases gdb
remains connected to the simulator, and target-specific commands
are directed to the simulator.
A target which only supports complete activation should push itself
onto the stack in its
to_open routine (by calling
push_target), and unpush itself from the stack in its
to_mourn_inferior routine (by calling
A target which supports both partial and complete activation should
to_open, but not call
to_mourn_inferior. Instead, it should
to_open, depending on whether the target is fully active
after connection. It should also call
time the inferior becomes fully active (e.g. in
target_mark_exited when the inferior becomes inactive (in
to_mourn_inferior). The target should also make sure to call
target_mourn_inferior from its
to_kill, to return the
target to inactive state.