diff options
Diffstat (limited to 'gdb/remote.c')
-rw-r--r-- | gdb/remote.c | 99 |
1 files changed, 57 insertions, 42 deletions
diff --git a/gdb/remote.c b/gdb/remote.c index 40be8e6badc..d5a5cf66c72 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -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 = DEPRECATED_REGISTER_BYTES; /* OK */ + 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,6 +2951,9 @@ 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; @@ -3196,6 +3205,9 @@ 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; @@ -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; @@ -4625,33 +4637,33 @@ extended_remote_async_create_inferior (char *exec_file, char *args, char **env) /* 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_FROM_PC. 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. */ - -/* 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. */ - -#if defined (LITTLE_REMOTE_BREAKPOINT) && defined (BIG_REMOTE_BREAKPOINT) && !defined(REMOTE_BREAKPOINT) -#define REMOTE_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. */ + +/* 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 (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 @@ -4665,7 +4677,7 @@ 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; @@ -4702,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) @@ -4718,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 @@ -4747,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 @@ -4846,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) @@ -4872,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 ()) @@ -6268,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); } |