* defs.h (extract_signed_integer, extract_unsigned_integer,
[deliverable/binutils-gdb.git] / gdb / procfs.c
index 5976624a1b6f1f9f2258634bf169f3f19b8e24c6..80479e351709c24a1ee3404f3bfcfc2142a76a09 100644 (file)
@@ -1,26 +1,25 @@
 /* Machine independent support for SVR4 /proc (process file system) for GDB.
 
 /* Machine independent support for SVR4 /proc (process file system) for GDB.
 
-   Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation,
-   Inc.
+   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2006, 2007, 2008, 2009
+   Free Software Foundation, Inc.
 
    Written by Michael Snyder at Cygnus Solutions.
    Based on work by Fred Fish, Stu Grossman, Geoff Noer, and others.
 
 
    Written by Michael Snyder at Cygnus Solutions.
    Based on work by Fred Fish, Stu Grossman, Geoff Noer, and others.
 
-This file is part of GDB.
+   This file is part of GDB.
 
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software Foundation,
-Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "inferior.h"
 
 #include "defs.h"
 #include "inferior.h"
@@ -29,6 +28,8 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "elf-bfd.h"           /* for elfcore_write_* */
 #include "gdbcmd.h"
 #include "gdbthread.h"
 #include "elf-bfd.h"           /* for elfcore_write_* */
 #include "gdbcmd.h"
 #include "gdbthread.h"
+#include "regcache.h"
+#include "inf-child.h"
 
 #if defined (NEW_PROC_API)
 #define _STRUCTURED_PROC 1     /* Should be done by configure script. */
 
 #if defined (NEW_PROC_API)
 #define _STRUCTURED_PROC 1     /* Should be done by configure script. */
@@ -49,6 +50,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "gdb_assert.h"
 #include "inflow.h"
 #include "auxv.h"
 #include "gdb_assert.h"
 #include "inflow.h"
 #include "auxv.h"
+#include "procfs.h"
 
 /*
  * PROCFS.C
 
 /*
  * PROCFS.C
@@ -111,34 +113,36 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  * This module defines the GDB target vector and its methods.
  */
 
  * This module defines the GDB target vector and its methods.
  */
 
-static void procfs_open (char *, int);
-static void procfs_attach (char *, int);
-static void procfs_detach (char *, int);
-static void procfs_resume (ptid_t, int, enum target_signal);
-static int procfs_can_run (void);
-static void procfs_stop (void);
+static void procfs_attach (struct target_ops *, char *, int);
+static void procfs_detach (struct target_ops *, char *, int);
+static void procfs_resume (struct target_ops *,
+                          ptid_t, int, enum target_signal);
+static void procfs_stop (ptid_t);
 static void procfs_files_info (struct target_ops *);
 static void procfs_files_info (struct target_ops *);
-static void procfs_fetch_registers (int);
-static void procfs_store_registers (int);
+static void procfs_fetch_registers (struct target_ops *,
+                                   struct regcache *, int);
+static void procfs_store_registers (struct target_ops *,
+                                   struct regcache *, int);
 static void procfs_notice_signals (ptid_t);
 static void procfs_notice_signals (ptid_t);
-static void procfs_prepare_to_store (void);
-static void procfs_kill_inferior (void);
-static void procfs_mourn_inferior (void);
-static void procfs_create_inferior (char *, char *, char **, int);
-static ptid_t procfs_wait (ptid_t, struct target_waitstatus *);
-static int procfs_xfer_memory (CORE_ADDR, char *, int, int,
+static void procfs_kill_inferior (struct target_ops *ops);
+static void procfs_mourn_inferior (struct target_ops *ops);
+static void procfs_create_inferior (struct target_ops *, char *, 
+                                   char *, char **, int);
+static ptid_t procfs_wait (struct target_ops *,
+                          ptid_t, struct target_waitstatus *, int);
+static int procfs_xfer_memory (CORE_ADDR, gdb_byte *, int, int,
                               struct mem_attrib *attrib,
                               struct target_ops *);
 static LONGEST procfs_xfer_partial (struct target_ops *ops,
                                    enum target_object object,
                                    const char *annex,
                               struct mem_attrib *attrib,
                               struct target_ops *);
 static LONGEST procfs_xfer_partial (struct target_ops *ops,
                                    enum target_object object,
                                    const char *annex,
-                                   void *readbuf, const void *writebuf,
+                                   gdb_byte *readbuf, const gdb_byte *writebuf,
                                    ULONGEST offset, LONGEST len);
 
                                    ULONGEST offset, LONGEST len);
 
-static int procfs_thread_alive (ptid_t);
+static int procfs_thread_alive (struct target_ops *ops, ptid_t);
 
 
-void procfs_find_new_threads (void);
-char *procfs_pid_to_str (ptid_t);
+void procfs_find_new_threads (struct target_ops *ops);
+char *procfs_pid_to_str (struct target_ops *, ptid_t);
 
 static int proc_find_memory_regions (int (*) (CORE_ADDR,
                                              unsigned long,
 
 static int proc_find_memory_regions (int (*) (CORE_ADDR,
                                              unsigned long,
@@ -150,57 +154,74 @@ static char * procfs_make_note_section (bfd *, int *);
 
 static int procfs_can_use_hw_breakpoint (int, int, int);
 
 
 static int procfs_can_use_hw_breakpoint (int, int, int);
 
-struct target_ops procfs_ops;          /* the target vector */
+#if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64)
+/* When GDB is built as 64-bit application on Solaris, the auxv data is
+   presented in 64-bit format.  We need to provide a custom parser to handle 
+   that.  */
+static int
+procfs_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
+                  gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
+{
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+  gdb_byte *ptr = *readptr;
 
 
-static void
-init_procfs_ops (void)
+  if (endptr == ptr)
+    return 0;
+  
+  if (endptr - ptr < 8 * 2)
+    return -1;
+
+  *typep = extract_unsigned_integer (ptr, 4, byte_order);
+  ptr += 8;
+  /* The size of data is always 64-bit.  If the application is 32-bit,
+     it will be zero extended, as expected.  */
+  *valp = extract_unsigned_integer (ptr, 8, byte_order);
+  ptr += 8;
+
+  *readptr = ptr;
+  return 1;
+}
+#endif
+
+struct target_ops *
+procfs_target (void)
 {
 {
-  procfs_ops.to_shortname           = "procfs";
-  procfs_ops.to_longname            = "Unix /proc child process";
-  procfs_ops.to_doc                 =
+  struct target_ops *t = inf_child_target ();
+
+  t->to_shortname           = "procfs";
+  t->to_longname            = "Unix /proc child process";
+  t->to_doc                 =
     "Unix /proc child process (started by the \"run\" command).";
     "Unix /proc child process (started by the \"run\" command).";
-  procfs_ops.to_open                = procfs_open;
-  procfs_ops.to_can_run             = procfs_can_run;
-  procfs_ops.to_create_inferior     = procfs_create_inferior;
-  procfs_ops.to_kill                = procfs_kill_inferior;
-  procfs_ops.to_mourn_inferior      = procfs_mourn_inferior;
-  procfs_ops.to_attach              = procfs_attach;
-  procfs_ops.to_detach              = procfs_detach;
-  procfs_ops.to_wait                = procfs_wait;
-  procfs_ops.to_resume              = procfs_resume;
-  procfs_ops.to_prepare_to_store    = procfs_prepare_to_store;
-  procfs_ops.to_fetch_registers     = procfs_fetch_registers;
-  procfs_ops.to_store_registers     = procfs_store_registers;
-  procfs_ops.to_xfer_partial        = procfs_xfer_partial;
-  procfs_ops.deprecated_xfer_memory = procfs_xfer_memory;
-  procfs_ops.to_insert_breakpoint   =  memory_insert_breakpoint;
-  procfs_ops.to_remove_breakpoint   =  memory_remove_breakpoint;
-  procfs_ops.to_notice_signals      = procfs_notice_signals;
-  procfs_ops.to_files_info          = procfs_files_info;
-  procfs_ops.to_stop                = procfs_stop;
-
-  procfs_ops.to_terminal_init       = terminal_init_inferior;
-  procfs_ops.to_terminal_inferior   = terminal_inferior;
-  procfs_ops.to_terminal_ours_for_output = terminal_ours_for_output;
-  procfs_ops.to_terminal_ours       = terminal_ours;
-  procfs_ops.to_terminal_save_ours  = terminal_save_ours;
-  procfs_ops.to_terminal_info       = child_terminal_info;
-
-  procfs_ops.to_find_new_threads    = procfs_find_new_threads;
-  procfs_ops.to_thread_alive        = procfs_thread_alive;
-  procfs_ops.to_pid_to_str          = procfs_pid_to_str;
-
-  procfs_ops.to_has_all_memory      = 1;
-  procfs_ops.to_has_memory          = 1;
-  procfs_ops.to_has_execution       = 1;
-  procfs_ops.to_has_stack           = 1;
-  procfs_ops.to_has_registers       = 1;
-  procfs_ops.to_stratum             = process_stratum;
-  procfs_ops.to_has_thread_control  = tc_schedlock;
-  procfs_ops.to_find_memory_regions = proc_find_memory_regions;
-  procfs_ops.to_make_corefile_notes = procfs_make_note_section;
-  procfs_ops.to_can_use_hw_breakpoint = procfs_can_use_hw_breakpoint;
-  procfs_ops.to_magic               = OPS_MAGIC;
+  t->to_create_inferior     = procfs_create_inferior;
+  t->to_kill                = procfs_kill_inferior;
+  t->to_mourn_inferior      = procfs_mourn_inferior;
+  t->to_attach              = procfs_attach;
+  t->to_detach              = procfs_detach;
+  t->to_wait                = procfs_wait;
+  t->to_resume              = procfs_resume;
+  t->to_fetch_registers     = procfs_fetch_registers;
+  t->to_store_registers     = procfs_store_registers;
+  t->to_xfer_partial        = procfs_xfer_partial;
+  t->deprecated_xfer_memory = procfs_xfer_memory;
+  t->to_notice_signals      = procfs_notice_signals;
+  t->to_files_info          = procfs_files_info;
+  t->to_stop                = procfs_stop;
+
+  t->to_find_new_threads    = procfs_find_new_threads;
+  t->to_thread_alive        = procfs_thread_alive;
+  t->to_pid_to_str          = procfs_pid_to_str;
+
+  t->to_has_thread_control  = tc_schedlock;
+  t->to_find_memory_regions = proc_find_memory_regions;
+  t->to_make_corefile_notes = procfs_make_note_section;
+
+#if defined(PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64)
+  t->to_auxv_parse = procfs_auxv_parse;
+#endif
+
+  t->to_magic               = OPS_MAGIC;
+
+  return t;
 }
 
 /* =================== END, TARGET_OPS "MODULE" =================== */
 }
 
 /* =================== END, TARGET_OPS "MODULE" =================== */
@@ -682,7 +703,7 @@ open_procinfo_files (procinfo *pi, int which)
 static procinfo *
 create_procinfo (int pid, int tid)
 {
 static procinfo *
 create_procinfo (int pid, int tid)
 {
-  procinfo *pi, *parent;
+  procinfo *pi, *parent = NULL;
 
   if ((pi = find_procinfo (pid, tid)))
     return pi;                 /* Already exists, nothing to do. */
 
   if ((pi = find_procinfo (pid, tid)))
     return pi;                 /* Already exists, nothing to do. */
@@ -833,7 +854,7 @@ dead_procinfo (procinfo *pi, char *msg, int kill_p)
     kill (pi->pid, SIGKILL);
 
   destroy_procinfo (pi);
     kill (pi->pid, SIGKILL);
 
   destroy_procinfo (pi);
-  error ((msg));
+  error ("%s", msg);
 }
 
 /*
 }
 
 /*
@@ -2485,6 +2506,8 @@ proc_set_current_signal (procinfo *pi, int signo)
     char sinfo[sizeof (gdb_siginfo_t)];
   } arg;
   gdb_siginfo_t *mysinfo;
     char sinfo[sizeof (gdb_siginfo_t)];
   } arg;
   gdb_siginfo_t *mysinfo;
+  ptid_t wait_ptid;
+  struct target_waitstatus wait_status;
 
   /*
    * We should never have to apply this operation to any procinfo
 
   /*
    * We should never have to apply this operation to any procinfo
@@ -2508,10 +2531,31 @@ proc_set_current_signal (procinfo *pi, int signo)
 
   /* The pointer is just a type alias.  */
   mysinfo = (gdb_siginfo_t *) &arg.sinfo;
 
   /* The pointer is just a type alias.  */
   mysinfo = (gdb_siginfo_t *) &arg.sinfo;
-  mysinfo->si_signo = signo;
-  mysinfo->si_code  = 0;
-  mysinfo->si_pid   = getpid ();       /* ?why? */
-  mysinfo->si_uid   = getuid ();       /* ?why? */
+  get_last_target_status (&wait_ptid, &wait_status);
+  if (ptid_equal (wait_ptid, inferior_ptid)
+      && wait_status.kind == TARGET_WAITKIND_STOPPED
+      && wait_status.value.sig == target_signal_from_host (signo)
+      && proc_get_status (pi)
+#ifdef NEW_PROC_API
+      && pi->prstatus.pr_lwp.pr_info.si_signo == signo
+#else
+      && pi->prstatus.pr_info.si_signo == signo
+#endif
+      )
+    /* Use the siginfo associated with the signal being
+       redelivered.  */
+#ifdef NEW_PROC_API
+    memcpy (mysinfo, &pi->prstatus.pr_lwp.pr_info, sizeof (gdb_siginfo_t));
+#else
+    memcpy (mysinfo, &pi->prstatus.pr_info, sizeof (gdb_siginfo_t));
+#endif
+  else
+    {
+      mysinfo->si_signo = signo;
+      mysinfo->si_code  = 0;
+      mysinfo->si_pid   = getpid ();       /* ?why? */
+      mysinfo->si_uid   = getuid ();       /* ?why? */
+    }
 
 #ifdef NEW_PROC_API
   arg.cmd = PCSSIG;
 
 #ifdef NEW_PROC_API
   arg.cmd = PCSSIG;
@@ -2842,10 +2886,12 @@ proc_parent_pid (procinfo *pi)
 static void *
 procfs_address_to_host_pointer (CORE_ADDR addr)
 {
 static void *
 procfs_address_to_host_pointer (CORE_ADDR addr)
 {
+  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
   void *ptr;
 
   void *ptr;
 
-  gdb_assert (sizeof (ptr) == TYPE_LENGTH (builtin_type_void_data_ptr));
-  ADDRESS_TO_POINTER (builtin_type_void_data_ptr, &ptr, addr);
+  gdb_assert (sizeof (ptr) == TYPE_LENGTH (ptr_type));
+  gdbarch_address_to_pointer (target_gdbarch, ptr_type,
+                             (gdb_byte *) &ptr, addr);
   return ptr;
 }
 
   return ptr;
 }
 
@@ -2857,7 +2903,10 @@ procfs_address_to_host_pointer (CORE_ADDR addr)
 int
 proc_set_watchpoint (procinfo *pi, CORE_ADDR addr, int len, int wflags)
 {
 int
 proc_set_watchpoint (procinfo *pi, CORE_ADDR addr, int len, int wflags)
 {
-#if !defined (TARGET_HAS_HARDWARE_WATCHPOINTS)
+#if !defined (PCWATCH) && !defined (PIOCSWATCH)
+  /* If neither or these is defined, we can't support watchpoints.
+     This just avoids possibly failing to compile the below on such
+     systems.  */
   return 0;
 #else
 /* Horrible hack!  Detect Solaris 2.5, because this doesn't work on 2.5 */
   return 0;
 #else
 /* Horrible hack!  Detect Solaris 2.5, because this doesn't work on 2.5 */
@@ -2895,7 +2944,7 @@ proc_set_watchpoint (procinfo *pi, CORE_ADDR addr, int len, int wflags)
 #endif
 }
 
 #endif
 }
 
-#ifdef TM_I386SOL2_H           /* Is it hokey to use this? */
+#if (defined(__i386__) || defined(__x86_64__)) && defined (sun)
 
 #include <sys/sysi86.h>
 
 
 #include <sys/sysi86.h>
 
@@ -2987,7 +3036,45 @@ proc_get_LDT_entry (procinfo *pi, int key)
 #endif
 }
 
 #endif
 }
 
-#endif /* TM_I386SOL2_H */
+/*
+ * Function: procfs_find_LDT_entry
+ *
+ * Input:
+ *   ptid_t ptid;      // The GDB-style pid-plus-LWP.
+ *
+ * Return:
+ *   pointer to the corresponding LDT entry.
+ */
+
+struct ssd *
+procfs_find_LDT_entry (ptid_t ptid)
+{
+  gdb_gregset_t *gregs;
+  int            key;
+  procinfo      *pi;
+
+  /* Find procinfo for the lwp. */
+  if ((pi = find_procinfo (PIDGET (ptid), TIDGET (ptid))) == NULL)
+    {
+      warning (_("procfs_find_LDT_entry: could not find procinfo for %d:%ld."),
+              PIDGET (ptid), TIDGET (ptid));
+      return NULL;
+    }
+  /* get its general registers. */
+  if ((gregs = proc_get_gregs (pi)) == NULL)
+    {
+      warning (_("procfs_find_LDT_entry: could not read gregs for %d:%ld."),
+              PIDGET (ptid), TIDGET (ptid));
+      return NULL;
+    }
+  /* Now extract the GS register's lower 16 bits. */
+  key = (*gregs)[GS] & 0xffff;
+
+  /* Find the matching entry and return it. */
+  return proc_get_LDT_entry (pi, key);
+}
+
+#endif
 
 /* =============== END, non-thread part of /proc  "MODULE" =============== */
 
 
 /* =============== END, non-thread part of /proc  "MODULE" =============== */
 
@@ -3374,7 +3461,7 @@ static void remove_dbx_link_breakpoint (void);
    the address of the breakpoint, and the code that was replaced by
    a breakpoint.  */
 static int dbx_link_bpt_addr = 0;
    the address of the breakpoint, and the code that was replaced by
    a breakpoint.  */
 static int dbx_link_bpt_addr = 0;
-static char dbx_link_shadow_contents[BREAKPOINT_MAX];
+static void *dbx_link_bpt;
 
 /*
  * Function: procfs_debug_inferior
 
 /*
  * Function: procfs_debug_inferior
@@ -3506,13 +3593,13 @@ procfs_debug_inferior (procinfo *pi)
 }
 
 static void
 }
 
 static void
-procfs_attach (char *args, int from_tty)
+procfs_attach (struct target_ops *ops, char *args, int from_tty)
 {
   char *exec_file;
   int   pid;
 
   if (!args)
 {
   char *exec_file;
   int   pid;
 
   if (!args)
-    error_no_arg ("process-id to attach");
+    error_no_arg (_("process-id to attach"));
 
   pid = atoi (args);
   if (pid == getpid ())
 
   pid = atoi (args);
   if (pid == getpid ())
@@ -3523,36 +3610,36 @@ procfs_attach (char *args, int from_tty)
       exec_file = get_exec_file (0);
 
       if (exec_file)
       exec_file = get_exec_file (0);
 
       if (exec_file)
-       printf_filtered ("Attaching to program `%s', %s\n",
+       printf_filtered (_("Attaching to program `%s', %s\n"),
                         exec_file, target_pid_to_str (pid_to_ptid (pid)));
       else
                         exec_file, target_pid_to_str (pid_to_ptid (pid)));
       else
-       printf_filtered ("Attaching to %s\n",
+       printf_filtered (_("Attaching to %s\n"),
                         target_pid_to_str (pid_to_ptid (pid)));
 
       fflush (stdout);
     }
   inferior_ptid = do_attach (pid_to_ptid (pid));
                         target_pid_to_str (pid_to_ptid (pid)));
 
       fflush (stdout);
     }
   inferior_ptid = do_attach (pid_to_ptid (pid));
-  push_target (&procfs_ops);
+  push_target (ops);
 }
 
 static void
 }
 
 static void
-procfs_detach (char *args, int from_tty)
+procfs_detach (struct target_ops *ops, char *args, int from_tty)
 {
   int sig = 0;
 {
   int sig = 0;
+  int pid = PIDGET (inferior_ptid);
 
   if (args)
     sig = atoi (args);
 
   if (from_tty)
     {
 
   if (args)
     sig = atoi (args);
 
   if (from_tty)
     {
-      int pid = PIDGET (inferior_ptid);
       char *exec_file;
 
       exec_file = get_exec_file (0);
       if (exec_file == NULL)
        exec_file = "";
 
       char *exec_file;
 
       exec_file = get_exec_file (0);
       if (exec_file == NULL)
        exec_file = "";
 
-      printf_filtered ("Detaching from program: %s, %s\n", exec_file,
+      printf_filtered (_("Detaching from program: %s, %s\n"), exec_file,
                       target_pid_to_str (pid_to_ptid (pid)));
       gdb_flush (gdb_stdout);
     }
                       target_pid_to_str (pid_to_ptid (pid)));
       gdb_flush (gdb_stdout);
     }
@@ -3560,14 +3647,17 @@ procfs_detach (char *args, int from_tty)
   do_detach (sig);
 
   inferior_ptid = null_ptid;
   do_detach (sig);
 
   inferior_ptid = null_ptid;
-  unpush_target (&procfs_ops);
+  detach_inferior (pid);
+  unpush_target (ops);
 }
 
 static ptid_t
 do_attach (ptid_t ptid)
 {
   procinfo *pi;
 }
 
 static ptid_t
 do_attach (ptid_t ptid)
 {
   procinfo *pi;
+  struct inferior *inf;
   int fail;
   int fail;
+  int lwpid;
 
   if ((pi = create_procinfo (PIDGET (ptid), 0)) == NULL)
     perror (_("procfs: out of memory in 'attach'"));
 
   if ((pi = create_procinfo (PIDGET (ptid), 0)) == NULL)
     perror (_("procfs: out of memory in 'attach'"));
@@ -3615,9 +3705,19 @@ do_attach (ptid_t ptid)
   if ((fail = procfs_debug_inferior (pi)) != 0)
     dead_procinfo (pi, "do_attach: failed in procfs_debug_inferior", NOKILL);
 
   if ((fail = procfs_debug_inferior (pi)) != 0)
     dead_procinfo (pi, "do_attach: failed in procfs_debug_inferior", NOKILL);
 
+  inf = add_inferior (pi->pid);
   /* Let GDB know that the inferior was attached.  */
   /* Let GDB know that the inferior was attached.  */
-  attach_flag = 1;
-  return MERGEPID (pi->pid, proc_get_current_thread (pi));
+  inf->attach_flag = 1;
+
+  /* Create a procinfo for the current lwp.  */
+  lwpid = proc_get_current_thread (pi);
+  create_procinfo (pi->pid, lwpid);
+
+  /* Add it to gdb's thread list.  */
+  ptid = MERGEPID (pi->pid, lwpid);
+  add_thread (ptid);
+
+  return ptid;
 }
 
 static void
 }
 
 static void
@@ -3648,7 +3748,7 @@ do_detach (int signo)
 
   if (signo || (proc_flags (pi) & (PR_STOPPED | PR_ISTOP)))
     if (signo || !(pi->was_stopped) ||
 
   if (signo || (proc_flags (pi) & (PR_STOPPED | PR_ISTOP)))
     if (signo || !(pi->was_stopped) ||
-       query ("Was stopped when attached, make it runnable again? "))
+       query (_("Was stopped when attached, make it runnable again? ")))
       {
        /* Clear any pending signal.  */
        if (!proc_clear_current_fault (pi))
       {
        /* Clear any pending signal.  */
        if (!proc_clear_current_fault (pi))
@@ -3661,7 +3761,6 @@ do_detach (int signo)
          proc_warn (pi, "do_detach, set_rlc", __LINE__);
       }
 
          proc_warn (pi, "do_detach, set_rlc", __LINE__);
       }
 
-  attach_flag = 0;
   destroy_procinfo (pi);
 }
 
   destroy_procinfo (pi);
 }
 
