Remove sanitized-out Magic Cap support, will never be released
[deliverable/binutils-gdb.git] / gdb / monitor.c
index 503930ff3cd105c380f0e4fa5c48ff1cfc232886..b7a56aa57d33c65b3205b240a0576f58ac2b2dba 100644 (file)
@@ -59,6 +59,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "dcache.h"
 #include "srec.h"
 
+static char *dev_name;
+static struct target_ops *targ_ops;
+
 static int readchar PARAMS ((int timeout));
 
 static void monitor_command PARAMS ((char *args, int fromtty));
@@ -353,6 +356,7 @@ monitor_expect (string, buf, buflen)
   char *p = string;
   int obuflen = buflen;
   int c;
+  extern struct target_ops *targ_ops;
 
   immediate_quit = 1;
   while (1)
@@ -393,6 +397,11 @@ monitor_expect (string, buf, buflen)
                return 0;
            }
        }
+      else if ((c == '\021' || c == '\023') &&
+              (strcmp(targ_ops->to_shortname, "m32r") == 0))
+       { /* m32r monitor emits random DC1/DC3 chars */
+         continue;
+       }
       else
        {
          p = string;
@@ -450,14 +459,13 @@ monitor_expect_regexp (pat, buf, buflen)
    o give your command
    o *then* wait for the prompt.
 
-   Thus the last thing that a procedure does with the serial line
-   will be an monitor_expect_prompt().  Exception:  monitor_resume does not
-   wait for the prompt, because the terminal is being handed over
-   to the inferior.  However, the next thing which happens after that
-   is a monitor_wait which does wait for the prompt.
-   Note that this includes abnormal exit, e.g. error().  This is
-   necessary to prevent getting into states from which we can't
-   recover.  */
+   Thus the last thing that a procedure does with the serial line will
+   be an monitor_expect_prompt().  Exception: monitor_resume does not
+   wait for the prompt, because the terminal is being handed over to
+   the inferior.  However, the next thing which happens after that is
+   a monitor_wait which does wait for the prompt.  Note that this
+   includes abnormal exit, e.g. error().  This is necessary to prevent
+   getting into states from which we can't recover.  */
 
 int
 monitor_expect_prompt (buf, buflen)
@@ -521,9 +529,6 @@ compile_pattern (pattern, compiled_pattern, fastmap)
 /* Open a connection to a remote debugger. NAME is the filename used
    for communication.  */
 
-static char *dev_name;
-static struct target_ops *targ_ops;
-
 void
 monitor_open (args, mon_ops, from_tty)
      char *args;
@@ -954,11 +959,11 @@ monitor_fetch_register (regno)
 
 static void monitor_dump_regs ()
 {
+  char buf[1024];
+  int resp_len;
+
   if (current_monitor->dump_registers)
     {
-      char buf[200];
-      int resp_len;
-
       monitor_printf (current_monitor->dump_registers);
       resp_len = monitor_expect_prompt (buf, sizeof (buf));
       parse_register_dump (buf, resp_len);
@@ -1004,7 +1009,10 @@ monitor_store_register (regno)
 
  /* send the register deposit command */
 
-  monitor_printf (current_monitor->setreg.cmd, name, val);
+  if (current_monitor->flags & MO_REGISTER_VALUE_FIRST)
+    monitor_printf (current_monitor->setreg.cmd, val, name);
+  else
+    monitor_printf (current_monitor->setreg.cmd, name, val);
 
 /* It's possible that there are actually some monitors out there that
    will prompt you when you set a register.  In that case, you may
@@ -1080,12 +1088,16 @@ monitor_write_memory (memaddr, myaddr, len)
        }
     }
 
+#if 0
+  /* Can't actually use long longs if VAL is an int (nice idea, though).  */
   if ((memaddr & 0x7) == 0 && len >= 8 && current_monitor->setmem.cmdll)
     {
       len = 8;
       cmd = current_monitor->setmem.cmdll;
     }
-  else if ((memaddr & 0x3) == 0 && len >= 4 && current_monitor->setmem.cmdl)
+  else
+#endif
+  if ((memaddr & 0x3) == 0 && len >= 4 && current_monitor->setmem.cmdl)
     {
       len = 4;
       cmd = current_monitor->setmem.cmdl;
@@ -1128,12 +1140,18 @@ monitor_read_memory_single (memaddr, myaddr, len)
   char *cmd;
   int i;
 
+#if 0
+  /* Can't actually use long longs (nice idea, though).  In fact, the
+     call to strtoul below will fail if it tries to convert a value
+     that's too big to fit in a long.  */
   if ((memaddr & 0x7) == 0 && len >= 8 && current_monitor->getmem.cmdll)
     {
       len = 8;
       cmd = current_monitor->getmem.cmdll;
     }
-  else if ((memaddr & 0x3) == 0 && len >= 4 && current_monitor->getmem.cmdl)
+  else
+#endif
+  if ((memaddr & 0x3) == 0 && len >= 4 && current_monitor->getmem.cmdl)
     {
       len = 4;
       cmd = current_monitor->getmem.cmdl;
@@ -1149,32 +1167,33 @@ monitor_read_memory_single (memaddr, myaddr, len)
       cmd = current_monitor->getmem.cmdb;
     }
 
-/* Send the examine command.  */
+  /* Send the examine command.  */
 
   monitor_printf (cmd, memaddr);
 
-/* If RESP_DELIM is specified, we search for that as a leading delimiter for
-   the register value.  Otherwise, we just start searching from the start of
-   the buf.  */
+  /* If RESP_DELIM is specified, we search for that as a leading
+     delimiter for the memory value.  Otherwise, we just start
+     searching from the start of the buf.  */
 
   if (current_monitor->getmem.resp_delim)
     monitor_expect_regexp (&getmem_resp_delim_pattern, NULL, 0);
 
-/* Now, read the appropriate number of hex digits for this loc, skipping
-   spaces.  */
+  /* Now, read the appropriate number of hex digits for this loc,
+     skipping spaces.  */
 
-  /* Skip leading spaces and "0x" if MO_HEX_PREFIX flag is set */
+  /* Skip leading spaces and "0x" if MO_HEX_PREFIX flag is set. */
   if (current_monitor->flags & MO_HEX_PREFIX) 
     {
       int c;
+
       c = readchar (timeout);
       while (c == ' ')
        c = readchar (timeout);
       if ((c == '0') && ((c = readchar (timeout)) == 'x'))
        ;
       else
-         error ("monitor_read_memory_single (0x%x):  bad response from monitor: %.*s%c.",
-                memaddr, i, membuf, c);
+       error ("monitor_read_memory_single (0x%x):  bad response from monitor: %.*s%c.",
+              memaddr, i, membuf, c);
     }
   for (i = 0; i < len * 2; i++)
     {
@@ -1251,20 +1270,21 @@ monitor_read_memory (memaddr, myaddr, len)
 
   len = min (len, 16);
 
-/* See if xfer would cross a 16 byte boundary.  If so, clip it.  */
+  /* See if xfer would cross a 16 byte boundary.  If so, clip it.  */
   if (((memaddr ^ (memaddr + len - 1)) & ~0xf) != 0)
     len = ((memaddr + len) & ~0xf) - memaddr;
 
- /* send the memory examine command */
 /* send the memory examine command */
 
   if (current_monitor->flags & MO_GETMEM_NEEDS_RANGE)
     monitor_printf (current_monitor->getmem.cmdb, memaddr, memaddr + len - 1);
   else
     monitor_printf (current_monitor->getmem.cmdb, memaddr, len);
 
-/* If TERM is present, we wait for that to show up.  Also, (if TERM is
-   present), we will send TERM_CMD if that is present.  In any case, we collect
-   all of the output into buf, and then wait for the normal prompt.  */
+  /* If TERM is present, we wait for that to show up.  Also, (if TERM
+     is present), we will send TERM_CMD if that is present.  In any
+     case, we collect all of the output into buf, and then wait for
+     the normal prompt.  */
 
   if (current_monitor->getmem.term)
     {
@@ -1286,9 +1306,9 @@ monitor_read_memory (memaddr, myaddr, len)
 
   p = buf;
 
-  /* If RESP_DELIM is specified, we search for that as a leading delimiter for
-     the values.  Otherwise, we just start searching from the start of the buf.
-   */
+  /* If RESP_DELIM is specified, we search for that as a leading
+     delimiter for the values.  Otherwise, we just start searching
+     from the start of the buf.  */
 
   if (current_monitor->getmem.resp_delim)
     {
@@ -1401,7 +1421,13 @@ monitor_insert_breakpoint (addr, shadow)
      char *shadow;
 {
   int i;
+  /* This is only used to compute the size of a breakpoint.  */
+#ifdef BREAKPOINT
   static unsigned char break_insn[] = BREAKPOINT;
+#else
+  /* In the bi-endian case we assume breakpoints are the same size.  */
+  static unsigned char break_insn[] = BIG_BREAKPOINT;
+#endif
 
   for (i = 0; i < NUM_MONITOR_BREAKPOINTS; i++)
     {
This page took 0.025936 seconds and 4 git commands to generate.