* Makefile.in: Add dependencies for remote-fileio.o.
[deliverable/binutils-gdb.git] / gdb / remote.c
index 8a7451e4ad771e18db0c4b2a884b9078829343d1..d5a5cf66c728fb3384692f8b5c0c0146b29498da 100644 (file)
@@ -55,6 +55,8 @@
 
 #include "gdbcore.h" /* for exec_bfd */
 
+#include "remote-fileio.h"
+
 /* Prototypes for local functions */
 static void cleanup_sigint_signal_handler (void *dummy);
 static void initialize_sigint_signal_handler (void);
@@ -67,10 +69,6 @@ void async_remote_interrupt_twice (gdb_client_data);
 
 static void build_remote_gdbarch_data (void);
 
-static int remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len);
-
-static int remote_read_bytes (CORE_ADDR memaddr, char *myaddr, int len);
-
 static void remote_files_info (struct target_ops *ignore);
 
 static int remote_xfer_memory (CORE_ADDR memaddr, char *myaddr,
@@ -261,9 +259,10 @@ init_remote_state (struct gdbarch *gdbarch)
   int regnum;
   struct remote_state *rs = xmalloc (sizeof (struct remote_state));
 
-  /* Start out by having the remote protocol mimic the existing
-     behavour - just copy in the description of the register cache.  */
-  rs->sizeof_g_packet = REGISTER_BYTES; /* OK use.   */
+  if (DEPRECATED_REGISTER_BYTES != 0)
+    rs->sizeof_g_packet = DEPRECATED_REGISTER_BYTES;
+  else
+    rs->sizeof_g_packet = 0;
 
   /* Assume a 1:1 regnum<->pnum table.  */
   rs->regs = xcalloc (NUM_REGS + NUM_PSEUDO_REGS, sizeof (struct packet_reg));
@@ -274,8 +273,11 @@ init_remote_state (struct gdbarch *gdbarch)
       r->regnum = regnum;
       r->offset = REGISTER_BYTE (regnum);
       r->in_g_packet = (regnum < NUM_REGS);
-      /* ...size = REGISTER_RAW_SIZE (regnum); */
       /* ...name = REGISTER_NAME (regnum); */
+
+      /* Compute packet size by accumulating the size of all registers. */
+      if (DEPRECATED_REGISTER_BYTES == 0)
+        rs->sizeof_g_packet += register_size (current_gdbarch, regnum);
     }
 
   /* Default maximum number of characters in a packet body. Many
@@ -1985,8 +1987,10 @@ get_offsets (void)
   if (symfile_objfile == NULL)
     return;
 
-  offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS);
-  memcpy (offs, symfile_objfile->section_offsets, SIZEOF_SECTION_OFFSETS);
+  offs = ((struct section_offsets *) 
+         alloca (SIZEOF_N_SECTION_OFFSETS (symfile_objfile->num_sections)));
+  memcpy (offs, symfile_objfile->section_offsets, 
+         SIZEOF_N_SECTION_OFFSETS (symfile_objfile->num_sections));
 
   offs->offsets[SECT_OFF_TEXT (symfile_objfile)] = text_addr;
 
@@ -2097,8 +2101,10 @@ remote_cisco_objfile_relocate (bfd_signed_vma text_off, bfd_signed_vma data_off,
          broken for xcoff, dwarf, sdb-coff, etc.  But there is no
          simple canonical representation for this stuff.  */
 
-      offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS);
-      memcpy (offs, symfile_objfile->section_offsets, SIZEOF_SECTION_OFFSETS);
+      offs = (struct section_offsets *) 
+       alloca (SIZEOF_N_SECTION_OFFSETS (symfile_objfile->num_sections));
+      memcpy (offs, symfile_objfile->section_offsets, 
+             SIZEOF_N_SECTION_OFFSETS (symfile_objfile->num_sections));
 
       offs->offsets[SECT_OFF_TEXT (symfile_objfile)] = text_off;
       offs->offsets[SECT_OFF_DATA (symfile_objfile)] = data_off;
@@ -2945,10 +2951,13 @@ remote_wait (ptid_t ptid, struct target_waitstatus *status)
        case 'E':               /* Error of some sort */
          warning ("Remote failure reply: %s", buf);
          continue;
