Set proc->priv->new_inferior out of linux_add_process
authorYao Qi <yao.qi@linaro.org>
Fri, 24 Jul 2015 13:40:34 +0000 (14:40 +0100)
committerYao Qi <yao.qi@linaro.org>
Fri, 24 Jul 2015 13:40:34 +0000 (14:40 +0100)
Nowadays, we set proc->priv->new_inferior to 1 inside linux_add_process,
and new_inferior is used as a flag to initialise target description later.
linux_add_process is used for the three cases, fork/vfork event
(handle_extended_wait), run the program (linux_create_inferior), and
attach to the process (linux_attach).  In the first case, the child's
target description is copied from parent's, so we don't need to initialise
target description again later, which means we don't need to set
proc->priv->new_inferior to 1 in this case.  For the rest of two cases,
we need this flag.

This patch move the code setting proc->priv->new_inferior to 1 inside
linux_add_process to linux_create_inferior and linux_attach.  No
functionality is changed.

gdb/gdbserver:

2015-07-24  Yao Qi  <yao.qi@linaro.org>

* linux-low.c (linux_add_process): Don't set
proc->priv->new_inferior.
(linux_create_inferior): Set proc->priv->new_inferior to 1.
(linux_attach): Likewise.

gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-low.c

index 6fbd6640796f05bb401e228744e0536956c97f18..d215d7a39ee284612dc2c28e85e1f7a01e695843 100644 (file)
@@ -1,3 +1,10 @@
+2015-07-24  Yao Qi  <yao.qi@linaro.org>
+
+       * linux-low.c (linux_add_process): Don't set
+       proc->priv->new_inferior.
+       (linux_create_inferior): Set proc->priv->new_inferior to 1.
+       (linux_attach): Likewise.
+
 2015-07-24  Yao Qi  <yao.qi@linaro.org>
 
        * server.c (start_inferior): Code refactor.
index 2dafb033bcec62b38c930f852788895932c95748..fa9dc29ded406754565201bb26797c43b79dc1b8 100644 (file)
@@ -405,9 +405,6 @@ linux_add_process (int pid, int attached)
   proc = add_process (pid, attached);
   proc->priv = xcalloc (1, sizeof (*proc->priv));
 
-  /* Set the arch when the first LWP stops.  */
-  proc->priv->new_inferior = 1;
-
   if (the_low_target.new_process != NULL)
     proc->priv->arch_private = the_low_target.new_process ();
 
@@ -766,6 +763,7 @@ linux_create_inferior (char *program, char **allargs)
   ptid_t ptid;
   struct cleanup *restore_personality
     = maybe_disable_address_space_randomization (disable_randomization);
+  struct process_info *proc;
 
 #if defined(__UCLIBC__) && defined(HAS_NOMMU)
   pid = vfork ();
@@ -813,7 +811,9 @@ linux_create_inferior (char *program, char **allargs)
 
   do_cleanups (restore_personality);
 
-  linux_add_process (pid, 0);
+  proc = linux_add_process (pid, 0);
+  /* Set the arch when the first LWP stops.  */
+  proc->priv->new_inferior = 1;
 
   ptid = ptid_build (pid, pid, 0);
   new_lwp = add_lwp (ptid);
@@ -959,6 +959,7 @@ linux_attach (unsigned long pid)
 {
   ptid_t ptid = ptid_build (pid, pid, 0);
   int err;
+  struct process_info *proc;
 
   /* Attach to PID.  We will check for other threads
      soon.  */
@@ -967,7 +968,9 @@ linux_attach (unsigned long pid)
     error ("Cannot attach to process %ld: %s",
           pid, linux_ptrace_attach_fail_reason_string (ptid, err));
 
-  linux_add_process (pid, 1);
+  proc = linux_add_process (pid, 1);
+  /* Set the arch when the first LWP stops.  */
+  proc->priv->new_inferior = 1;
 
   if (!non_stop)
     {
This page took 0.034614 seconds and 4 git commands to generate.