Phase 1 of the ptid_t changes.
[deliverable/binutils-gdb.git] / gdb / remote-sds.c
index 3ab5f44bbef67707ce0a538fb582c0d83c650eef..27bc2416aea53e0c2fd3a57deb6f1d6f9e380d38 100644 (file)
@@ -1,21 +1,22 @@
 /* Remote target communications for serial-line targets using SDS' protocol.
-   Copyright 1997 Free Software Foundation, Inc.
+   Copyright 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
 
-This file is part of GDB.
+   This file is part of GDB.
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 /* This interface was written by studying the behavior of the SDS
    monitor on an ADS 821/860 board, and by consulting the
@@ -30,13 +31,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "bfd.h"
 #include "symfile.h"
 #include "target.h"
-#include "wait.h"
 #include "gdbcmd.h"
 #include "objfiles.h"
 #include "gdb-stabs.h"
 #include "gdbthread.h"
 #include "gdbcore.h"
-#include "dcache.h"
+#include "regcache.h"
 
 #ifdef USG
 #include <sys/types.h>
@@ -45,72 +45,72 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include <signal.h>
 #include "serial.h"
 
-extern void _initialize_remote_sds PARAMS ((void));
+extern void _initialize_remote_sds (void);
 
 /* Declarations of local functions. */
 
-static int sds_write_bytes PARAMS ((CORE_ADDR, char *, int));
+static int sds_write_bytes (CORE_ADDR, char *, int);
 
-static int sds_read_bytes PARAMS ((CORE_ADDR, char *, int));
+static int sds_read_bytes (CORE_ADDR, char *, int);
 
-static void sds_files_info PARAMS ((struct target_ops *ignore));
+static void sds_files_info (struct target_ops *ignore);
 
-static int sds_xfer_memory PARAMS ((CORE_ADDR, char *,
-                                   int, int, struct target_ops *));
+static int sds_xfer_memory (CORE_ADDR, char *, int, int, 
+                           struct mem_attrib *, struct target_ops *);
 
-static void sds_prepare_to_store PARAMS ((void));
+static void sds_prepare_to_store (void);
 
-static void sds_fetch_registers PARAMS ((int));
+static void sds_fetch_registers (int);
 
-static void sds_resume PARAMS ((int, int, enum target_signal));
+static void sds_resume (ptid_t, int, enum target_signal);
 
-static int sds_start_remote PARAMS ((PTR));
+static int sds_start_remote (PTR);
 
-static void sds_open PARAMS ((char *, int));
+static void sds_open (char *, int);
 
-static void sds_close PARAMS ((int));
+static void sds_close (int);
 
-static void sds_store_registers PARAMS ((int));
+static void sds_store_registers (int);
 
-static void sds_mourn PARAMS ((void));
+static void sds_mourn (void);
 
-static void sds_create_inferior PARAMS ((char *, char *, char **));
+static void sds_create_inferior (char *, char *, char **);
 
-static void sds_load PARAMS ((char *, int));
+static void sds_load (char *, int);
 
-static int getmessage PARAMS ((unsigned char *, int));
+static int getmessage (unsigned char *, int);
 
-static int putmessage PARAMS ((unsigned char *, int));
+static int putmessage (unsigned char *, int);
 
-static int sds_send PARAMS ((unsigned char *, int));
+static int sds_send (unsigned char *, int);
 
-static int readchar PARAMS ((int));
+static int readchar (int);
 
-static int sds_wait PARAMS ((int, struct target_waitstatus *));
+static ptid_t sds_wait (ptid_t, struct target_waitstatus *);
 
-static void sds_kill PARAMS ((void));
+static void sds_kill (void);
 
-static int tohex PARAMS ((int));
+static int tohex (int);
 
-static int fromhex PARAMS ((int));
+static int fromhex (int);
 
-static void sds_detach PARAMS ((char *, int));
+static void sds_detach (char *, int);
 
-static void sds_interrupt PARAMS ((int));
+static void sds_interrupt (int);
 
-static void sds_interrupt_twice PARAMS ((int));
+static void sds_interrupt_twice (int);
 
