GDB/MI: Document support for -exec-run --start in -list-features
[deliverable/binutils-gdb.git] / gdb / remote-mips.c
index bc82bc8c5145fbcaa596917f1a4d567ceb4f5701..e4e508341cc34a27d828392fb847560abc9c7b64 100644 (file)
@@ -1,8 +1,6 @@
 /* Remote debugging interface for MIPS remote debugging protocol.
 
-   Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 1993-2013 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support.  Written by Ian Lance Taylor
    <ian@cygnus.com>.
 #include "serial.h"
 #include "target.h"
 #include "exceptions.h"
-#include "gdb_string.h"
-#include "gdb_stat.h"
+#include <string.h>
+#include <sys/stat.h>
+#include "gdb_usleep.h"
 #include "regcache.h"
 #include <ctype.h>
 #include "mips-tdep.h"
 #include "gdbthread.h"
+#include "gdb_bfd.h"
 \f
 
 /* Breakpoint types.  Values 0, 1, and 2 must agree with the watch
@@ -63,7 +63,7 @@ static int mips_receive_trailer (unsigned char *trlr, int *pgarbage,
                                 int *pch, int timeout);
 
 static int mips_cksum (const unsigned char *hdr,
-                      const unsigned char *data, int len);
+                      const char *data, int len);
 
 static void mips_send_packet (const char *s, int get_ack);
 
@@ -84,9 +84,7 @@ static void ddb_open (char *name, int from_tty);
 
 static void lsi_open (char *name, int from_tty);
 
-static void mips_close (int quitting);
-
-static void mips_detach (struct target_ops *ops, char *args, int from_tty);
+static void mips_close (void);
 
 static int mips_map_regno (struct gdbarch *, int);
 
@@ -108,12 +106,12 @@ static void mips_files_info (struct target_ops *ignore);
 
 static void mips_mourn_inferior (struct target_ops *ops);
 
-static int pmon_makeb64 (unsigned long v, char *p, int n, int *chksum);
+static int pmon_makeb64 (unsigned long v, char *p, int n, unsigned int *chksum);
 
-static int pmon_zeroset (int recsize, char **buff, int *amount,
+static int pmon_zeroset (int recsize, char **buff, unsigned int *amount,
                         unsigned int *chksum);
 
-static int pmon_checkset (int recsize, char **buff, int *value);
+static int pmon_checkset (int recsize, char **buff, unsigned int *value);
 
 static void pmon_make_fastrec (char **outbuf, unsigned char *inbuf,
                               int *inptr, int inamount, int *recsize,
@@ -488,17 +486,11 @@ static void ATTRIBUTE_NORETURN
 mips_error (char *string,...)
 {
   va_list args;
-
-  va_start (args, string);
+  char *fmt;
 
   target_terminal_ours ();
   wrap_here ("");              /* Force out any buffered output.  */
   gdb_flush (gdb_stdout);
-  if (error_pre_print)
-    fputs_filtered (error_pre_print, gdb_stderr);
-  vfprintf_filtered (gdb_stderr, string, args);
-  fprintf_filtered (gdb_stderr, "\n");
-  va_end (args);
   gdb_flush (gdb_stderr);
 
   /* Clean up in such a way that mips_close won't try to talk to the
@@ -506,11 +498,16 @@ mips_error (char *string,...)
      it).  */
   close_ports ();
 
-  printf_unfiltered ("Ending remote MIPS debugging.\n");
   if (!ptid_equal (inferior_ptid, null_ptid))
     target_mourn_inferior ();
 
-  deprecated_throw_reason (RETURN_ERROR);
+  fmt = concat (_("Ending remote MIPS debugging: "),
+               string, (char *) NULL);
+  make_cleanup (xfree, fmt);
+
+  va_start (args, string);
+  throw_verror (TARGET_CLOSE_ERROR, fmt, args);
+  va_end (args);
 }
 
 /* putc_readable - print a character, displaying non-printable chars in
@@ -588,6 +585,7 @@ mips_expect_timeout (const char *string, int timeout)
     }
 
   immediate_quit++;
+  QUIT;
   while (1)
     {
       int c;
@@ -672,13 +670,13 @@ mips_readchar (int timeout)
   if (ch == SERIAL_TIMEOUT && timeout == -1)   /* Watchdog went off.  */
     {
       target_mourn_inferior ();
-      error ("Watchdog has expired.  Target detached.\n");
+      error (_("Watchdog has expired.  Target detached."));
     }
 
   if (ch == SERIAL_EOF)
