* tracepoint.c (trace_start_command): Set trace_running_p.
[deliverable/binutils-gdb.git] / gdb / remote-bug.c
index 641895e6820f4e0d91a4be8eac2b7b63cd219dfc..4e29c0eee4825b63b94197b071ceaaab2c9b22fd 100644 (file)
@@ -18,13 +18,13 @@ 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
 #include "inferior.h"
 #include "wait.h"
 
-#include <string.h>
+#include "gdb_string.h"
 #include <ctype.h>
 #include <fcntl.h>
 #include <signal.h>
@@ -66,7 +66,8 @@ static int srec_max_retries = 3;
    record.  I call this download a "frame".  Srec_frame says how many
    bytes will be represented in each frame.  */
 
-static int srec_frame = 160;
+#define SREC_SIZE 160
+static int srec_frame = SREC_SIZE;
 
 /* This variable determines how many bytes will be represented in each
    S3 s-record.  */
@@ -138,6 +139,7 @@ bug_load (args, fromtty)
   s = abfd->sections;
   while (s != (asection *) NULL)
     {
+      srec_frame = SREC_SIZE;
       if (s->flags & SEC_LOAD)
        {
          int i;
@@ -242,7 +244,8 @@ bug_open (args, from_tty)
 
 void
 bug_resume (pid, step, sig)
-     int pid, step, sig;
+     int pid, step;
+     enum target_signal sig;
 {
   dcache_flush (gr_get_dcache());
 
@@ -267,19 +270,21 @@ bug_resume (pid, step, sig)
 static char *wait_strings[] = {
   "At Breakpoint",
   "Exception: Data Access Fault (Local Bus Timeout)",
-  "\r8???-Bug>",
+  "\r8??\?-Bug>",      /* The '\?' avoids creating a trigraph */
   "\r197-Bug>",
   NULL,
 };
 
 int
-bug_wait (status)
-     WAITTYPE *status;
+bug_wait (pid, status)
+     int pid;
+     struct target_waitstatus *status;
 {
   int old_timeout = sr_get_timeout();
   int old_immediate_quit = immediate_quit;
 
-  WSETEXIT ((*status), 0);
+  status->kind = TARGET_WAITKIND_EXITED;
+  status->value.integer = 0;
 
   /* read off leftovers from resume so that the rest can be passed
      back out as stdout.  */
@@ -296,13 +301,15 @@ bug_wait (status)
   switch (gr_multi_scan(wait_strings, need_artificial_trap == 0))
     {
     case 0: /* breakpoint case */
-      WSETSTOP ((*status), SIGTRAP);
+      status->kind = TARGET_WAITKIND_STOPPED;
+      status->value.sig = TARGET_SIGNAL_TRAP;
       /* user output from the target can be discarded here. (?) */
       gr_expect_prompt();
       break;
 
     case 1: /* bus error */
-      WSETSTOP ((*status), SIGBUS);
+      status->kind = TARGET_WAITKIND_STOPPED;
+      status->value.sig = TARGET_SIGNAL_BUS;
       /* user output from the target can be discarded here. (?) */
       gr_expect_prompt();
       break;
@@ -312,14 +319,16 @@ bug_wait (status)
       if (need_artificial_trap != 0)
        {
          /* stepping */
-         WSETSTOP ((*status), SIGTRAP);
+         status->kind = TARGET_WAITKIND_STOPPED;
+         status->value.sig = TARGET_SIGNAL_TRAP;
          need_artificial_trap--;
          break;
        }
       else
        {
          /* exit case */
-         WSETEXIT ((*status), 0);
+         status->kind = TARGET_WAITKIND_EXITED;
+         status->value.integer = 0;
          break;
        }
 
@@ -424,8 +433,6 @@ static void
 bug_fetch_register(regno)
      int regno;
 {
-  REGISTER_TYPE regval;
-
   sr_check_open();
 
   if (regno == -1)
@@ -443,18 +450,21 @@ bug_fetch_register(regno)
     }
   else if (regno < XFP_REGNUM)
     {
-      sr_write("rs ", 3);
-      sr_write_cr(get_reg_name(regno));
-      sr_expect("=");
-      regval = sr_get_hex_word();
-      gr_expect_prompt();
-      supply_register(regno, (char *) &regval);
+      char buffer[MAX_REGISTER_RAW_SIZE];
+
+      sr_write ("rs ", 3);
+      sr_write_cr (get_reg_name(regno));
+      sr_expect ("=");
+      store_unsigned_integer (buffer, REGISTER_RAW_SIZE (regno),
+                             sr_get_hex_word());
+      gr_expect_prompt ();
+      supply_register (regno, buffer);
     }
   else
     {
       /* Float register so we need to parse a strange data format. */
       long p;
-      unsigned char value[10];
+      unsigned char fpreg_buf[10];
 
       sr_write("rs ", 3);
       sr_write(get_reg_name(regno), strlen(get_reg_name(regno)));
@@ -466,31 +476,31 @@ bug_fetch_register(regno)
 
       /* sign */
       p = sr_get_hex_digit(1);
-      value[0] = p << 7;
+      fpreg_buf[0] = p << 7;
 
       /* exponent */
       sr_expect("_");
       p = sr_get_hex_digit(1);
-      value[0] += (p << 4);
-      value[0] += sr_get_hex_digit(1);
+      fpreg_buf[0] += (p << 4);
+      fpreg_buf[0] += sr_get_hex_digit(1);
 
-      value[1] = sr_get_hex_digit(1) << 4;
+      fpreg_buf[1] = sr_get_hex_digit(1) << 4;
 
       /* fraction */
       sr_expect("_");
-      value[1] += sr_get_hex_digit(1);
+      fpreg_buf[1] += sr_get_hex_digit(1);
 
-      value[2] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
-      value[3] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
-      value[4] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
-      value[5] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
-      value[6] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
-      value[7] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
-      value[8] = 0;
-      value[9] = 0;
+      fpreg_buf[2] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
+      fpreg_buf[3] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
+      fpreg_buf[4] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
+      fpreg_buf[5] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
+      fpreg_buf[6] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
+      fpreg_buf[7] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
+      fpreg_buf[8] = 0;
+      fpreg_buf[9] = 0;
 
       gr_expect_prompt();
-      supply_register(regno, value);
+      supply_register(regno, fpreg_buf);
     }
 
   return;
@@ -526,23 +536,24 @@ bug_store_register (regno)
                read_register(regno));
       else
        {
-         unsigned char *value = &registers[REGISTER_BYTE(regno)];
+         unsigned char *fpreg_buf =
+           (unsigned char *)&registers[REGISTER_BYTE(regno)];
          
          sprintf(buffer, "rs %s %1x_%02x%1x_%1x%02x%02x%02x%02x%02x%02x;d",
                  regname,
                  /* sign */
-                 (value[0] >> 7) & 0xf,
+                 (fpreg_buf[0] >> 7) & 0xf,
                  /* exponent */
-                 value[0] & 0x7f,
-                 (value[1] >> 8) & 0xf,
+                 fpreg_buf[0] & 0x7f,
+                 (fpreg_buf[1] >> 8) & 0xf,
                  /* fraction */
-                 value[1] & 0xf,
-                 value[2],
-                 value[3],
-                 value[4],
-                 value[5],
-                 value[6],
-                 value[7]);
+                 fpreg_buf[1] & 0xf,
+                 fpreg_buf[2],
+                 fpreg_buf[3],
+                 fpreg_buf[4],
+                 fpreg_buf[5],
+                 fpreg_buf[6],
+                 fpreg_buf[7]);
        }
 
       sr_write_cr(buffer);
@@ -674,7 +685,7 @@ bug_write_memory (memaddr, myaddr, len)
   int checksum;
   int x;
   int retries;
-  char buffer[(srec_bytes + 8) << 1];
+  char *buffer = alloca ((srec_bytes + 8) << 1);
 
   retries = 0;
 
@@ -952,8 +963,7 @@ bug_clear_breakpoints ()
 struct target_ops bug_ops =
 {
   "bug", "Remote BUG monitor",
-  "Use the mvme187 board running the BUG monitor connected\n\
-by a serial line.",
+  "Use the mvme187 board running the BUG monitor connected by a serial line.",
 
   bug_open, gr_close,
   0, gr_detach, bug_resume, bug_wait,  /* attach */
@@ -999,6 +1009,9 @@ This affects the communication protocol with the remote target.",
                  &setlist),
      &showlist);
 
+#if 0
+  /* This needs to set SREC_SIZE, not srec_frame which gets changed at the
+     end of a download.  But do we need the option at all?  */
   add_show_from_set
     (add_set_cmd ("srec-frame", class_support, var_uinteger,
                  (char *) &srec_frame,
@@ -1007,6 +1020,7 @@ Set the number of bytes in an S-record frame.\n\
 This affects the communication protocol with the remote target.",
                  &setlist),
      &showlist);
+#endif /* 0 */
 
   add_show_from_set
     (add_set_cmd ("srec-noise", class_support, var_zinteger,
This page took 0.027668 seconds and 4 git commands to generate.