-static void interrupt_query PARAMS ((void));
+static void interrupt_query (void);
 
-static int read_frame PARAMS ((char *));
+static int read_frame (char *);
 
-static int sds_insert_breakpoint PARAMS ((CORE_ADDR, char *));
+static int sds_insert_breakpoint (CORE_ADDR, char *);
 
-static int sds_remove_breakpoint PARAMS ((CORE_ADDR, char *));
+static int sds_remove_breakpoint (CORE_ADDR, char *);
 
-static void init_sds_ops PARAMS ((void));
+static void init_sds_ops (void);
 
-static void sds_command PARAMS ((char *args, int from_tty));
+static void sds_command (char *args, int from_tty);
 
 /* Define the target operations vector. */
 
@@ -142,14 +142,13 @@ static int next_msg_id;
 static int just_started;
 
 static int message_pending;
-
 \f
+
 /* Clean up connection to a remote debugger.  */
 
 /* ARGSUSED */
 static void
-sds_close (quitting)
-     int quitting;
+sds_close (int quitting)
 {
   if (sds_desc)
     SERIAL_CLOSE (sds_desc);
@@ -159,13 +158,12 @@ sds_close (quitting)
 /* Stub for catch_errors.  */
 
 static int
-sds_start_remote (dummy)
-     PTR dummy;
+sds_start_remote (PTR dummy)
 {
   char c;
   unsigned char buf[200];
 
-  immediate_quit = 1;          /* Allow user to interrupt it */
+  immediate_quit++;            /* Allow user to interrupt it */
 
   /* Ack any packet which the remote side has already sent.  */
   SERIAL_WRITE (sds_desc, "{#*\r\n", 5);
@@ -183,7 +181,7 @@ sds_start_remote (dummy)
   buf[0] = 0;
   sds_send (buf, 1);
 
-  immediate_quit = 0;
+  immediate_quit--;
 
   start_remote ();             /* Initialize gdb process mechanisms */
   return 1;
@@ -192,12 +190,8 @@ sds_start_remote (dummy)
 /* Open a connection to a remote debugger.
    NAME is the filename used for communication.  */
 
-static DCACHE *sds_dcache;
-
 static void
-sds_open (name, from_tty)
-     char *name;
-     int from_tty;
+sds_open (char *name, int from_tty)
 {
   if (name == 0)
     error ("To open a remote debug connection, you need to specify what serial\n\
@@ -207,8 +201,6 @@ device is attached to the remote system (e.g. /dev/ttya).");
 
   unpush_target (&sds_ops);
 
-  sds_dcache = dcache_init (sds_read_bytes, sds_write_bytes);
-
   sds_desc = SERIAL_OPEN (name);
   if (!sds_desc)
     perror_with_name (name);
@@ -242,7 +234,7 @@ device is attached to the remote system (e.g. /dev/ttya).");
   /* Start the remote connection; if error (0), discard this target.
      In particular, if the user quits, be sure to discard it (we'd be
      in an inconsistent state otherwise).  */
-  if (!catch_errors (sds_start_remote, NULL, 
+  if (!catch_errors (sds_start_remote, NULL,
                     "Couldn't establish connection to remote target\n",
                     RETURN_MASK_ALL))
     pop_target ();
@@ -254,9 +246,7 @@ device is attached to the remote system (e.g. /dev/ttya).");
    die when it hits one.  */
 
 static void
-sds_detach (args, from_tty)
-     char *args;
-     int from_tty;
+sds_detach (char *args, int from_tty)
 {
   char buf[PBUFSIZ];
 
@@ -277,34 +267,29 @@ sds_detach (args, from_tty)
 /* Convert hex digit A to a number.  */
 
 static int
-fromhex (a)
-     int a;
+fromhex (int a)
 {
   if (a >= '0' && a <= '9')
     return a - '0';
   else if (a >= 'a' && a <= 'f')
     return a - 'a' + 10;
-  else 
+  else
     error ("Reply contains invalid hex digit %d", a);
 }
 
 /* Convert number NIB to a hex digit.  */
 
 static int
-tohex (nib)
-     int nib;
+tohex (int nib)
 {
   if (nib < 10)
-    return '0'+nib;
+    return '0' + nib;
   else
-    return 'a'+nib-10;
+    return 'a' + nib - 10;
 }
 
 static int
-tob64 (inbuf, outbuf, len)
-     unsigned char *inbuf;
-     char *outbuf;
-     int len;
+tob64 (unsigned char *inbuf, char *outbuf, int len)
 {
   int i, sum;
   char *p;
@@ -317,22 +302,20 @@ tob64 (inbuf, outbuf, len)
     {
       /* Collect the next three bytes into a number.  */
       sum = ((long) *inbuf++) << 16;
-      sum |= ((long) *inbuf++) <<  8;
+      sum |= ((long) *inbuf++) << 8;
       sum |= ((long) *inbuf++);
 
       /* Spit out 4 6-bit encodings.  */
       *p++ = ((sum >> 18) & 0x3f) + '0';
       *p++ = ((sum >> 12) & 0x3f) + '0';
-      *p++ = ((sum >>  6) & 0x3f) + '0';
+      *p++ = ((sum >> 6) & 0x3f) + '0';
       *p++ = (sum & 0x3f) + '0';
     }
   return (p - outbuf);
 }
 
 static int
-fromb64 (inbuf, outbuf, len)
-     char *inbuf, *outbuf;
-     int len;
+fromb64 (char *inbuf, char *outbuf, int len)
 {
   int i, sum;
 
@@ -342,41 +325,37 @@ fromb64 (inbuf, outbuf, len)
   for (i = 0; i < len; i += 4)
     {
       /* Collect 4 6-bit digits.  */
-      sum  = (*inbuf++ - '0') << 18;
+      sum = (*inbuf++ - '0') << 18;
       sum |= (*inbuf++ - '0') << 12;
-      sum |= (*inbuf++ - '0') <<  6;
+      sum |= (*inbuf++ - '0') << 6;
       sum |= (*inbuf++ - '0');
 
       /* Now take the resulting 24-bit number and get three bytes out
          of it.  */
       *outbuf++ = (sum >> 16) & 0xff;
-      *outbuf++ = (sum >>  8) & 0xff;
+      *outbuf++ = (sum >> 8) & 0xff;
       *outbuf++ = sum & 0xff;
     }
 
   return (len / 4) * 3;
 }
-
 \f
+
 /* Tell the remote machine to resume.  */
 
 static enum target_signal last_sent_signal = TARGET_SIGNAL_0;
 int last_sent_step;
 
 static void
-sds_resume (pid, step, siggnal)
-     int pid, step;
-     enum target_signal siggnal;
+sds_resume (ptid_t ptid, int step, enum target_signal siggnal)
 {
   unsigned char buf[PBUFSIZ];
 
-  dcache_flush (sds_dcache);
-
   last_sent_signal = siggnal;
   last_sent_step = step;
 
   buf[0] = (step ? 21 : 20);
-  buf[1] = 0;  /* (should be signal?) */
+  buf[1] = 0;                  /* (should be signal?) */
 
   sds_send (buf, 2);
 }
@@ -385,31 +364,29 @@ sds_resume (pid, step, siggnal)
    us a message pending notice.  */
 
 static void
-sds_interrupt (signo)
-     int signo;
+sds_interrupt (int signo)
 {
   unsigned char buf[PBUFSIZ];
 
   /* If this doesn't work, try more severe steps.  */
   signal (signo, sds_interrupt_twice);
-  
+
   if (remote_debug)
-    printf_unfiltered ("sds_interrupt called\n");
+    fprintf_unfiltered (gdb_stdlog, "sds_interrupt called\n");
 
   buf[0] = 25;
   sds_send (buf, 1);
 }
 
-static void (*ofunc)();
+static void (*ofunc) ();
 
 /* The user typed ^C twice.  */
 
 static void
-sds_interrupt_twice (signo)
-     int signo;
+sds_interrupt_twice (int signo)
 {
   signal (signo, ofunc);
-  
+
   interrupt_query ();
 
   signal (signo, sds_interrupt);
@@ -418,7 +395,7 @@ sds_interrupt_twice (signo)
 /* Ask the user what to do when an interrupt is received.  */
 
 static void
-interrupt_query ()
+interrupt_query (void)
 {
   target_terminal_ours ();
 
@@ -439,10 +416,8 @@ int kill_kludge;
    STATUS just as `wait' would.  Returns "pid" (though it's not clear
    what, if anything, that means in the case of this target).  */
 
-static int
-sds_wait (pid, status)
-     int pid;
-     struct target_waitstatus *status;
+static ptid_t
+sds_wait (ptid_t ptid, struct target_waitstatus *status)
 {
   unsigned char buf[PBUFSIZ];
   int retlen;
@@ -458,7 +433,7 @@ sds_wait (pid, status)
     {
       just_started = 0;
       status->kind = TARGET_WAITKIND_STOPPED;
-      return inferior_pid;
+      return inferior_ptid;
     }
 
   while (1)
@@ -471,8 +446,8 @@ sds_wait (pid, status)
          retlen = sds_send (buf, 1);
          if (remote_debug)
            {
-             fprintf_unfiltered (gdb_stderr, "Signals: %04x %02x %02x\n",
-                                 ((int) buf[0]) << 8 + buf[1],
+             fprintf_unfiltered (gdb_stdlog, "Signals: %02x%02x %02x %02x\n",
+                                 buf[0], buf[1],
                                  buf[2], buf[3]);
            }
          message_pending = 0;
@@ -481,8 +456,8 @@ sds_wait (pid, status)
          goto got_status;
        }
     }
- got_status:
-  return inferior_pid;
+got_status:
+  return inferior_ptid;
 }
 
 static unsigned char sprs[16];
@@ -492,12 +467,10 @@ static unsigned char sprs[16];
 
 /* ARGSUSED */
 static void
-sds_fetch_registers (regno)
-     int regno;
+sds_fetch_registers (int regno)
 {
   unsigned char buf[PBUFSIZ];
   int i, retlen;
-  char *p;
   char regs[REGISTER_BYTES];
 
   /* Unimplemented registers read as all bits zero.  */
@@ -524,25 +497,24 @@ sds_fetch_registers (regno)
   /* (should warn about reply too short) */
 
   for (i = 0; i < NUM_REGS; i++)
-    supply_register (i, &regs[REGISTER_BYTE(i)]);
+    supply_register (i, &regs[REGISTER_BYTE (i)]);
 }
 
 /* Prepare to store registers.  Since we may send them all, we have to
    read out the ones we don't want to change first.  */
 
-static void 
-sds_prepare_to_store ()
+static void
+sds_prepare_to_store (void)
 {
   /* Make sure the entire registers array is valid.  */
-  read_register_bytes (0, (char *)NULL, REGISTER_BYTES);
+  read_register_bytes (0, (char *) NULL, REGISTER_BYTES);
 }
 
 /* Store register REGNO, or all registers if REGNO == -1, from the contents
    of REGISTERS.  FIXME: ignores errors.  */
 
 static void
-sds_store_registers (regno)
-     int regno;
+sds_store_registers (int regno)
 {
   unsigned char *p, buf[PBUFSIZ];
   int i;
@@ -583,10 +555,7 @@ sds_store_registers (regno)
    Returns number of bytes transferred, or 0 for error.  */
 
 static int
-sds_write_bytes (memaddr, myaddr, len)
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
+sds_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
 {
   int max_buf_size;            /* Max size of packet output buffer */
   int origlen;
@@ -607,8 +576,8 @@ sds_write_bytes (memaddr, myaddr, len)
       buf[1] = 0;
       buf[2] = (int) (memaddr >> 24) & 0xff;
       buf[3] = (int) (memaddr >> 16) & 0xff;
-      buf[4] = (int) (memaddr >>  8) & 0xff;
-      buf[5] = (int) (memaddr      ) & 0xff;
+      buf[4] = (int) (memaddr >> 8) & 0xff;
+      buf[5] = (int) (memaddr) & 0xff;
       buf[6] = 1;
       buf[7] = 0;
 
@@ -634,10 +603,7 @@ sds_write_bytes (memaddr, myaddr, len)
    Returns number of bytes transferred, or 0 for error.  */
 
 static int
-sds_read_bytes (memaddr, myaddr, len)
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
+sds_read_bytes (CORE_ADDR memaddr, char *myaddr, int len)
 {
   int max_buf_size;            /* Max size of packet output buffer */
   int origlen, retlen;
@@ -658,10 +624,10 @@ sds_read_bytes (memaddr, myaddr, len)
       buf[1] = 0;
       buf[2] = (int) (memaddr >> 24) & 0xff;
       buf[3] = (int) (memaddr >> 16) & 0xff;
-      buf[4] = (int) (memaddr >>  8) & 0xff;
-      buf[5] = (int) (memaddr      ) & 0xff;
+      buf[4] = (int) (memaddr >> 8) & 0xff;
+      buf[5] = (int) (memaddr) & 0xff;
       buf[6] = (int) (todo >> 8) & 0xff;
-      buf[7] = (int) (todo     ) & 0xff;
+      buf[7] = (int) (todo) & 0xff;
       buf[8] = 1;
 
       retlen = sds_send (buf, 9);
@@ -687,24 +653,27 @@ sds_read_bytes (memaddr, myaddr, len)
 /* Read or write LEN bytes from inferior memory at MEMADDR,
    transferring to or from debugger address MYADDR.  Write to inferior
    if SHOULD_WRITE is nonzero.  Returns length of data written or
-   read; 0 for error.  */
+   read; 0 for error.  TARGET is unused.  */
 
 /* ARGSUSED */
 static int
-sds_xfer_memory(memaddr, myaddr, len, should_write, target)
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
-     int should_write;
-     struct target_ops *target;                        /* ignored */
+sds_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write,
+                struct mem_attrib *attrib ATTRIBUTE_UNUSED,
+                struct target_ops *target ATTRIBUTE_UNUSED)
 {
-  return dcache_xfer_memory (sds_dcache, memaddr, myaddr, len, should_write);
-}
+  int res;
 
+  if (should_write)
+    res = sds_write_bytes (memaddr, myaddr, len);
+  else
+    res = sds_read_bytes (memaddr, myaddr, len);
+  
+  return res;
+}
 \f
+
 static void
-sds_files_info (ignore)
-     struct target_ops *ignore;
+sds_files_info (struct target_ops *ignore)
 {
   puts_filtered ("Debugging over a serial connection, using SDS protocol.\n");
 }
@@ -715,15 +684,14 @@ sds_files_info (ignore)
 /* Read a single character from the remote end, masking it down to 7 bits. */
 
 static int
-readchar (timeout)
-     int timeout;
+readchar (int timeout)
 {
   int ch;
 
   ch = SERIAL_READCHAR (sds_desc, timeout);
 
   if (remote_debug > 1 && ch >= 0)
-    printf_unfiltered("%c(%x)", ch, ch);
+    fprintf_unfiltered (gdb_stdlog, "%c(%x)", ch, ch);
 
   switch (ch)
     {
@@ -742,9 +710,7 @@ readchar (timeout)
    because 253, 254, and 255 are special flags in the protocol.)  */
 
 static int
-compute_checksum (csum, buf, len)
-     int csum, len;
-     char *buf;
+compute_checksum (int csum, char *buf, int len)
 {
   int i;
 
@@ -759,9 +725,7 @@ compute_checksum (csum, buf, len)
    into BUF also.  */
 
 static int
-sds_send (buf, len)
-     unsigned char *buf;
-     int len;
+sds_send (unsigned char *buf, int len)
 {
   putmessage (buf, len);
 
@@ -771,30 +735,26 @@ sds_send (buf, len)
 /* Send a message to the remote machine.  */
 
 static int
-putmessage (buf, len)
-     unsigned char *buf;
-     int len;
+putmessage (unsigned char *buf, int len)
 {
   int i, enclen;
   unsigned char csum = 0;
   char buf2[PBUFSIZ], buf3[PBUFSIZ];
   unsigned char header[3];
-  int ch;
-  int tcount = 0;
   char *p;
 
   /* Copy the packet into buffer BUF2, encapsulating it
      and giving it a checksum.  */
 
   if (len > 170)               /* Prosanity check */
-    abort();
+    internal_error (__FILE__, __LINE__, "failed internal consistency check");
 
   if (remote_debug)
     {
-      fprintf_unfiltered (gdb_stderr, "Message to send: \"");
+      fprintf_unfiltered (gdb_stdlog, "Message to send: \"");
       for (i = 0; i < len; ++i)
-       fprintf_unfiltered (gdb_stderr, "%02x", buf[i]);
-      fprintf_unfiltered (gdb_stderr, "\"\n");
+       fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]);
+      fprintf_unfiltered (gdb_stdlog, "\"\n");
     }
 
   p = buf2;
@@ -803,7 +763,7 @@ putmessage (buf, len)
   if (len % 3 != 0)
     {
       buf[len] = '\0';
-      buf[len+1] = '\0';
+      buf[len + 1] = '\0';
     }
 
   header[1] = next_msg_id;
@@ -830,31 +790,27 @@ putmessage (buf, len)
 
   while (1)
     {
-      int started_error_output = 0;
-
       if (remote_debug)
        {
          *p = '\0';
-         printf_unfiltered ("Sending encoded: \"%s\"", buf2);
-         printf_unfiltered ("  (Checksum %d, id %d, length %d)\n",
-                            header[0], header[1], header[2]);
-         gdb_flush (gdb_stdout);
+         fprintf_unfiltered (gdb_stdlog, "Sending encoded: \"%s\"", buf2);
+         fprintf_unfiltered (gdb_stdlog,
+                             "  (Checksum %d, id %d, length %d)\n",
+                             header[0], header[1], header[2]);
+         gdb_flush (gdb_stdlog);
        }
       if (SERIAL_WRITE (sds_desc, buf2, p - buf2))
        perror_with_name ("putmessage: write failed");
 
       return 1;
-
     }
-
 }
 
 /* Come here after finding the start of the frame.  Collect the rest
    into BUF.  Returns 0 on any error, 1 on success.  */
 
 static int
-read_frame (buf)
-     char *buf;
+read_frame (char *buf)
 {
   char *bp;
   int c;
@@ -869,11 +825,12 @@ read_frame (buf)
        {
        case SERIAL_TIMEOUT:
          if (remote_debug)
-           puts_filtered ("Timeout in mid-message, retrying\n");
+           fputs_filtered ("Timeout in mid-message, retrying\n", gdb_stdlog);
          return 0;
        case '$':
          if (remote_debug)
-           puts_filtered ("Saw new packet start in middle of old one\n");
+           fputs_filtered ("Saw new packet start in middle of old one\n",
+                           gdb_stdlog);
          return 0;             /* Start a new packet, count retries */
        case '\r':
          break;
@@ -882,7 +839,7 @@ read_frame (buf)
          {
            *bp = '\000';
            if (remote_debug)
-             fprintf_unfiltered (gdb_stderr, "Received encoded: \"%s\"\n",
+             fprintf_unfiltered (gdb_stdlog, "Received encoded: \"%s\"\n",
                                  buf);
            return 1;
          }
@@ -910,9 +867,7 @@ read_frame (buf)
    while the target is executing user code.  */
 
 static int
-getmessage (buf, forever)
-     unsigned char *buf;
-     int forever;
+getmessage (unsigned char *buf, int forever)
 {
   int c, c2, c3;
   int tries;
@@ -925,11 +880,7 @@ getmessage (buf, forever)
 
   if (forever)
     {
-#ifdef MAINTENANCE_CMDS
       timeout = watchdog > 0 ? watchdog : -1;
-#else
-      timeout = -1;
-#endif
     }
 
   else
@@ -940,12 +891,12 @@ getmessage (buf, forever)
   for (tries = 1; tries <= MAX_TRIES; tries++)
     {
       /* This can loop forever if the remote side sends us characters
-        continuously, but if it pauses, we'll get a zero from readchar
-        because of timeout.  Then we'll count that as a retry.  */
+         continuously, but if it pauses, we'll get a zero from readchar
+         because of timeout.  Then we'll count that as a retry.  */
 
       /* Note that we will only wait forever prior to the start of a packet.
-        After that, we expect characters to arrive at a brisk pace.  They
-        should show up within sds_timeout intervals.  */
+         After that, we expect characters to arrive at a brisk pace.  They
+         should show up within sds_timeout intervals.  */
 
       do
        {
@@ -953,22 +904,20 @@ getmessage (buf, forever)
 
          if (c == SERIAL_TIMEOUT)
            {
-#ifdef MAINTENANCE_CMDS
              if (forever)      /* Watchdog went off.  Kill the target. */
                {
                  target_mourn_inferior ();
                  error ("Watchdog has expired.  Target detached.\n");
                }
-#endif
              if (remote_debug)
-               puts_filtered ("Timed out.\n");
+               fputs_filtered ("Timed out.\n", gdb_stdlog);
              goto retry;
            }
        }
       while (c != '$' && c != '{');
 
       /* We might have seen a "trigraph", a sequence of three characters
-        that indicate various sorts of communication state.  */
+         that indicate various sorts of communication state.  */
 
       if (c == '{')
        {
@@ -976,12 +925,12 @@ getmessage (buf, forever)
          c2 = readchar (timeout);
          c3 = readchar (timeout);
          if (remote_debug)
-           fprintf_unfiltered (gdb_stderr, "Trigraph %c%c%c received\n",
+           fprintf_unfiltered (gdb_stdlog, "Trigraph %c%c%c received\n",
                                c, c2, c3);
          if (c3 == '+')
            {
              message_pending = 1;
-             return 0; /*????*/
+             return 0;         /*???? */
            }
          continue;
        }
@@ -1002,7 +951,7 @@ getmessage (buf, forever)
 
          if (csum != header[0])
            fprintf_unfiltered (gdb_stderr,
-                               "Checksum mismatch: computed %d, received %d\n",
+                           "Checksum mismatch: computed %d, received %d\n",
                                csum, header[0]);
 
          if (header[2] == 0xff)
@@ -1010,15 +959,15 @@ getmessage (buf, forever)
 
          if (remote_debug)
            {
-             fprintf_unfiltered (gdb_stderr,
-                                 "... (Got checksum %d, id %d, length %d)\n",
+             fprintf_unfiltered (gdb_stdlog,
+                               "... (Got checksum %d, id %d, length %d)\n",
                                  header[0], header[1], header[2]);
-             fprintf_unfiltered (gdb_stderr, "Message received: \"");
+             fprintf_unfiltered (gdb_stdlog, "Message received: \"");
              for (i = 0; i < len; ++i)
                {
-                 fprintf_unfiltered (gdb_stderr, "%02x", (unsigned char) buf[i]);
+                 fprintf_unfiltered (gdb_stdlog, "%02x", (unsigned char) buf[i]);
                }
-             fprintf_unfiltered (gdb_stderr, "\"\n");
+             fprintf_unfiltered (gdb_stdlog, "\"\n");
            }
 
          /* no ack required? */
@@ -1037,25 +986,22 @@ getmessage (buf, forever)
 }
 \f
 static void
-sds_kill ()
+sds_kill (void)
 {
   /* Don't try to do anything to the target.  */
 }
 
 static void
-sds_mourn ()
+sds_mourn (void)
 {
   unpush_target (&sds_ops);
   generic_mourn_inferior ();
 }
 
 static void
-sds_create_inferior (exec_file, args, env)
-     char *exec_file;
-     char *args;
-     char **env;
+sds_create_inferior (char *exec_file, char *args, char **env)
 {
-  inferior_pid = 42000;
+  inferior_ptid = pid_to_ptid (42000);
 
   /* Clean up from the last time we were running.  */
   clear_proceed_status ();
@@ -1065,13 +1011,11 @@ sds_create_inferior (exec_file, args, env)
 }
 
 static void
-sds_load (filename, from_tty)
-    char *filename;
-    int from_tty;
+sds_load (char *filename, int from_tty)
 {
   generic_load (filename, from_tty);
 
-  inferior_pid = 0;
+  inferior_ptid = null_ptid;
 }
 \f
 /* The SDS monitor has commands for breakpoint insertion, although it
@@ -1079,9 +1023,7 @@ sds_load (filename, from_tty)
    replaced instruction back to the debugger.  */
 
 static int
-sds_insert_breakpoint (addr, contents_cache)
-     CORE_ADDR addr;
-     char *contents_cache;
+sds_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
 {
   int i, retlen;
   unsigned char *p, buf[PBUFSIZ];
@@ -1091,9 +1033,9 @@ sds_insert_breakpoint (addr, contents_cache)
   *p++ = 0;
   *p++ = (int) (addr >> 24) & 0xff;
   *p++ = (int) (addr >> 16) & 0xff;
-  *p++ = (int) (addr >>  8) & 0xff;
-  *p++ = (int) (addr      ) & 0xff;
-  
+  *p++ = (int) (addr >> 8) & 0xff;
+  *p++ = (int) (addr) & 0xff;
+
   retlen = sds_send (buf, p - buf);
 
   for (i = 0; i < 4; ++i)
@@ -1103,9 +1045,7 @@ sds_insert_breakpoint (addr, contents_cache)
 }
 
 static int
-sds_remove_breakpoint (addr, contents_cache)
-     CORE_ADDR addr;
-     char *contents_cache;
+sds_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
 {
   int i, retlen;
   unsigned char *p, buf[PBUFSIZ];
@@ -1115,8 +1055,8 @@ sds_remove_breakpoint (addr, contents_cache)
   *p++ = 0;
   *p++ = (int) (addr >> 24) & 0xff;
   *p++ = (int) (addr >> 16) & 0xff;
-  *p++ = (int) (addr >>  8) & 0xff;
-  *p++ = (int) (addr      ) & 0xff;
+  *p++ = (int) (addr >> 8) & 0xff;
+  *p++ = (int) (addr) & 0xff;
   for (i = 0; i < 4; ++i)
     *p++ = contents_cache[i];
 
@@ -1125,8 +1065,8 @@ sds_remove_breakpoint (addr, contents_cache)
   return 0;
 }
 \f
-static void 
-init_sds_ops ()
+static void
+init_sds_ops (void)
 {
   sds_ops.to_shortname = "sds";
   sds_ops.to_longname = "Remote serial target with SDS protocol";
@@ -1161,9 +1101,7 @@ Specify the serial device it is connected to (e.g. /dev/ttya).";
    reply message.  */
 
 static void
-sds_command (args, from_tty)
-     char *args;
-     int from_tty;
+sds_command (char *args, int from_tty)
 {
   char *p;
   int i, len, retlen;
@@ -1186,21 +1124,21 @@ sds_command (args, from_tty)
   for (i = 0; i < retlen; ++i)
     {
       printf_filtered ("%02x", buf[i]);
-    }  
+    }
   printf_filtered ("\n");
 }
 
 void
-_initialize_remote_sds ()
+_initialize_remote_sds (void)
 {
   init_sds_ops ();
   add_target (&sds_ops);
 
   add_show_from_set (add_set_cmd ("sdstimeout", no_class,
-                                 var_integer, (char *)&sds_timeout,
-                                 "Set timeout value for sds read.\n", &setlist),
+                                 var_integer, (char *) &sds_timeout,
+                            "Set timeout value for sds read.\n", &setlist),
                     &showlist);
 
   add_com ("sds", class_obscure, sds_command,
-          "Send a command to the SDS monitor."); 
+          "Send a command to the SDS monitor.");
 }
This page took 0.041629 seconds and 4 git commands to generate.