static LONGEST core_xfer_partial (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len) { switch (object) { case TARGET_OBJECT_MEMORY: return section_table_xfer_memory_partial (readbuf, writebuf, offset, len, core_data->sections, core_data->sections_end, NULL); case TARGET_OBJECT_AUXV: if (readbuf) { /* When the aux vector is stored in core file, BFD represents this with a fake section called ".auxv". */ struct bfd_section *section; bfd_size_type size; section = bfd_get_section_by_name (core_bfd, ".auxv"); if (section == NULL) return -1; size = bfd_section_size (core_bfd, section); if (offset >= size) return 0; size -= offset; if (size > len) size = len; if (size > 0 && !bfd_get_section_contents (core_bfd, section, readbuf, (file_ptr) offset, size)) { warning (_("Couldn't read NT_AUXV note in core file.")); return -1; } return size; } return -1; case TARGET_OBJECT_WCOOKIE: if (readbuf) { /* When the StackGhost cookie is stored in core file, BFD represents this with a fake section called ".wcookie". */ struct bfd_section *section; bfd_size_type size; section = bfd_get_section_by_name (core_bfd, ".wcookie"); if (section == NULL) return -1; size = bfd_section_size (core_bfd, section); if (offset >= size) return 0; size -= offset; if (size > len) size = len; if (size > 0 && !bfd_get_section_contents (core_bfd, section, readbuf, (file_ptr) offset, size)) { warning (_("Couldn't read StackGhost cookie in core file.")); return -1; } return size; } return -1; case TARGET_OBJECT_LIBRARIES: if (core_gdbarch && gdbarch_core_xfer_shared_libraries_p (core_gdbarch)) { if (writebuf) return -1; return gdbarch_core_xfer_shared_libraries (core_gdbarch, readbuf, offset, len); } /* FALL THROUGH */ case TARGET_OBJECT_LIBRARIES_AIX: if (core_gdbarch && gdbarch_core_xfer_shared_libraries_aix_p (core_gdbarch)) { if (writebuf) return -1; return gdbarch_core_xfer_shared_libraries_aix (core_gdbarch, readbuf, offset, len); } /* FALL THROUGH */ case TARGET_OBJECT_SPU: if (readbuf && annex) { /* When the SPU contexts are stored in a core file, BFD represents this with a fake section called "SPU/<annex>". */ struct bfd_section *section; bfd_size_type size; char sectionstr[100]; xsnprintf (sectionstr, sizeof sectionstr, "SPU/%s", annex); section = bfd_get_section_by_name (core_bfd, sectionstr); if (section == NULL) return -1; size = bfd_section_size (core_bfd, section); if (offset >= size) return 0; size -= offset; if (size > len) size = len; if (size > 0 && !bfd_get_section_contents (core_bfd, section, readbuf, (file_ptr) offset, size)) { warning (_("Couldn't read SPU section in core file.")); return -1; } return size; } else if (readbuf) { /* NULL annex requests list of all present spuids. */ struct spuid_list list; list.buf = readbuf; list.offset = offset; list.len = len; list.pos = 0; list.written = 0; bfd_map_over_sections (core_bfd, add_to_spuid_list, &list); return list.written; } return -1; case TARGET_OBJECT_SIGNAL_INFO: if (readbuf) return get_core_siginfo (core_bfd, readbuf, offset, len); return -1; default: if (ops->beneath != NULL) return ops->beneath->to_xfer_partial (ops->beneath, object, annex, readbuf, writebuf, offset, len); return -1; } }
enum target_xfer_status core_target::xfer_partial (enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) { switch (object) { case TARGET_OBJECT_MEMORY: return (section_table_xfer_memory_partial (readbuf, writebuf, offset, len, xfered_len, m_core_section_table.sections, m_core_section_table.sections_end, NULL)); case TARGET_OBJECT_AUXV: if (readbuf) { /* When the aux vector is stored in core file, BFD represents this with a fake section called ".auxv". */ struct bfd_section *section; bfd_size_type size; section = bfd_get_section_by_name (core_bfd, ".auxv"); if (section == NULL) return TARGET_XFER_E_IO; size = bfd_section_size (core_bfd, section); if (offset >= size) return TARGET_XFER_EOF; size -= offset; if (size > len) size = len; if (size == 0) return TARGET_XFER_EOF; if (!bfd_get_section_contents (core_bfd, section, readbuf, (file_ptr) offset, size)) { warning (_("Couldn't read NT_AUXV note in core file.")); return TARGET_XFER_E_IO; } *xfered_len = (ULONGEST) size; return TARGET_XFER_OK; } return TARGET_XFER_E_IO; case TARGET_OBJECT_WCOOKIE: if (readbuf) { /* When the StackGhost cookie is stored in core file, BFD represents this with a fake section called ".wcookie". */ struct bfd_section *section; bfd_size_type size; section = bfd_get_section_by_name (core_bfd, ".wcookie"); if (section == NULL) return TARGET_XFER_E_IO; size = bfd_section_size (core_bfd, section); if (offset >= size) return TARGET_XFER_EOF; size -= offset; if (size > len) size = len; if (size == 0) return TARGET_XFER_EOF; if (!bfd_get_section_contents (core_bfd, section, readbuf, (file_ptr) offset, size)) { warning (_("Couldn't read StackGhost cookie in core file.")); return TARGET_XFER_E_IO; } *xfered_len = (ULONGEST) size; return TARGET_XFER_OK; } return TARGET_XFER_E_IO; case TARGET_OBJECT_LIBRARIES: if (m_core_gdbarch != nullptr && gdbarch_core_xfer_shared_libraries_p (m_core_gdbarch)) { if (writebuf) return TARGET_XFER_E_IO; else { *xfered_len = gdbarch_core_xfer_shared_libraries (m_core_gdbarch, readbuf, offset, len); if (*xfered_len == 0) return TARGET_XFER_EOF; else return TARGET_XFER_OK; } } /* FALL THROUGH */ case TARGET_OBJECT_LIBRARIES_AIX: if (m_core_gdbarch != nullptr && gdbarch_core_xfer_shared_libraries_aix_p (m_core_gdbarch)) { if (writebuf) return TARGET_XFER_E_IO; else { *xfered_len = gdbarch_core_xfer_shared_libraries_aix (m_core_gdbarch, readbuf, offset, len); if (*xfered_len == 0) return TARGET_XFER_EOF; else return TARGET_XFER_OK; } } /* FALL THROUGH */ case TARGET_OBJECT_SPU: if (readbuf && annex) { /* When the SPU contexts are stored in a core file, BFD represents this with a fake section called "SPU/<annex>". */ struct bfd_section *section; bfd_size_type size; char sectionstr[100]; xsnprintf (sectionstr, sizeof sectionstr, "SPU/%s", annex); section = bfd_get_section_by_name (core_bfd, sectionstr); if (section == NULL) return TARGET_XFER_E_IO; size = bfd_section_size (core_bfd, section); if (offset >= size) return TARGET_XFER_EOF; size -= offset; if (size > len) size = len; if (size == 0) return TARGET_XFER_EOF; if (!bfd_get_section_contents (core_bfd, section, readbuf, (file_ptr) offset, size)) { warning (_("Couldn't read SPU section in core file.")); return TARGET_XFER_E_IO; } *xfered_len = (ULONGEST) size; return TARGET_XFER_OK; } else if (readbuf) { /* NULL annex requests list of all present spuids. */ struct spuid_list list; list.buf = readbuf; list.offset = offset; list.len = len; list.pos = 0; list.written = 0; bfd_map_over_sections (core_bfd, add_to_spuid_list, &list); if (list.written == 0) return TARGET_XFER_EOF; else { *xfered_len = (ULONGEST) list.written; return TARGET_XFER_OK; } } return TARGET_XFER_E_IO; case TARGET_OBJECT_SIGNAL_INFO: if (readbuf) { if (m_core_gdbarch != nullptr && gdbarch_core_xfer_siginfo_p (m_core_gdbarch)) { LONGEST l = gdbarch_core_xfer_siginfo (m_core_gdbarch, readbuf, offset, len); if (l >= 0) { *xfered_len = l; if (l == 0) return TARGET_XFER_EOF; else return TARGET_XFER_OK; } } } return TARGET_XFER_E_IO; default: return this->beneath ()->xfer_partial (object, annex, readbuf, writebuf, offset, len, xfered_len); } }