+2015-07-24 Yao Qi <yao.qi@linaro.org>
+
+ * linux-low.c (linux_arch_setup): New function.
+ (linux_low_filter_event): If proc->tdesc is NULL and
+ proc->attached is true, call the_low_target.arch_setup.
+ Otherwise, keep status pending, and return.
+ (linux_resume_one_lwp_throw): Don't call get_pc if
+ thread->while_stepping isn't NULL. Don't call
+ get_thread_regcache if proc->tdesc is NULL.
+ (need_step_over_p): Return 0 if proc->tdesc is NULL.
+ (linux_target_ops): Install arch_setup.
+ * server.c (start_inferior): Call the_target->arch_setup.
+ * target.h (struct target_ops) <arch_setup>: New field.
+ (target_arch_setup): New marco.
+ * lynx-low.c (lynx_target_ops): Update.
+ * nto-low.c (nto_target_ops): Update.
+ * spu-low.c (spu_target_ops): Update.
+ * win32-low.c (win32_target_ops): Update.
+
2015-07-24 Yao Qi <yao.qi@linaro.org>
* linux-low.c (linux_add_process): Don't set
return pid;
}
+/* Implement the arch_setup target_ops method. */
+
+static void
+linux_arch_setup (void)
+{
+ the_low_target.arch_setup ();
+}
+
/* Attach to an inferior process. Returns 0 on success, ERRNO on
error. */
{
struct process_info *proc;
- /* Architecture-specific setup after inferior is running. This
- needs to happen after we have attached to the inferior and it
- is stopped for the first time, but before we access any
- inferior registers. */
+ /* Architecture-specific setup after inferior is running. */
proc = find_process_pid (pid_of (thread));
- if (proc->priv->new_inferior)
+ if (proc->tdesc == NULL)
{
- struct thread_info *saved_thread;
+ if (proc->attached)
+ {
+ struct thread_info *saved_thread;
- saved_thread = current_thread;
- current_thread = thread;
+ /* This needs to happen after we have attached to the
+ inferior and it is stopped for the first time, but
+ before we access any inferior registers. */
+ saved_thread = current_thread;
+ current_thread = thread;
- the_low_target.arch_setup ();
+ the_low_target.arch_setup ();
- current_thread = saved_thread;
+ current_thread = saved_thread;
- proc->priv->new_inferior = 0;
+ proc->priv->new_inferior = 0;
+ }
+ else
+ {
+ /* The process is started, but GDBserver will do
+ architecture-specific setup after the program stops at
+ the first instruction. */
+ child->status_pending_p = 1;
+ child->status_pending = wstat;
+ return child;
+ }
}
}
struct thread_info *thread = get_lwp_thread (lwp);
struct thread_info *saved_thread;
int fast_tp_collecting;
+ struct process_info *proc = get_thread_process (thread);
+
+ /* Note that target description may not be initialised
+ (proc->tdesc == NULL) at this point because the program hasn't
+ stopped at the first instruction yet. It means GDBserver skips
+ the extra traps from the wrapper program (see option --wrapper).
+ Code in this function that requires register access should be
+ guarded by proc->tdesc == NULL or something else. */
if (lwp->stopped == 0)
return;
/* Cancel actions that rely on GDB not changing the PC (e.g., the
user used the "jump" command, or "set $pc = foo"). */
- if (lwp->stop_pc != get_pc (lwp))
+ if (thread->while_stepping != NULL && lwp->stop_pc != get_pc (lwp))
{
/* Collecting 'while-stepping' actions doesn't make sense
anymore. */
step = 1;
}
- if (the_low_target.get_pc != NULL)
+ if (proc->tdesc != NULL && the_low_target.get_pc != NULL)
{
struct regcache *regcache = get_thread_regcache (current_thread, 1);
struct lwp_info *lwp = get_thread_lwp (thread);
struct thread_info *saved_thread;
CORE_ADDR pc;
+ struct process_info *proc = get_thread_process (thread);
+
+ /* GDBserver is skipping the extra traps from the wrapper program,
+ don't have to do step over. */
+ if (proc->tdesc == NULL)
+ return 0;
/* LWPs which will not be resumed are not interesting, because we
might not wait for them next time through linux_wait. */
static struct target_ops linux_target_ops = {
linux_create_inferior,
+ linux_arch_setup,
linux_attach,
linux_kill,
linux_detach,
int (*create_inferior) (char *program, char **args);
+ /* Architecture-specific setup. */
+ void (*arch_setup) (void);
+
/* Attach to a running process.
PID is the process ID to attach to, specified by the user
#define create_inferior(program, args) \
(*the_target->create_inferior) (program, args)
+#define target_arch_setup() \
+ do \
+ { \
+ if (the_target->arch_setup != NULL) \
+ (*the_target->arch_setup) (); \
+ } while (0)
+
#define myattach(pid) \
(*the_target->attach) (pid)