* config/tc-alpha.c (O_samegp): New.
[external/binutils.git] / gdb / remote-es.c
index 04ec81b..dabbcd8 100644 (file)
@@ -1,5 +1,7 @@
 /* Memory-access and commands for remote es1800 processes, for GDB.
-   Copyright (C) 1988, 1992 Free Software Foundation, Inc.
+
+   Copyright 1988, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
+   2001, 2002 Free Software Foundation, Inc.
 
    This file is added to GDB to make it possible to do debugging via an
    ES-1800 emulator. The code was originally written by Johan Holmberg
@@ -7,87 +9,88 @@
    TT/SJ. It was modified for gdb 4.0 by TX/DK Jan Nordenand by TX/DKG
    Harald Johansen.
 
-This file is part of GDB.
+   This file is part of GDB.
 
-GDB 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 1, or (at your option)
-any later version.
+   GDB 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 1, or (at your option)
+   any later version.
 
-GDB 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.
+   GDB 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 GDB; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+   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.  */
 
 
 /* Emulator communication protocol.
    All values are encoded in ascii hex digits.
 
-        Request
-Command
-Reply
-       read registers:
-DR<cr>
-     - 0 -    - 1 -    - 2 -    - 3 -      - 4 -    - 5 -    -- 6 -   - 7 - 
-D = XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX   XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
-A = XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX   XXXXXXXX XXXXXXXX XXXXXXXX 
-    PC = XXXXXX       SSP = XXXXXX    USP = XXXXXX     SR = XXXXXXXX
- >
-Each byte of register data is described by two hex digits.
-
-       write regs
-D0=XXXXXXXX<cr>
- >D1=XXXXXXXX<cr>
- >D2=XXXXXXXX<cr>
- >D3=XXXXXXXX<cr>
- >D4=XXXXXXXX<cr>
- >D5=XXXXXXXX<cr>
- >D6=XXXXXXXX<cr>
- >D7=XXXXXXXX<cr>
- >A0=XXXXXXXX<cr>
- >A1=XXXXXXXX<cr>
- >A2=XXXXXXXX<cr>
- >A3=XXXXXXXX<cr>
- >A4=XXXXXXXX<cr>
- >A5=XXXXXXXX<cr>
- >A6=XXXXXXXX<cr>
- >A7=XXXXXXXX<cr>
- >SR=XXXXXXXX<cr>
- >PC=XXXXXX<cr>
- >
-Each byte of register data is described by two hex digits.
-
-       read mem
-@.BAA..AA
-$FFFFFFXX
- >
-AA..AA is address, XXXXXXX is the contents
-
-       write mem
-       @.BAA..AA=$XXXXXXXX
- >
-AA..AA is address, XXXXXXXX is data
-
-       cont
-PC=$AA..AA
- >RBK
-R>
-AA..AA is address to resume. If AA..AA is omitted, resume at same address.
-
-       step
-PC=$AA..AA
- >STP
-R>
-AA..AA is address to resume. If AA..AA is omitted, resume at same address.
-
-       kill req
-STP
- >
-*/
+   Request
+   Command
+   Reply
+   read registers:
+   DR<cr>
+   - 0 -    - 1 -    - 2 -    - 3 -      - 4 -    - 5 -    -- 6 -   - 7 - 
+   D = XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX   XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
+   A = XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX   XXXXXXXX XXXXXXXX XXXXXXXX 
+   PC = XXXXXX       SSP = XXXXXX    USP = XXXXXX     SR = XXXXXXXX
  >
+   Each byte of register data is described by two hex digits.
+
+   write regs
+   D0=XXXXXXXX<cr>
  >D1=XXXXXXXX<cr>
  >D2=XXXXXXXX<cr>
  >D3=XXXXXXXX<cr>
  >D4=XXXXXXXX<cr>
  >D5=XXXXXXXX<cr>
  >D6=XXXXXXXX<cr>
  >D7=XXXXXXXX<cr>
  >A0=XXXXXXXX<cr>
  >A1=XXXXXXXX<cr>
  >A2=XXXXXXXX<cr>
  >A3=XXXXXXXX<cr>
  >A4=XXXXXXXX<cr>
  >A5=XXXXXXXX<cr>
  >A6=XXXXXXXX<cr>
  >A7=XXXXXXXX<cr>
  >SR=XXXXXXXX<cr>
  >PC=XXXXXX<cr>
  >
+   Each byte of register data is described by two hex digits.
+
+   read mem
+   @.BAA..AA
+   $FFFFFFXX
  >
+   AA..AA is address, XXXXXXX is the contents
+
+   write mem
+   @.BAA..AA=$XXXXXXXX
  >
+   AA..AA is address, XXXXXXXX is data
+
+   cont
+   PC=$AA..AA
  >RBK
+   R>
+   AA..AA is address to resume. If AA..AA is omitted, resume at same address.
+
+   step
+   PC=$AA..AA
  >STP
+   R>
+   AA..AA is address to resume. If AA..AA is omitted, resume at same address.
+
+   kill req
+   STP
  >
+ */
 
 
 #include <stdio.h>
@@ -96,147 +99,110 @@ STP
 #include <sys/file.h>
 #include <errno.h>
 #include <ctype.h>
-#include <string.h>
 #include <setjmp.h>
 #include <fcntl.h>
 #include "defs.h"
+#include "gdb_string.h"
 #include "frame.h"
 #include "inferior.h"
 #include "target.h"
-#include "wait.h"
 #include "command.h"
+#include "symfile.h"
 #include "remote-utils.h"
 #include "gdbcore.h"
 #include "serial.h"
+#include "regcache.h"
+#include "value.h"
 
 /* Prototypes for local functions */
 
-static void
-es1800_child_detach PARAMS ((char *, int));
+static void es1800_child_detach (char *, int);
 
-static void
-es1800_child_open PARAMS ((char *, int));
+static void es1800_child_open (char *, int);
 
-static void 
-es1800_transparent PARAMS ((char *, int));
+static void es1800_transparent (char *, int);
 
-static void
-es1800_create_inferior PARAMS ((char *, char *, char **));
+static void es1800_create_inferior (char *, char *, char **);
 
-static void
-es1800_load PARAMS ((char *, int));
+static void es1800_load (char *, int);
 
-static void
-es1800_kill PARAMS ((void));
+static void es1800_kill (void);
 
-static int
-verify_break PARAMS ((int));
+static int verify_break (int);
 
-static int
-es1800_remove_breakpoint PARAMS ((CORE_ADDR, char *));
+static int es1800_remove_breakpoint (CORE_ADDR, char *);
 
-static int
-es1800_insert_breakpoint PARAMS ((CORE_ADDR, char *));
+static int es1800_insert_breakpoint (CORE_ADDR, char *);
 
-static void
-es1800_files_info PARAMS ((struct target_ops *));
+static void es1800_files_info (struct target_ops *);
 
 static int
-es1800_xfer_inferior_memory PARAMS ((CORE_ADDR, char *, int, int,
-                                    struct target_ops *));
+es1800_xfer_inferior_memory (CORE_ADDR, char *, int, int,
+                            struct mem_attrib *, struct target_ops *);
 
-static void 
-es1800_prepare_to_store PARAMS ((void));
+static void es1800_prepare_to_store (void);
 
-static int es1800_wait PARAMS ((int, struct target_waitstatus *));
+static ptid_t es1800_wait (ptid_t, struct target_waitstatus *);
 
-static void es1800_resume PARAMS ((int, int, enum target_signal));
+static void es1800_resume (ptid_t, int, enum target_signal);
 
-static void
-es1800_detach PARAMS ((char *, int));
+static void es1800_detach (char *, int);
 
-static void
-es1800_attach PARAMS ((char *, int));
+static void es1800_attach (char *, int);
 
-static int
-damn_b PARAMS ((char *));
+static int damn_b (char *);
 
-static void
-es1800_open PARAMS ((char *, int));
+static void es1800_open (char *, int);
 
-static void
-es1800_timer PARAMS ((void));
+static void es1800_timer (void);
 
-static void
-es1800_reset PARAMS ((char *));
+static void es1800_reset (char *);
 
-static void
-es1800_request_quit PARAMS ((void));
+static void es1800_request_quit (void);
 
-static int
-readchar PARAMS ((void));
+static int readchar (void);
 
-static void
-expect PARAMS ((char *, int));
+static void expect (char *, int);
 
-static void
-expect_prompt PARAMS ((void));
+static void expect_prompt (void);
 
-static void
-download PARAMS ((FILE *, int, int));
+static void download (FILE *, int, int);
 
 #if 0
-static void
-bfd_copy PARAMS ((bfd *, bfd *));
+static void bfd_copy (bfd *, bfd *);
 #endif
 
-static void
-get_break_addr PARAMS ((int, CORE_ADDR *));
+static void get_break_addr (int, CORE_ADDR *);
 
-static int
-fromhex PARAMS ((int));
+static int fromhex (int);
 
-static int
-tohex PARAMS ((int));
+static int tohex (int);
 
-static void
-es1800_close PARAMS ((int));
+static void es1800_close (int);
 
-static void
-es1800_fetch_registers PARAMS ((void));
+static void es1800_fetch_registers (void);
 
-static void
-es1800_fetch_register PARAMS ((int));
+static void es1800_fetch_register (int);
 
-static void
-es1800_store_register PARAMS ((int));
+static void es1800_store_register (int);
 
-static void
-es1800_read_bytes PARAMS ((CORE_ADDR, char *, int));
+static void es1800_read_bytes (CORE_ADDR, char *, int);
 
-static void
-es1800_write_bytes PARAMS ((CORE_ADDR, char *, int));
+static void es1800_write_bytes (CORE_ADDR, char *, int);
 
-static void
-send_with_reply PARAMS ((char *, char *, int));
+static void send_with_reply (char *, char *, int);
 
