inf->attach_flag = attached;
- /* This may be the first inferior we hear about. */
- if (!target_has_execution)
- {
- if (rs->extended)
- target_mark_running (&extended_remote_ops);
- else
- target_mark_running (&remote_ops);
- }
-
return inf;
}
{
if (rs->buf[0] == 'W' || rs->buf[0] == 'X')
{
- if (args->extended_p)
- {
- /* We're connected, but not running. Drop out before we
- call start_remote. */
- target_mark_exited (args->target);
- return;
- }
- else
+ if (!args->extended_p)
error (_("The target is not running (try extended-remote?)"));
+
+ /* We're connected, but not running. Drop out before we
+ call start_remote. */
+ return;
}
else
{
if (thread_count () == 0)
{
- if (args->extended_p)
- {
- /* We're connected, but not running. Drop out before we
- call start_remote. */
- target_mark_exited (args->target);
- return;
- }
- else
+ if (!args->extended_p)
error (_("The target is not running (try extended-remote?)"));
- }
- if (args->extended_p)
- target_mark_running (args->target);
+ /* We're connected, but not running. Drop out before we
+ call start_remote. */
+ return;
+ }
/* Let the stub know that we want it to return the thread. */
remote_check_symbols (symfile_objfile);
}
- /* If code is shared between processes, then breakpoints are global
- too; Insert them now. */
- if (gdbarch_has_global_solist (target_gdbarch)
+ /* If breakpoints are global, insert them now. */
+ if (gdbarch_has_global_breakpoints (target_gdbarch)
&& breakpoints_always_inserted_mode ())
insert_breakpoints ();
}
But if we're connected to a target system with no running process,
then we will still be connected when it returns. Ask this question
first, before target_preopen has a chance to kill anything. */
- if (remote_desc != NULL && !target_has_execution)
+ if (remote_desc != NULL && !have_inferiors ())
{
if (!from_tty
|| query (_("Already connected to a remote target. Disconnect? ")))
process, we may still be connected. If we are starting "target
remote" now, the extended-remote target will not have been
removed by unpush_target. */
- if (remote_desc != NULL && !target_has_execution)
+ if (remote_desc != NULL && !have_inferiors ())
pop_target ();
/* Make sure we send the passed signals list the next time we resume. */
}
push_target (target); /* Switch to using remote target now. */
- /* Assume that the target is not running, until we learn otherwise. */
- if (extended_p)
- target_mark_exited (target);
-
/* Register extra event sources in the event loop. */
remote_async_inferior_event_token
= create_async_event_handler (remote_async_inferior_event_handler,
/* Nothing to do. */
return;
- /* FIXME: cagney/1999-09-27: Shouldn't need to test for
- sync_execution here. This function should only be called when
- GDB is resuming the inferior in the forground. A background
- resume (``run&'') should leave GDB in control of the terminal and
- consequently should not call this code. */
- if (!sync_execution)
- return;
- /* FIXME: cagney/1999-09-27: Closely related to the above. Make
- calls target_terminal_*() idenpotent. The event-loop GDB talking
- to an asynchronous target with a synchronous command calls this
- function from both event-top.c and infrun.c/infcmd.c. Once GDB
- stops trying to transfer the terminal to the target when it
- shouldn't this guard can go away. */
+ /* FIXME: cagney/1999-09-27: Make calls to target_terminal_*()
+ idempotent. The event-loop GDB talking to an asynchronous target
+ with a synchronous command calls this function from both
+ event-top.c and infrun.c/infcmd.c. Once GDB stops trying to
+ transfer the terminal to the target when it shouldn't this guard
+ can go away. */
if (!remote_async_terminal_ours_p)
return;
delete_file_handler (input_fd);
return;
/* See FIXME in remote_terminal_inferior. */
- if (!sync_execution)
- return;
- /* See FIXME in remote_terminal_inferior. */
if (remote_async_terminal_ours_p)
return;
cleanup_sigint_signal_handler (NULL);
/* The non-stop mode version of target_wait. */
static ptid_t
-remote_wait_ns (ptid_t ptid, struct target_waitstatus *status)
+remote_wait_ns (ptid_t ptid, struct target_waitstatus *status, int options)
{
struct remote_state *rs = get_remote_state ();
struct remote_arch_state *rsa = get_remote_arch_state ();
if (stop_reply != NULL)
return process_stop_reply (stop_reply, status);
- /* Still no event. If we're in asynchronous mode, then just
+ /* Still no event. If we're just polling for an event, then
return to the event loop. */
- if (remote_is_async_p ())
+ if (options & TARGET_WNOHANG)
{
status->kind = TARGET_WAITKIND_IGNORE;
return minus_one_ptid;
}
- /* Otherwise, asynchronous mode is masked, so do a blocking
- wait. */
+ /* Otherwise do a blocking wait. */
ret = getpkt_or_notif_sane (&rs->buf, &rs->buf_size,
1 /* forever */);
}
STATUS just as `wait' would. */
static ptid_t
-remote_wait_as (ptid_t ptid, struct target_waitstatus *status)
+remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
{
struct remote_state *rs = get_remote_state ();
struct remote_arch_state *rsa = get_remote_arch_state ();
char *buf, *p;
struct stop_reply *stop_reply;
+ again:
+
status->kind = TARGET_WAITKIND_IGNORE;
status->value.integer = 0;
}
if (status->kind == TARGET_WAITKIND_IGNORE)
- /* Nothing interesting happened. */
- return minus_one_ptid;
+ {
+ /* Nothing interesting happened. If we're doing a non-blocking
+ poll, we're done. Otherwise, go back to waiting. */
+ if (options & TARGET_WNOHANG)
+ return minus_one_ptid;
+ else
+ goto again;
+ }
else if (status->kind != TARGET_WAITKIND_EXITED
&& status->kind != TARGET_WAITKIND_SIGNALLED)
{
static ptid_t
remote_wait (struct target_ops *ops,
- ptid_t ptid, struct target_waitstatus *status)
+ ptid_t ptid, struct target_waitstatus *status, int options)
{
ptid_t event_ptid;
if (non_stop)
- event_ptid = remote_wait_ns (ptid, status);
+ event_ptid = remote_wait_ns (ptid, status, options);
else
- {
- /* In synchronous mode, keep waiting until the target stops. In
- asynchronous mode, always return to the event loop. */
-
- do
- {
- event_ptid = remote_wait_as (ptid, status);
- }
- while (status->kind == TARGET_WAITKIND_IGNORE
- && !target_can_async_p ());
- }
+ event_ptid = remote_wait_as (ptid, status, options);
if (target_can_async_p ())
{
int c;
int tries;
int timeout;
- int val;
+ int val = -1;
/* We're reading a new response. Make sure we don't look at a
previously cached response. */
so that the user can say "kill" again. */
inferior_ptid = magic_null_ptid;
}
- else
- {
- /* Mark this (still pushed) target as not executable until we
- restart it. */
- target_mark_exited (target);
- }
}
- else
- /* Always remove execution if this was the last process. */
- target_mark_exited (target);
}
}
which don't, we insert a traditional memory breakpoint. */
static int
-remote_insert_breakpoint (struct bp_target_info *bp_tgt)
+remote_insert_breakpoint (struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
{
/* Try the "Z" s/w breakpoint packet if it is not already disabled.
If it succeeds, then set the support to PACKET_ENABLE. If it
char *p;
int bpsize;
- gdbarch_breakpoint_from_pc (target_gdbarch, &addr, &bpsize);
+ gdbarch_breakpoint_from_pc (gdbarch, &addr, &bpsize);
rs = get_remote_state ();
p = rs->buf;
}
}
- return memory_insert_breakpoint (bp_tgt);
+ return memory_insert_breakpoint (gdbarch, bp_tgt);
}
static int
-remote_remove_breakpoint (struct bp_target_info *bp_tgt)
+remote_remove_breakpoint (struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
{
CORE_ADDR addr = bp_tgt->placed_address;
struct remote_state *rs = get_remote_state ();
return (rs->buf[0] == 'E');
}
- return memory_remove_breakpoint (bp_tgt);
+ return memory_remove_breakpoint (gdbarch, bp_tgt);
}
static int
static int
-remote_insert_hw_breakpoint (struct bp_target_info *bp_tgt)
+remote_insert_hw_breakpoint (struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
{
CORE_ADDR addr;
struct remote_state *rs;
instruction, even though we aren't inserting one ourselves. */
gdbarch_breakpoint_from_pc
- (target_gdbarch, &bp_tgt->placed_address, &bp_tgt->placed_size);
+ (gdbarch, &bp_tgt->placed_address, &bp_tgt->placed_size);
if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE)
return -1;
static int
-remote_remove_hw_breakpoint (struct bp_target_info *bp_tgt)
+remote_remove_hw_breakpoint (struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
{
CORE_ADDR addr;
struct remote_state *rs = get_remote_state ();
struct remote_state *rs = get_remote_state ();
asection *s;
unsigned long host_crc, target_crc;
- extern bfd *exec_bfd;
struct cleanup *old_chain;
char *tmp;
char *sectdata;
remote_ops.to_log_command = serial_log_command;
remote_ops.to_get_thread_local_address = remote_get_thread_local_address;
remote_ops.to_stratum = process_stratum;
- remote_ops.to_has_all_memory = 1;
- remote_ops.to_has_memory = 1;
- remote_ops.to_has_stack = 1;
- remote_ops.to_has_registers = 1;
- remote_ops.to_has_execution = 1;
+ remote_ops.to_has_all_memory = default_child_has_all_memory;
+ remote_ops.to_has_memory = default_child_has_memory;
+ remote_ops.to_has_stack = default_child_has_stack;
+ remote_ops.to_has_registers = default_child_has_registers;
+ remote_ops.to_has_execution = default_child_has_execution;
remote_ops.to_has_thread_control = tc_schedlock; /* can lock scheduler */
remote_ops.to_can_execute_reverse = remote_can_execute_reverse;
remote_ops.to_magic = OPS_MAGIC;