-    mips_error ("End of file from remote");
+    mips_error (_("End of file from remote"));
   if (ch == SERIAL_ERROR)
-    mips_error ("Error reading from remote: %s", safe_strerror (errno));
+    mips_error (_("Error reading from remote: %s"), safe_strerror (errno));
   if (remote_debug > 1)
     {
       /* Don't use _filtered; we can't deal with a QUIT out of
@@ -713,7 +711,7 @@ mips_readchar (int timeout)
       /* At this point, about the only thing we can do is abort the command
          in progress and get back to command level as quickly as possible.  */
 
-      error ("Remote board reset, debug protocol re-initialized.");
+      error (_("Remote board reset, debug protocol re-initialized."));
     }
 
   if (ch == mips_monitor_prompt[state])
@@ -771,8 +769,8 @@ mips_receive_header (unsigned char *hdr, int *pgarbage, int ch, int timeout)
 
              if (mips_syn_garbage > 0
                  && *pgarbage > mips_syn_garbage)
-               mips_error ("Debug protocol failure:  more "
-                           "than %d characters before a sync.",
+               mips_error (_("Debug protocol failure:  more "
+                           "than %d characters before a sync."),
                            mips_syn_garbage);
            }
        }
@@ -823,12 +821,13 @@ mips_receive_trailer (unsigned char *trlr, int *pgarbage,
 }
 
 /* Get the checksum of a packet.  HDR points to the packet header.
-   DATA points to the packet data.  LEN is the length of DATA.  */
+   DATASTR points to the packet data.  LEN is the length of DATASTR.  */
 
 static int
-mips_cksum (const unsigned char *hdr, const unsigned char *data, int len)
+mips_cksum (const unsigned char *hdr, const char *datastr, int len)
 {
   const unsigned char *p;
+  const unsigned char *data = (const unsigned char *) datastr;
   int c;
   int cksum;
 
@@ -860,7 +859,7 @@ mips_send_packet (const char *s, int get_ack)
 
   len = strlen (s);
   if (len > DATA_MAXLEN)
-    mips_error ("MIPS protocol data packet too long: %s", s);
+    mips_error (_("MIPS protocol data packet too long: %s"), s);
 
   packet = (unsigned char *) alloca (HDR_LENGTH + len + TRLR_LENGTH + 1);
 
@@ -871,7 +870,7 @@ mips_send_packet (const char *s, int get_ack)
 
   memcpy (packet + HDR_LENGTH, s, len);
 
-  cksum = mips_cksum (packet, packet + HDR_LENGTH, len);
+  cksum = mips_cksum (packet, (char *) packet + HDR_LENGTH, len);
   packet[HDR_LENGTH + len + TRLR_INDX_CSUM1] = TRLR_SET_CSUM1 (cksum);
   packet[HDR_LENGTH + len + TRLR_INDX_CSUM2] = TRLR_SET_CSUM2 (cksum);
   packet[HDR_LENGTH + len + TRLR_INDX_CSUM3] = TRLR_SET_CSUM3 (cksum);
@@ -898,7 +897,7 @@ mips_send_packet (const char *s, int get_ack)
 
       if (serial_write (mips_desc, packet,
                        HDR_LENGTH + len + TRLR_LENGTH) != 0)
-       mips_error ("write to target failed: %s", safe_strerror (errno));
+       mips_error (_("write to target failed: %s"), safe_strerror (errno));
 
       if (!get_ack)
        return;
@@ -975,8 +974,7 @@ mips_send_packet (const char *s, int get_ack)
 
          /* If the checksum does not match the trailer checksum, this
             is a bad packet; ignore it.  */
-         if (mips_cksum (hdr, (unsigned char *) NULL, 0)
-             != TRLR_GET_CKSUM (trlr))
+         if (mips_cksum (hdr, NULL, 0) != TRLR_GET_CKSUM (trlr))
            continue;
 
          if (remote_debug > 0)
@@ -1006,7 +1004,7 @@ mips_send_packet (const char *s, int get_ack)
        }
     }
 
