Don't emit symbols seen only in dynamic object, don't read duplicate
[deliverable/binutils-gdb.git] / gdb / linux-nat.c
index 5a80311808d2fdf2d76f08d6e193b0080f7bc950..b0b9cf32b9367fe52ddedb6485d819760a5761af 100644 (file)
@@ -276,6 +276,7 @@ linux_test_for_tracefork (int original_pid)
          ret = ptrace (PTRACE_KILL, second_pid, 0, 0);
          if (ret != 0)
            warning (_("linux_test_for_tracefork: failed to kill second child"));
+         my_waitpid (second_pid, &status, 0);
        }
     }
   else
@@ -985,10 +986,10 @@ lin_lwp_attach_lwp (ptid_t ptid, int verbose)
     {
       /* We assume that the LWP representing the original process is
          already stopped.  Mark it as stopped in the data structure
-         that the linux ptrace layer uses to keep track of threads.
-         Note that this won't have already been done since the main
-         thread will have, we assume, been stopped by an attach from a
-         different layer.  */
+         that the GNU/linux ptrace layer uses to keep track of
+         threads.  Note that this won't have already been done since
+         the main thread will have, we assume, been stopped by an
+         attach from a different layer.  */
       lp->stopped = 1;
     }
 }
@@ -2395,11 +2396,11 @@ linux_nat_thread_alive (ptid_t ptid)
                        target_pid_to_str (ptid),
                        errno ? safe_strerror (errno) : "OK");
 
-  /* Not every Linux target implements PTRACE_PEEKUSER.
-     But we can handle that case gracefully since ptrace
-     will first do a lookup for the process based upon the
-     passed-in pid.  If that fails we will get either -ESRCH
-     or -EPERM, otherwise the child exists and is alive.  */
+  /* Not every Linux kernel implements PTRACE_PEEKUSER.  But we can
+     handle that case gracefully since ptrace will first do a lookup
+     for the process based upon the passed-in pid.  If that fails we
+     will get either -ESRCH or -EPERM, otherwise the child exists and
+     is alive.  */
   if (errno == ESRCH || errno == EPERM)
     return 0;
 
@@ -2549,70 +2550,52 @@ linux_nat_do_thread_registers (bfd *obfd, ptid_t ptid,
   unsigned long lwp = ptid_get_lwp (ptid);
   struct gdbarch *gdbarch = current_gdbarch;
   const struct regset *regset;
-  int core_regset_p, record_reg_p;
+  int core_regset_p;
 
   core_regset_p = gdbarch_regset_from_core_section_p (gdbarch);
-  record_reg_p = 1;
-  if (core_regset_p)
-    {
-      regset = gdbarch_regset_from_core_section (gdbarch, ".reg",
-                                                sizeof (gregs));
-      if (regset)
-       regset->collect_regset (regset, current_regcache, -1,
-                               &gregs, sizeof (gregs));
-      else
-       record_reg_p = 0;
-    }
+  if (core_regset_p
+      && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg",
+                                                    sizeof (gregs))) != NULL
+      && regset->collect_regset != NULL)
+    regset->collect_regset (regset, current_regcache, -1,
+                           &gregs, sizeof (gregs));
   else
     fill_gregset (&gregs, -1);
 
-  if (record_reg_p)
-    note_data = (char *) elfcore_write_prstatus (obfd,
-                                                note_data,
-                                                note_size,
-                                                lwp,
-                                                stop_signal, &gregs);
-
-  record_reg_p = 1;
-  if (core_regset_p)
-    {
-      regset = gdbarch_regset_from_core_section (gdbarch, ".reg2",
-                                                sizeof (fpregs));
-      if (regset)
-       regset->collect_regset (regset, current_regcache, -1,
-                               &fpregs, sizeof (fpregs));
-      else
-       record_reg_p = 0;
-    }
+  note_data = (char *) elfcore_write_prstatus (obfd,
+                                              note_data,
+                                              note_size,
+                                              lwp,
+                                              stop_signal, &gregs);
+
+  if (core_regset_p
+      && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2",
+                                                    sizeof (fpregs))) != NULL
+      && regset->collect_regset != NULL)
+    regset->collect_regset (regset, current_regcache, -1,
+                           &fpregs, sizeof (fpregs));
   else
     fill_fpregset (&fpregs, -1);
 
-  if (record_reg_p)
-    note_data = (char *) elfcore_write_prfpreg (obfd,
-                                               note_data,
-                                               note_size,
-                                               &fpregs, sizeof (fpregs));
+  note_data = (char *) elfcore_write_prfpreg (obfd,
+                                             note_data,
+                                             note_size,
+                                             &fpregs, sizeof (fpregs));
 
 #ifdef FILL_FPXREGSET
-  record_reg_p = 1;
-  if (core_regset_p)
-    {
-      regset = gdbarch_regset_from_core_section (gdbarch, ".reg-xfp",
-                                                sizeof (fpxregs));
-      if (regset)
-       regset->collect_regset (regset, current_regcache, -1,
-                               &fpxregs, sizeof (fpxregs));
-      else
-       record_reg_p = 0;
-    }
+  if (core_regset_p
+      && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-xfp",
+                                                    sizeof (fpxregs))) != NULL
+      && regset->collect_regset != NULL)
+    regset->collect_regset (regset, current_regcache, -1,
+                           &fpxregs, sizeof (fpxregs));
   else
     fill_fpxregset (&fpxregs, -1);
 
-  if (record_reg_p)
-    note_data = (char *) elfcore_write_prxfpreg (obfd,
-                                                note_data,
-                                                note_size,
-                                                &fpxregs, sizeof (fpxregs));
+  note_data = (char *) elfcore_write_prxfpreg (obfd,
+                                              note_data,
+                                              note_size,
+                                              &fpxregs, sizeof (fpxregs));
 #endif
   return note_data;
 }
@@ -2715,7 +2698,8 @@ linux_nat_make_corefile_notes (bfd *obfd, int *note_size)
       note_data = thread_args.note_data;
     }
 
-  auxv_len = target_auxv_read (&current_target, &auxv);
+  auxv_len = target_read_alloc (&current_target, TARGET_OBJECT_AUXV,
+                               NULL, &auxv);
   if (auxv_len > 0)
     {
       note_data = elfcore_write_note (obfd, note_data, note_size,
@@ -3197,8 +3181,6 @@ linux_target (void)
 void
 linux_nat_add_target (struct target_ops *t)
 {
-  extern void thread_db_init (struct target_ops *);
-
   /* Save the provided single-threaded target.  We save this in a separate
      variable because another target we've inherited from (e.g. inf-ptrace)
      may have saved a pointer to T; we want to use it for the final
This page took 0.037276 seconds and 4 git commands to generate.