Allow for the possibility that the local labels won't be in the objdump output.
[deliverable/binutils-gdb.git] / gdb / monitor.c
index b57365e53343e55831b56cc7cfb68e5e60bae58b..025a2cdabf5f9be1f832aa48afb322228bb8c843 100644 (file)
@@ -1,5 +1,6 @@
 /* Remote debugging interface for boot monitors, for GDB.
-   Copyright 1990-1993, 1995-1997, 1999-2000 Free Software Foundation, Inc.
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+   2000, 2001 Free Software Foundation, Inc.
    Contributed by Cygnus Support.  Written by Rob Savoye for Cygnus.
    Resurrected from the ashes by Stu Grossman.
 
@@ -23,7 +24,7 @@
 /* This file was derived from various remote-* modules. It is a collection
    of generic support functions so GDB can talk directly to a ROM based
    monitor. This saves use from having to hack an exception based handler
-   into existance, and makes for quick porting.
+   into existence, and makes for quick porting.
 
    This module talks to a debug monitor called 'MONITOR', which
    We communicate with MONITOR via either a direct serial line, or a TCP
@@ -40,7 +41,6 @@
 #include "defs.h"
 #include "gdbcore.h"
 #include "target.h"
-#include "gdb_wait.h"
 #include <signal.h>
 #include <ctype.h>
 #include "gdb_string.h"
@@ -51,8 +51,8 @@
 #include "gdbcmd.h"
 #include "inferior.h"
 #include "gdb_regex.h"
-#include "dcache.h"
 #include "srec.h"
+#include "regcache.h"
 
 static char *dev_name;
 static struct target_ops *targ_ops;
@@ -78,7 +78,9 @@ static void monitor_fetch_registers (int regno);
 static void monitor_store_registers (int regno);
 static void monitor_prepare_to_store (void);
 static int monitor_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len,
-                               int write, struct target_ops *target);
+                               int write, 
+                               struct mem_attrib *attrib,
+                               struct target_ops *target);
 static void monitor_files_info (struct target_ops *ops);
 static int monitor_insert_breakpoint (CORE_ADDR addr, char *shadow);
 static int monitor_remove_breakpoint (CORE_ADDR addr, char *shadow);
@@ -130,7 +132,6 @@ static char getmem_resp_delim_fastmap[256];
 static int dump_reg_flag;      /* Non-zero means do a dump_registers cmd when
                                   monitor_wait wakes up.  */
 
-static DCACHE *remote_dcache;
 static int first_time = 0;     /* is this the first time we're executing after 
                                   gaving created the child proccess? */
 
@@ -336,7 +337,7 @@ monitor_printf_noecho (char *pattern,...)
 
   len = strlen (sndbuf);
   if (len + 1 > sizeof sndbuf)
-    abort ();
+    internal_error (__FILE__, __LINE__, "failed internal consistency check");
 
   if (monitor_debug_p)
     {
@@ -364,7 +365,7 @@ monitor_printf (char *pattern,...)
 
   len = strlen (sndbuf);
   if (len + 1 > sizeof sndbuf)
-    abort ();
+    internal_error (__FILE__, __LINE__, "failed internal consistency check");
 
   if (monitor_debug_p)
     {
@@ -521,7 +522,7 @@ monitor_expect (char *string, char *buf, int buflen)
       fprintf_unfiltered (gdb_stdlog, "MON Expecting '%s'\n", safe_string);
     }
 
-  immediate_quit = 1;
+  immediate_quit++;
   while (1)
     {
       if (buf)
@@ -529,7 +530,7 @@ monitor_expect (char *string, char *buf, int buflen)
          if (buflen < 2)
            {
              *buf = '\000';
-             immediate_quit = 0;
+             immediate_quit--;
              return -1;
            }
 
@@ -549,7 +550,7 @@ monitor_expect (char *string, char *buf, int buflen)
          p++;
          if (*p == '\0')
            {
-             immediate_quit = 0;
+             immediate_quit--;
 
              if (buf)
                {
@@ -754,8 +755,8 @@ monitor_open (char *args, struct monitor_ops *mon_ops, int from_tty)
   unpush_target (targ_ops);
 
   if (dev_name)
-    free (dev_name);
-  dev_name = strsave (args);
+    xfree (dev_name);
+  dev_name = xstrdup (args);
 
   monitor_desc = SERIAL_OPEN (dev_name);
 
@@ -838,17 +839,6 @@ monitor_open (char *args, struct monitor_ops *mon_ops, int from_tty)
 
   monitor_printf (current_monitor->line_term);
 
-  if (!remote_dcache)
-    {
-      if (current_monitor->flags & MO_HAS_BLOCKWRITES)
-       remote_dcache = dcache_init (monitor_read_memory, 
-                                    monitor_write_memory_block);
-      else
-       remote_dcache = dcache_init (monitor_read_memory, monitor_write_memory);
-    }
-  else
-    dcache_flush (remote_dcache);
-
   start_remote ();
 }
 
@@ -864,7 +854,7 @@ monitor_close (int quitting)
   /* Free breakpoint memory */
   if (breakaddr != NULL)
     {
-      free (breakaddr);
+      xfree (breakaddr);
       breakaddr = NULL;
     }
 
@@ -931,12 +921,6 @@ monitor_supply_register (int regno, char *valstr)
 
 /* Tell the remote machine to resume.  */
 
-void
-flush_monitor_dcache (void)
-{
-  dcache_flush (remote_dcache);
-}
-
 static void
 monitor_resume (int pid, int step, enum target_signal sig)
 {
@@ -950,7 +934,6 @@ monitor_resume (int pid, int step, enum target_signal sig)
        dump_reg_flag = 1;
       return;
     }
-  dcache_flush (remote_dcache);
   if (step)
     monitor_printf (current_monitor->step);
   else
@@ -1305,7 +1288,7 @@ monitor_dump_regs (void)
       parse_register_dump (buf, resp_len);
     }
   else
-    abort ();                  /* Need some way to read registers */
+    internal_error (__FILE__, __LINE__, "failed internal consistency check");                  /* Need some way to read registers */
 }
 
 static void
@@ -2002,15 +1985,30 @@ monitor_read_memory (CORE_ADDR memaddr, char *myaddr, int len)
   return len;
 }
 
+/* Transfer LEN bytes between target address MEMADDR and GDB address
+   MYADDR.  Returns 0 for success, errno code for failure. TARGET is
+   unused. */
+
 static int
-monitor_xfer_memory (memaddr, myaddr, len, write, target)
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
-     int write;
-     struct target_ops *target;        /* ignored */
+monitor_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+                    struct mem_attrib *attrib ATTRIBUTE_UNUSED,
+                    struct target_ops *target ATTRIBUTE_UNUSED)
 {
-  return dcache_xfer_memory (remote_dcache, memaddr, myaddr, len, write);
+  int res;
+
+  if (write)
+    {
+      if (current_monitor->flags & MO_HAS_BLOCKWRITES)
+       res = monitor_write_memory_block(memaddr, myaddr, len);
+      else
+       res = monitor_write_memory(memaddr, myaddr, len);
+    }
+  else
+    {
+      res = monitor_read_memory(memaddr, myaddr, len);
+    }
+
+  return res;
 }
 
 static void
@@ -2147,7 +2145,6 @@ monitor_wait_srec_ack (void)
 static void
 monitor_load (char *file, int from_tty)
 {
-  dcache_flush (remote_dcache);
   monitor_debug ("MON load\n");
 
   if (current_monitor->load_routine)
This page took 0.025352 seconds and 4 git commands to generate.