-static void
-send_command PARAMS ((char *));
+static void send_command (char *);
 
-static void
-send PARAMS ((char *));
+static void send (char *);
 
-static void
-getmessage PARAMS ((char *, int));
+static void getmessage (char *, int);
 
-static void
-es1800_mourn_inferior PARAMS ((void));
+static void es1800_mourn_inferior (void);
 
-static void
-es1800_create_break_insn PARAMS ((char *, int));
+static void es1800_create_break_insn (char *, int);
 
-static void
-es1800_init_break PARAMS ((char *, int));
+static void es1800_init_break (char *, int);
 
 /* Local variables */
 
@@ -246,14 +212,14 @@ es1800_init_break PARAMS ((char *, int));
 static FILE *log_file;
 #endif
 
-extern struct target_ops es1800_ops;           /* Forward decl */
+extern struct target_ops es1800_ops;   /* Forward decl */
 extern struct target_ops es1800_child_ops;     /* Forward decl */
 
 static int kiodebug;
-static int timeout = 100; 
-static char *savename;                         /* Name of i/o device used */
+static int timeout = 100;
+static char *savename;         /* Name of i/o device used */
 static serial_ttystate es1800_saved_ttystate;
-static int es1800_fc_save;                     /* Save fcntl state */
+static int es1800_fc_save;     /* Save fcntl state */
 
 /* indicates that the emulator uses 32-bit data-adress (68020-mode) 
    instead of 24-bit (68000 -mode) */
@@ -267,7 +233,7 @@ static int m68020;
    es1800_open knows that we don't have a file open when the program
    starts.  */
 
-static serial_t es1800_desc = NULL;
+static struct serial *es1800_desc = NULL;
 
 #define        PBUFSIZ 1000
 #define HDRLEN sizeof("@.BAAAAAAAA=$VV\r")
@@ -280,14 +246,14 @@ static serial_t es1800_desc = NULL;
 static int es1800_break_vec = 0;
 static char es1800_break_insn[2];
 static long es1800_break_address;
-static void (*old_sigint)();           /* Old signal-handler for sigint */
+static void (*old_sigint) ();  /* Old signal-handler for sigint */
 static jmp_buf interrupt;
 
 /* Local signalhandler to allow breaking tranfers or program run.
    Rely on global variables: old_sigint(), interrupt */
 
 static void
