aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote.c
diff options
context:
space:
mode:
authorStu Grossman <grossman@cygnus>1994-03-21 19:57:38 +0000
committerStu Grossman <grossman@cygnus>1994-03-21 19:57:38 +0000
commit72bba93b85e2e8c887df447c4237d0e7c21d07d8 (patch)
tree9f5fb008f8a97b4b4acd26c64fd1802442d63b36 /gdb/remote.c
parent4fd5eed484d95b5a5647a0bba76533ba66cb57a3 (diff)
downloadgdb-72bba93b85e2e8c887df447c4237d0e7c21d07d8.zip
gdb-72bba93b85e2e8c887df447c4237d0e7c21d07d8.tar.gz
gdb-72bba93b85e2e8c887df447c4237d0e7c21d07d8.tar.bz2
Mon Mar 21 11:02:51 1994 Stu Grossman (grossman at cygnus.com)
* alpha-tdep.c: Gobs of changes (many imported from mips-tdep) to improve remote debugging efficiency. Also fixed problems with doing function calls for programs with no entry points. * infcmd.c (run_stack_dummy): Use CALL_DUMMY_ADDRESS instead of entry_point_address. * inferior.h (PC_IN_CALL_DUMMY): ditto. * mdebugread.c (parse_symbol, parse_procedure, parse_external, parse_lines): Pass section_offsets info to these routines so that we can relocate symbol table entries upon readin. * (psymtab_to_symtab_1): Set symtab->primary to tell objfile_relocate to do relocations for our symbols. * (ecoff_relocate_efi): New routine to relocate adr field of PDRs (which hang off of the symbol table). * Use prim_record_minimal_symbols_and_info instead of prim_record_minimal_symbols to supply section info to make minimal symbol relocations work. * minsyms.c (prim_record_minimal_symbols_and_info): If section is -1, try to deduce it from ms_type. * objfiles.c (objfile_relocate): Use ALL_OBJFILE_SYMTABS where appropriate. Handle relocation of MIPS_EFI symbols special. Also, add code to relocate objfile->sections data structure. * remote.c (get_offsets): Use new protocol message to acquire section offsets from the target. * (remote_wait): Get rid of relocation stuff. That's all handled by objfile_relocate now. * config/alpha/alpha-nw.mt (TM_FILE): Use tm-alphanw.h. * config/alpha/tm-alpha.h: Define CALL_DUMMY_ADDRESS, and VM_MIN_ADDRESS. * config/alpha/tm-alphanw.h: DECR_PC_AFTER_BREAK=0, VM_MIN_ADDRESS=0.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r--gdb/remote.c166
1 files changed, 66 insertions, 100 deletions
diff --git a/gdb/remote.c b/gdb/remote.c
index 7240f0b..d969e11 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -90,22 +90,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
AA = signal number
n... = register number
r... = register contents
- or... WAA The process extited, and AA is
+ or... WAA The process exited, and AA is
the exit status. This is only
applicable for certains sorts of
targets.
- or... NAATT;DD;BB Relocate the object file.
- AA = signal number
- TT = text address
- DD = data address
- BB = bss address
- This is used by the NLM stub,
- which is why it only has three
- addresses rather than one per
- section: the NLM stub always
- sees only three sections, even
- though gdb may see more.
-
kill request k
toggle debug d toggle debug flag (see 386 & 68k stubs)
@@ -116,17 +104,33 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
we can extend the protocol and GDB
can tell whether the stub it is
talking to uses the old or the new.
+<<<<<<< remote.c
+ search tAA:PP,MM Search backwards starting at address
+||||||| 1.81
+ search tAA:PP,MM Search backword starting at address
+=======
search tAA:PP,MM Search backward starting at address
+>>>>>>> 1.82
AA for a match with pattern PP and
mask MM. PP and MM are 4 bytes.
Not supported by all stubs.
+<<<<<<< remote.c
+ general query qXXXX Request info about XXXX.
+ general set QXXXX=yyyy Set value of XXXX to yyyy.
+ query sect offs qOffsets Get section offsets. Reply is
+ Text=xxx;Data=yyy;Bss=zzz
+*/
+
+||||||| 1.81
+=======
Responses can be run-length encoded to save space. A '*' means that
the next two characters are hex digits giving a repeat count which
stands for that many repititions of the character preceding the '*'.
Note that this means that responses cannot contain '*'. Example:
"0*03" means the same as "0000". */
+>>>>>>> 1.82
#include "defs.h"
#include <string.h>
#include <fcntl.h>
@@ -265,6 +269,49 @@ remote_close (quitting)
remote_desc = NULL;
}
+/* Query the remote side for the text, data and bss offsets. */
+
+static void
+get_offsets ()
+{
+ unsigned char buf [PBUFSIZ];
+ int nvals;
+ CORE_ADDR text_addr, data_addr, bss_addr;
+ struct section_offsets *offs;
+
+ putpkt ("qOffsets");
+
+ getpkt (buf, 1);
+
+ if (buf[0] == 'E')
+ {
+ warning ("Remote failure reply: %s", buf);
+ return;
+ }
+
+ nvals = sscanf (buf, "Text=%lx;Data=%lx;Bss=%lx", &text_addr, &data_addr,
+ &bss_addr);
+ if (nvals != 3)
+ error ("Malformed response to offset query, %s", buf);
+
+ if (symfile_objfile == NULL)
+ return;
+
+ offs = (struct section_offsets *) alloca (sizeof (struct section_offsets)
+ + symfile_objfile->num_sections
+ * sizeof (offs->offsets));
+ memcpy (offs, symfile_objfile->section_offsets,
+ sizeof (struct section_offsets)
+ + symfile_objfile->num_sections
+ * sizeof (offs->offsets));
+
+ ANOFFSET (offs, SECT_OFF_TEXT) = text_addr;
+ ANOFFSET (offs, SECT_OFF_DATA) = data_addr;
+ ANOFFSET (offs, SECT_OFF_BSS) = bss_addr;
+
+ objfile_relocate (symfile_objfile, offs);
+}
+
/* Stub for catch_errors. */
static int
@@ -274,13 +321,16 @@ remote_start_remote (dummy)
immediate_quit = 1; /* Allow user to interrupt it */
/* Ack any packet which the remote side has already sent. */
- /* I'm not sure this \r is needed; we don't use it any other time we
- send an ack. */
- SERIAL_WRITE (remote_desc, "+\r", 2);
+
+ SERIAL_WRITE (remote_desc, "+", 1);
+
+ get_offsets (); /* Get text, data & bss offsets */
+
putpkt ("?"); /* initiate a query from remote machine */
immediate_quit = 0;
start_remote (); /* Initialize gdb process mechanisms */
+
return 1;
}
@@ -536,90 +586,6 @@ remote_wait (pid, status)
}
break;
}
- else if (buf[0] == 'N')
- {
- unsigned char *p1;
- bfd_vma text_addr, data_addr, bss_addr;
-
- /* Relocate object file. Format is NAATT;DD;BB where AA is
- the signal number, TT is the new text address, DD is the
- new data address, and BB is the new bss address. This is
- used by the NLM stub; gdb may see more sections. */
- p = &buf[3];
- text_addr = strtoul (p, &p1, 16);
- if (p1 == p || *p1 != ';')
- warning ("Malformed relocation packet: Packet '%s'", buf);
- p = p1 + 1;
- data_addr = strtoul (p, &p1, 16);
- if (p1 == p || *p1 != ';')
- warning ("Malformed relocation packet: Packet '%s'", buf);
- p = p1 + 1;
- bss_addr = strtoul (p, &p1, 16);
- if (p1 == p)
- warning ("Malformed relocation packet: Packet '%s'", buf);
-
- if (symfile_objfile != NULL
- && (ANOFFSET (symfile_objfile->section_offsets,
- SECT_OFF_TEXT) != text_addr
- || ANOFFSET (symfile_objfile->section_offsets,
- SECT_OFF_DATA) != data_addr
- || ANOFFSET (symfile_objfile->section_offsets,
- SECT_OFF_BSS) != bss_addr))
- {
- struct section_offsets *offs;
-
- /* FIXME: This code assumes gdb-stabs.h is being used;
- it's broken for xcoff, dwarf, sdb-coff, etc. But
- there is no simple canonical representation for this
- stuff. (Just what does "text" as seen by the stub
- mean, anyway?). */
-
- offs = ((struct section_offsets *)
- alloca (sizeof (struct section_offsets)
- + (symfile_objfile->num_sections
- * sizeof (offs->offsets))));
- memcpy (offs, symfile_objfile->section_offsets,
- (sizeof (struct section_offsets)
- + (symfile_objfile->num_sections
- * sizeof (offs->offsets))));
- ANOFFSET (offs, SECT_OFF_TEXT) = text_addr;
- ANOFFSET (offs, SECT_OFF_DATA) = data_addr;
- ANOFFSET (offs, SECT_OFF_BSS) = bss_addr;
-
- objfile_relocate (symfile_objfile, offs);
- {
- struct obj_section *s;
- bfd *abfd;
-
- abfd = symfile_objfile->obfd;
-
- for (s = symfile_objfile->sections;
- s < symfile_objfile->sections_end; ++s)
- {
- flagword flags;
-
- flags = bfd_get_section_flags (abfd, s->the_bfd_section);
-
- if (flags & SEC_CODE)
- {
- s->addr += text_addr;
- s->endaddr += text_addr;
- }
- else if (flags & (SEC_DATA | SEC_LOAD))
- {
- s->addr += data_addr;
- s->endaddr += data_addr;
- }
- else if (flags & SEC_ALLOC)
- {
- s->addr += bss_addr;
- s->endaddr += bss_addr;
- }
- }
- }
- }
- break;
- }
else if (buf[0] == 'W')
{
/* The remote process exited. */