- return pid_to_ptid (pid);
-}
-
-/* Execute one dummy breakpoint instruction. This way we give the kernel
- a chance to do some housekeeping and update inferior's internal data,
- including u_area. */
-
-static void
-exec_one_dummy_insn (struct regcache *regcache)
-{
-#define DUMMY_INSN_ADDR AIX_TEXT_SEGMENT_BASE+0x200
-
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
- int ret, status, pid;
- CORE_ADDR prev_pc;
- void *bp;
-
- /* We plant one dummy breakpoint into DUMMY_INSN_ADDR address. We
- assume that this address will never be executed again by the real
- code. */
-
- bp = deprecated_insert_raw_breakpoint (gdbarch, NULL, DUMMY_INSN_ADDR);
-
- /* You might think this could be done with a single ptrace call, and
- you'd be correct for just about every platform I've ever worked
- on. However, rs6000-ibm-aix4.1.3 seems to have screwed this up --
- the inferior never hits the breakpoint (it's also worth noting
- powerpc-ibm-aix4.1.3 works correctly). */
- prev_pc = regcache_read_pc (regcache);
- regcache_write_pc (regcache, DUMMY_INSN_ADDR);
- if (ARCH64 ())
- ret = rs6000_ptrace64 (PT_CONTINUE, PIDGET (inferior_ptid), 1, 0, NULL);
- else
- ret = rs6000_ptrace32 (PT_CONTINUE, PIDGET (inferior_ptid),
- (int *) 1, 0, NULL);
-
- if (ret != 0)
- perror (_("pt_continue"));
-
- do
- {
- pid = waitpid (PIDGET (inferior_ptid), &status, 0);
- }
- while (pid != PIDGET (inferior_ptid));
-
- regcache_write_pc (regcache, prev_pc);
- deprecated_remove_raw_breakpoint (gdbarch, bp);
-}
-\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);
- new_symfile_objfile (obj, 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, *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 = xstrdup (mem);
-
- fd = LDI_FD (ldi, arch64);
- abfd = gdb_bfd_open (filename, gnutarget, fd < 0 ? -1 : fd);
- if (!abfd)
- {
- warning (_("Could not open `%s' as an executable file: %s"),
- filename, 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 = gdb_bfd_openr_next_archived_file (abfd, NULL);
- while (last != NULL)
- {
- bfd *next;
-
- if (strcmp (mem, last->filename) == 0)
- break;
-
- next = gdb_bfd_openr_next_archived_file (abfd, last);
- gdb_bfd_unref (last);
- last = next;
- }
-
- if (!last)
- {
- warning (_("\"%s\": member \"%s\" missing."), filename, mem);
- gdb_bfd_unref (abfd);
- return NULL;
- }
-
- if (!bfd_check_format (last, bfd_object))
- {
- warning (_("\"%s\": member \"%s\" not in executable format: %s."),
- filename, mem, bfd_errmsg (bfd_get_error ()));
- gdb_bfd_unref (last);
- gdb_bfd_unref (abfd);
- return NULL;
- }
-
- vp = map_vmap (last, abfd);
- /* map_vmap acquired a reference to LAST, so we can release
- ours. */
- gdb_bfd_unref (last);
- }
- else
- {
- warning (_("\"%s\": not in executable format: %s."),
- filename, bfd_errmsg (bfd_get_error ()));
- gdb_bfd_unref (abfd);
- return NULL;
- }
- obj = allocate_objfile (vp->bfd, 0);
- vp->objfile = obj;
-
- /* Always add symbols for the main objfile. */
- if (vp == vmap || auto_solib_add)
- vmap_add_symbols (vp);
-
- /* Anything needing a reference to ABFD has already acquired it, so
- release our local reference. */
- gdb_bfd_unref (abfd);
-
- return vp;