+       case 'F':               /* File-I/O request */
+         remote_fileio_request (buf);
+         continue;
        case 'T':               /* Status with PC, SP, FP, ... */
          {
            int i;
-           char* regs = (char*) alloca (MAX_REGISTER_RAW_SIZE);
+           char regs[MAX_REGISTER_SIZE];
 
            /* Expedited reply, containing Signal, {regno, reg} repeat */
            /*  format is:  'Tssn...:r...;n...:r...;n...:r...;#cc', where
@@ -3196,10 +3205,13 @@ remote_async_wait (ptid_t ptid, struct target_waitstatus *status)
        case 'E':               /* Error of some sort */
          warning ("Remote failure reply: %s", buf);
          continue;
+       case 'F':               /* File-I/O request */
+         remote_fileio_request (buf);
+         continue;
        case 'T':               /* Status with PC, SP, FP, ... */
          {
            int i;
-           char* regs = (char*) alloca (MAX_REGISTER_RAW_SIZE);
+           char regs[MAX_REGISTER_SIZE];
 
            /* Expedited reply, containing Signal, {regno, reg} repeat */
            /*  format is:  'Tssn...:r...;n...:r...;n...:r...;#cc', where
@@ -3529,7 +3541,7 @@ remote_prepare_to_store (void)
          forcing the register cache to read its and not the target
          registers.  */
       deprecated_read_register_bytes (0, (char *) NULL,
-                                     REGISTER_BYTES); /* OK use.  */
+                                     DEPRECATED_REGISTER_BYTES); /* OK */
       break;
     case PACKET_ENABLE:
       break;
@@ -3546,7 +3558,7 @@ store_register_using_P (int regnum)
   struct packet_reg *reg = packet_reg_from_regnum (rs, regnum);
   /* Try storing a single register.  */
   char *buf = alloca (rs->remote_packet_size);
-  char *regp = alloca (MAX_REGISTER_RAW_SIZE);
+  char regp[MAX_REGISTER_SIZE];
   char *p;
   int i;
 
@@ -3750,7 +3762,7 @@ check_binary_download (CORE_ADDR addr)
    Returns number of bytes transferred, or 0 (setting errno) for
    error.  Only transfer a single packet. */
 
-static int
+int
 remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
 {
   unsigned char *buf;
@@ -3894,7 +3906,7 @@ remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
    caller and its callers caller ;-) already contains code for
    handling partial reads. */
 
-static int
+int
 remote_read_bytes (CORE_ADDR memaddr, char *myaddr, int len)
 {
   char *buf;
@@ -4624,47 +4636,48 @@ extended_remote_async_create_inferior (char *exec_file, char *args, char **env)
 }
 \f
 
-/* On some machines, e.g. 68k, we may use a different breakpoint instruction
-   than other targets; in those use REMOTE_BREAKPOINT instead of just
-   BREAKPOINT.  Also, bi-endian targets may define LITTLE_REMOTE_BREAKPOINT
-   and BIG_REMOTE_BREAKPOINT.  If none of these are defined, we just call
-   the standard routines that are in mem-break.c.  */
+/* On some machines, e.g. 68k, we may use a different breakpoint
+   instruction than other targets; in those use
+   DEPRECATED_REMOTE_BREAKPOINT instead of just BREAKPOINT_FROM_PC.
+   Also, bi-endian targets may define
+   DEPRECATED_LITTLE_REMOTE_BREAKPOINT and
+   DEPRECATED_BIG_REMOTE_BREAKPOINT.  If none of these are defined, we
+   just call the standard routines that are in mem-break.c.  */
 
-/* FIXME, these ought to be done in a more dynamic fashion.  For instance,
-   the choice of breakpoint instruction affects target program design and
-   vice versa, and by making it user-tweakable, the special code here
-   goes away and we need fewer special GDB configurations.  */
+/* NOTE: cagney/2003-06-08: This is silly.  A remote and simulator
+   target should use an identical BREAKPOINT_FROM_PC.  As for native,
+   the ARCH-OS-tdep.c code can override the default.  */
 
-#if defined (LITTLE_REMOTE_BREAKPOINT) && defined (BIG_REMOTE_BREAKPOINT) && !defined(REMOTE_BREAKPOINT)
-#define REMOTE_BREAKPOINT
+#if defined (DEPRECATED_LITTLE_REMOTE_BREAKPOINT) && defined (DEPRECATED_BIG_REMOTE_BREAKPOINT) && !defined(DEPRECATED_REMOTE_BREAKPOINT)
+#define DEPRECATED_REMOTE_BREAKPOINT
 #endif
 
-#ifdef REMOTE_BREAKPOINT
+#ifdef DEPRECATED_REMOTE_BREAKPOINT
 
 /* If the target isn't bi-endian, just pretend it is.  */
-#if !defined (LITTLE_REMOTE_BREAKPOINT) && !defined (BIG_REMOTE_BREAKPOINT)
-#define LITTLE_REMOTE_BREAKPOINT REMOTE_BREAKPOINT
-#define BIG_REMOTE_BREAKPOINT REMOTE_BREAKPOINT
+#if !defined (DEPRECATED_LITTLE_REMOTE_BREAKPOINT) && !defined (DEPRECATED_BIG_REMOTE_BREAKPOINT)
+#define DEPRECATED_LITTLE_REMOTE_BREAKPOINT DEPRECATED_REMOTE_BREAKPOINT
+#define DEPRECATED_BIG_REMOTE_BREAKPOINT DEPRECATED_REMOTE_BREAKPOINT
 #endif
 
-static unsigned char big_break_insn[] = BIG_REMOTE_BREAKPOINT;
-static unsigned char little_break_insn[] = LITTLE_REMOTE_BREAKPOINT;
+static unsigned char big_break_insn[] = DEPRECATED_BIG_REMOTE_BREAKPOINT;
+static unsigned char little_break_insn[] = DEPRECATED_LITTLE_REMOTE_BREAKPOINT;
 
-#endif /* REMOTE_BREAKPOINT */
+#endif /* DEPRECATED_REMOTE_BREAKPOINT */
 
-/* Insert a breakpoint on targets that don't have any better breakpoint
-   support.  We read the contents of the target location and stash it,
-   then overwrite it with a breakpoint instruction.  ADDR is the target
-   location in the target machine.  CONTENTS_CACHE is a pointer to 
-   memory allocated for saving the target contents.  It is guaranteed
-   by the caller to be long enough to save sizeof BREAKPOINT bytes (this
-   is accomplished via BREAKPOINT_MAX).  */
+/* Insert a breakpoint on targets that don't have any better
+   breakpoint support.  We read the contents of the target location
+   and stash it, then overwrite it with a breakpoint instruction.
+   ADDR is the target location in the target machine.  CONTENTS_CACHE
+   is a pointer to memory allocated for saving the target contents.
+   It is guaranteed by the caller to be long enough to save the number
+   of bytes returned by BREAKPOINT_FROM_PC.  */
 
 static int
 remote_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
 {
   struct remote_state *rs = get_remote_state ();
-#ifdef REMOTE_BREAKPOINT
+#ifdef DEPRECATED_REMOTE_BREAKPOINT
   int val;
 #endif  
   int bp_size;
@@ -4701,7 +4714,7 @@ remote_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
        }
     }
 