-es1800_request_quit ()
+es1800_request_quit (void)
 {
   /* restore original signalhandler */
   signal (SIGINT, old_sigint);
@@ -297,11 +263,10 @@ es1800_request_quit ()
 
 /* Reset emulator.
    Sending reset character(octal 32) to emulator.
-   quit - return to '(esgdb)' prompt or continue       */
+   quit - return to '(esgdb)' prompt or continue        */
 
 static void
-es1800_reset (quit)
-     char *quit;
+es1800_reset (char *quit)
 {
   char buf[80];
 
@@ -328,9 +293,7 @@ es1800_reset (quit)
    from_tty - says whether to be verbose or not */
 
 static void
-es1800_open (name, from_tty)
-     char *name;
-     int from_tty;
+es1800_open (char *name, int from_tty)
 {
   char buf[PBUFSIZ];
   char *p;
@@ -338,7 +301,7 @@ es1800_open (name, from_tty)
 
   m68020 = 0;
 
-  if (!name)           /* no device name given in target command */
+  if (!name)                   /* no device name given in target command */
     {
       error_no_arg ("serial port device name");
     }
@@ -350,43 +313,43 @@ es1800_open (name, from_tty)
 
 #ifndef DEBUG_STDIN
 
-  es1800_desc = SERIAL_OPEN (name);
+  es1800_desc = serial_open (name);
   if (es1800_desc == NULL)
     {
       perror_with_name (name);
     }
   savename = savestring (name, strlen (name));
 
-  es1800_saved_ttystate = SERIAL_GET_TTY_STATE (es1800_desc);
+  es1800_saved_ttystate = serial_get_tty_state (es1800_desc);
 
-  if ((fcflag = fcntl (es1800_desc->fd, F_GETFL, 0)) == -1)
+  if ((fcflag = fcntl (deprecated_serial_fd (es1800_desc), F_GETFL, 0)) == -1)
     {
       perror_with_name ("fcntl serial");
     }
   es1800_fc_save = fcflag;
 
-  fcflag = (fcflag & (FREAD | FWRITE)); /* mask out any funny stuff */
-  if (fcntl (es1800_desc->fd, F_SETFL, fcflag) == -1)
+  fcflag = (fcflag & (FREAD | FWRITE));                /* mask out any funny stuff */
+  if (fcntl (deprecated_serial_fd (es1800_desc), F_SETFL, fcflag) == -1)
     {
       perror_with_name ("fcntl serial");
     }
 
   if (baud_rate != -1)
     {
-      if (SERIAL_SETBAUDRATE (es1800_desc, baud_rate))
+      if (serial_setbaudrate (es1800_desc, baud_rate))
        {
-         SERIAL_CLOSE (es1800_desc);
+         serial_close (es1800_desc);
          perror_with_name (name);
        }
     }
 
-  SERIAL_RAW (es1800_desc);
+  serial_raw (es1800_desc);
 
   /* If there is something sitting in the buffer we might take it as a
      response to a command, which would be bad.  */
-  SERIAL_FLUSH_INPUT (es1800_desc);
+  serial_flush_input (es1800_desc);
 
-#endif /* DEBUG_STDIN */
+#endif /* DEBUG_STDIN */
 
   push_target (&es1800_ops);   /* Switch to using remote target now */
   if (from_tty)
@@ -402,29 +365,37 @@ es1800_open (name, from_tty)
       perror_with_name (LOG_FILE);
     }
 
-#endif /* LOG_FILE */
+#endif /* LOG_FILE */
 
   /* Hello?  Are you there?, also check mode  */
 
   /*  send_with_reply( "DB 0 TO 1", buf, sizeof(buf)); */
-  /*  for (p = buf, i = 0; *p++ =='0';)  */   /* count the number of zeros */
+  /*  for (p = buf, i = 0; *p++ =='0';)  *//* count the number of zeros */
   /*      i++; */
 
   send ("\032");
-  getmessage (buf, sizeof (buf));  /* send reset character */
+  getmessage (buf, sizeof (buf));      /* send reset character */
 
   if (from_tty)
     {
       printf ("Checking mode.... ");
     }
-  /*  m68020 = (i==8); */   /* if eight zeros then we are in m68020 mode */
+  /*  m68020 = (i==8); *//* if eight zeros then we are in m68020 mode */
 
-  /* What kind of processor am i talking to ?*/
+  /* What kind of processor am i talking to ? */
   p = buf;
-  while (*p++ != '\n') {;}
-  while (*p++ != '\n') {;}
-  while (*p++ != '\n') {;}
-  for (i = 0; i < 20; i++, p++) {;}
+  while (*p++ != '\n')
+    {;
+    }
+  while (*p++ != '\n')
+    {;
+    }
+  while (*p++ != '\n')
+    {;
+    }
+  for (i = 0; i < 20; i++, p++)
+    {;
+    }
   m68020 = !strncmp (p, "68020", 5);
   if (from_tty)
     {
@@ -450,24 +421,23 @@ es1800_open (name, from_tty)
 }
 
 /*  Close out all files and local state before this target loses control.
-    quitting - are we quitting gdb now? */
+   quitting - are we quitting gdb now? */
 
 static void
-es1800_close (quitting)
-     int quitting;
+es1800_close (int quitting)
 {
   if (es1800_desc != NULL)
     {
       printf ("\nClosing connection to emulator...\n");
-      if (SERIAL_SET_TTY_STATE (es1800_desc, es1800_saved_ttystate) < 0)
+      if (serial_set_tty_state (es1800_desc, es1800_saved_ttystate) < 0)
        print_sys_errmsg ("warning: unable to restore tty state", errno);
-      fcntl (es1800_desc->fd, F_SETFL, es1800_fc_save);
-      SERIAL_CLOSE (es1800_desc);
+      fcntl (deprecated_serial_fd (es1800_desc), F_SETFL, es1800_fc_save);
+      serial_close (es1800_desc);
       es1800_desc = NULL;
     }
   if (savename != NULL)
     {
-      free (savename);
+      xfree (savename);
     }
   savename = NULL;
 
@@ -486,18 +456,16 @@ es1800_close (quitting)
       log_file = NULL;
     }
 
-#endif /* LOG_FILE */
+#endif /* LOG_FILE */
 
 }
 
 /*  Attaches to a process on the target side
-    proc_id  - the id of the process to be attached.
-    from_tty - says whether to be verbose or not */
+   proc_id  - the id of the process to be attached.
+   from_tty - says whether to be verbose or not */
 
 static void
-es1800_attach (args, from_tty)
-    char *args;
-    int from_tty;
+es1800_attach (char *args, int from_tty)
 {
   error ("Cannot attach to pid %s, this feature is not implemented yet.",
         args);
@@ -510,14 +478,12 @@ es1800_attach (args, from_tty)
    Close the open connection to the remote debugger.
    Use this when you want to detach and do something else
    with your gdb.
+
    args     - arguments given to the 'detach' command
    from_tty - says whether to be verbose or not */
 
 static void
-es1800_detach (args, from_tty)
-     char *args;
-     int from_tty;
+es1800_detach (char *args, int from_tty)
 {
   if (args)
     {
@@ -536,10 +502,7 @@ es1800_detach (args, from_tty)
    siggnal - the signal value to be given to the target (0 = no signal) */
 
 static void
-es1800_resume (pid, step, siggnal)
-     int pid;
-     int step;
-     enum target_signal siggnal;
+es1800_resume (ptid_t ptid, int step, enum target_signal siggnal)
 {
   char buf[PBUFSIZ];
 
@@ -549,7 +512,7 @@ es1800_resume (pid, step, siggnal)
     }
   if (step)
     {
-      strcpy (buf,"STP\r");
+      strcpy (buf, "STP\r");
       send (buf);
     }
   else
@@ -561,11 +524,9 @@ es1800_resume (pid, step, siggnal)
 /* Wait until the remote machine stops, then return,
    storing status in STATUS just as `wait' would.
    status -  */
-static int
-es1800_wait (pid, status)
-     int pid;
-     struct target_waitstatus *status;
+
+static ptid_t
+es1800_wait (ptid_t ptid, struct target_waitstatus *status)
 {
   unsigned char buf[PBUFSIZ];
   int old_timeout = timeout;
@@ -573,14 +534,14 @@ es1800_wait (pid, status)
   status->kind = TARGET_WAITKIND_EXITED;
   status->value.integer = 0;
 
-  timeout = 0;         /* Don't time out -- user program is running. */
+  timeout = 0;                 /* Don't time out -- user program is running. */
   if (!setjmp (interrupt))
     {
       old_sigint = signal (SIGINT, es1800_request_quit);
       while (1)
-        {
-         getmessage (buf, sizeof(buf));
-         if (strncmp ( buf, "\r\n* BREAK *", 11) == 0) 
+       {
+         getmessage (buf, sizeof (buf));
+         if (strncmp (buf, "\r\n* BREAK *", 11) == 0)
            {
              status->kind = TARGET_WAITKIND_STOPPED;
              status->value.sig = TARGET_SIGNAL_TRAP;
@@ -608,7 +569,7 @@ es1800_wait (pid, status)
              status->value.sig = TARGET_SIGNAL_QUIT;
              break;
            }
-        }
+       }
     }
   else
     {
@@ -621,16 +582,16 @@ es1800_wait (pid, status)
          printf (" emulator stopped\n");
          status->kind = TARGET_WAITKIND_STOPPED;
          status->value.sig = TARGET_SIGNAL_INT;
-        }
+       }
       else
        {
          fflush (stdin);
-         es1800_reset ((char*) 1);
+         es1800_reset ((char *) 1);
        }
     }
   signal (SIGINT, old_sigint);
   timeout = old_timeout;
-  return (0);
+  return inferior_ptid;
 }
 
 
@@ -638,19 +599,18 @@ es1800_wait (pid, status)
    regno - the register to be fetched (fetch all registers if -1) */
 
 static void
-es1800_fetch_register (regno)
-     int regno;
+es1800_fetch_register (int regno)
 {
   char buf[PBUFSIZ];
   int k;
   int r;
   char *p;
-  static char regtab[18][4] = 
-    {
-      "D0 ", "D1 ", "D2 ", "D3 ", "D4 ", "D5 ", "D6 ", "D7 ",
-      "A0 ", "A1 ", "A2 ", "A3 ", "A4 ", "A5 ", "A6 ", "SSP",
-      "SR ", "PC "
-    };
+  static char regtab[18][4] =
+  {
+    "D0 ", "D1 ", "D2 ", "D3 ", "D4 ", "D5 ", "D6 ", "D7 ",
+    "A0 ", "A1 ", "A2 ", "A3 ", "A4 ", "A5 ", "A6 ", "SSP",
+    "SR ", "PC "
+  };
 
   if ((regno < 15) || (regno == 16) || (regno == 17))
     {
@@ -659,11 +619,11 @@ es1800_fetch_register (regno)
       p = buf;
       for (k = 0; k < 4; k++)
        {
-         if ((p[k*2 + 1] == 0) || (p[k*2 + 2] == 0))
+         if ((p[k * 2 + 1] == 0) || (p[k * 2 + 2] == 0))
            {
              error ("Emulator reply is too short: %s", buf);
            }
-         registers[r++] = (fromhex (p[k*2 + 1]) * 16) + fromhex (p[k*2 + 2]);
+         registers[r++] = (fromhex (p[k * 2 + 1]) * 16) + fromhex (p[k * 2 + 2]);
        }
     }
   else
@@ -676,7 +636,7 @@ es1800_fetch_register (regno)
    Always fetches all registers. */
 
 static void
-es1800_fetch_registers ()
+es1800_fetch_registers (void)
 {
   char buf[PBUFSIZ];
   char SR_buf[PBUFSIZ];
@@ -695,16 +655,18 @@ es1800_fetch_registers ()
 
   /*  parsing row one - D0-D7-registers  */
 
-  while (*p++ != '\n') {;}
+  while (*p++ != '\n')
+    {;
+    }
   for (i = 4; i < 70; i += (i == 39 ? 3 : 1))
     {
       for (k = 0; k < 4; k++)
        {
-         if (p[i+0] == 0 || p[i+1] == 0)
+         if (p[i + 0] == 0 || p[i + 1] == 0)
            {
              error ("Emulator reply is too short: %s", buf);
            }
-         registers[r++] = (fromhex (p[i+0]) * 16) + fromhex (p[i+1]);
+         registers[r++] = (fromhex (p[i + 0]) * 16) + fromhex (p[i + 1]);
          i += 2;
        }
     }
@@ -712,22 +674,26 @@ es1800_fetch_registers ()
 
   /*  parsing row two - A0-A6-registers  */
 
-  while (*p++ != '\n') {;}
+  while (*p++ != '\n')
+    {;
+    }
   for (i = 4; i < 61; i += (i == 39 ? 3 : 1))
     {
       for (k = 0; k < 4; k++)
        {
-         if (p[i+0] == 0 || p[i+1] == 0)
+         if (p[i + 0] == 0 || p[i + 1] == 0)
            {
              error ("Emulator reply is too short: %s", buf);
            }
-         registers[r++] = (fromhex (p[i+0])) * 16 + fromhex (p[i+1]);
+         registers[r++] = (fromhex (p[i + 0])) * 16 + fromhex (p[i + 1]);
          i += 2;
        }
     }
   p += i;
 
-  while (*p++ != '\n') {;}
+  while (*p++ != '\n')
+    {;
+    }
 
   /* fetch SSP-, SR- and PC-registers  */
 
@@ -739,7 +705,7 @@ es1800_fetch_registers ()
 
   if (m68020)
     {
-      if (*p == '3')            /* use masterstackpointer MSP */
+      if (*p == '3')           /* use masterstackpointer MSP */
        {
          send_with_reply ("MSP", buf, sizeof (buf));
        }
@@ -747,50 +713,53 @@ es1800_fetch_registers ()
        {
          send_with_reply ("ISP", buf, sizeof (buf));
        }
-      else                     /* use userstackpointer USP  */
+      else
+       /* use userstackpointer USP  */
        {
-         send_with_reply ("USP", buf, sizeof (buf)); 
+         send_with_reply ("USP", buf, sizeof (buf));
        }
       p = buf;
-      for (k = 0; k<4; k++)
+      for (k = 0; k < 4; k++)
        {
-         if (p[k*2+1] == 0 || p[k*2+2] == 0)
+         if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
            {
              error ("Emulator reply is too short: %s", buf);
            }
-         registers[r++] = fromhex (buf[k*2+1]) * 16 + fromhex (buf[k*2+2]);
+         registers[r++] = fromhex (buf[k * 2 + 1]) * 16 + fromhex (buf[k * 2 + 2]);
        }
 
       p = SR_buf;
       for (k = 0; k < 4; k++)
        {
-         if (p[k*2+1] == 0 || p[k*2+2] == 0)
+         if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
            {
              error ("Emulator reply is too short: %s", buf);
            }
          registers[r++] =
-           fromhex (SR_buf[k*2+1]) * 16 + fromhex (SR_buf[k*2+2]);
+           fromhex (SR_buf[k * 2 + 1]) * 16 + fromhex (SR_buf[k * 2 + 2]);
        }
       send_with_reply ("PC", buf, sizeof (buf));
       p = buf;
-      for (k = 0; k<4; k++)
+      for (k = 0; k < 4; k++)
        {
-         if (p[k*2+1] == 0 || p[k*2+2] == 0)
+         if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
            {
              error ("Emulator reply is too short: %s", buf);
            }
-         registers[r++] = fromhex (buf[k*2+1]) * 16 + fromhex (buf[k*2+2]);
+         registers[r++] = fromhex (buf[k * 2 + 1]) * 16 + fromhex (buf[k * 2 + 2]);
        }
     }
-  else    /* 68000-mode */
-    {                       
-      if (*p == '2') /* use supervisorstackpointer SSP  */
+  else
+    /* 68000-mode */
+    {
+      if (*p == '2')           /* use supervisorstackpointer SSP  */
        {
-         send_with_reply ("SSP", buf, sizeof (buf)); 
+         send_with_reply ("SSP", buf, sizeof (buf));
        }
-      else  /* use userstackpointer USP  */
+      else
+       /* use userstackpointer USP  */
        {
-         send_with_reply ("USP", buf, sizeof (buf)); 
+         send_with_reply ("USP", buf, sizeof (buf));
        }
 
       /* fetch STACKPOINTER */
@@ -798,11 +767,11 @@ es1800_fetch_registers ()
       p = buf;
       for (k = 0; k < 4; k++)
        {
-         if (p[k*2 + 1] == 0 || p[k*2 + 2] == 0)
+         if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
            {
              error ("Emulator reply is too short: %s", buf);
            }
-         registers[r++] = fromhex (buf[k*2+1]) * 16 + fromhex (buf[k*2+2]);
+         registers[r++] = fromhex (buf[k * 2 + 1]) * 16 + fromhex (buf[k * 2 + 2]);
        }
 
       /* fetch STATUS */
@@ -810,45 +779,44 @@ es1800_fetch_registers ()
       p = SR_buf;
       for (k = 0; k < 4; k++)
        {
-         if (p[k*2+1] == 0 || p[k*2+2] == 0)
+         if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
            {
              error ("Emulator reply is too short: %s", buf);
            }
          registers[r++] =
-           fromhex (SR_buf[k*2+1]) * 16 + fromhex (SR_buf[k*2+2]);
+           fromhex (SR_buf[k * 2 + 1]) * 16 + fromhex (SR_buf[k * 2 + 2]);
        }
 
       /* fetch PC */
 
-      send_with_reply ("PC", buf, sizeof (buf)); 
+      send_with_reply ("PC", buf, sizeof (buf));
       p = buf;
       for (k = 0; k < 4; k++)
        {
-         if (p[k*2+1] == 0 || p[k*2+2] == 0)
+         if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
            {
              error ("Emulator reply is too short: %s", buf);
            }
-         registers[r++] = fromhex (buf[k*2+1]) * 16 + fromhex (buf[k*2+2]);
-       }    
+         registers[r++] = fromhex (buf[k * 2 + 1]) * 16 + fromhex (buf[k * 2 + 2]);
+       }
     }
 }
 
 /* Store register value, located in REGISTER, on the target processor.
    regno - the register-number of the register to store
-           (-1 means store them all)
+   (-1 means store them all)
    FIXME: Return errno value.  */
 
 static void
-es1800_store_register(regno)
-     int regno;
+es1800_store_register (int regno)
 {
 
   static char regtab[18][4] =
-    {
-      "D0 ", "D1 ", "D2 ", "D3 ", "D4 ", "D5 ", "D6 ", "D7 ",
-      "A0 ", "A1 ", "A2 ", "A3 ", "A4 ", "A5 ", "A6 ", "SSP",
-      "SR ", "PC "
-    };
+  {
+    "D0 ", "D1 ", "D2 ", "D3 ", "D4 ", "D5 ", "D6 ", "D7 ",
+    "A0 ", "A1 ", "A2 ", "A3 ", "A4 ", "A5 ", "A6 ", "SSP",
+    "SR ", "PC "
+  };
 
   char buf[PBUFSIZ];
   char SR_buf[PBUFSIZ];
@@ -861,17 +829,18 @@ es1800_store_register(regno)
 
   r = (unsigned char *) registers;
 
-  if (regno == -1)  /* write all registers */
+  if (regno == -1)             /* write all registers */
     {
       j = 0;
       k = 18;
     }
-  else              /* write one register */
+  else
+    /* write one register */
     {
       j = regno;
-      k = regno+1;
-      r += regno * 4; 
-    }    
+      k = regno + 1;
+      r += regno * 4;
+    }
 
   if ((regno == -1) || (regno == 15))
     {
@@ -881,37 +850,38 @@ es1800_store_register(regno)
       p += 5;
       if (m68020)
        {
-         if (*p == '3') /* use masterstackpointer MSP */
+         if (*p == '3')        /* use masterstackpointer MSP */
            {
-             strcpy (stack_pointer,"MSP");  
+             strcpy (stack_pointer, "MSP");
            }
          else
            {
-             if (*p == '2') /* use interruptstackpointer ISP  */
+             if (*p == '2')    /* use interruptstackpointer ISP  */
                {
-                 strcpy (stack_pointer,"ISP");  
+                 strcpy (stack_pointer, "ISP");
                }
              else
                {
-                 strcpy (stack_pointer,"USP");  /* use userstackpointer USP  */
+                 strcpy (stack_pointer, "USP");        /* use userstackpointer USP  */
                }
            }
        }
-      else  /* 68000-mode */
+      else
+       /* 68000-mode */
        {
-         if (*p == '2') /* use supervisorstackpointer SSP  */
+         if (*p == '2')        /* use supervisorstackpointer SSP  */
            {
-             strcpy (stack_pointer,"SSP");  
+             strcpy (stack_pointer, "SSP");
            }
          else
            {
-             strcpy (stack_pointer,"USP");/* use userstackpointer USP  */  
+             strcpy (stack_pointer, "USP");    /* use userstackpointer USP  */
            }
        }
-      strcpy (regtab[15],stack_pointer);
+      strcpy (regtab[15], stack_pointer);
     }
 
-  for (i = j; i<k; i++)
+  for (i = j; i < k; i++)
     {
       buf[0] = regtab[i][0];
       buf[1] = regtab[i][1];
@@ -928,15 +898,15 @@ es1800_store_register(regno)
       buf[12] = tohex (*r++ & 0x0f);
       buf[13] = 0;
 
-      send_with_reply (buf, buf, sizeof (buf)); /* FIXME, reply not used? */
+      send_with_reply (buf, buf, sizeof (buf));                /* FIXME, reply not used? */
     }
 }
 
 
 /* Prepare to store registers.  */
 
-static void 
-es1800_prepare_to_store ()
+static void
+es1800_prepare_to_store (void)
 {
   /* Do nothing, since we can store individual regs */
 }
@@ -944,8 +914,7 @@ es1800_prepare_to_store ()
 /* Convert hex digit A to a number.  */
 
 static int
-fromhex (a)
-     int a;
+fromhex (int a)
 {
   if (a >= '0' && a <= '9')
     {
@@ -970,8 +939,7 @@ fromhex (a)
 /* Convert number NIB to a hex digit.  */
 
 static int
-tohex (nib)
-     int nib;
+tohex (int nib)
 {
   if (nib < 10)
     {
@@ -986,19 +954,17 @@ tohex (nib)
 /* Read or write LEN bytes from inferior memory at MEMADDR, transferring
    to or from debugger address MYADDR.  Write to inferior if WRITE is
    nonzero.  Returns length of data written or read; 0 for error. 
+
    memaddr - the target's address
    myaddr  - gdb's address
    len     - number of bytes 
-   write   - write if != 0 otherwise read      */
+   write   - write if != 0 otherwise read
+   tops    - unused */
 
 static int
-es1800_xfer_inferior_memory (memaddr, myaddr, len, write, tops)
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
-     int write;
-     struct target_ops *tops;  /* Unused */
+es1800_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len,
+                            int write, struct mem_attrib *attrib,
+                            struct target_ops *target)
 {
   int origlen = len;
   int xfersize;
@@ -1018,7 +984,7 @@ es1800_xfer_inferior_memory (memaddr, myaddr, len, write, tops)
       myaddr += xfersize;
       len -= xfersize;
     }
-  return (origlen); /* no error possible */
+  return (origlen);            /* no error possible */
 }
 
 
@@ -1027,16 +993,13 @@ es1800_xfer_inferior_memory (memaddr, myaddr, len, write, tops)
    MEMADDR is the address in the remote memory space.
    MYADDR is the address of the buffer in our space.
    LEN is the number of bytes.
+
    memaddr - the target's address
    myaddr  - gdb's address
    len     - number of bytes   */
 
 static void
-es1800_write_bytes (memaddr, myaddr, len)
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
+es1800_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
 {
   char buf[PBUFSIZ];
   int i;
@@ -1045,26 +1008,24 @@ es1800_write_bytes (memaddr, myaddr, len)
   p = myaddr;
   for (i = 0; i < len; i++)
     {
-      sprintf (buf, "@.B$%x=$%x", memaddr+i, (*p++) & 0xff);
-      send_with_reply (buf, buf, sizeof (buf));      /* FIXME send_command? */
+      sprintf (buf, "@.B$%x=$%x", memaddr + i, (*p++) & 0xff);
+      send_with_reply (buf, buf, sizeof (buf));                /* FIXME send_command? */
     }
 }
 
 
 /* Read memory data directly from the emulator.
    This does not use the data cache; the data cache uses this.
+
    memaddr - the target's address
    myaddr  - gdb's address
    len     - number of bytes   */
 
 static void
-es1800_read_bytes (memaddr, myaddr, len)
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
+es1800_read_bytes (CORE_ADDR memaddr, char *myaddr, int len)
 {
-  static int DB_tab[16] = {8,11,14,17,20,23,26,29,34,37,40,43,46,49,52,55};
+  static int DB_tab[16] =
+  {8, 11, 14, 17, 20, 23, 26, 29, 34, 37, 40, 43, 46, 49, 52, 55};
   char buf[PBUFSIZ];
   int i;
   int low_addr;
@@ -1073,42 +1034,43 @@ es1800_read_bytes (memaddr, myaddr, len)
 
   if (len > PBUFSIZ / 2 - 1)
     {
-      abort ();
+      internal_error (__FILE__, __LINE__, "failed internal consistency check");
     }
 
-  if (len == 1)        /* The emulator does not like expressions like:  */
+  if (len == 1)                        /* The emulator does not like expressions like:  */
     {
-      len = 2; /* DB.B $20018 TO $20018                       */
+      len = 2;                 /* DB.B $20018 TO $20018                       */
     }
 
   /* Reply describes registers byte by byte, each byte encoded as two hex
      characters.  */
 
-  sprintf (buf, "DB.B $%x TO $%x", memaddr, memaddr+len-1);
+  sprintf (buf, "DB.B $%x TO $%x", memaddr, memaddr + len - 1);
   send_with_reply (buf, buf, sizeof (buf));
   b = buf;
-  low_addr = memaddr&0x0f;
+  low_addr = memaddr & 0x0f;
   for (i = low_addr; i < low_addr + len; i++)
     {
       if ((!(i % 16)) && i)
-       {   /* if (i = 16,32,48)  */
-         while (*p++!='\n') {;}
+       {                       /* if (i = 16,32,48)  */
+         while (*p++ != '\n')
+           {;
+           }
          b = p;
        }
-      p = b + DB_tab[i%16] + (m68020 ? 2 : 0);
+      p = b + DB_tab[i % 16] + (m68020 ? 2 : 0);
       if (p[0] == 32 || p[1] == 32)
        {
          error ("Emulator reply is too short: %s", buf);
        }
-      myaddr[i-low_addr] = fromhex (p[0]) * 16 + fromhex (p[1]);
+      myaddr[i - low_addr] = fromhex (p[0]) * 16 + fromhex (p[1]);
     }
 }
 
-/* Information about the current target  */
+/* Display information about the current target.  TOPS is unused.  */
 
 static void
-es1800_files_info (tops)
-     struct target_ops *tops;  /* Unused */
+es1800_files_info (struct target_ops *tops)
 {
   printf ("ES1800 Attached to %s at %d baud in %s mode\n", savename, 19200,
          MODE);
@@ -1117,21 +1079,19 @@ es1800_files_info (tops)
 
 /* We read the contents of the target location and stash it,
    then overwrite it with a breakpoint instruction.
+
    addr           - is the target location in the target machine.
    contents_cache - is a pointer to memory allocated for saving the target contents.
-                    It is guaranteed by the caller to be long enough to save sizeof 
-                    BREAKPOINT bytes.
+   It is guaranteed by the caller to be long enough to save sizeof 
+   BREAKPOINT bytes.
+
    FIXME: This size is target_arch dependent and should be available in
    the target_arch transfer vector, if we ever have one...  */
 
 static int
-es1800_insert_breakpoint (addr, contents_cache)
-     CORE_ADDR addr;
-     char *contents_cache;
+es1800_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
 {
-  int val; 
+  int val;
 
   val = target_read_memory (addr, contents_cache, sizeof (es1800_break_insn));
 
@@ -1146,16 +1106,14 @@ es1800_insert_breakpoint (addr, contents_cache)
 
 
 /* Write back the stashed instruction
+
    addr           - is the target location in the target machine.
    contents_cache - is a pointer to memory allocated for saving the target contents.
-                    It is guaranteed by the caller to be long enough to save sizeof 
-                    BREAKPOINT bytes.  */
+   It is guaranteed by the caller to be long enough to save sizeof 
+   BREAKPOINT bytes.    */
+
 static int
-es1800_remove_breakpoint (addr, contents_cache)
-     CORE_ADDR addr;
-     char *contents_cache;
+es1800_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
 {
 
   return (target_write_memory (addr, contents_cache,
@@ -1166,9 +1124,7 @@ es1800_remove_breakpoint (addr, contents_cache)
    Primitive datastructures containing the es1800 breakpoint instruction  */
 
 static void
-es1800_create_break_insn (ins, vec)
-     char *ins;
-     int vec;
+es1800_create_break_insn (char *ins, int vec)
 {
   if (vec == 15)
     {
@@ -1184,38 +1140,35 @@ es1800_create_break_insn (ins, vec)
    vec - trap vector used for breakpoints  */
 
 static int
-verify_break (vec)
-     int vec;
+verify_break (int vec)
 {
   CORE_ADDR memaddress;
   char buf[8];
-  char *instr = "NqNqNqNs";      /* breakpoint routine */
+  char *instr = "NqNqNqNs";    /* breakpoint routine */
   int status;
 
   get_break_addr (vec, &memaddress);
 
   if (memaddress)
     {
-      status = target_read_memory (memaddress, buf, 8); 
+      status = target_read_memory (memaddress, buf, 8);
       if (status != 0)
        {
          memory_error (status, memaddress);
        }
-      return (STRCMP (instr, buf));
+      return (strcmp (instr, buf));
     }
-    return (-1);
+  return (-1);
 }
 
 
 /* get_break_addr ()
-   find address of breakpint routine
+   find address of breakpoint routine
    vec - trap vector used for breakpoints
-   addrp - store the address here      */
+   addrp - store the address here       */
 
 static void
-get_break_addr (vec, addrp)
-     int vec;
-     CORE_ADDR *addrp;
+get_break_addr (int vec, CORE_ADDR *addrp)
 {
   CORE_ADDR memaddress = 0;
   int status;
@@ -1230,33 +1183,33 @@ get_break_addr (vec, addrp)
       p = buf;
       for (k = 0; k < 4; k++)
        {
-         if ((p[k*2 + 1] == 0) || (p[k*2 + 2] == 0))
+         if ((p[k * 2 + 1] == 0) || (p[k * 2 + 2] == 0))
            {
              error ("Emulator reply is too short: %s", buf);
            }
-         base_addr[k] = (fromhex (p[k*2 + 1]) * 16) + fromhex (p[k*2 + 2]);
+         base_addr[k] = (fromhex (p[k * 2 + 1]) * 16) + fromhex (p[k * 2 + 2]);
        }
       /* base addr of exception vector table */
       memaddress = *((CORE_ADDR *) base_addr);
     }
 
-    memaddress += (vec + 32) * 4;     /* address of trap vector */
-    status = target_read_memory (memaddress, (char *) addrp, 4); 
-    if (status != 0)                                                   
-      {
-       memory_error (status, memaddress);
-      }
+  memaddress += (vec + 32) * 4;        /* address of trap vector */
+  status = target_read_memory (memaddress, (char *) addrp, 4);
+  if (status != 0)
+    {
+      memory_error (status, memaddress);
+    }
 }
 
 
 /* Kill an inferior process */
 
 static void
-es1800_kill ()
+es1800_kill (void)
 {
-  if (inferior_pid != 0)
+  if (!ptid_equal (inferior_ptid, null_ptid))
     {
-      inferior_pid = 0;
+      inferior_ptid = null_ptid;
       es1800_mourn_inferior ();
     }
 }
@@ -1268,12 +1221,10 @@ es1800_kill ()
    Also loads the trap routine, and sets the ES1800 breakpoint on it
    filename - the a.out to be loaded
    from_tty - says whether to be verbose or not
-   FIXME Uses emulator overlay memory for trap routine */
+   FIXME Uses emulator overlay memory for trap routine  */
+
 static void
-es1800_load (filename, from_tty)
-     char *filename;
-     int from_tty;
+es1800_load (char *filename, int from_tty)
 {
 
   FILE *instream;
@@ -1282,51 +1233,51 @@ es1800_load (filename, from_tty)
   struct cleanup *old_chain;
   int es1800_load_format = 5;
 
-  if (es1800_desc == NULL) 
+  if (es1800_desc == NULL)
     {
       printf ("No emulator attached, type emulator-command first\n");
       return;
     }
 
   filename = tilde_expand (filename);
-  make_cleanup (free, filename);
+  make_cleanup (xfree, filename);
 
   switch (es1800_load_format)
     {
-      case 2:   /* Extended Tekhex  */
-        if (from_tty)
-         {
-           printf ("Converting \"%s\" to Extended Tekhex Format\n", filename);
-         }
-       sprintf (buf, "tekhex %s", filename);
-       system (buf);
-       sprintf (loadname, "out.hex");
-       break;
-
-      case 5:   /* Motorola S-rec  */
-       if (from_tty)
-         {
-           printf ("Converting \"%s\" to Motorola S-record format\n",
-                   filename);
-         }
-       /* in the future the source code in copy (part of binutils-1.93) will
-          be included in this file */
-       sprintf (buf,
-                "copy -s \"a.out-sunos-big\" -d \"srec\" %s /tmp/out.hex",
-                filename);
-       system (buf);
-       sprintf (loadname, "/tmp/out.hex");
-       break;
-
-      default:
-       error ("Downloading format not defined\n");
-    }
+    case 2:                    /* Extended Tekhex  */
+      if (from_tty)
+       {
+         printf ("Converting \"%s\" to Extended Tekhex Format\n", filename);
+       }
+      sprintf (buf, "tekhex %s", filename);
+      system (buf);
+      sprintf (loadname, "out.hex");
+      break;
+
+    case 5:                    /* Motorola S-rec  */
+      if (from_tty)
+       {
+         printf ("Converting \"%s\" to Motorola S-record format\n",
+                 filename);
+       }
+      /* in the future the source code in copy (part of binutils-1.93) will
+         be included in this file */
+      sprintf (buf,
+              "copy -s \"a.out-sunos-big\" -d \"srec\" %s /tmp/out.hex",
+              filename);
+      system (buf);
+      sprintf (loadname, "/tmp/out.hex");
+      break;
+
+    default:
+      error ("Downloading format not defined\n");
+    }
+
   breakpoint_init_inferior ();
-  inferior_pid = 0;
+  inferior_ptid = null_ptid;
   if (from_tty)
     {
-      printf ("Downloading \"%s\" to the ES 1800\n",filename);
+      printf ("Downloading \"%s\" to the ES 1800\n", filename);
     }
   if ((instream = fopen (loadname, "r")) == NULL)
     {
@@ -1356,7 +1307,7 @@ es1800_load (filename, from_tty)
 
   do_cleanups (old_chain);
   expect_prompt ();
-  readchar ();  /* FIXME I am getting a ^G = 7 after the prompt  */
+  readchar ();                 /* FIXME I am getting a ^G = 7 after the prompt  */
   printf ("\n");
 
   if (fclose (instream) == EOF)
@@ -1370,7 +1321,7 @@ es1800_load (filename, from_tty)
       system (buf);
     }
 
-  symbol_file_command (filename, from_tty);   /* reading symbol table */
+  symbol_file_add_main (filename, from_tty);   /* reading symbol table */
   immediate_quit--;
 }
 
@@ -1379,9 +1330,7 @@ es1800_load (filename, from_tty)
 #define NUMCPYBYTES 20
 
 static void
-bfd_copy (from_bfd, to_bfd)
-     bfd *from_bfd;
-     bfd *to_bfd;
+bfd_copy (bfd *from_bfd, bfd *to_bfd)
 {
   asection *p, *new;
   int i;
@@ -1403,40 +1352,37 @@ bfd_copy (from_bfd, to_bfd)
          error ("bfd_set_section_flags");
        }
       new->vma = p->vma;
-      
-      for (i = 0; (i + NUMCPYBYTES) < p->_cooked_size ; i += NUMCPYBYTES)
+
+      for (i = 0; (i + NUMCPYBYTES) < p->_cooked_size; i += NUMCPYBYTES)
        {
          if (!bfd_get_section_contents (from_bfd, p, (PTR) buf, (file_ptr) i,
-                                       (bfd_size_type) NUMCPYBYTES))
+                                        (bfd_size_type) NUMCPYBYTES))
            {
              error ("bfd_get_section_contents\n");
            }
-       if (!bfd_set_section_contents (to_bfd, new, (PTR) buf, (file_ptr) i,
-                                     (bfd_size_type) NUMCPYBYTES))
-         {
-           error ("bfd_set_section_contents\n");
-         }
-      }
+         if (!bfd_set_section_contents (to_bfd, new, (PTR) buf, (file_ptr) i,
+                                        (bfd_size_type) NUMCPYBYTES))
+           {
+             error ("bfd_set_section_contents\n");
+           }
+       }
       bfd_get_section_contents (from_bfd, p, (PTR) buf, (file_ptr) i,
                                (bfd_size_type) (p->_cooked_size - i));
-      bfd_set_section_contents (to_bfd, new, (PTR) buf,(file_ptr) i,
+      bfd_set_section_contents (to_bfd, new, (PTR) buf, (file_ptr) i,
                                (bfd_size_type) (p->_cooked_size - i));
     }
 }
 
 #endif
 
-/* Start an process on the es1800 and set inferior_pid to the new
+/* Start an process on the es1800 and set inferior_ptid to the new
    process' pid.
    execfile - the file to run
    args     - arguments passed to the program
-   env      - the environment vector to pass   */
+   env      - the environment vector to pass    */
 
 static void
-es1800_create_inferior (execfile, args, env)
-     char *execfile;
-     char *args;
-     char **env;
+es1800_create_inferior (char *execfile, char *args, char **env)
 {
   int entry_pt;
   int pid;
@@ -1468,7 +1414,7 @@ es1800_create_inferior (execfile, args, env)
 
   if (execfile == 0 || exec_bfd == 0)
     {
-      error ("No exec file specified");
+      error ("No executable file specified");
     }
 
   entry_pt = (int) bfd_get_start_address (exec_bfd);
@@ -1482,7 +1428,7 @@ es1800_create_inferior (execfile, args, env)
   /* The "process" (board) is already stopped awaiting our commands, and
      the program is already downloaded.  We just set its PC and go.  */
 
-  inferior_pid = pid;          /* Needed for wait_for_inferior below */
+  inferior_ptid = pid_to_ptid (pid);   /* Needed for wait_for_inferior below */
 
   clear_proceed_status ();
 
@@ -1512,7 +1458,7 @@ es1800_create_inferior (execfile, args, env)
 /* The process has died, clean up.  */
 
 static void
-es1800_mourn_inferior ()
+es1800_mourn_inferior (void)
 {
   remove_breakpoints ();
   unpush_target (&es1800_child_ops);
@@ -1525,12 +1471,10 @@ es1800_mourn_inferior ()
    Let the user break out immediately. 
    string - the string to expect
    nowait - break out if string not the emulator's first respond otherwise
-            read until string is found (== 0)   */
+   read until string is found (== 0)   */
+
 static void
-expect (string, nowait)
-     char *string;
-    int nowait;
+expect (char *string, int nowait)
 {
   char c;
   char *p = string;
@@ -1558,9 +1502,9 @@ expect (string, nowait)
        }
       else
        {
-         printf ("\'%s\' expected\n" , string);
+         printf ("\'%s\' expected\n", string);
          printf ("char %d is %d", p - string, c);
-         error ("\n" );
+         error ("\n");
        }
     }
 }
@@ -1568,7 +1512,7 @@ expect (string, nowait)
 /* Keep discarding input until we see the prompt.  */
 
 static void
-expect_prompt ()
+expect_prompt (void)
 {
   expect (">", 0);
 }
@@ -1581,7 +1525,7 @@ expect_prompt ()
 /* read from stdin */
 
 static int
-readchar ()
+readchar (void)
 {
   char buf[1];
 
@@ -1596,17 +1540,17 @@ readchar ()
   return (buf[0] & 0x7f);
 }
 
-#else  /* !DEBUG_STDIN */
+#else /* !DEBUG_STDIN */
 
 /* Read a character from the remote system, doing all the fancy
    timeout stuff.  */
 
 static int
-readchar ()
+readchar (void)
 {
   int ch;
 
-  ch = SERIAL_READCHAR (es1800_desc, timeout);
+  ch = serial_readchar (es1800_desc, timeout);
 
   /* FIXME: doing an error() here will probably cause trouble, at least if from
      es1800_wait.  */
@@ -1623,7 +1567,7 @@ readchar ()
   return (ch);
 }
 
-#endif /* DEBUG_STDIN */
+#endif /* DEBUG_STDIN */
 
 
 /* Send a command to the emulator and save the reply.
@@ -1633,12 +1577,10 @@ readchar ()
    len    - size of buf  */
 
 static void
-send_with_reply (string, buf, len)
-    char *string, *buf;
-    int len;
+send_with_reply (char *string, char *buf, int len)
 {
   send (string);
-  SERIAL_WRITE (es1800_desc, "\r", 1);
+  serial_write (es1800_desc, "\r", 1);
 
 #ifndef DEBUG_STDIN
   expect (string, 1);
@@ -1652,13 +1594,12 @@ send_with_reply (string, buf, len)
 /* Send the command in STR to the emulator adding \r. check
    the echo for consistency. 
    string - the es1800 command  */
+
 static void
-send_command (string)
-     char *string;
+send_command (char *string)
 {
   send (string);
-  SERIAL_WRITE (es1800_desc, "\r", 1);
+  serial_write (es1800_desc, "\r", 1);
 
 #ifndef DEBUG_STDIN
   expect (string, 0);
@@ -1671,25 +1612,22 @@ send_command (string)
    string - the es1800 command  */
 
 static void
-send (string)
-     char *string;
+send (char *string)
 {
-  if (kiodebug) 
+  if (kiodebug)
     {
       fprintf (stderr, "Sending: %s\n", string);
     }
-  SERIAL_WRITE (es1800_desc, string, strlen (string));
+  serial_write (es1800_desc, string, strlen (string));
 }
 
 
 /* Read a message from the emulator and store it in BUF. 
    buf    - containing the emulator reply on return
    len    - size of buf  */
+
 static void
-getmessage (buf, len)
-     char *buf;
-     int len;
+getmessage (char *buf, int len)
 {
   char *bp;
   int c;
@@ -1706,9 +1644,9 @@ getmessage (buf, len)
   c = readchar ();
   do
     {
-      if (c) 
+      if (c)
        {
-         if (len-- < 2) /* char and terminaling NULL */
+         if (len-- < 2)        /* char and terminaling NULL */
            {
              error ("input buffer overrun\n");
            }
@@ -1722,32 +1660,29 @@ getmessage (buf, len)
     }
   while (!prompt_found);
   *bp = 0;
-  
+
   if (kiodebug)
     {
-      fprintf (stderr,"message received :%s\n", buf);
+      fprintf (stderr, "message received :%s\n", buf);
     }
 }
 
 static void
-download (instream, from_tty, format)
-FILE *instream;
-     int from_tty;
-     int format;
+download (FILE *instream, int from_tty, int format)
 {
   char c;
   char buf[160];
   int i = 0;
 
-  send_command ("SET #2,$1A");                  /* reset char = ^Z */
-  send_command ("SET #3,$11,$13");              /* XON  XOFF */
+  send_command ("SET #2,$1A"); /* reset char = ^Z */
+  send_command ("SET #3,$11,$13");     /* XON  XOFF */
   if (format == 2)
     {
       send_command ("SET #26,#2");
     }
   else
     {
-      send_command ("SET #26,#5");             /* Format=Extended Tekhex */
+      send_command ("SET #26,#5");     /* Format=Extended Tekhex */
     }
   send_command ("DFB = $10");
   send_command ("PUR");
@@ -1759,18 +1694,18 @@ FILE *instream;
       printf ("    0 records loaded...\r");
     }
   while (fgets (buf, 160, instream))
-      {
-       send (buf);
-       if (from_tty)
-         {
-           printf ("%5d\b\b\b\b\b",++i);
-           fflush (stdout);
-         }
-       if ((c = readchar ()) != 006) 
-         {
-           error ("expected ACK");
-         }
-      }
+    {
+      send (buf);
+      if (from_tty)
+       {
+         printf ("%5d\b\b\b\b\b", ++i);
+         fflush (stdout);
+       }
+      if ((c = readchar ()) != 006)
+       {
+         error ("expected ACK");
+       }
+    }
   if (from_tty)
     {
       printf ("- All");
@@ -1787,11 +1722,9 @@ FILE *instream;
 /* Talk directly to the emulator
    FIXME, uses busy wait, and is SUNOS (or at least BSD) specific  */
 
-/*ARGSUSED*/
-static void 
-es1800_transparent (args, from_tty)
-     char *args;
-     int from_tty;
+/*ARGSUSED */
+static void
+es1800_transparent (char *args, int from_tty)
 {
   int console;
   struct sgttyb modebl;
@@ -1809,7 +1742,7 @@ es1800_transparent (args, from_tty)
   int i;
 
   dont_repeat ();
-  if (es1800_desc == NULL) 
+  if (es1800_desc == NULL)
     {
       printf ("No emulator attached, type emulator-command first\n");
       return;
@@ -1822,7 +1755,7 @@ es1800_transparent (args, from_tty)
   printf (" >");
   fflush (stdout);
 
-  if ((console = open ("/dev/tty", O_RDWR)) == -1) 
+  if ((console = open ("/dev/tty", O_RDWR)) == -1)
     {
       perror_with_name ("/dev/tty:");
     }
@@ -1846,14 +1779,14 @@ es1800_transparent (args, from_tty)
     }
 
   console_mode_save = modebl;
-  modebl.sg_flags = RAW; 
+  modebl.sg_flags = RAW;
 
   if (ioctl (console, TIOCSETP, &modebl))
     {
       perror_with_name ("ioctl console");
     }
 
-  if ((fcflag = fcntl (es1800_desc->fd, F_GETFL, 0)) == -1)
+  if ((fcflag = fcntl (deprecated_serial_fd (es1800_desc), F_GETFL, 0)) == -1)
     {
       perror_with_name ("fcntl serial");
     }
@@ -1861,13 +1794,13 @@ es1800_transparent (args, from_tty)
   es1800_fc_save = fcflag;
   fcflag = fcflag | FNDELAY;
 
-  if (fcntl (es1800_desc->fd, F_SETFL, fcflag) == -1)
+  if (fcntl (deprecated_serial_fd (es1800_desc), F_SETFL, fcflag) == -1)
     {
       perror_with_name ("fcntl serial");
     }
 
   while (1)
-    { 
+    {
       cc = read (console, inputbuf, inputcnt);
       if (cc != -1)
        {
@@ -1875,20 +1808,20 @@ es1800_transparent (args, from_tty)
            {
              break;
            }
-         for (i = 0; i < cc; )
+         for (i = 0; i < cc;)
            {
              es1800_buf[es1800_cnt++] = inputbuf[i++];
            }
-         if ((cc = SERIAL_WRITE (es1800_desc, es1800_buf, es1800_cnt)) == -1)
+         if ((cc = serial_write (es1800_desc, es1800_buf, es1800_cnt)) == -1)
            {
              perror_with_name ("FEL! write:");
            }
          es1800_cnt -= cc;
-         if (es1800_cnt && cc) 
+         if (es1800_cnt && cc)
            {
              for (i = 0; i < es1800_cnt; i++)
                {
-                 es1800_buf[i] = es1800_buf[cc+i];
+                 es1800_buf[i] = es1800_buf[cc + i];
                }
            }
        }
@@ -1896,24 +1829,24 @@ es1800_transparent (args, from_tty)
        {
          perror_with_name ("FEL! read:");
        }
-      
-      cc = read (es1800_desc->fd,inputbuf,inputcnt);
+
+      cc = read (deprecated_serial_fd (es1800_desc), inputbuf, inputcnt);
       if (cc != -1)
        {
-         for (i = 0; i < cc; )
+         for (i = 0; i < cc;)
            {
              consolebuf[consolecnt++] = inputbuf[i++];
            }
-         if ((cc = write (console,consolebuf,consolecnt)) == -1)
+         if ((cc = write (console, consolebuf, consolecnt)) == -1)
            {
              perror_with_name ("FEL! write:");
            }
          consolecnt -= cc;
-         if (consolecnt && cc) 
+         if (consolecnt && cc)
            {
              for (i = 0; i < consolecnt; i++)
                {
-                 consolebuf[i] = consolebuf[cc+i];
+                 consolebuf[i] = consolebuf[cc + i];
                }
            }
        }
@@ -1936,7 +1869,7 @@ es1800_transparent (args, from_tty)
 
   close (console);
 
-  if (fcntl (es1800_desc->fd, F_SETFL, es1800_fc_save) == -1)
+  if (fcntl (deprecated_serial_fd (es1800_desc), F_SETFL, es1800_fc_save) == -1)
     {
       perror_with_name ("FEL! fcntl");
     }
@@ -1947,9 +1880,7 @@ es1800_transparent (args, from_tty)
 #endif /* PROVIDE_TRANSPARENT */
 
 static void
-es1800_init_break (args, from_tty)
-     char *args;
-     int from_tty;
+es1800_init_break (char *args, int from_tty)
 {
   CORE_ADDR memaddress = 0;
   char buf[PBUFSIZ];
@@ -1981,164 +1912,210 @@ es1800_init_break (args, from_tty)
       p = buf;
       for (k = 0; k < 4; k++)
        {
-         if ((p[k*2 + 1] == 0) || (p[k*2 + 2] == 0))
+         if ((p[k * 2 + 1] == 0) || (p[k * 2 + 2] == 0))
            {
              error ("Emulator reply is too short: %s", buf);
            }
-         base_addr[k] = (fromhex (p[k*2 + 1]) * 16) + fromhex (p[k*2 + 2]);
+         base_addr[k] = (fromhex (p[k * 2 + 1]) * 16) + fromhex (p[k * 2 + 2]);
        }
       /* base addr of exception vector table */
-      memaddress =  *((CORE_ADDR *) base_addr);
+      memaddress = *((CORE_ADDR *) base_addr);
     }
 
-  memaddress += (es1800_break_vec + 32) * 4;     /* address of trap vector */
+  memaddress += (es1800_break_vec + 32) * 4;   /* address of trap vector */
 
   sprintf (buf, "@.L%lx=$%lx", memaddress, es1800_break_address);
-  send_command (buf);   /* set the address of the break routine in the */
-                      /* trap vector */
-  
-  sprintf (buf, "@.L%lx=$4E714E71", es1800_break_address);      /* NOP; NOP */
+  send_command (buf);          /* set the address of the break routine in the */
+  /* trap vector */
+
+  sprintf (buf, "@.L%lx=$4E714E71", es1800_break_address);     /* NOP; NOP */
   send_command (buf);
-  sprintf (buf, "@.L%lx=$4E714E73", es1800_break_address + 4);  /* NOP; RTE */
+  sprintf (buf, "@.L%lx=$4E714E73", es1800_break_address + 4); /* NOP; RTE */
   send_command (buf);
-  
+
   sprintf (buf, "AC2=$%lx", es1800_break_address + 4);
   /* breakpoint at es1800-break_address */
   send_command (buf);
-  send_command ("WHEN AC2 THEN BRK");          /* ie in exception routine */
+  send_command ("WHEN AC2 THEN BRK");  /* ie in exception routine */
 
   if (from_tty)
     {
       printf ("Breakpoint (trap $%x) routine at address: %lx\n",
              es1800_break_vec, es1800_break_address);
     }
-}        
+}
 
 static void
-es1800_child_open (arg, from_tty)
-     char *arg;
-     int from_tty;
+es1800_child_open (char *arg, int from_tty)
 {
   error ("Use the \"run\" command to start a child process.");
 }
 
 static void
-es1800_child_detach (args, from_tty)
-     char *args;
-     int from_tty;
+es1800_child_detach (char *args, int from_tty)
 {
   if (args)
     {
       error ("Argument given to \"detach\" when remotely debugging.");
     }
-  
+
   pop_target ();
   if (from_tty)
     {
-      printf ("Ending debugging the process %d.\n", inferior_pid);
+      printf ("Ending debugging the process %d.\n", PIDGET (inferior_ptid));
     }
 }
 
 
 /* Define the target subroutine names  */
 
-struct target_ops es1800_ops =
+struct target_ops es1800_ops;
+
+static void
+init_es1800_ops (void)
 {
-  "es1800",                    /* to_shortname */
-                               /* to_longname */
-  "Remote serial target in ES1800-emulator protocol",
-                               /* to_doc */
-  "Remote debugging on the es1800 emulator via a serial line.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya).",
-  es1800_open,                 /* to_open */
-  es1800_close,                        /* to_close */
-  es1800_attach,               /* to_attach */
-  es1800_detach,               /* to_detach */
-  es1800_resume,               /* to_resume */
-  NULL,                                /* to_wait */
-  NULL,                                /* to_fetch_registers */
-  NULL,                                /* to_store_registers */
-  es1800_prepare_to_store,     /* to_prepare_to_store */
-  es1800_xfer_inferior_memory, /* to_xfer_memory */
-  es1800_files_info,           /* to_files_info */
-  es1800_insert_breakpoint,    /* to_insert_breakpoint */
-  es1800_remove_breakpoint,    /* to_remove_breakpoint */
-  NULL,                                /* to_terminal_init */
-  NULL,                                /* to_terminal_inferior */
-  NULL,                                /* to_terminal_ours_for_output */
-  NULL,                                /* to_terminal_ours */
-  NULL,                                /* to_terminal_info */
-  NULL,                                /* to_kill */
-  es1800_load,                 /* to_load */
-  NULL,                                /* to_lookup_symbol */
-  es1800_create_inferior,      /* to_create_inferior */
-  NULL,                                /* to_mourn_inferior */
-  0,                           /* to_can_run */
-  0,                           /* to_notice_signals */
-  0,                           /* to_stop */
-  core_stratum,                        /* to_stratum */
-  0,                           /* to_next */
-  0,                           /* to_has_all_memory */
-  1,                           /* to_has_memory */
-  0,                           /* to_has_stack */
-  0,                           /* to_has_registers */
-  0,                           /* to_has_execution */
-  NULL,                                /* to_sections */
-  NULL,                                /* to_sections_end */
-  OPS_MAGIC                    /* to_magic (always last) */
-};
+  es1800_ops.to_shortname = "es1800";
+  es1800_ops.to_longname = "Remote serial target in ES1800-emulator protocol";
+  es1800_ops.to_doc = "Remote debugging on the es1800 emulator via a serial line.\n\
+Specify the serial device it is connected to (e.g. /dev/ttya).";
+  es1800_ops.to_open = es1800_open;
+  es1800_ops.to_close = es1800_close;
+  es1800_ops.to_attach = es1800_attach;
+  es1800_ops.to_post_attach = NULL;
+  es1800_ops.to_require_attach = NULL;
+  es1800_ops.to_detach = es1800_detach;
+  es1800_ops.to_require_detach = NULL;
+  es1800_ops.to_resume = es1800_resume;
+  es1800_ops.to_wait = NULL;
+  es1800_ops.to_post_wait = NULL;
+  es1800_ops.to_fetch_registers = NULL;
+  es1800_ops.to_store_registers = NULL;
+  es1800_ops.to_prepare_to_store = es1800_prepare_to_store;
+  es1800_ops.to_xfer_memory = es1800_xfer_inferior_memory;
+  es1800_ops.to_files_info = es1800_files_info;
+  es1800_ops.to_insert_breakpoint = es1800_insert_breakpoint;
+  es1800_ops.to_remove_breakpoint = es1800_remove_breakpoint;
+  es1800_ops.to_terminal_init = NULL;
+  es1800_ops.to_terminal_inferior = NULL;
+  es1800_ops.to_terminal_ours_for_output = NULL;
+  es1800_ops.to_terminal_ours = NULL;
+  es1800_ops.to_terminal_info = NULL;
+  es1800_ops.to_kill = NULL;
+  es1800_ops.to_load = es1800_load;
+  es1800_ops.to_lookup_symbol = NULL;
+  es1800_ops.to_create_inferior = es1800_create_inferior;
+  es1800_ops.to_post_startup_inferior = NULL;
+  es1800_ops.to_acknowledge_created_inferior = NULL;
+  es1800_ops.to_clone_and_follow_inferior = NULL;
+  es1800_ops.to_post_follow_inferior_by_clone = NULL;
+  es1800_ops.to_insert_fork_catchpoint = NULL;
+  es1800_ops.to_remove_fork_catchpoint = NULL;
+  es1800_ops.to_insert_vfork_catchpoint = NULL;
+  es1800_ops.to_remove_vfork_catchpoint = NULL;
+  es1800_ops.to_has_forked = NULL;
+  es1800_ops.to_has_vforked = NULL;
+  es1800_ops.to_can_follow_vfork_prior_to_exec = NULL;
+  es1800_ops.to_post_follow_vfork = NULL;
+  es1800_ops.to_insert_exec_catchpoint = NULL;
+  es1800_ops.to_remove_exec_catchpoint = NULL;
+  es1800_ops.to_has_execd = NULL;
+  es1800_ops.to_reported_exec_events_per_exec_call = NULL;
+  es1800_ops.to_has_exited = NULL;
+  es1800_ops.to_mourn_inferior = NULL;
+  es1800_ops.to_can_run = 0;
+  es1800_ops.to_notice_signals = 0;
+  es1800_ops.to_thread_alive = 0;
+  es1800_ops.to_stop = 0;
+  es1800_ops.to_pid_to_exec_file = NULL;
+  es1800_ops.to_stratum = core_stratum;
+  es1800_ops.DONT_USE = 0;
+  es1800_ops.to_has_all_memory = 0;
+  es1800_ops.to_has_memory = 1;
+  es1800_ops.to_has_stack = 0;
+  es1800_ops.to_has_registers = 0;
+  es1800_ops.to_has_execution = 0;
+  es1800_ops.to_sections = NULL;
+  es1800_ops.to_sections_end = NULL;
+  es1800_ops.to_magic = OPS_MAGIC;
+}
 
 /* Define the target subroutine names  */
 
-struct target_ops es1800_child_ops =
+struct target_ops es1800_child_ops;
+
+static void
+init_es1800_child_ops (void)
 {
-  "es1800_process",            /* to_shortname */
-                               /* to_longname */
-  "Remote serial target in ES1800-emulator protocol",
-                               /* to_doc */
-  "Remote debugging on the es1800 emulator via a serial line.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya).",
-  es1800_child_open,           /* to_open */
-  NULL,                                /* to_close */
-  es1800_attach,               /* to_attach */
-  es1800_child_detach,         /* to_detach */
-  es1800_resume,               /* to_resume */
-  es1800_wait,                 /* to_wait */
-  es1800_fetch_register,       /* to_fetch_registers */
-  es1800_store_register,       /* to_store_registers */
-  es1800_prepare_to_store,     /* to_prepare_to_store */
-  es1800_xfer_inferior_memory, /* to_xfer_memory */
-  es1800_files_info,           /* to_files_info */
-  es1800_insert_breakpoint,    /* to_insert_breakpoint */
-  es1800_remove_breakpoint,    /* to_remove_breakpoint */
-  NULL,                                /* to_terminal_init */
-  NULL,                                /* to_terminal_inferior */
-  NULL,                                /* to_terminal_ours_for_output */
-  NULL,                                /* to_terminal_ours */
-  NULL,                                /* to_terminal_info */
-  es1800_kill,                 /* to_kill */
-  es1800_load,                 /* to_load */
-  NULL,                                /* to_lookup_symbol */
-  es1800_create_inferior,      /* to_create_inferior */
-  es1800_mourn_inferior,       /* to_mourn_inferior */
-  0,                           /* to_can_run */
-  0,                           /* notice_signals */
-  0,                           /* to_stop */
-  process_stratum,             /* to_stratum */
-  0,                           /* to_next */
-  1,                           /* to_has_all_memory */
-  1,                           /* to_has_memory */
-  1,                           /* to_has_stack */
-  1,                           /* to_has_registers */
-  1,                           /* to_has_execution */
-  NULL,                                /* to_sections */
-  NULL,                                /* to_sections_end */
-  OPS_MAGIC                    /* to_magic (always last) */
-};
+  es1800_child_ops.to_shortname = "es1800_process";
+  es1800_child_ops.to_longname = "Remote serial target in ES1800-emulator protocol";
+  es1800_child_ops.to_doc = "Remote debugging on the es1800 emulator via a serial line.\n\
+Specify the serial device it is connected to (e.g. /dev/ttya).";
+  es1800_child_ops.to_open = es1800_child_open;
+  es1800_child_ops.to_close = NULL;
+  es1800_child_ops.to_attach = es1800_attach;
+  es1800_child_ops.to_post_attach = NULL;
+  es1800_child_ops.to_require_attach = NULL;
+  es1800_child_ops.to_detach = es1800_child_detach;
+  es1800_child_ops.to_require_detach = NULL;
+  es1800_child_ops.to_resume = es1800_resume;
+  es1800_child_ops.to_wait = es1800_wait;
+  es1800_child_ops.to_post_wait = NULL;
+  es1800_child_ops.to_fetch_registers = es1800_fetch_register;
+  es1800_child_ops.to_store_registers = es1800_store_register;
+  es1800_child_ops.to_prepare_to_store = es1800_prepare_to_store;
+  es1800_child_ops.to_xfer_memory = es1800_xfer_inferior_memory;
+  es1800_child_ops.to_files_info = es1800_files_info;
+  es1800_child_ops.to_insert_breakpoint = es1800_insert_breakpoint;
+  es1800_child_ops.to_remove_breakpoint = es1800_remove_breakpoint;
+  es1800_child_ops.to_terminal_init = NULL;
+  es1800_child_ops.to_terminal_inferior = NULL;
+  es1800_child_ops.to_terminal_ours_for_output = NULL;
+  es1800_child_ops.to_terminal_ours = NULL;
+  es1800_child_ops.to_terminal_info = NULL;
+  es1800_child_ops.to_kill = es1800_kill;
+  es1800_child_ops.to_load = es1800_load;
+  es1800_child_ops.to_lookup_symbol = NULL;
+  es1800_child_ops.to_create_inferior = es1800_create_inferior;
+  es1800_child_ops.to_post_startup_inferior = NULL;
+  es1800_child_ops.to_acknowledge_created_inferior = NULL;
+  es1800_child_ops.to_clone_and_follow_inferior = NULL;
+  es1800_child_ops.to_post_follow_inferior_by_clone = NULL;
+  es1800_child_ops.to_insert_fork_catchpoint = NULL;
+  es1800_child_ops.to_remove_fork_catchpoint = NULL;
+  es1800_child_ops.to_insert_vfork_catchpoint = NULL;
+  es1800_child_ops.to_remove_vfork_catchpoint = NULL;
+  es1800_child_ops.to_has_forked = NULL;
+  es1800_child_ops.to_has_vforked = NULL;
+  es1800_child_ops.to_can_follow_vfork_prior_to_exec = NULL;
+  es1800_child_ops.to_post_follow_vfork = NULL;
+  es1800_child_ops.to_insert_exec_catchpoint = NULL;
+  es1800_child_ops.to_remove_exec_catchpoint = NULL;
+  es1800_child_ops.to_has_execd = NULL;
+  es1800_child_ops.to_reported_exec_events_per_exec_call = NULL;
+  es1800_child_ops.to_has_exited = NULL;
+  es1800_child_ops.to_mourn_inferior = es1800_mourn_inferior;
+  es1800_child_ops.to_can_run = 0;
+  es1800_child_ops.to_notice_signals = 0;
+  es1800_child_ops.to_thread_alive = 0;
+  es1800_child_ops.to_stop = 0;
+  es1800_child_ops.to_pid_to_exec_file = NULL;
+  es1800_child_ops.to_stratum = process_stratum;
+  es1800_child_ops.DONT_USE = 0;
+  es1800_child_ops.to_has_all_memory = 1;
+  es1800_child_ops.to_has_memory = 1;
+  es1800_child_ops.to_has_stack = 1;
+  es1800_child_ops.to_has_registers = 1;
+  es1800_child_ops.to_has_execution = 1;
+  es1800_child_ops.to_sections = NULL;
+  es1800_child_ops.to_sections_end = NULL;
+  es1800_child_ops.to_magic = OPS_MAGIC;
+}
 
 void
-_initialize_es1800 ()
+_initialize_es1800 (void)
 {
+  init_es1800_ops ();
+  init_es1800_child_ops ();
   add_target (&es1800_ops);
   add_target (&es1800_child_ops);
 #ifdef PROVIDE_TRANSPARENT
@@ -2146,5 +2123,5 @@ _initialize_es1800 ()
           "Start transparent communication with the ES 1800 emulator.");
 #endif /* PROVIDE_TRANSPARENT */
   add_com ("init_break", class_support, es1800_init_break,
-          "Download break routine and initialize break facility on ES 1800");
+        "Download break routine and initialize break facility on ES 1800");
 }