示例#1
0
static enum target_xfer_status
rs6000_xfer_shared_libraries
(struct target_ops *ops, enum target_object object,
 const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf,
 ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
{
    gdb_byte *ldi_buf;
    ULONGEST result;
    struct cleanup *cleanup;

    /* This function assumes that it is being run with a live process.
       Core files are handled via gdbarch.  */
    gdb_assert (target_has_execution);

    if (writebuf)
        return TARGET_XFER_E_IO;

    ldi_buf = rs6000_ptrace_ldinfo (inferior_ptid);
    gdb_assert (ldi_buf != NULL);
    cleanup = make_cleanup (xfree, ldi_buf);
    result = rs6000_aix_ld_info_to_xml (target_gdbarch (), ldi_buf,
    readbuf, offset, len, 1);
    xfree (ldi_buf);

    do_cleanups (cleanup);

    if (result == 0)
        return TARGET_XFER_EOF;
    else
    {
        *xfered_len = result;
        return TARGET_XFER_OK;
    }
}
示例#2
0
enum target_xfer_status
rs6000_nat_target::xfer_shared_libraries
  (enum target_object object,
   const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf,
   ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
{
  ULONGEST result;

  /* This function assumes that it is being run with a live process.
     Core files are handled via gdbarch.  */
  gdb_assert (target_has_execution);

  if (writebuf)
    return TARGET_XFER_E_IO;

  gdb::byte_vector ldi_buf = rs6000_ptrace_ldinfo (inferior_ptid);
  result = rs6000_aix_ld_info_to_xml (target_gdbarch (), ldi_buf.data (),
				      readbuf, offset, len, 1);

  if (result == 0)
    return TARGET_XFER_EOF;
  else
    {
      *xfered_len = result;
      return TARGET_XFER_OK;
    }
}
示例#3
0
static LONGEST
rs6000_xfer_shared_libraries
  (struct target_ops *ops, enum target_object object,
   const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf,
   ULONGEST offset, LONGEST len)
{
  const int arch64 = ARCH64 ();
  LdInfo *ldi_data;
  LdInfo *ldi;
  struct obstack obstack;
  const char *buf;
  LONGEST len_avail;

  if (writebuf)
    return -1;

  /* Get the ldinfo raw data: If debugging a live process, we get it
     using ptrace.  Otherwise, the info is stored in the .ldinfo
     section of the core file.  */

  if (target_has_execution)
    ldi_data = rs6000_ptrace_ldinfo (inferior_ptid);
  else
    ldi_data = rs6000_core_ldinfo (core_bfd);

  /* Convert the raw data into an XML representation.  */

  obstack_init (&obstack);
  obstack_grow_str (&obstack, "<library-list version=\"1.0\">\n");

  ldi = ldi_data;
  while (1)
    {
      /* Close the fd.  We cannot use it, because we cannot assume
	 that the user of this descriptor will be in the same
	 process.  */
      close (LDI_FD (ldi, arch64));

      rs6000_xfer_shared_library (ldi, &obstack);

      if (!LDI_NEXT (ldi, arch64))
	break;
      ldi = (LdInfo *) ((char *) ldi + LDI_NEXT (ldi, arch64));
    }

  xfree (ldi_data);

  obstack_grow_str0 (&obstack, "</library-list>\n");

  buf = obstack_finish (&obstack);
  len_avail = strlen (buf);
  if (offset >= len_avail)
    len= 0;
  else
    {
      if (len > len_avail - offset)
        len = len_avail - offset;
      memcpy (readbuf, buf + offset, len);
    }

  obstack_free (&obstack, NULL);
  return len;
}