-  mips_error ("Remote did not acknowledge packet");
+  mips_error (_("Remote did not acknowledge packet"));
 }
 
 /* Receive and acknowledge a packet, returning the data in BUFF (which
@@ -1037,7 +1035,7 @@ mips_receive_packet (char *buff, int throw_error, int timeout)
       if (mips_receive_header (hdr, &garbage, ch, timeout) != 0)
        {
          if (throw_error)
-           mips_error ("Timed out waiting for remote packet");
+           mips_error (_("Timed out waiting for remote packet"));
          else
            return -1;
        }
@@ -1077,7 +1075,7 @@ mips_receive_packet (char *buff, int throw_error, int timeout)
          if (rch == SERIAL_TIMEOUT)
            {
              if (throw_error)
-               mips_error ("Timed out waiting for remote packet");
+               mips_error (_("Timed out waiting for remote packet"));
              else
                return -1;
            }
@@ -1099,7 +1097,7 @@ mips_receive_packet (char *buff, int throw_error, int timeout)
       if (err == -1)
        {
          if (throw_error)
-           mips_error ("Timed out waiting for packet");
+           mips_error (_("Timed out waiting for packet"));
          else
            return -1;
        }
@@ -1141,7 +1139,7 @@ mips_receive_packet (char *buff, int throw_error, int timeout)
       ack[HDR_INDX_LEN1] = HDR_SET_LEN1 (0, 0, mips_receive_seq);
       ack[HDR_INDX_SEQ] = HDR_SET_SEQ (0, 0, mips_receive_seq);
 
-      cksum = mips_cksum (ack, (unsigned char *) NULL, 0);
+      cksum = mips_cksum (ack, NULL, 0);
 
       ack[HDR_LENGTH + TRLR_INDX_CSUM1] = TRLR_SET_CSUM1 (cksum);
       ack[HDR_LENGTH + TRLR_INDX_CSUM2] = TRLR_SET_CSUM2 (cksum);
@@ -1159,7 +1157,8 @@ mips_receive_packet (char *buff, int throw_error, int timeout)
       if (serial_write (mips_desc, ack, HDR_LENGTH + TRLR_LENGTH) != 0)
        {
          if (throw_error)
-           mips_error ("write to target failed: %s", safe_strerror (errno));
+           mips_error (_("write to target failed: %s"),
+                       safe_strerror (errno));
          else
            return -1;
        }
@@ -1181,7 +1180,7 @@ mips_receive_packet (char *buff, int throw_error, int timeout)
   ack[HDR_INDX_LEN1] = HDR_SET_LEN1 (0, 0, mips_receive_seq);
   ack[HDR_INDX_SEQ] = HDR_SET_SEQ (0, 0, mips_receive_seq);
 
-  cksum = mips_cksum (ack, (unsigned char *) NULL, 0);
+  cksum = mips_cksum (ack, NULL, 0);
 
   ack[HDR_LENGTH + TRLR_INDX_CSUM1] = TRLR_SET_CSUM1 (cksum);
   ack[HDR_LENGTH + TRLR_INDX_CSUM2] = TRLR_SET_CSUM2 (cksum);
@@ -1199,7 +1198,7 @@ mips_receive_packet (char *buff, int throw_error, int timeout)
   if (serial_write (mips_desc, ack, HDR_LENGTH + TRLR_LENGTH) != 0)
     {
       if (throw_error)
-       mips_error ("write to target failed: %s", safe_strerror (errno));
+       mips_error (_("write to target failed: %s"), safe_strerror (errno));
       else
        return -1;
     }
@@ -1240,7 +1239,7 @@ mips_request (int cmd,
              int timeout,
              char *buff)
 {
-  int addr_size = gdbarch_addr_bit (target_gdbarch) / 8;
+  int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8;
   char myBuff[DATA_MAXLEN + 1];
   char response_string[17];
   int len;
@@ -1287,7 +1286,7 @@ mips_request (int cmd,
              &rpid, &rcmd, &rerrflg, response_string) != 4
       || !read_hex_value (response_string, &rresponse)
       || (cmd != '\0' && rcmd != cmd))
-    mips_error ("Bad response from remote board");
+    mips_error (_("Bad response from remote board"));
 
   if (rerrflg != 0)
     {
@@ -1349,7 +1348,7 @@ mips_enter_debug (void)
   else                         /* Assume IDT monitor by default.  */
     mips_send_command ("db tty0\r", 0);
 