@@ -3680,21 +3779,16 @@ do_detach (int signo)
    when the process is resumed.  */
 
 static void
    when the process is resumed.  */
 
 static void
-procfs_fetch_registers (int regnum)
+procfs_fetch_registers (struct target_ops *ops,
+                       struct regcache *regcache, int regnum)
 {
   gdb_gregset_t *gregs;
   procinfo *pi;
   int pid = PIDGET (inferior_ptid);
   int tid = TIDGET (inferior_ptid);
 {
   gdb_gregset_t *gregs;
   procinfo *pi;
   int pid = PIDGET (inferior_ptid);
   int tid = TIDGET (inferior_ptid);
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
 
 
-  /* First look up procinfo for the main process.  */
-  pi = find_procinfo_or_die (pid, 0);
-
-  /* If the event thread is not the same as GDB's requested thread
-     (ie. inferior_ptid), then look up procinfo for the requested
-     thread.  */
-  if (tid != 0 && tid != proc_get_current_thread (pi))
-    pi = find_procinfo_or_die (pid, tid);
+  pi = find_procinfo_or_die (pid, tid);
 
   if (pi == NULL)
     error (_("procfs: fetch_registers failed to find procinfo for %s"),
 
   if (pi == NULL)
     error (_("procfs: fetch_registers failed to find procinfo for %s"),
@@ -3704,39 +3798,25 @@ procfs_fetch_registers (int regnum)
   if (gregs == NULL)
     proc_error (pi, "fetch_registers, get_gregs", __LINE__);
 
   if (gregs == NULL)
     proc_error (pi, "fetch_registers, get_gregs", __LINE__);
 
-  supply_gregset (gregs);
+  supply_gregset (regcache, (const gdb_gregset_t *) gregs);
 
 
-  if (FP0_REGNUM >= 0)         /* Do we have an FPU?  */
+  if (gdbarch_fp0_regnum (gdbarch) >= 0) /* Do we have an FPU?  */
     {
       gdb_fpregset_t *fpregs;
 
     {
       gdb_fpregset_t *fpregs;
 
-      if ((regnum >= 0 && regnum < FP0_REGNUM)
-         || regnum == PC_REGNUM
-         || regnum == SP_REGNUM)
+      if ((regnum >= 0 && regnum < gdbarch_fp0_regnum (gdbarch))
+         || regnum == gdbarch_pc_regnum (gdbarch)
+         || regnum == gdbarch_sp_regnum (gdbarch))
        return;                 /* Not a floating point register.  */
 
       fpregs = proc_get_fpregs (pi);
       if (fpregs == NULL)
        proc_error (pi, "fetch_registers, get_fpregs", __LINE__);
 
        return;                 /* Not a floating point register.  */
 
       fpregs = proc_get_fpregs (pi);
       if (fpregs == NULL)
        proc_error (pi, "fetch_registers, get_fpregs", __LINE__);
 
-      supply_fpregset (fpregs);
+      supply_fpregset (regcache, (const gdb_fpregset_t *) fpregs);
     }
 }
 
     }
 }
 
-/* Get ready to modify the registers array.  On machines which store
-   individual registers, this doesn't need to do anything.  On
-   machines which store all the registers in one fell swoop, such as
-   /proc, this makes sure that registers contains all the registers
-   from the program being debugged.  */
-
-static void
-procfs_prepare_to_store (void)
-{
-#ifdef CHILD_PREPARE_TO_STORE
-  CHILD_PREPARE_TO_STORE ();
-#endif
-}
-
 /* Store register REGNUM back into the inferior.  If REGNUM is -1, do
    this for all registers.
 
 /* Store register REGNUM back into the inferior.  If REGNUM is -1, do
    this for all registers.
 
@@ -3748,21 +3828,16 @@ procfs_prepare_to_store (void)
    writing one register might affect the value of others, etc.  */
 
 static void
    writing one register might affect the value of others, etc.  */
 
 static void
-procfs_store_registers (int regnum)
+procfs_store_registers (struct target_ops *ops,
+                       struct regcache *regcache, int regnum)
 {
   gdb_gregset_t *gregs;
   procinfo *pi;
   int pid = PIDGET (inferior_ptid);
   int tid = TIDGET (inferior_ptid);
 {
   gdb_gregset_t *gregs;
   procinfo *pi;
   int pid = PIDGET (inferior_ptid);
   int tid = TIDGET (inferior_ptid);
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
 
 
-  /* First find procinfo for main process.  */
-  pi = find_procinfo_or_die (pid, 0);
-
-  /* If the event thread is not the same as GDB's requested thread
-     (ie. inferior_ptid), then look up procinfo for the requested
-     thread.  */
-  if (tid != 0 && tid != proc_get_current_thread (pi))
-    pi = find_procinfo_or_die (pid, tid);
+  pi = find_procinfo_or_die (pid, tid);
 
   if (pi == NULL)
     error (_("procfs: store_registers: failed to find procinfo for %s"),
 
   if (pi == NULL)
     error (_("procfs: store_registers: failed to find procinfo for %s"),
@@ -3772,24 +3847,24 @@ procfs_store_registers (int regnum)
   if (gregs == NULL)
     proc_error (pi, "store_registers, get_gregs", __LINE__);
 
   if (gregs == NULL)
     proc_error (pi, "store_registers, get_gregs", __LINE__);
 
-  fill_gregset (gregs, regnum);
+  fill_gregset (regcache, gregs, regnum);
   if (!proc_set_gregs (pi))
     proc_error (pi, "store_registers, set_gregs", __LINE__);
 
   if (!proc_set_gregs (pi))
     proc_error (pi, "store_registers, set_gregs", __LINE__);
 
-  if (FP0_REGNUM >= 0)         /* Do we have an FPU?  */
+  if (gdbarch_fp0_regnum (gdbarch) >= 0) /* Do we have an FPU?  */
     {
       gdb_fpregset_t *fpregs;
 
     {
       gdb_fpregset_t *fpregs;
 
-      if ((regnum >= 0 && regnum < FP0_REGNUM)
-         || regnum == PC_REGNUM
-         || regnum == SP_REGNUM)
+      if ((regnum >= 0 && regnum < gdbarch_fp0_regnum (gdbarch))
+         || regnum == gdbarch_pc_regnum (gdbarch)
+         || regnum == gdbarch_sp_regnum (gdbarch))
        return;                 /* Not a floating point register.  */
 
       fpregs = proc_get_fpregs (pi);
       if (fpregs == NULL)
        proc_error (pi, "store_registers, get_fpregs", __LINE__);
 
        return;                 /* Not a floating point register.  */
 
       fpregs = proc_get_fpregs (pi);
       if (fpregs == NULL)
        proc_error (pi, "store_registers, get_fpregs", __LINE__);
 
-      fill_fpregset (fpregs, regnum);
+      fill_fpregset (regcache, fpregs, regnum);
       if (!proc_set_fpregs (pi))
        proc_error (pi, "store_registers, set_fpregs", __LINE__);
     }
       if (!proc_set_fpregs (pi))
        proc_error (pi, "store_registers, set_fpregs", __LINE__);
     }
@@ -3875,7 +3950,8 @@ syscall_is_lwp_create (procinfo *pi, int scall)
  */
 
 static ptid_t
  */
 
 static ptid_t
-procfs_wait (ptid_t ptid, struct target_waitstatus *status)
+procfs_wait (struct target_ops *ops,
+            ptid_t ptid, struct target_waitstatus *status, int options)
 {
   /* First cut: loosely based on original version 2.1 */
   procinfo *pi;
 {
   /* First cut: loosely based on original version 2.1 */
   procinfo *pi;
@@ -3973,14 +4049,17 @@ wait_again:
              case PR_SYSENTRY:
                if (syscall_is_lwp_exit (pi, what))
                  {
              case PR_SYSENTRY:
                if (syscall_is_lwp_exit (pi, what))
                  {
-                   printf_filtered ("[%s exited]\n",
-                                    target_pid_to_str (retval));
+                   if (print_thread_events)
+                     printf_unfiltered (_("[%s exited]\n"),
+                                        target_pid_to_str (retval));
                    delete_thread (retval);
                    status->kind = TARGET_WAITKIND_SPURIOUS;
                    return retval;
                  }
                else if (syscall_is_exit (pi, what))
                  {
                    delete_thread (retval);
                    status->kind = TARGET_WAITKIND_SPURIOUS;
                    return retval;
                  }
                else if (syscall_is_exit (pi, what))
                  {
+                   struct inferior *inf;
+
                    /* Handle SYS_exit call only */
                    /* Stopped at entry to SYS_exit.
                       Make it runnable, resume it, then use
                    /* Handle SYS_exit call only */
                    /* Stopped at entry to SYS_exit.
                       Make it runnable, resume it, then use
@@ -3994,7 +4073,9 @@ wait_again:
                       TARGET_WAITKIND_SPURIOUS.  */
                    if (!proc_run_process (pi, 0, 0))
                      proc_error (pi, "target_wait, run_process", __LINE__);
                       TARGET_WAITKIND_SPURIOUS.  */
                    if (!proc_run_process (pi, 0, 0))
                      proc_error (pi, "target_wait, run_process", __LINE__);
-                   if (attach_flag)
+
+                   inf = find_inferior_pid (pi->pid);
+                   if (inf->attach_flag)
                      {
                        /* Don't call wait: simulate waiting for exit,
                           return a "success" exit code.  Bogus: what if
                      {
                        /* Don't call wait: simulate waiting for exit,
                           return a "success" exit code.  Bogus: what if
@@ -4020,7 +4101,7 @@ wait_again:
                  }
                else
                  {
                  }
                else
                  {
-                   printf_filtered ("procfs: trapped on entry to ");
+                   printf_filtered (_("procfs: trapped on entry to "));
                    proc_prettyprint_syscall (proc_what (pi), 0);
                    printf_filtered ("\n");
 #ifndef PIOCSSPCACT
                    proc_prettyprint_syscall (proc_what (pi), 0);
                    printf_filtered ("\n");
 #ifndef PIOCSSPCACT
@@ -4030,7 +4111,7 @@ wait_again:
                      if ((nsysargs = proc_nsysarg (pi)) > 0 &&
                          (sysargs  = proc_sysargs (pi)) != NULL)
                        {
                      if ((nsysargs = proc_nsysarg (pi)) > 0 &&
                          (sysargs  = proc_sysargs (pi)) != NULL)
                        {
-                         printf_filtered ("%ld syscall arguments:\n", nsysargs);
+                         printf_filtered (_("%ld syscall arguments:\n"), nsysargs);
                          for (i = 0; i < nsysargs; i++)
                            printf_filtered ("#%ld: 0x%08lx\n",
                                             i, sysargs[i]);
                          for (i = 0; i < nsysargs; i++)
                            printf_filtered ("#%ld: 0x%08lx\n",
                                             i, sysargs[i]);
@@ -4096,19 +4177,17 @@ wait_again:
                    temp_ptid = MERGEPID (pi->pid, temp_tid);
                    /* If not in GDB's thread list, add it.  */
                    if (!in_thread_list (temp_ptid))
                    temp_ptid = MERGEPID (pi->pid, temp_tid);
                    /* If not in GDB's thread list, add it.  */
                    if (!in_thread_list (temp_ptid))
-                     {
-                       printf_filtered ("[New %s]\n",
-                                        target_pid_to_str (temp_ptid));
-                       add_thread (temp_ptid);
-                     }
+                     add_thread (temp_ptid);
+
                    /* Return to WFI, but tell it to immediately resume. */
                    status->kind = TARGET_WAITKIND_SPURIOUS;
                    return inferior_ptid;
                  }
                else if (syscall_is_lwp_exit (pi, what))
                  {
                    /* Return to WFI, but tell it to immediately resume. */
                    status->kind = TARGET_WAITKIND_SPURIOUS;
                    return inferior_ptid;
                  }
                else if (syscall_is_lwp_exit (pi, what))
                  {
-                   printf_filtered ("[%s exited]\n",
-                                    target_pid_to_str (retval));
+                   if (print_thread_events)
+                     printf_unfiltered (_("[%s exited]\n"),
+                                        target_pid_to_str (retval));
                    delete_thread (retval);
                    status->kind = TARGET_WAITKIND_SPURIOUS;
                    return retval;
                    delete_thread (retval);
                    status->kind = TARGET_WAITKIND_SPURIOUS;
                    return retval;
@@ -4124,7 +4203,7 @@ wait_again:
                  }
                else
                  {
                  }
                else
                  {
-                   printf_filtered ("procfs: trapped on exit from ");
+                   printf_filtered (_("procfs: trapped on exit from "));
                    proc_prettyprint_syscall (proc_what (pi), 0);
                    printf_filtered ("\n");
 #ifndef PIOCSSPCACT
                    proc_prettyprint_syscall (proc_what (pi), 0);
                    printf_filtered ("\n");
 #ifndef PIOCSSPCACT
@@ -4134,7 +4213,7 @@ wait_again:
                      if ((nsysargs = proc_nsysarg (pi)) > 0 &&
                          (sysargs  = proc_sysargs (pi)) != NULL)
                        {
                      if ((nsysargs = proc_nsysarg (pi)) > 0 &&
                          (sysargs  = proc_sysargs (pi)) != NULL)
                        {
-                         printf_filtered ("%ld syscall arguments:\n", nsysargs);
+                         printf_filtered (_("%ld syscall arguments:\n"), nsysargs);
                          for (i = 0; i < nsysargs; i++)
                            printf_filtered ("#%ld: 0x%08lx\n",
                                             i, sysargs[i]);
                          for (i = 0; i < nsysargs; i++)
                            printf_filtered ("#%ld: 0x%08lx\n",
                                             i, sysargs[i]);
@@ -4152,7 +4231,7 @@ wait_again:
 #else
                if (retry < 5)
                  {
 #else
                if (retry < 5)
                  {
-                   printf_filtered ("Retry #%d:\n", retry);
+                   printf_filtered (_("Retry #%d:\n"), retry);
                    pi->status_valid = 0;
                    goto wait_again;
                  }
                    pi->status_valid = 0;
                    goto wait_again;
                  }
@@ -4166,11 +4245,7 @@ wait_again:
                    /* If not in GDB's thread list, add it.  */
                    temp_ptid = MERGEPID (pi->pid, temp_tid);
                    if (!in_thread_list (temp_ptid))
                    /* If not in GDB's thread list, add it.  */
                    temp_ptid = MERGEPID (pi->pid, temp_tid);
                    if (!in_thread_list (temp_ptid))
-                     {
-                       printf_filtered ("[New %s]\n",
-                                        target_pid_to_str (temp_ptid));
-                       add_thread (temp_ptid);
-                     }
+                     add_thread (temp_ptid);
 
                    status->kind = TARGET_WAITKIND_STOPPED;
                    status->value.sig = 0;
 
                    status->kind = TARGET_WAITKIND_STOPPED;
                    status->value.sig = 0;
@@ -4207,7 +4282,8 @@ wait_again:
                      then remove it.  See comments in procfs_init_inferior()
                      for more details.  */
                   if (dbx_link_bpt_addr != 0
                      then remove it.  See comments in procfs_init_inferior()
                      for more details.  */
                   if (dbx_link_bpt_addr != 0
-                      && dbx_link_bpt_addr == read_pc ())
+                      && dbx_link_bpt_addr
+                        == regcache_read_pc (get_current_regcache ()))
                     remove_dbx_link_breakpoint ();
 
                  wstat = (SIGTRAP << 8) | 0177;
                     remove_dbx_link_breakpoint ();
 
                  wstat = (SIGTRAP << 8) | 0177;
@@ -4230,7 +4306,7 @@ wait_again:
                default:         /* FIXME: use si_signo if possible for fault */
                  retval = pid_to_ptid (-1);
                  printf_filtered ("procfs:%d -- ", __LINE__);
                default:         /* FIXME: use si_signo if possible for fault */
                  retval = pid_to_ptid (-1);
                  printf_filtered ("procfs:%d -- ", __LINE__);
-                 printf_filtered ("child stopped for unknown reason:\n");
+                 printf_filtered (_("child stopped for unknown reason:\n"));
                  proc_prettyprint_why (why, what, 1);
                  error (_("... giving up..."));
                  break;
                  proc_prettyprint_why (why, what, 1);
                  error (_("... giving up..."));
                  break;
@@ -4238,7 +4314,7 @@ wait_again:
                break;  /* case PR_FAULTED: */
              default:  /* switch (why) unmatched */
                printf_filtered ("procfs:%d -- ", __LINE__);
                break;  /* case PR_FAULTED: */
              default:  /* switch (why) unmatched */
                printf_filtered ("procfs:%d -- ", __LINE__);
-               printf_filtered ("child stopped for unknown reason:\n");
+               printf_filtered (_("child stopped for unknown reason:\n"));
                proc_prettyprint_why (why, what, 1);
                error (_("... giving up..."));
                break;
                proc_prettyprint_why (why, what, 1);
                error (_("... giving up..."));
                break;
@@ -4257,24 +4333,9 @@ wait_again:
                   * If we don't create a procinfo, resume may be unhappy
                   * later.
                   */
                   * If we don't create a procinfo, resume may be unhappy
                   * later.
                   */
-                 printf_filtered ("[New %s]\n", target_pid_to_str (retval));
                  add_thread (retval);
                  if (find_procinfo (PIDGET (retval), TIDGET (retval)) == NULL)
                    create_procinfo (PIDGET (retval), TIDGET (retval));
                  add_thread (retval);
                  if (find_procinfo (PIDGET (retval), TIDGET (retval)) == NULL)
                    create_procinfo (PIDGET (retval), TIDGET (retval));
-
-                 /* In addition, it's possible that this is the first
-                  * new thread we've seen, in which case we may not
-                  * have created entries for inferior_ptid yet.
-                  */
-                 if (TIDGET (inferior_ptid) != 0)
-                   {
-                     if (!in_thread_list (inferior_ptid))
-                       add_thread (inferior_ptid);
-                     if (find_procinfo (PIDGET (inferior_ptid),
-                                        TIDGET (inferior_ptid)) == NULL)
-                       create_procinfo (PIDGET (inferior_ptid),
-                                        TIDGET (inferior_ptid));
-                   }
                }
            }
          else  /* flags do not indicate STOPPED */
                }
            }
          else  /* flags do not indicate STOPPED */
@@ -4299,18 +4360,18 @@ wait_again:
 
 static LONGEST
 procfs_xfer_partial (struct target_ops *ops, enum target_object object,
 
 static LONGEST
 procfs_xfer_partial (struct target_ops *ops, enum target_object object,
-                    const char *annex, void *readbuf,
-                    const void *writebuf, ULONGEST offset, LONGEST len)
+                    const char *annex, gdb_byte *readbuf,
+                    const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
 {
   switch (object)
     {
     case TARGET_OBJECT_MEMORY:
       if (readbuf)
 {
   switch (object)
     {
     case TARGET_OBJECT_MEMORY:
       if (readbuf)
-       return (*ops->deprecated_xfer_memory) (offset, readbuf, len,
-                                              0/*write*/, NULL, ops);
+       return (*ops->deprecated_xfer_memory) (offset, readbuf,
+                                              len, 0/*read*/, NULL, ops);
       if (writebuf)
       if (writebuf)
-       return (*ops->deprecated_xfer_memory) (offset, writebuf, len,
-                                              1/*write*/, NULL, ops);
+       return (*ops->deprecated_xfer_memory) (offset, (gdb_byte *) writebuf,
+                                              len, 1/*write*/, NULL, ops);
       return -1;
 
 #ifdef NEW_PROC_API
       return -1;
 
 #ifdef NEW_PROC_API
@@ -4339,7 +4400,7 @@ procfs_xfer_partial (struct target_ops *ops, enum target_object object,
    negative values, but this capability isn't implemented here.) */
 
 static int
    negative values, but this capability isn't implemented here.) */
 
 static int
-procfs_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int dowrite,
+procfs_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int dowrite,
                    struct mem_attrib *attrib, struct target_ops *target)
 {
   procinfo *pi;
                    struct mem_attrib *attrib, struct target_ops *target)
 {
   procinfo *pi;
@@ -4413,7 +4474,7 @@ invalidate_cache (procinfo *parent, procinfo *pi, void *ptr)
       if (!proc_set_gregs (pi))        /* flush gregs cache */
        proc_warn (pi, "target_resume, set_gregs",
                   __LINE__);
       if (!proc_set_gregs (pi))        /* flush gregs cache */
        proc_warn (pi, "target_resume, set_gregs",
                   __LINE__);
-  if (FP0_REGNUM >= 0)
+  if (gdbarch_fp0_regnum (target_gdbarch) >= 0)
     if (pi->fpregs_dirty)
       if (parent == NULL ||
          proc_get_current_thread (parent) != pi->tid)
     if (pi->fpregs_dirty)
       if (parent == NULL ||
          proc_get_current_thread (parent) != pi->tid)
@@ -4484,7 +4545,8 @@ make_signal_thread_runnable (procinfo *process, procinfo *pi, void *ptr)
  */
 
 static void
  */
 
 static void
-procfs_resume (ptid_t ptid, int step, enum target_signal signo)
+procfs_resume (struct target_ops *ops,
+              ptid_t ptid, int step, enum target_signal signo)
 {
   procinfo *pi, *thread;
   int native_signo;
 {
   procinfo *pi, *thread;
   int native_signo;
@@ -4614,49 +4676,12 @@ procfs_notice_signals (ptid_t ptid)
 static void
 procfs_files_info (struct target_ops *ignore)
 {
 static void
 procfs_files_info (struct target_ops *ignore)
 {
-  printf_filtered ("\tUsing the running image of %s %s via /proc.\n",
-                  attach_flag? "attached": "child",
+  struct inferior *inf = current_inferior ();
+  printf_filtered (_("\tUsing the running image of %s %s via /proc.\n"),
+                  inf->attach_flag? "attached": "child",
                   target_pid_to_str (inferior_ptid));
 }
 
                   target_pid_to_str (inferior_ptid));
 }
 
-/*
- * Function: target_open
- *
- * A dummy: you don't open procfs.
- */
-
-static void
-procfs_open (char *args, int from_tty)
-{
-  error (_("Use the \"run\" command to start a Unix child process."));
-}
-
-/*
- * Function: target_can_run
- *
- * This tells GDB that this target vector can be invoked
- * for "run" or "attach".
- */
-
-int procfs_suppress_run = 0;   /* Non-zero if procfs should pretend not to
-                                  be a runnable target.  Used by targets
-                                  that can sit atop procfs, such as solaris
-                                  thread support.  */
-
-
-static int
-procfs_can_run (void)
-{
-  /* This variable is controlled by modules that sit atop procfs that
-     may layer their own process structure atop that provided here.
-     sol-thread.c does this because of the Solaris two-level thread
-     model.  */
-
-  /* NOTE: possibly obsolete -- use the thread_stratum approach instead. */
-
-  return !procfs_suppress_run;
-}
-
 /*
  * Function: target_stop
  *
 /*
  * Function: target_stop
  *
@@ -4667,9 +4692,9 @@ procfs_can_run (void)
  */
 
 static void
  */
 
 static void
-procfs_stop (void)
+procfs_stop (ptid_t ptid)
 {
 {
-  kill (-inferior_process_group, SIGINT);
+  kill (-inferior_process_group (), SIGINT);
 }
 
 /*
 }
 
 /*
@@ -4744,7 +4769,7 @@ unconditionally_kill_inferior (procinfo *pi)
  */
 
 static void
  */
 
 static void
-procfs_kill_inferior (void)
+procfs_kill_inferior (struct target_ops *ops)
 {
   if (!ptid_equal (inferior_ptid, null_ptid)) /* ? */
     {
 {
   if (!ptid_equal (inferior_ptid, null_ptid)) /* ? */
     {
@@ -4764,7 +4789,7 @@ procfs_kill_inferior (void)
  */
 
 static void
  */
 
 static void
-procfs_mourn_inferior (void)
+procfs_mourn_inferior (struct target_ops *ops)
 {
   procinfo *pi;
 
 {
   procinfo *pi;
 
@@ -4775,7 +4800,15 @@ procfs_mourn_inferior (void)
       if (pi)
        destroy_procinfo (pi);
     }
       if (pi)
        destroy_procinfo (pi);
     }
-  unpush_target (&procfs_ops);
+  unpush_target (ops);
+
+  if (dbx_link_bpt != NULL)
+    {
+      deprecated_remove_raw_breakpoint (target_gdbarch, dbx_link_bpt);
+      dbx_link_bpt_addr = 0;
+      dbx_link_bpt = NULL;
+    }
+
   generic_mourn_inferior ();
 }
 
   generic_mourn_inferior ();
 }
 
@@ -4789,16 +4822,16 @@ procfs_mourn_inferior (void)
  */
 
 static void
  */
 
 static void
-procfs_init_inferior (int pid)
+procfs_init_inferior (struct target_ops *ops, int pid)
 {
   procinfo *pi;
   gdb_sigset_t signals;
   int fail;
 {
   procinfo *pi;
   gdb_sigset_t signals;
   int fail;
+  int lwpid;
 
   /* This routine called on the parent side (GDB side)
      after GDB forks the inferior.  */
 
   /* This routine called on the parent side (GDB side)
      after GDB forks the inferior.  */
-
-  push_target (&procfs_ops);
+  push_target (ops);
 
   if ((pi = create_procinfo (pid, 0)) == NULL)
     perror ("procfs: out of memory in 'init_inferior'");
 
   if ((pi = create_procinfo (pid, 0)) == NULL)
     perror ("procfs: out of memory in 'init_inferior'");
@@ -4854,9 +4887,17 @@ procfs_init_inferior (int pid)
   if (!proc_set_run_on_last_close (pi))
     proc_error (pi, "init_inferior, set_RLC", __LINE__);
 
   if (!proc_set_run_on_last_close (pi))
     proc_error (pi, "init_inferior, set_RLC", __LINE__);
 
-  /* The 'process ID' we return to GDB is composed of
-     the actual process ID plus the lwp ID. */
-  inferior_ptid = MERGEPID (pi->pid, proc_get_current_thread (pi));
+  /* We now have have access to the lwpid of the main thread/lwp.  */
+  lwpid = proc_get_current_thread (pi);
+
+  /* Create a procinfo for the main lwp.  */
+  create_procinfo (pid, lwpid);
+
+  /* We already have a main thread registered in the thread table at
+     this point, but it didn't have any lwp info yet.  Notify the core
+     about it.  This changes inferior_ptid as well.  */
+  thread_change_ptid (pid_to_ptid (pid),
+                     MERGEPID (pid, lwpid));
 
   /* Typically two, one trap to exec the shell, one to exec the
      program being debugged.  Defined by "inferior.h".  */
 
   /* Typically two, one trap to exec the shell, one to exec the
      program being debugged.  Defined by "inferior.h".  */
@@ -4885,7 +4926,6 @@ procfs_init_inferior (int pid)
      has been inserted, the syssgi() notifications are no longer necessary,
      so they should be canceled.  */
   proc_trace_syscalls_1 (pi, SYS_syssgi, PR_SYSEXIT, FLAG_SET, 0);
      has been inserted, the syssgi() notifications are no longer necessary,
      so they should be canceled.  */
   proc_trace_syscalls_1 (pi, SYS_syssgi, PR_SYSEXIT, FLAG_SET, 0);
-  dbx_link_bpt_addr = 0;
 #endif
 }
 
 #endif
 }
 
@@ -4912,7 +4952,7 @@ procfs_set_exec_trap (void)
   sysset_t *exitset;
 
   if ((pi = create_procinfo (getpid (), 0)) == NULL)
   sysset_t *exitset;
 
   if ((pi = create_procinfo (getpid (), 0)) == NULL)
-    perror_with_name ("procfs: create_procinfo failed in child.");
+    perror_with_name (_("procfs: create_procinfo failed in child."));
 
   if (open_procinfo_files (pi, FD_CTL) == 0)
     {
 
   if (open_procinfo_files (pi, FD_CTL) == 0)
     {
@@ -5017,11 +5057,13 @@ procfs_set_exec_trap (void)
  */
 
 static void
  */
 
 static void
-procfs_create_inferior (char *exec_file, char *allargs, char **env,
-                       int from_tty)
+procfs_create_inferior (struct target_ops *ops, char *exec_file,
+                       char *allargs, char **env, int from_tty)
 {
   char *shell_file = getenv ("SHELL");
   char *tryname;
 {
   char *shell_file = getenv ("SHELL");
   char *tryname;
+  int pid;
+
   if (shell_file != NULL && strchr (shell_file, '/') == NULL)
     {
 
   if (shell_file != NULL && strchr (shell_file, '/') == NULL)
     {
 
@@ -5090,8 +5132,10 @@ procfs_create_inferior (char *exec_file, char *allargs, char **env,
       shell_file = tryname;
     }
 
       shell_file = tryname;
     }
 
-  fork_inferior (exec_file, allargs, env, procfs_set_exec_trap,
-                procfs_init_inferior, NULL, shell_file);
+  pid = fork_inferior (exec_file, allargs, env, procfs_set_exec_trap,
+                      NULL, NULL, shell_file);
+
+  procfs_init_inferior (ops, pid);
 
 #ifdef SYS_syssgi
   /* Make sure to cancel the syssgi() syscall-exit notifications.  
 
 #ifdef SYS_syssgi
   /* Make sure to cancel the syssgi() syscall-exit notifications.  
@@ -5102,11 +5146,6 @@ procfs_create_inferior (char *exec_file, char *allargs, char **env,
   proc_trace_syscalls_1 (find_procinfo_or_die (PIDGET (inferior_ptid), 0),
                          SYS_syssgi, PR_SYSEXIT, FLAG_RESET, 0);
 #endif
   proc_trace_syscalls_1 (find_procinfo_or_die (PIDGET (inferior_ptid), 0),
                          SYS_syssgi, PR_SYSEXIT, FLAG_RESET, 0);
 #endif
-  
-  /* We are at the first instruction we care about.  */
-  /* Pedal to the metal... */
-
-  proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
 }
 
 /*
 }
 
 /*
@@ -5121,7 +5160,7 @@ procfs_notice_thread (procinfo *pi, procinfo *thread, void *ptr)
 {
   ptid_t gdb_threadid = MERGEPID (pi->pid, thread->tid);
 
 {
   ptid_t gdb_threadid = MERGEPID (pi->pid, thread->tid);
 
-  if (!in_thread_list (gdb_threadid))
+  if (!in_thread_list (gdb_threadid) || is_exited (gdb_threadid))
     add_thread (gdb_threadid);
 
   return 0;
     add_thread (gdb_threadid);
 
   return 0;
@@ -5135,7 +5174,7 @@ procfs_notice_thread (procinfo *pi, procinfo *thread, void *ptr)
  */
 
 void
  */
 
 void
-procfs_find_new_threads (void)
+procfs_find_new_threads (struct target_ops *ops)
 {
   procinfo *pi;
 
 {
   procinfo *pi;
 
@@ -5155,7 +5194,7 @@ procfs_find_new_threads (void)
  */
 
 static int
  */
 
 static int
-procfs_thread_alive (ptid_t ptid)
+procfs_thread_alive (struct target_ops *ops, ptid_t ptid)
 {
   int proc, thread;
   procinfo *pi;
 {
   int proc, thread;
   procinfo *pi;
@@ -5180,7 +5219,7 @@ procfs_thread_alive (ptid_t ptid)
 /* Convert PTID to a string.  Returns the string in a static buffer.  */
 
 char *
 /* Convert PTID to a string.  Returns the string in a static buffer.  */
 
 char *
-procfs_pid_to_str (ptid_t ptid)
+procfs_pid_to_str (struct target_ops *ops, ptid_t ptid)
 {
   static char buf[80];
 
 {
   static char buf[80];
 
@@ -5254,14 +5293,11 @@ procfs_set_watchpoint (ptid_t ptid, CORE_ADDR addr, int len, int rwflag,
 
    Note:  procfs_can_use_hw_breakpoint() is not yet used by all
    procfs.c targets due to the fact that some of them still define
 
    Note:  procfs_can_use_hw_breakpoint() is not yet used by all
    procfs.c targets due to the fact that some of them still define
-   TARGET_CAN_USE_HARDWARE_WATCHPOINT.  */
+   target_can_use_hardware_watchpoint.  */
 
 static int
 procfs_can_use_hw_breakpoint (int type, int cnt, int othertype)
 {
 
 static int
 procfs_can_use_hw_breakpoint (int type, int cnt, int othertype)
 {
-#ifndef TARGET_HAS_HARDWARE_WATCHPOINTS
-  return 0;
-#else
   /* Due to the way that proc_set_watchpoint() is implemented, host
      and target pointers must be of the same size.  If they are not,
      we can't use hardware watchpoints.  This limitation is due to the
   /* Due to the way that proc_set_watchpoint() is implemented, host
      and target pointers must be of the same size.  If they are not,
      we can't use hardware watchpoints.  This limitation is due to the
@@ -5270,13 +5306,13 @@ procfs_can_use_hw_breakpoint (int type, int cnt, int othertype)
      procfs_address_to_host_pointer will reveal that an internal error
      will be generated when the host and target pointer sizes are
      different.  */
      procfs_address_to_host_pointer will reveal that an internal error
      will be generated when the host and target pointer sizes are
      different.  */
-  if (sizeof (void *) != TYPE_LENGTH (builtin_type_void_data_ptr))
+  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+  if (sizeof (void *) != TYPE_LENGTH (ptr_type))
     return 0;
 
   /* Other tests here???  */
 
   return 1;
     return 0;
 
   /* Other tests here???  */
 
   return 1;
-#endif
 }
 
 /*
 }
 
 /*
@@ -5286,13 +5322,12 @@ procfs_can_use_hw_breakpoint (int type, int cnt, int othertype)
  * else returns zero.
  */
 
  * else returns zero.
  */
 
-int
-procfs_stopped_by_watchpoint (ptid_t ptid)
+static int
+procfs_stopped_by_watchpoint (void)
 {
   procinfo *pi;
 
 {
   procinfo *pi;
 
-  pi = find_procinfo_or_die (PIDGET (ptid) == -1 ?
-                            PIDGET (inferior_ptid) : PIDGET (ptid), 0);
+  pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
 
   if (!pi)     /* If no process, then not stopped by watchpoint!  */
     return 0;
 
   if (!pi)     /* If no process, then not stopped by watchpoint!  */
     return 0;
@@ -5314,45 +5349,53 @@ procfs_stopped_by_watchpoint (ptid_t ptid)
   return 0;
 }
 
   return 0;
 }
 
-#ifdef TM_I386SOL2_H
-/*
- * Function: procfs_find_LDT_entry
- *
- * Input:
- *   ptid_t ptid;      // The GDB-style pid-plus-LWP.
- *
- * Return:
- *   pointer to the corresponding LDT entry.
- */
-
-struct ssd *
-procfs_find_LDT_entry (ptid_t ptid)
+static int
+procfs_insert_watchpoint (CORE_ADDR addr, int len, int type)
 {
 {
-  gdb_gregset_t *gregs;
-  int            key;
-  procinfo      *pi;
-
-  /* Find procinfo for the lwp. */
-  if ((pi = find_procinfo (PIDGET (ptid), TIDGET (ptid))) == NULL)
+  if (!target_have_steppable_watchpoint
+      && !gdbarch_have_nonsteppable_watchpoint (target_gdbarch))
     {
     {
-      warning (_("procfs_find_LDT_entry: could not find procinfo for %d:%d."),
-              PIDGET (ptid), TIDGET (ptid));
-      return NULL;
+      /* When a hardware watchpoint fires off the PC will be left at
+        the instruction following the one which caused the
+        watchpoint.  It will *NOT* be necessary for GDB to step over
+        the watchpoint.  */
+      return procfs_set_watchpoint (inferior_ptid, addr, len, type, 1);
     }
     }
-  /* get its general registers. */
-  if ((gregs = proc_get_gregs (pi)) == NULL)
+  else
     {
     {
-      warning (_("procfs_find_LDT_entry: could not read gregs for %d:%d."),
-              PIDGET (ptid), TIDGET (ptid));
-      return NULL;
+      /* When a hardware watchpoint fires off the PC will be left at
+        the instruction which caused the watchpoint.  It will be
+        necessary for GDB to step over the watchpoint.  */
+      return procfs_set_watchpoint (inferior_ptid, addr, len, type, 0);
     }
     }
-  /* Now extract the GS register's lower 16 bits. */
-  key = (*gregs)[GS] & 0xffff;
+}
 
 
-  /* Find the matching entry and return it. */
-  return proc_get_LDT_entry (pi, key);
+static int
+procfs_remove_watchpoint (CORE_ADDR addr, int len, int type)
+{
+  return procfs_set_watchpoint (inferior_ptid, addr, 0, 0, 0);
+}
+
+static int
+procfs_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+{
+  /* The man page for proc(4) on Solaris 2.6 and up says that the
+     system can support "thousands" of hardware watchpoints, but gives
+     no method for finding out how many; It doesn't say anything about
+     the allowed size for the watched area either.  So we just tell
+     GDB 'yes'.  */
+  return 1;
+}
+
+void
+procfs_use_watchpoints (struct target_ops *t)
+{
+  t->to_stopped_by_watchpoint = procfs_stopped_by_watchpoint;
+  t->to_insert_watchpoint = procfs_insert_watchpoint;
+  t->to_remove_watchpoint = procfs_remove_watchpoint;
+  t->to_region_ok_for_hw_watchpoint = procfs_region_ok_for_hw_watchpoint;
+  t->to_can_use_hw_breakpoint = procfs_can_use_hw_breakpoint;
 }
 }
-#endif /* TM_I386SOL2_H */
 
 /*
  * Memory Mappings Functions:
 
 /*
  * Memory Mappings Functions:
@@ -5481,31 +5524,6 @@ int solib_mappings_callback (struct prmap *map,
   return (*func) (fd, (CORE_ADDR) map->pr_vaddr);
 }
 
   return (*func) (fd, (CORE_ADDR) map->pr_vaddr);
 }
 
-/*
- * Function: proc_iterate_over_mappings
- *
- * Uses the unified "iterate_over_mappings" function
- * to implement the exported interface to solib-svr4.c.
- *
- * Given a pointer to a function, call that function once for every
- * mapped address space in the process.  The callback function
- * receives an open file descriptor for the file corresponding to
- * that mapped address space (if there is one), and the base address
- * of the mapped space.  Quit when the callback function returns a
- * nonzero value, or at teh end of the mappings.
- *
- * Returns: the first non-zero return value of the callback function,
- * or zero.
- */
-
-int
-proc_iterate_over_mappings (int (*func) (int, CORE_ADDR))
-{
-  procinfo *pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
-
-  return iterate_over_mappings (pi, func, pi, solib_mappings_callback);
-}
-
 /*
  * Function: find_memory_regions_callback
  *
 /*
  * Function: find_memory_regions_callback
  *
@@ -5575,11 +5593,11 @@ remove_dbx_link_breakpoint (void)
   if (dbx_link_bpt_addr == 0)
     return;
 
   if (dbx_link_bpt_addr == 0)
     return;
 
-  if (memory_remove_breakpoint (dbx_link_bpt_addr,
-                                dbx_link_shadow_contents) != 0)
+  if (deprecated_remove_raw_breakpoint (target_gdbarch, dbx_link_bpt) != 0)
     warning (_("Unable to remove __dbx_link breakpoint."));
 
   dbx_link_bpt_addr = 0;
     warning (_("Unable to remove __dbx_link breakpoint."));
 
   dbx_link_bpt_addr = 0;
+  dbx_link_bpt = NULL;
 }
 
 /* Return the address of the __dbx_link() function in the file
 }
 
 /* Return the address of the __dbx_link() function in the file
@@ -5647,7 +5665,9 @@ insert_dbx_link_bpt_in_file (int fd, CORE_ADDR ignored)
     {
       /* Insert the breakpoint.  */
       dbx_link_bpt_addr = sym_addr;
     {
       /* Insert the breakpoint.  */
       dbx_link_bpt_addr = sym_addr;
-      if (target_insert_breakpoint (sym_addr, dbx_link_shadow_contents) != 0)
+      dbx_link_bpt = deprecated_insert_raw_breakpoint (target_gdbarch,
+                                                      sym_addr);
+      if (dbx_link_bpt == NULL)
         {
           warning (_("Failed to insert dbx_link breakpoint."));
           bfd_close (abfd);
         {
           warning (_("Failed to insert dbx_link breakpoint."));
           bfd_close (abfd);
@@ -5730,23 +5750,28 @@ mappingflags (long flags)
 static int
 info_mappings_callback (struct prmap *map, int (*ignore) (), void *unused)
 {
 static int
 info_mappings_callback (struct prmap *map, int (*ignore) (), void *unused)
 {
-  char *data_fmt_string;
+  unsigned int pr_off;
 
 
-  if (TARGET_ADDR_BIT == 32)
-    data_fmt_string   = "\t%#10lx %#10lx %#10x %#10x %7s\n";
-  else
-    data_fmt_string   = "  %#18lx %#18lx %#10x %#10x %7s\n";
-
-  printf_filtered (data_fmt_string,
-                  (unsigned long) map->pr_vaddr,
-                  (unsigned long) map->pr_vaddr + map->pr_size - 1,
-                  map->pr_size,
 #ifdef PCAGENT /* Horrible hack: only defined on Solaris 2.6+ */
 #ifdef PCAGENT /* Horrible hack: only defined on Solaris 2.6+ */
-                  (unsigned int) map->pr_offset,
+  pr_off = (unsigned int) map->pr_offset;
 #else
 #else
-                  map->pr_off,
+  pr_off = map->pr_off;
 #endif
 #endif
-                  mappingflags (map->pr_mflags));
+
+  if (gdbarch_addr_bit (target_gdbarch) == 32)
+    printf_filtered ("\t%#10lx %#10lx %#10lx %#10x %7s\n",
+                    (unsigned long) map->pr_vaddr,
+                    (unsigned long) map->pr_vaddr + map->pr_size - 1,
+                    (unsigned long) map->pr_size,
+                    pr_off,
+                    mappingflags (map->pr_mflags));
+  else
+    printf_filtered ("  %#18lx %#18lx %#10lx %#10x %7s\n",
+                    (unsigned long) map->pr_vaddr,
+                    (unsigned long) map->pr_vaddr + map->pr_size - 1,
+                    (unsigned long) map->pr_size,
+                    pr_off,
+                    mappingflags (map->pr_mflags));
 
   return 0;
 }
 
   return 0;
 }
@@ -5760,23 +5785,24 @@ info_mappings_callback (struct prmap *map, int (*ignore) (), void *unused)
 static void
 info_proc_mappings (procinfo *pi, int summary)
 {
 static void
 info_proc_mappings (procinfo *pi, int summary)
 {
-  char *header_fmt_string;
-
-  if (TARGET_PTR_BIT == 32)
-    header_fmt_string = "\t%10s %10s %10s %10s %7s\n";
-  else
-    header_fmt_string = "  %18s %18s %10s %10s %7s\n";
-
   if (summary)
     return;    /* No output for summary mode. */
 
   if (summary)
     return;    /* No output for summary mode. */
 
-  printf_filtered ("Mapped address spaces:\n\n");
-  printf_filtered (header_fmt_string,
-                  "Start Addr",
-                  "  End Addr",
-                  "      Size",
-                  "    Offset",
-                  "Flags");
+  printf_filtered (_("Mapped address spaces:\n\n"));
+  if (gdbarch_ptr_bit (target_gdbarch) == 32)
+    printf_filtered ("\t%10s %10s %10s %10s %7s\n",
+                    "Start Addr",
+                    "  End Addr",
+                    "      Size",
+                    "    Offset",
+                    "Flags");
+  else
+    printf_filtered ("  %18s %18s %10s %10s %7s\n",
+                    "Start Addr",
+                    "  End Addr",
+                    "      Size",
+                    "    Offset",
+                    "Flags");
 
   iterate_over_mappings (pi, NULL, NULL, info_mappings_callback);
   printf_filtered ("\n");
 
   iterate_over_mappings (pi, NULL, NULL, info_mappings_callback);
   printf_filtered ("\n");
@@ -5803,10 +5829,8 @@ info_proc_cmd (char *args, int from_tty)
   old_chain = make_cleanup (null_cleanup, 0);
   if (args)
     {
   old_chain = make_cleanup (null_cleanup, 0);
   if (args)
     {
-      if ((argv = buildargv (args)) == NULL)
-       nomem (0);
-      else
-       make_cleanup_freeargv (argv);
+      argv = gdb_buildargv (args);
+      make_cleanup_freeargv (argv);
     }
   while (argv != NULL && *argv != NULL)
     {
     }
   while (argv != NULL && *argv != NULL)
     {
@@ -5854,7 +5878,7 @@ info_proc_cmd (char *args, int from_tty)
 
   if (process)
     {
 
   if (process)
     {
-      printf_filtered ("process %d flags:\n", process->pid);
+      printf_filtered (_("process %d flags:\n"), process->pid);
       proc_prettyprint_flags (proc_flags (process), 1);
       if (proc_flags (process) & (PR_STOPPED | PR_ISTOP))
        proc_prettyprint_why (proc_why (process), proc_what (process), 1);
       proc_prettyprint_flags (proc_flags (process), 1);
       if (proc_flags (process) & (PR_STOPPED | PR_ISTOP))
        proc_prettyprint_why (proc_why (process), proc_what (process), 1);
@@ -5864,7 +5888,7 @@ info_proc_cmd (char *args, int from_tty)
     }
   if (thread)
     {
     }
   if (thread)
     {
-      printf_filtered ("thread %d flags:\n", thread->tid);
+      printf_filtered (_("thread %d flags:\n"), thread->tid);
       proc_prettyprint_flags (proc_flags (thread), 1);
       if (proc_flags (thread) & (PR_STOPPED | PR_ISTOP))
        proc_prettyprint_why (proc_why (thread), proc_what (thread), 1);
       proc_prettyprint_flags (proc_flags (thread), 1);
       if (proc_flags (thread) & (PR_STOPPED | PR_ISTOP))
        proc_prettyprint_why (proc_why (thread), proc_what (thread), 1);
@@ -5927,7 +5951,7 @@ proc_trace_syscalls (char *args, int from_tty, int entry_or_exit, int mode)
     error (_("you must be debugging a process to use this command."));
 
   if (args == NULL || args[0] == 0)
     error (_("you must be debugging a process to use this command."));
 
   if (args == NULL || args[0] == 0)
-    error_no_arg ("system call to trace");
+    error_no_arg (_("system call to trace"));
 
   pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
   if (isdigit (args[0]))
 
   pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
   if (isdigit (args[0]))
@@ -5966,20 +5990,18 @@ proc_untrace_sysexit_cmd (char *args, int from_tty)
 void
 _initialize_procfs (void)
 {
 void
 _initialize_procfs (void)
 {
-  init_procfs_ops ();
-  add_target (&procfs_ops);
-  add_info ("proc", info_proc_cmd,
-           "Show /proc process information about any running process.\n\
+  add_info ("proc", info_proc_cmd, _("\
+Show /proc process information about any running process.\n\
 Specify process id, or use the program being debugged by default.\n\
 Specify process id, or use the program being debugged by default.\n\
-Specify keyword 'mappings' for detailed info on memory mappings.");
+Specify keyword 'mappings' for detailed info on memory mappings."));
   add_com ("proc-trace-entry", no_class, proc_trace_sysentry_cmd,
   add_com ("proc-trace-entry", no_class, proc_trace_sysentry_cmd,
-          "Give a trace of entries into the syscall.");
+          _("Give a trace of entries into the syscall."));
   add_com ("proc-trace-exit", no_class, proc_trace_sysexit_cmd,
   add_com ("proc-trace-exit", no_class, proc_trace_sysexit_cmd,
-          "Give a trace of exits from the syscall.");
+          _("Give a trace of exits from the syscall."));
   add_com ("proc-untrace-entry", no_class, proc_untrace_sysentry_cmd,
   add_com ("proc-untrace-entry", no_class, proc_untrace_sysentry_cmd,
-          "Cancel a trace of entries into the syscall.");
+          _("Cancel a trace of entries into the syscall."));
   add_com ("proc-untrace-exit", no_class, proc_untrace_sysexit_cmd,
   add_com ("proc-untrace-exit", no_class, proc_untrace_sysexit_cmd,
-          "Cancel a trace of exits from the syscall.");
+          _("Cancel a trace of exits from the syscall."));
 }
 
 /* =================== END, GDB  "MODULE" =================== */
 }
 
 /* =================== END, GDB  "MODULE" =================== */
@@ -6002,21 +6024,45 @@ procfs_first_available (void)
   return pid_to_ptid (procinfo_list ? procinfo_list->pid : -1);
 }
 
   return pid_to_ptid (procinfo_list ? procinfo_list->pid : -1);
 }
 
+static int
+find_signalled_thread (struct thread_info *info, void *data)
+{
+  if (info->stop_signal != TARGET_SIGNAL_0
+      && ptid_get_pid (info->ptid) == ptid_get_pid (inferior_ptid))
+    return 1;
+
+  return 0;
+}
+
+static enum target_signal
+find_stop_signal (void)
+{
+  struct thread_info *info =
+    iterate_over_threads (find_signalled_thread, NULL);
+
+  if (info)
+    return info->stop_signal;
+  else
+    return TARGET_SIGNAL_0;
+}
+
 /* ===================  GCORE .NOTE "MODULE" =================== */
 #if defined (UNIXWARE) || defined (PIOCOPENLWP) || defined (PCAGENT)
 /* gcore only implemented on solaris and unixware (so far) */
 
 static char *
 procfs_do_thread_registers (bfd *obfd, ptid_t ptid,
 /* ===================  GCORE .NOTE "MODULE" =================== */
 #if defined (UNIXWARE) || defined (PIOCOPENLWP) || defined (PCAGENT)
 /* gcore only implemented on solaris and unixware (so far) */
 
 static char *
 procfs_do_thread_registers (bfd *obfd, ptid_t ptid,
-                           char *note_data, int *note_size)
+                           char *note_data, int *note_size,
+                           enum target_signal stop_signal)
 {
 {
+  struct regcache *regcache = get_thread_regcache (ptid);
   gdb_gregset_t gregs;
   gdb_fpregset_t fpregs;
   unsigned long merged_pid;
 
   merged_pid = TIDGET (ptid) << 16 | PIDGET (ptid);
 
   gdb_gregset_t gregs;
   gdb_fpregset_t fpregs;
   unsigned long merged_pid;
 
   merged_pid = TIDGET (ptid) << 16 | PIDGET (ptid);
 
-  fill_gregset (&gregs, -1);
+  fill_gregset (regcache, &gregs, -1);
 #if defined (UNIXWARE)
   note_data = (char *) elfcore_write_lwpstatus (obfd,
                                                note_data,
 #if defined (UNIXWARE)
   note_data = (char *) elfcore_write_lwpstatus (obfd,
                                                note_data,
@@ -6032,7 +6078,7 @@ procfs_do_thread_registers (bfd *obfd, ptid_t ptid,
                                               stop_signal,
                                               &gregs);
 #endif
                                               stop_signal,
                                               &gregs);
 #endif
-  fill_fpregset (&fpregs, -1);
+  fill_fpregset (regcache, &fpregs, -1);
   note_data = (char *) elfcore_write_prfpreg (obfd,
                                              note_data,
                                              note_size,
   note_data = (char *) elfcore_write_prfpreg (obfd,
                                              note_data,
                                              note_size,
@@ -6045,6 +6091,7 @@ struct procfs_corefile_thread_data {
   bfd *obfd;
   char *note_data;
   int *note_size;
   bfd *obfd;
   char *note_data;
   int *note_size;
+  enum target_signal stop_signal;
 };
 
 static int
 };
 
 static int
@@ -6052,13 +6099,14 @@ procfs_corefile_thread_callback (procinfo *pi, procinfo *thread, void *data)
 {
   struct procfs_corefile_thread_data *args = data;
 
 {
   struct procfs_corefile_thread_data *args = data;
 
-  if (pi != NULL && thread->tid != 0)
+  if (pi != NULL)
     {
       ptid_t saved_ptid = inferior_ptid;
       inferior_ptid = MERGEPID (pi->pid, thread->tid);
       args->note_data = procfs_do_thread_registers (args->obfd, inferior_ptid,
                                                    args->note_data,
     {
       ptid_t saved_ptid = inferior_ptid;
       inferior_ptid = MERGEPID (pi->pid, thread->tid);
       args->note_data = procfs_do_thread_registers (args->obfd, inferior_ptid,
                                                    args->note_data,
-                                                   args->note_size);
+                                                   args->note_size,
+                                                   args->stop_signal);
       inferior_ptid = saved_ptid;
     }
   return 0;
       inferior_ptid = saved_ptid;
     }
   return 0;
@@ -6076,7 +6124,7 @@ procfs_make_note_section (bfd *obfd, int *note_size)
   char *note_data = NULL;
   char *inf_args;
   struct procfs_corefile_thread_data thread_args;
   char *note_data = NULL;
   char *inf_args;
   struct procfs_corefile_thread_data thread_args;
-  char *auxv;
+  gdb_byte *auxv;
   int auxv_len;
 
   if (get_exec_file (0))
   int auxv_len;
 
   if (get_exec_file (0))
@@ -6103,7 +6151,7 @@ procfs_make_note_section (bfd *obfd, int *note_size)
                                               psargs);
 
 #ifdef UNIXWARE
                                               psargs);
 
 #ifdef UNIXWARE
-  fill_gregset (&gregs, -1);
+  fill_gregset (get_current_regcache (), &gregs, -1);
   note_data = elfcore_write_pstatus (obfd, note_data, note_size,
                                     PIDGET (inferior_ptid),
                                     stop_signal, &gregs);
   note_data = elfcore_write_pstatus (obfd, note_data, note_size,
                                     PIDGET (inferior_ptid),
                                     stop_signal, &gregs);
@@ -6112,21 +6160,15 @@ procfs_make_note_section (bfd *obfd, int *note_size)
   thread_args.obfd = obfd;
   thread_args.note_data = note_data;
   thread_args.note_size = note_size;
   thread_args.obfd = obfd;
   thread_args.note_data = note_data;
   thread_args.note_size = note_size;
+  thread_args.stop_signal = find_stop_signal ();
   proc_iterate_over_threads (pi, procfs_corefile_thread_callback, &thread_args);
 
   proc_iterate_over_threads (pi, procfs_corefile_thread_callback, &thread_args);
 
-  if (thread_args.note_data == note_data)
-    {
-      /* iterate_over_threads didn't come up with any threads;
-        just use inferior_ptid. */
-      note_data = procfs_do_thread_registers (obfd, inferior_ptid,
-                                             note_data, note_size);
-    }
-  else
-    {
-      note_data = thread_args.note_data;
-    }
+  /* There should be always at least one thread.  */
+  gdb_assert (thread_args.note_data != note_data);
+  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,
   if (auxv_len > 0)
     {
       note_data = elfcore_write_note (obfd, note_data, note_size,
This page took 0.044207 seconds and 4 git commands to generate.