-#ifdef REMOTE_BREAKPOINT  
+#ifdef DEPRECATED_REMOTE_BREAKPOINT  
   val = target_read_memory (addr, contents_cache, sizeof big_break_insn);
 
   if (val == 0)
@@ -4717,7 +4730,7 @@ remote_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
   return val;
 #else
   return memory_insert_breakpoint (addr, contents_cache);
-#endif /* REMOTE_BREAKPOINT */
+#endif /* DEPRECATED_REMOTE_BREAKPOINT */
 }
 
 static int
@@ -4746,11 +4759,11 @@ remote_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
       return (buf[0] == 'E');
     }
 
-#ifdef REMOTE_BREAKPOINT
+#ifdef DEPRECATED_REMOTE_BREAKPOINT
   return target_write_memory (addr, contents_cache, sizeof big_break_insn);
 #else
   return memory_remove_breakpoint (addr, contents_cache);
-#endif /* REMOTE_BREAKPOINT */
+#endif /* DEPRECATED_REMOTE_BREAKPOINT */
 }
 
 static int
@@ -4845,7 +4858,7 @@ remote_remove_watchpoint (CORE_ADDR addr, int len, int type)
 int remote_hw_watchpoint_limit = -1;
 int remote_hw_breakpoint_limit = -1;
 
-int
+static int
 remote_check_watch_resources (int type, int cnt, int ot)
 {
   if (type == bp_hardware_breakpoint)
@@ -4871,13 +4884,13 @@ remote_check_watch_resources (int type, int cnt, int ot)
   return -1;
 }
 
-int
+static int
 remote_stopped_by_watchpoint (void)
 {
     return remote_stopped_by_watchpoint_p;
 }
 
-CORE_ADDR
+static CORE_ADDR
 remote_stopped_data_address (void)
 {
   if (remote_stopped_by_watchpoint ())
@@ -6267,4 +6280,7 @@ Set use of remote protocol `Z' packets",
                                set_remote_protocol_Z_packet_cmd,
                                show_remote_protocol_Z_packet_cmd,
                                &remote_set_cmdlist, &remote_show_cmdlist);
+
+  /* Eventually initialize fileio.  See fileio.c */
+  initialize_remote_fileio (remote_set_cmdlist, remote_show_cmdlist);
 }
This page took 0.03286 seconds and 4 git commands to generate.