aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Schauer <Peter.Schauer@mytum.de>1997-08-15 21:10:32 +0000
committerPeter Schauer <Peter.Schauer@mytum.de>1997-08-15 21:10:32 +0000
commit05d52ace86cc898264acb8f23a97e22cb199ed36 (patch)
treee0051a3c2ad0d9ef0f486531f446b7b58a56774a
parentbe3d1b6f9e44f02435baac46febfe810a724b6d9 (diff)
downloadgdb-05d52ace86cc898264acb8f23a97e22cb199ed36.zip
gdb-05d52ace86cc898264acb8f23a97e22cb199ed36.tar.gz
gdb-05d52ace86cc898264acb8f23a97e22cb199ed36.tar.bz2
* infrun.c (wait_for_inferior): Add the symbols for any
newly loaded objects upon a TARGET_WAITKIND_LOADED event. Rewrite code which determines the TOC address for calling functions in the inferior under AIX. * rs6000-nat.c (find_toc_address): New function to determine the required TOC address from a function address. (_initialize_core_rs6000): Set up find_toc_address_hook to point to find_toc_address. (xcoff_relocate_symtab, xcoff_relocate_core): Remove add_text_to_loadinfo calls. (exec_one_dummy_insn): Change pid and status to int to get rid of compiler warnings. (xcoff_relocate_symtab): Cast ldi to `int *' when passing it to ptrace to get rid of compiler warnings. * rs6000-tdep.c: Add definition for find_toc_address_hook. (rs6000_fix_call_dummy): If find_toc_address_hook is non zero, patch TOC address load code in the call dummy with the value returned from find_toc_address_hook. (struct loadinfo, loadinfo, loadinfolen, loadinfotextindex, xcoff_init_loadinfo, free_loadinfo, xcoff_add_toc_to_loadinfo, add_text_to_loadinfo, find_toc_address): Remove. (_initialize_rs6000_tdep): Remove initialization of coff_add_toc_to_loadinfo_hook and xcoff_init_loadinfo_hook. * xcoffread.c (coff_add_toc_to_loadinfo_hook, xcoff_init_loadinfo_hook): Remove. (struct coff_symfile_info): Add toc_offset field. (scan_xcoff_symtab): Record toc_offset value in toc_offset field instead of calling xcoff_add_toc_to_loadinfo_hook. (get_toc_offset): New function to return the value of the toc_offset field for an object file. (xcoff_initial_scan): Remove call of xcoff_init_loadinfo_hook. * xcoffsolib.h (add_text_to_loadinfo): Remove declaration. * config/rs6000/tm-rs6000.h: Add declarations for find_toc_address_hook and get_toc_offset.
-rw-r--r--gdb/ChangeLog46
-rw-r--r--gdb/rs6000-nat.c50
-rw-r--r--gdb/rs6000-tdep.c146
-rw-r--r--gdb/xcoffread.c34
-rw-r--r--gdb/xcoffsolib.h3
5 files changed, 109 insertions, 170 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ed6635d..ce9084d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,49 @@
+Fri Aug 15 13:59:37 1997 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
+
+ * infrun.c (wait_for_inferior): Add the symbols for any
+ newly loaded objects upon a TARGET_WAITKIND_LOADED event.
+
+ Rewrite code which determines the TOC address for calling functions
+ in the inferior under AIX.
+ * rs6000-nat.c (find_toc_address): New function to determine
+ the required TOC address from a function address.
+ (_initialize_core_rs6000): Set up find_toc_address_hook to point
+ to find_toc_address.
+ (xcoff_relocate_symtab, xcoff_relocate_core): Remove
+ add_text_to_loadinfo calls.
+ (exec_one_dummy_insn): Change pid and status to int to get rid of
+ compiler warnings.
+ (xcoff_relocate_symtab): Cast ldi to `int *' when passing it to
+ ptrace to get rid of compiler warnings.
+ * rs6000-tdep.c: Add definition for find_toc_address_hook.
+ (rs6000_fix_call_dummy): If find_toc_address_hook is non zero,
+ patch TOC address load code in the call dummy with the value
+ returned from find_toc_address_hook.
+ (struct loadinfo, loadinfo, loadinfolen,
+ loadinfotextindex, xcoff_init_loadinfo, free_loadinfo,
+ xcoff_add_toc_to_loadinfo, add_text_to_loadinfo, find_toc_address):
+ Remove.
+ (_initialize_rs6000_tdep): Remove initialization of
+ coff_add_toc_to_loadinfo_hook and xcoff_init_loadinfo_hook.
+ * xcoffread.c (coff_add_toc_to_loadinfo_hook,
+ xcoff_init_loadinfo_hook): Remove.
+ (struct coff_symfile_info): Add toc_offset field.
+ (scan_xcoff_symtab): Record toc_offset value in toc_offset field
+ instead of calling xcoff_add_toc_to_loadinfo_hook.
+ (get_toc_offset): New function to return the value of the
+ toc_offset field for an object file.
+ (xcoff_initial_scan): Remove call of xcoff_init_loadinfo_hook.
+ * xcoffsolib.h (add_text_to_loadinfo): Remove declaration.
+ * config/rs6000/tm-rs6000.h: Add declarations for
+ find_toc_address_hook and get_toc_offset.
+
+Wed Aug 13 19:31:28 1997 Stan Shebs <shebs@andros.cygnus.com>
+
+ * remote-sds.c: New file, interface to SDS-compatible monitors.
+ * Makefile.in (remote-sds.o): Add build rule.
+ * config/powerpc/ppc-eabi.mt, config/powerpc/ppc-sim.mt
+ (TDEPFILES): Add remote-sds.o.
+
Tue Aug 12 14:37:18 1997 Geoffrey Noer <noer@cygnus.com>
* ocd.c (ocd_wait): loop until we're in BDM mode instead of
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index 7311055..b57054f 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -73,9 +73,6 @@ static void
exec_one_dummy_insn PARAMS ((void));
extern void
-add_text_to_loadinfo PARAMS ((CORE_ADDR textaddr, CORE_ADDR dataaddr));
-
-extern void
fixup_breakpoints PARAMS ((CORE_ADDR low, CORE_ADDR high, CORE_ADDR delta));
/* Conversion from gdb-to-system special purpose register numbers.. */
@@ -248,7 +245,7 @@ exec_one_dummy_insn ()
#define DUMMY_INSN_ADDR (TEXT_SEGMENT_BASE)+0x200
char shadow_contents[BREAKPOINT_MAX]; /* Stash old bkpt addr contents */
- unsigned int status, pid;
+ int status, pid;
CORE_ADDR prev_pc;
/* We plant one dummy breakpoint into DUMMY_INSN_ADDR address. We assume that
@@ -623,25 +620,12 @@ xcoff_relocate_symtab (pid)
errno = 0;
ptrace (PT_LDINFO, pid, (PTRACE_ARG3_TYPE) ldi,
- MAX_LOAD_SEGS * sizeof(*ldi), ldi);
+ MAX_LOAD_SEGS * sizeof(*ldi), (int *) ldi);
if (errno)
perror_with_name ("ptrace ldinfo");
vmap_ldinfo (ldi);
- do {
- /* We are allowed to assume CORE_ADDR == pointer. This code is
- native only. */
- add_text_to_loadinfo ((CORE_ADDR) ldi->ldinfo_textorg,
- (CORE_ADDR) ldi->ldinfo_dataorg);
- } while (ldi->ldinfo_next
- && (ldi = (void *) (ldi->ldinfo_next + (char *) ldi)));
-
-#if 0
- /* Now that we've jumbled things around, re-sort them. */
- sort_minimal_symbols ();
-#endif
-
/* relocate the exec and core sections as well. */
vmap_exec ();
}
@@ -780,9 +764,6 @@ xcoff_relocate_core (target)
}
vmap_symtab (vp);
-
- add_text_to_loadinfo ((CORE_ADDR)ldip->ldinfo_textorg,
- (CORE_ADDR)ldip->ldinfo_dataorg);
} while (ldip->ldinfo_next != 0);
vmap_exec ();
breakpoint_re_set ();
@@ -794,7 +775,30 @@ kernel_u_size ()
{
return (sizeof (struct user));
}
+
+/* Under AIX, we have to pass the correct TOC pointer to a function
+ when calling functions in the inferior.
+ We try to find the relative toc offset of the objfile containing PC
+ and add the current load address of the data segment from the vmap. */
+
+static CORE_ADDR
+find_toc_address (pc)
+ CORE_ADDR pc;
+{
+ struct vmap *vp;
+ for (vp = vmap; vp; vp = vp->nxt)
+ {
+ if (pc >= vp->tstart && pc < vp->tend)
+ {
+ /* vp->objfile is only NULL for the exec file. */
+ return vp->dstart + get_toc_offset (vp->objfile == NULL
+ ? symfile_objfile
+ : vp->objfile);
+ }
+ }
+ error ("Unable to find TOC entry for pc 0x%x\n", pc);
+}
/* Register that we are able to handle rs6000 core file formats. */
@@ -808,6 +812,10 @@ static struct core_fns rs6000_core_fns =
void
_initialize_core_rs6000 ()
{
+ /* Initialize hook in rs6000-tdep.c for determining the TOC address when
+ calling functions in the inferior. */
+ find_toc_address_hook = &find_toc_address;
+
/* For native configurations, where this module is included, inform
the xcoffsolib module where it can find the function for symbol table
relocation at runtime. */
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index d4b7659..39d7ff4 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -44,9 +44,13 @@ static struct sstep_breaks {
char data[4];
} stepBreaks[2];
-/* Static function prototypes */
+/* Hook for determining the TOC address when calling functions in the
+ inferior under AIX. The initialization code in rs6000-nat.c sets
+ this hook to point to find_toc_address. */
+
+CORE_ADDR (*find_toc_address_hook) PARAMS ((CORE_ADDR)) = NULL;
-static CORE_ADDR find_toc_address PARAMS ((CORE_ADDR pc));
+/* Static function prototypes */
static CORE_ADDR branch_dest PARAMS ((int opcode, int instr, CORE_ADDR pc,
CORE_ADDR safety));
@@ -651,19 +655,22 @@ rs6000_fix_call_dummy (dummyname, pc, fun, nargs, args, type, gcc_p)
int ii;
CORE_ADDR target_addr;
- CORE_ADDR tocvalue;
- target_addr = fun;
- tocvalue = find_toc_address (target_addr);
+ if (find_toc_address_hook != NULL)
+ {
+ CORE_ADDR tocvalue;
- ii = *(int*)((char*)dummyname + TOC_ADDR_OFFSET);
- ii = (ii & 0xffff0000) | (tocvalue >> 16);
- *(int*)((char*)dummyname + TOC_ADDR_OFFSET) = ii;
+ tocvalue = (*find_toc_address_hook) (fun);
+ ii = *(int*)((char*)dummyname + TOC_ADDR_OFFSET);
+ ii = (ii & 0xffff0000) | (tocvalue >> 16);
+ *(int*)((char*)dummyname + TOC_ADDR_OFFSET) = ii;
- ii = *(int*)((char*)dummyname + TOC_ADDR_OFFSET+4);
- ii = (ii & 0xffff0000) | (tocvalue & 0x0000ffff);
- *(int*)((char*)dummyname + TOC_ADDR_OFFSET+4) = ii;
+ ii = *(int*)((char*)dummyname + TOC_ADDR_OFFSET+4);
+ ii = (ii & 0xffff0000) | (tocvalue & 0x0000ffff);
+ *(int*)((char*)dummyname + TOC_ADDR_OFFSET+4) = ii;
+ }
+ target_addr = fun;
ii = *(int*)((char*)dummyname + TARGET_ADDR_OFFSET);
ii = (ii & 0xffff0000) | (target_addr >> 16);
*(int*)((char*)dummyname + TARGET_ADDR_OFFSET) = ii;
@@ -1163,107 +1170,6 @@ rs6000_frame_chain (thisframe)
return fp;
}
-/* Keep an array of load segment information and their TOC table addresses.
- This info will be useful when calling a shared library function by hand. */
-
-struct loadinfo {
- CORE_ADDR textorg, dataorg;
- unsigned long toc_offset;
-};
-
-#define LOADINFOLEN 10
-
-static struct loadinfo *loadinfo = NULL;
-static int loadinfolen = 0;
-static int loadinfotocindex = 0;
-static int loadinfotextindex = 0;
-
-
-void
-xcoff_init_loadinfo ()
-{
- loadinfotocindex = 0;
- loadinfotextindex = 0;
-
- if (loadinfolen == 0) {
- loadinfo = (struct loadinfo *)
- xmalloc (sizeof (struct loadinfo) * LOADINFOLEN);
- loadinfolen = LOADINFOLEN;
- }
-}
-
-
-/* FIXME -- this is never called! */
-#if 0
-void
-free_loadinfo ()
-{
- if (loadinfo)
- free (loadinfo);
- loadinfo = NULL;
- loadinfolen = 0;
- loadinfotocindex = 0;
- loadinfotextindex = 0;
-}
-#endif
-
-/* this is called from xcoffread.c */
-
-void
-xcoff_add_toc_to_loadinfo (tocoff)
- unsigned long tocoff;
-{
- while (loadinfotocindex >= loadinfolen) {
- loadinfolen += LOADINFOLEN;
- loadinfo = (struct loadinfo *)
- xrealloc (loadinfo, sizeof(struct loadinfo) * loadinfolen);
- }
- loadinfo [loadinfotocindex++].toc_offset = tocoff;
-}
-
-void
-add_text_to_loadinfo (textaddr, dataaddr)
- CORE_ADDR textaddr;
- CORE_ADDR dataaddr;
-{
- while (loadinfotextindex >= loadinfolen) {
- loadinfolen += LOADINFOLEN;
- loadinfo = (struct loadinfo *)
- xrealloc (loadinfo, sizeof(struct loadinfo) * loadinfolen);
- }
- loadinfo [loadinfotextindex].textorg = textaddr;
- loadinfo [loadinfotextindex].dataorg = dataaddr;
- ++loadinfotextindex;
-}
-
-
-/* Note that this assumes that the "textorg" and "dataorg" elements of
- a member of this array are correlated with the "toc_offset" element
- of the same member. This is taken care of because the loops which
- assign the former (in xcoff_relocate_symtab or xcoff_relocate_core)
- and the latter (in scan_xcoff_symtab, via vmap_symtab, in
- vmap_ldinfo or xcoff_relocate_core) traverse the same objfiles in
- the same order. */
-
-static CORE_ADDR
-find_toc_address (pc)
- CORE_ADDR pc;
-{
- int ii, toc_entry;
- CORE_ADDR tocbase = 0;
-
- toc_entry = -1;
- for (ii=0; ii < loadinfotextindex; ++ii)
- if (pc > loadinfo[ii].textorg && loadinfo[ii].textorg > tocbase) {
- toc_entry = ii;
- tocbase = loadinfo[ii].textorg;
- }
-
- if (toc_entry == -1)
- error ("Unable to find TOC entry for pc 0x%x\n", pc);
- return loadinfo[toc_entry].dataorg + loadinfo[toc_entry].toc_offset;
-}
-
/* Return nonzero if ADDR (a function pointer) is in the data space and
is therefore a special function pointer. */
@@ -1296,22 +1202,6 @@ gdb_print_insn_powerpc (memaddr, info)
void
_initialize_rs6000_tdep ()
{
-#ifndef ELF_OBJECT_FORMAT
- {
- extern void (*xcoff_add_toc_to_loadinfo_hook) PARAMS ((unsigned long));
- extern void (*xcoff_init_loadinfo_hook) PARAMS ((void));
-
- /* Initialize hook in xcoffread for recording the toc offset value
- of a symbol table into the ldinfo structure, for native rs6000
- config. */
- xcoff_add_toc_to_loadinfo_hook = &xcoff_add_toc_to_loadinfo;
-
- /* Initialize hook in xcoffread for calling xcoff_init_loadinfo in
- a native rs6000 config. */
- xcoff_init_loadinfo_hook = &xcoff_init_loadinfo;
- }
-#endif /* ELF_OBJECT_FORMAT */
-
/* FIXME, this should not be decided via ifdef. */
#ifdef GDB_TARGET_POWERPC
tm_print_insn = gdb_print_insn_powerpc;
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 9200147..956f576 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -88,17 +88,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* This is output from LD. */
#define N_SETV 0x1C /* Pointer to set vector in data area. */
-
-/* Hook for recording the toc offset value of a symbol table into
- the ldinfo structure. */
-
-void (*xcoff_add_toc_to_loadinfo_hook) PARAMS ((unsigned long)) = NULL;
-
-/* Hook for recording how to call xcoff_init_loadinfo for a native
- rs6000 config only. */
-
-void (*xcoff_init_loadinfo_hook) PARAMS ((void)) = NULL;
-
/* We put a pointer to this structure in the read_symtab_private field
of the psymtab. */
@@ -185,6 +174,9 @@ struct coff_symfile_info {
/* Number of symbols in symtbl. */
int symtbl_num_syms;
+
+ /* Offset in data section to TOC anchor. */
+ CORE_ADDR toc_offset;
};
static struct complaint storclass_complaint =
@@ -2628,12 +2620,22 @@ scan_xcoff_symtab (section_offsets, objfile)
dependencies_used, textlow_not_set);
}
- /* Record the toc offset value of this symbol table into ldinfo structure.
+ /* Record the toc offset value of this symbol table into objfile structure.
If no XMC_TC0 is found, toc_offset should be zero. Another place to obtain
this information would be file auxiliary header. */
- if (xcoff_add_toc_to_loadinfo_hook != NULL)
- (*xcoff_add_toc_to_loadinfo_hook) ((unsigned long) toc_offset);
+ ((struct coff_symfile_info *) objfile->sym_private)->toc_offset = toc_offset;
+}
+
+/* Return the toc offset value for a given objfile. */
+
+CORE_ADDR
+get_toc_offset (objfile)
+ struct objfile *objfile;
+{
+ if (objfile)
+ return ((struct coff_symfile_info *) objfile->sym_private)->toc_offset;
+ return 0;
}
/* Scan and build partial symbols for a symbol file.
@@ -2662,10 +2664,6 @@ xcoff_initial_scan (objfile, section_offsets, mainline)
char *name;
unsigned int size;
- /* Initialize load info structure. */
- if (mainline && xcoff_init_loadinfo_hook != NULL)
- (*xcoff_init_loadinfo_hook) ();
-
info = (struct coff_symfile_info *) objfile -> sym_private;
symfile_bfd = abfd = objfile->obfd;
name = objfile->name;
diff --git a/gdb/xcoffsolib.h b/gdb/xcoffsolib.h
index 6ef98cb..77d691b 100644
--- a/gdb/xcoffsolib.h
+++ b/gdb/xcoffsolib.h
@@ -53,9 +53,6 @@ struct vmap_and_bfd {
extern struct vmap *vmap;
-extern void
-add_text_to_loadinfo PARAMS ((CORE_ADDR textaddr, CORE_ADDR dataaddr));
-
/* Hook for symbol table relocation at runtime. */
extern void (*xcoff_relocate_symtab_hook) PARAMS ((unsigned int));