- pid = wait (&status);
- }
- while (pid != PIDGET (inferior_ptid));
-
- write_pc (prev_pc);
- target_remove_breakpoint (DUMMY_INSN_ADDR, shadow_contents);
-}
-
-/* Fetch registers from the register section in core bfd. */
-
-static void
-fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
- int which, CORE_ADDR reg_addr)
-{
- CoreRegs *regs;
- int regi;
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
-
- if (which != 0)
- {
- fprintf_unfiltered
- (gdb_stderr,
- "Gdb error: unknown parameter to fetch_core_registers().\n");
- return;
- }
-
- regs = (CoreRegs *) core_reg_sect;
-
- /* Put the register values from the core file section in the regcache. */
-
- if (ARCH64 ())
- {
- for (regi = 0; regi < ppc_num_gprs; regi++)
- supply_register (tdep->ppc_gp0_regnum + regi,
- (char *) ®s->r64.gpr[regi]);
-
- if (tdep->ppc_fp0_regnum >= 0)
- for (regi = 0; regi < ppc_num_fprs; regi++)
- supply_register (tdep->ppc_fp0_regnum + regi,
- (char *) ®s->r64.fpr[regi]);
-
- supply_register (PC_REGNUM, (char *) ®s->r64.iar);
- supply_register (tdep->ppc_ps_regnum, (char *) ®s->r64.msr);
- supply_register (tdep->ppc_cr_regnum, (char *) ®s->r64.cr);
- supply_register (tdep->ppc_lr_regnum, (char *) ®s->r64.lr);
- supply_register (tdep->ppc_ctr_regnum, (char *) ®s->r64.ctr);
- supply_register (tdep->ppc_xer_regnum, (char *) ®s->r64.xer);
- if (tdep->ppc_fpscr_regnum >= 0)
- supply_register (tdep->ppc_fpscr_regnum, (char *) ®s->r64.fpscr);
- }
- else
- {
- for (regi = 0; regi < ppc_num_gprs; regi++)
- supply_register (tdep->ppc_gp0_regnum + regi,
- (char *) ®s->r32.gpr[regi]);
-
- if (tdep->ppc_fp0_regnum >= 0)
- for (regi = 0; regi < ppc_num_fprs; regi++)
- supply_register (tdep->ppc_fp0_regnum + regi,
- (char *) ®s->r32.fpr[regi]);
-
- supply_register (PC_REGNUM, (char *) ®s->r32.iar);
- supply_register (tdep->ppc_ps_regnum, (char *) ®s->r32.msr);
- supply_register (tdep->ppc_cr_regnum, (char *) ®s->r32.cr);
- supply_register (tdep->ppc_lr_regnum, (char *) ®s->r32.lr);
- supply_register (tdep->ppc_ctr_regnum, (char *) ®s->r32.ctr);
- supply_register (tdep->ppc_xer_regnum, (char *) ®s->r32.xer);
- if (tdep->ppc_fpscr_regnum >= 0)
- supply_register (tdep->ppc_fpscr_regnum, (char *) ®s->r32.fpscr);
- if (tdep->ppc_mq_regnum >= 0)
- supply_register (tdep->ppc_mq_regnum, (char *) ®s->r32.mq);
- }
-}
-\f
-
-/* Copy information about text and data sections from LDI to VP for a 64-bit
- process if ARCH64 and for a 32-bit process otherwise. */
-
-static void
-vmap_secs (struct vmap *vp, LdInfo *ldi, int arch64)
-{
- if (arch64)
- {
- vp->tstart = (CORE_ADDR) ldi->l64.ldinfo_textorg;
- vp->tend = vp->tstart + ldi->l64.ldinfo_textsize;
- vp->dstart = (CORE_ADDR) ldi->l64.ldinfo_dataorg;
- vp->dend = vp->dstart + ldi->l64.ldinfo_datasize;
- }
- else
- {
- vp->tstart = (unsigned long) ldi->l32.ldinfo_textorg;
- vp->tend = vp->tstart + ldi->l32.ldinfo_textsize;
- vp->dstart = (unsigned long) ldi->l32.ldinfo_dataorg;
- vp->dend = vp->dstart + ldi->l32.ldinfo_datasize;
- }
-
- /* The run time loader maps the file header in addition to the text
- section and returns a pointer to the header in ldinfo_textorg.
- Adjust the text start address to point to the real start address
- of the text section. */
- vp->tstart += vp->toffs;
-}
-
-/* handle symbol translation on vmapping */
-
-static void
-vmap_symtab (struct vmap *vp)
-{
- struct objfile *objfile;
- struct section_offsets *new_offsets;
- int i;
-
- objfile = vp->objfile;
- if (objfile == NULL)
- {
- /* OK, it's not an objfile we opened ourselves.
- Currently, that can only happen with the exec file, so
- relocate the symbols for the symfile. */
- if (symfile_objfile == NULL)
- return;
- objfile = symfile_objfile;
- }
- else if (!vp->loaded)
- /* If symbols are not yet loaded, offsets are not yet valid. */
- return;
-
- new_offsets =
- (struct section_offsets *)
- alloca (SIZEOF_N_SECTION_OFFSETS (objfile->num_sections));
-
- for (i = 0; i < objfile->num_sections; ++i)
- new_offsets->offsets[i] = ANOFFSET (objfile->section_offsets, i);
-
- /* The symbols in the object file are linked to the VMA of the section,
- relocate them VMA relative. */
- new_offsets->offsets[SECT_OFF_TEXT (objfile)] = vp->tstart - vp->tvma;
- new_offsets->offsets[SECT_OFF_DATA (objfile)] = vp->dstart - vp->dvma;
- new_offsets->offsets[SECT_OFF_BSS (objfile)] = vp->dstart - vp->dvma;
-
- objfile_relocate (objfile, new_offsets);
-}
-\f
-/* Add symbols for an objfile. */
-
-static int
-objfile_symbol_add (void *arg)
-{
- struct objfile *obj = (struct objfile *) arg;
-
- syms_from_objfile (obj, NULL, 0, 0, 0, 0);
- new_symfile_objfile (obj, 0, 0);
- return 1;
-}
-
-/* Add symbols for a vmap. Return zero upon error. */
-
-int
-vmap_add_symbols (struct vmap *vp)
-{
- if (catch_errors (objfile_symbol_add, vp->objfile,
- "Error while reading shared library symbols:\n",
- RETURN_MASK_ALL))
- {
- /* Note this is only done if symbol reading was successful. */
- vp->loaded = 1;
- vmap_symtab (vp);
- return 1;
- }
- return 0;
-}
-
-/* Add a new vmap entry based on ldinfo() information.
-
- If ldi->ldinfo_fd is not valid (e.g. this struct ld_info is from a
- core file), the caller should set it to -1, and we will open the file.
-
- Return the vmap new entry. */
-
-static struct vmap *
-add_vmap (LdInfo *ldi)
-{
- bfd *abfd, *last;
- char *mem, *objname, *filename;
- struct objfile *obj;
- struct vmap *vp;
- int fd;
- ARCH64_DECL (arch64);
-
- /* This ldi structure was allocated using alloca() in
- xcoff_relocate_symtab(). Now we need to have persistent object
- and member names, so we should save them. */
-
- filename = LDI_FILENAME (ldi, arch64);
- mem = filename + strlen (filename) + 1;
- mem = savestring (mem, strlen (mem));
- objname = savestring (filename, strlen (filename));
-
- fd = LDI_FD (ldi, arch64);
- if (fd < 0)
- /* Note that this opens it once for every member; a possible
- enhancement would be to only open it once for every object. */
- abfd = bfd_openr (objname, gnutarget);
- else
- abfd = bfd_fdopenr (objname, gnutarget, fd);
- if (!abfd)
- {
- warning ("Could not open `%s' as an executable file: %s",
- objname, bfd_errmsg (bfd_get_error ()));
- return NULL;
- }
-
- /* make sure we have an object file */
-
- if (bfd_check_format (abfd, bfd_object))
- vp = map_vmap (abfd, 0);
-
- else if (bfd_check_format (abfd, bfd_archive))
- {
- last = 0;
- /* FIXME??? am I tossing BFDs? bfd? */
- while ((last = bfd_openr_next_archived_file (abfd, last)))
- if (DEPRECATED_STREQ (mem, last->filename))
- break;
-
- if (!last)
- {
- warning ("\"%s\": member \"%s\" missing.", objname, mem);
- bfd_close (abfd);
- return NULL;
- }
-
- if (!bfd_check_format (last, bfd_object))
- {
- warning ("\"%s\": member \"%s\" not in executable format: %s.",
- objname, mem, bfd_errmsg (bfd_get_error ()));
- bfd_close (last);
- bfd_close (abfd);
- return NULL;
- }
-
- vp = map_vmap (last, abfd);
- }
- else
- {
- warning ("\"%s\": not in executable format: %s.",
- objname, bfd_errmsg (bfd_get_error ()));
- bfd_close (abfd);
- return NULL;