* serial.h (SERIAL_SET_TTY_STATE): Comment return value.
[deliverable/binutils-gdb.git] / gdb / remote-bug.c
index a1806fc8b519bf7291b989dcb5463003f60fd3c9..b3b72d28eca475e1d9928d236804d07aed9e5889 100644 (file)
@@ -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());
 
@@ -275,12 +278,13 @@ static char *wait_strings[] = {
 int
 bug_wait (pid, status)
      int pid;
-     WAITTYPE *status;
+     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.  */
@@ -297,13 +301,15 @@ bug_wait (pid, 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;
@@ -313,14 +319,16 @@ bug_wait (pid, 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;
        }
 
@@ -456,7 +464,7 @@ bug_fetch_register(regno)
     {
       /* 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)));
@@ -468,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;
@@ -528,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);
@@ -676,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;
 
@@ -954,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 */
@@ -1001,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,
@@ -1009,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.026773 seconds and 4 git commands to generate.