-  sleep (1);
+  gdb_usleep (1000000);
   serial_write (mips_desc, "\r", sizeof "\r" - 1);
 
   /* We don't need to absorb any spurious characters here, since the
@@ -1363,7 +1362,7 @@ mips_enter_debug (void)
     char buff[DATA_MAXLEN + 1];
 
     if (mips_receive_packet (buff, 1, 3) < 0)
-      mips_error ("Failed to initialize (didn't receive packet).");
+      mips_error (_("Failed to initialize (didn't receive packet)."));
   }
 }
 
@@ -1384,13 +1383,19 @@ mips_exit_debug (void)
       mips_request ('x', 0, 0, NULL, mips_receive_wait, NULL);
       mips_need_reply = 0;
       if (!mips_expect (" break!"))
-       return -1;
+       {
+         do_cleanups (old_cleanups);
+         return -1;
+       }
     }
   else
     mips_request ('x', 0, 0, &err, mips_receive_wait, NULL);
 
   if (!mips_expect (mips_monitor_prompt))
-    return -1;
+    {
+      do_cleanups (old_cleanups);
+      return -1;
+    }
 
   do_cleanups (old_cleanups);
 
@@ -1404,7 +1409,7 @@ static void
 mips_initialize (void)
 {
   int err;
-  struct cleanup *old_cleanups = make_cleanup (mips_initialize_cleanups, NULL);
+  struct cleanup *old_cleanups;
   int j;
 
   /* What is this code doing here?  I don't see any way it can happen, and
@@ -1413,10 +1418,12 @@ mips_initialize (void)
 
   if (mips_initializing)
     {
-      warning ("internal error: mips_initialize called twice");
+      warning (_("internal error: mips_initialize called twice"));
       return;
     }
 
+  old_cleanups = make_cleanup (mips_initialize_cleanups, NULL);
+
   mips_wait_flag = 0;
   mips_initializing = 1;
 
@@ -1487,7 +1494,7 @@ mips_initialize (void)
          }
          break;
        case 4:
-         mips_error ("Failed to initialize.");
+         mips_error (_("Failed to initialize."));
        }
 
       if (mips_expect (mips_monitor_prompt))
@@ -1537,11 +1544,11 @@ common_open (struct target_ops *ops, char *name, int from_tty,
             enum mips_monitor_type new_monitor,
             const char *new_monitor_prompt)
 {
-  char *ptype;
   char *serial_port_name;
   char *remote_name = 0;
   char *local_name = 0;
   char **argv;
+  struct cleanup *cleanup;
 
   if (name == 0)
     error (_("\
@@ -1557,7 +1564,7 @@ seen from the board via TFTP, specify that name as the third parameter.\n"));
   /* Parse the serial port name, the optional TFTP name, and the
      optional local TFTP name.  */
   argv = gdb_buildargv (name);
-  make_cleanup_freeargv (argv);
+  cleanup = make_cleanup_freeargv (argv);
 
   serial_port_name = xstrdup (argv[0]);
   if (argv[1])                 /* Remote TFTP name specified?  */
@@ -1598,7 +1605,7 @@ seen from the board via TFTP, specify that name as the third parameter.\n"));
        {
          udp_desc = serial_open (remote_name);
          if (!udp_desc)
-           perror_with_name ("Unable to open UDP port");
+           perror_with_name (_("Unable to open UDP port"));
          udp_in_use = 1;
        }
       else
@@ -1652,8 +1659,10 @@ seen from the board via TFTP, specify that name as the third parameter.\n"));
   reinit_frame_cache ();
   registers_changed ();
   stop_pc = regcache_read_pc (get_current_regcache ());
-  print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC);
+  print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1);
   xfree (serial_port_name);
+
+  do_cleanups (cleanup);
 }
 
 /* Open a connection to an IDT board.  */
@@ -1662,10 +1671,10 @@ static void
 mips_open (char *name, int from_tty)
 {
   const char *monitor_prompt = NULL;
-  if (gdbarch_bfd_arch_info (target_gdbarch) != NULL
-      && gdbarch_bfd_arch_info (target_gdbarch)->arch == bfd_arch_mips)
+  if (gdbarch_bfd_arch_info (target_gdbarch ()) != NULL
+      && gdbarch_bfd_arch_info (target_gdbarch ())->arch == bfd_arch_mips)
     {
-    switch (gdbarch_bfd_arch_info (target_gdbarch)->mach)
+    switch (gdbarch_bfd_arch_info (target_gdbarch ())->mach)
       {
       case bfd_mach_mips4100:
       case bfd_mach_mips4300:
@@ -1722,7 +1731,7 @@ lsi_open (char *name, int from_tty)
 /* Close a connection to the remote board.  */
 
 static void
-mips_close (int quitting)
+mips_close (void)
 {
   if (mips_is_open)
     {
@@ -1738,14 +1747,12 @@ mips_close (int quitting)
 /* Detach from the remote board.  */
 
 static void
-mips_detach (struct target_ops *ops, char *args, int from_tty)
+mips_detach (struct target_ops *ops, const char *args, int from_tty)
 {
   if (args)
-    error ("Argument given to \"detach\" when remotely debugging.");
-
-  pop_target ();
+    error (_("Argument given to \"detach\" when remotely debugging."));
 
-  mips_close (1);
+  unpush_target (ops);
 
   if (from_tty)
     printf_unfiltered ("Ending remote MIPS debugging.\n");
@@ -1757,7 +1764,7 @@ mips_detach (struct target_ops *ops, char *args, int from_tty)
 
 static void
 mips_resume (struct target_ops *ops,
-            ptid_t ptid, int step, enum target_signal siggnal)
+            ptid_t ptid, int step, enum gdb_signal siggnal)
 {
   int err;
 
@@ -1771,7 +1778,7 @@ mips_resume (struct target_ops *ops,
 /* Return the signal corresponding to SIG, where SIG is the number which
    the MIPS protocol uses for the signal.  */
 
-static enum target_signal
+static enum gdb_signal
 mips_signal_from_protocol (int sig)
 {
   /* We allow a few more signals than the IDT board actually returns, on
@@ -1779,13 +1786,13 @@ mips_signal_from_protocol (int sig)
      for these signals is widely agreed upon.  */
   if (sig <= 0
       || sig > 31)
-    return TARGET_SIGNAL_UNKNOWN;
+    return GDB_SIGNAL_UNKNOWN;
 
-  /* Don't want to use target_signal_from_host because we are converting
+  /* Don't want to use gdb_signal_from_host because we are converting
      from MIPS signal numbers, not host ones.  Our internal numbers
      match the MIPS numbers for the signals the board can return, which
      are: SIGINT, SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP.  */
-  return (enum target_signal) sig;
+  return (enum gdb_signal) sig;
 }
 
 /* Set the register designated by REGNO to the value designated by VALUE.  */
@@ -1793,7 +1800,7 @@ mips_signal_from_protocol (int sig)
 static void
 mips_set_register (int regno, ULONGEST value)
 {
-  char buf[MAX_REGISTER_SIZE];
+  gdb_byte buf[MAX_REGISTER_SIZE];
   struct regcache *regcache = get_current_regcache ();
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -1828,7 +1835,6 @@ mips_wait (struct target_ops *ops,
   ULONGEST rpc, rfp, rsp;
   char pc_string[17], fp_string[17], sp_string[17], flags[20];
   int nfields;
-  int i;
 
   interrupt_count = 0;
   hit_watchpoint = 0;
@@ -1839,7 +1845,7 @@ mips_wait (struct target_ops *ops,
   if (!mips_need_reply)
     {
       status->kind = TARGET_WAITKIND_STOPPED;
-      status->value.sig = TARGET_SIGNAL_TRAP;
+      status->value.sig = GDB_SIGNAL_TRAP;
       return inferior_ptid;
     }
 
@@ -1848,7 +1854,7 @@ mips_wait (struct target_ops *ops,
   rstatus = mips_request ('\000', 0, 0, &err, -1, buff);
   mips_wait_flag = 0;
   if (err)
-    mips_error ("Remote failure: %s", safe_strerror (errno));
+    mips_error (_("Remote failure: %s"), safe_strerror (errno));
 
   /* On returning from a continue, the PMON monitor seems to start
      echoing back the messages we send prior to sending back the
@@ -1954,7 +1960,7 @@ mips_wait (struct target_ops *ops,
          is not a normal breakpoint.  */
       if (strcmp (target_shortname, "lsi") == 0)
        {
-         char *func_name;
+         const char *func_name;
          CORE_ADDR func_start;
          CORE_ADDR pc = regcache_read_pc (get_current_regcache ());
 
@@ -2046,7 +2052,7 @@ mips_fetch_registers (struct target_ops *ops,
            val = mips_request ('r', pmon_reg, 0,
                                &err, mips_receive_wait, NULL);
          if (err)
-           mips_error ("Can't read register %d: %s", regno,
+           mips_error (_("Can't read register %d: %s"), regno,
                        safe_strerror (errno));
        }
     }
@@ -2085,7 +2091,8 @@ mips_store_registers (struct target_ops *ops,
                val,
                &err, mips_receive_wait, NULL);
   if (err)
-    mips_error ("Can't write register %d: %s", regno, safe_strerror (errno));
+    mips_error (_("Can't write register %d: %s"), regno,
+                safe_strerror (errno));
 }
 
 /* Fetch a word from the target board.  Return word fetched in location
@@ -2146,11 +2153,11 @@ static int
 mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
                  struct mem_attrib *attrib, struct target_ops *target)
 {
-  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
   int i;
   CORE_ADDR addr;
   int count;
-  char *buffer;
+  gdb_byte *buffer;
   int status;
 
   /* PMON targets do not cope well with 64 bit addresses.  Mask the
@@ -2281,8 +2288,7 @@ Give up (and stop debugging it)? ")))
 
          printf_unfiltered ("Ending remote MIPS debugging.\n");
          target_mourn_inferior ();
-
-         deprecated_throw_reason (RETURN_QUIT);
+         quit ();
        }
 
       target_terminal_inferior ();
@@ -2319,14 +2325,14 @@ mips_create_inferior (struct target_ops *ops, char *execfile,
 
   if (args && *args)
     {
-      warning ("\
-Can't pass arguments to remote MIPS board; arguments ignored.");
+      warning (_("\
+Can't pass arguments to remote MIPS board; arguments ignored."));
       /* And don't try to use them on the next "run" command.  */
       execute_command ("set args", 0);
     }
 
   if (execfile == 0 || exec_bfd == 0)
-    error ("No executable file specified");
+    error (_("No executable file specified"));
 
   entry_pt = (CORE_ADDR) bfd_get_start_address (exec_bfd);
 
@@ -2383,7 +2389,7 @@ mips_remove_breakpoint (struct gdbarch *gdbarch,
    is the number of hardware breakpoints already installed.  This
    implements the target_can_use_hardware_watchpoint macro.  */
 
-int
+static int
 mips_can_use_watchpoint (int type, int cnt, int othertype)
 {
   return cnt < MAX_LSI_BREAKPOINTS && strcmp (target_shortname, "lsi") == 0;
@@ -2417,7 +2423,7 @@ calculate_mask (CORE_ADDR addr, int len)
    for a write watchpoint, 1 for a read watchpoint, or 2 for a read/write
    watchpoint.  */
 
-int
+static int
 mips_insert_watchpoint (CORE_ADDR addr, int len, int type,
                        struct expression *cond)
 {
@@ -2429,7 +2435,7 @@ mips_insert_watchpoint (CORE_ADDR addr, int len, int type,
 
 /* Remove a watchpoint.  */
 
-int
+static int
 mips_remove_watchpoint (CORE_ADDR addr, int len, int type,
                        struct expression *cond)
 {
@@ -2442,7 +2448,7 @@ mips_remove_watchpoint (CORE_ADDR addr, int len, int type,
 /* Test to see if a watchpoint has been hit.  Return 1 if so; return 0,
    if not.  */
 
-int
+static int
 mips_stopped_by_watchpoint (void)
 {
   return hit_watchpoint;
@@ -2478,7 +2484,7 @@ static int
 mips_check_lsi_error (CORE_ADDR addr, int rerrflg)
 {
   struct lsi_error *err;
-  const char *saddr = paddress (target_gdbarch, addr);
+  const char *saddr = paddress (target_gdbarch (), addr);
 
   if (rerrflg == 0)            /* no error */
     return 0;
@@ -2546,13 +2552,13 @@ mips_common_breakpoint (%s): Unknown error: 0x%x\n",
 static int
 mips_common_breakpoint (int set, CORE_ADDR addr, int len, enum break_type type)
 {
-  int addr_size = gdbarch_addr_bit (target_gdbarch) / 8;
+  int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8;
   char buf[DATA_MAXLEN + 1];
   char cmd, rcmd;
   int rpid, rerrflg, rresponse, rlen;
   int nfields;
 
-  addr = gdbarch_addr_bits_remove (target_gdbarch, addr);
+  addr = gdbarch_addr_bits_remove (target_gdbarch (), addr);
 
   if (mips_monitor == MON_LSI)
     {
@@ -2578,9 +2584,9 @@ mips_common_breakpoint (int set, CORE_ADDR addr, int len, enum break_type type)
          /* Clear the table entry and tell PMON to clear the breakpoint.  */
          if (i == MAX_LSI_BREAKPOINTS)
            {
-             warning ("\
-mips_common_breakpoint: Attempt to clear bogus breakpoint at %s\n",
-                      paddress (target_gdbarch, addr));
+             warning (_("\
+mips_common_breakpoint: Attempt to clear bogus breakpoint at %s"),
+                      paddress (target_gdbarch (), addr));
              return 1;
            }
 
@@ -2593,8 +2599,8 @@ mips_common_breakpoint: Attempt to clear bogus breakpoint at %s\n",
 
          nfields = sscanf (buf, "0x%x b 0x0 0x%x", &rpid, &rerrflg);
          if (nfields != 2)
-           mips_error ("\
-mips_common_breakpoint: Bad response from remote board: %s",
+           mips_error (_("mips_common_breakpoint: "
+                       "Bad response from remote board: %s"),
                        buf);
 
          return (mips_check_lsi_error (addr, rerrflg));
@@ -2646,8 +2652,8 @@ mips_common_breakpoint: Bad response from remote board: %s",
          nfields = sscanf (buf, "0x%x %c 0x%x 0x%x",
                            &rpid, &rcmd, &rresponse, &rerrflg);
          if (nfields != 4 || rcmd != cmd || rresponse > 255)
-           mips_error ("\
-mips_common_breakpoint: Bad response from remote board: %s",
+           mips_error (_("mips_common_breakpoint: "
+                       "Bad response from remote board: %s"),
                        buf);
 
          if (rerrflg != 0)
@@ -2718,8 +2724,8 @@ mips_common_breakpoint: Bad response from remote board: %s",
                        &rpid, &rcmd, &rerrflg, &rresponse);
 
       if (nfields != 4 || rcmd != cmd)
-       mips_error ("\
-mips_common_breakpoint: Bad response from remote board: %s",
+       mips_error (_("mips_common_breakpoint: "
+                   "Bad response from remote board: %s"),
                    buf);
 
       if (rerrflg != 0)
@@ -2731,7 +2737,7 @@ mips_common_breakpoint: Bad response from remote board: %s",
          if (rresponse != 22)  /* invalid argument */
            fprintf_unfiltered (gdb_stderr, "\
 mips_common_breakpoint (%s):  Got error: 0x%x\n",
-                               paddress (target_gdbarch, addr), rresponse);
+                               paddress (target_gdbarch (), addr), rresponse);
          return 1;
        }
     }
@@ -2757,17 +2763,18 @@ send_srec (char *srec, int len, CORE_ADDR addr)
       switch (ch)
        {
        case SERIAL_TIMEOUT:
-         error ("Timeout during download.");
+         error (_("Timeout during download."));
          break;
        case 0x6:               /* ACK */
          return;
        case 0x15:              /* NACK */
          fprintf_unfiltered (gdb_stderr,
                              "Download got a NACK at byte %s!  Retrying.\n",
-                             paddress (target_gdbarch, addr));
+                             paddress (target_gdbarch (), addr));
          continue;
        default:
-         error ("Download got unexpected ack char: 0x%x, retrying.\n", ch);
+         error (_("Download got unexpected ack char: 0x%x, retrying."),
+                ch);
        }
     }
 }
@@ -2779,24 +2786,28 @@ mips_load_srec (char *args)
 {
   bfd *abfd;
   asection *s;
-  char *buffer, srec[1024];
+  char srec[1024];
+  bfd_byte *buffer;
   unsigned int i;
   unsigned int srec_frame = 200;
   int reclen;
+  struct cleanup *cleanup;
   static int hashmark = 1;
 
   buffer = alloca (srec_frame * 2 + 256);
 
-  abfd = bfd_openr (args, 0);
+  abfd = gdb_bfd_open (args, NULL, -1);
   if (!abfd)
     {
       printf_filtered ("Unable to open file %s\n", args);
       return;
     }
 
+  cleanup = make_cleanup_bfd_unref (abfd);
   if (bfd_check_format (abfd, bfd_object) == 0)
     {
       printf_filtered ("File is not an object file\n");
+      do_cleanups (cleanup);
       return;
     }
 
@@ -2850,6 +2861,7 @@ mips_load_srec (char *args)
   send_srec (srec, reclen, abfd->start_address);
 
   serial_flush_input (mips_desc);
+  do_cleanups (cleanup);
 }
 
 /*
@@ -2968,7 +2980,7 @@ static char encoding[] =
    characters written into the buffer.  */
 
 static int
-pmon_makeb64 (unsigned long v, char *p, int n, int *chksum)
+pmon_makeb64 (unsigned long v, char *p, int n, unsigned int *chksum)
 {
   int count = (n / 6);
 
@@ -3016,7 +3028,8 @@ pmon_makeb64 (unsigned long v, char *p, int n, int *chksum)
    escape sequence into the data stream.  */
 
 static int
-pmon_zeroset (int recsize, char **buff, int *amount, unsigned int *chksum)
+pmon_zeroset (int recsize, char **buff,
+             unsigned int *amount, unsigned int *chksum)
 {
   int count;
 
@@ -3042,7 +3055,7 @@ pmon_zeroset (int recsize, char **buff, int *amount, unsigned int *chksum)
    the record elements added by this call.  */
 
 static int
-pmon_checkset (int recsize, char **buff, int *value)
+pmon_checkset (int recsize, char **buff, unsigned int *value)
 {
   int count;
 
@@ -3339,7 +3352,13 @@ static void
 pmon_download (char *buffer, int length)
 {
   if (tftp_in_use)
-    fwrite (buffer, 1, length, tftp_file);
+    {
+      size_t written;
+
+      written = fwrite (buffer, 1, length, tftp_file);
+      if (written < length)
+       perror_with_name (tftp_localname);
+    }
   else
     serial_write (udp_in_use ? udp_desc : mips_desc, buffer, length);
 }
@@ -3360,20 +3379,23 @@ pmon_load_fast (char *file)
   int bintotal = 0;
   int final = 0;
   int finished = 0;
+  struct cleanup *cleanup;
 
   buffer = (char *) xmalloc (MAXRECSIZE + 1);
   binbuf = (unsigned char *) xmalloc (BINCHUNK);
 
-  abfd = bfd_openr (file, 0);
+  abfd = gdb_bfd_open (file, NULL, -1);
   if (!abfd)
     {
       printf_filtered ("Unable to open file %s\n", file);
       return;
     }
+  cleanup = make_cleanup_bfd_unref (abfd);
 
   if (bfd_check_format (abfd, bfd_object) == 0)
     {
       printf_filtered ("File is not an object file\n");
+      do_cleanups (cleanup);
       return;
     }
 
@@ -3497,6 +3519,7 @@ pmon_load_fast (char *file)
       pmon_end_download (final, bintotal);
     }
 
+  do_cleanups (cleanup);
   return;
 }
 
@@ -3509,7 +3532,7 @@ mips_load (char *file, int from_tty)
 
   /* Get the board out of remote debugging mode.  */
   if (mips_exit_debug ())
-    error ("mips_load:  Couldn't get into monitor mode.");
+    error (_("mips_load:  Couldn't get into monitor mode."));
 
   if (mips_monitor != MON_IDT)
     pmon_load_fast (file);
This page took 0.035697 seconds and 4 git commands to generate.