mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-21 04:42:53 +08:00
2ed4b5488f
Hi, This patch replaces -1 with TARGET_XFER_E_IO in the implementations of to_xfer_partial and their callees. This change is quite mechanical, and makes the next patch shorter. gdb: 2014-02-07 Yao Qi <yao@codesourcery.com> * auxv.c (procfs_xfer_auxv): Replace -1 with TARGET_XFER_E_IO. (ld_so_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. (darwin_xfer_partial): Likewise. * exec.c (exec_xfer_partial): Likewise. * gnu-nat.c (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_uregs): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo): Likewise. (linux_proc_xfer_spu): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_qxfer): Likewise. (remote_write_qxfer, remote_read_qxfer): Likewise. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. (spu_xfer_partial): Likewise. * target.c (memory_xfer_partial_1): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise.
103 lines
2.8 KiB
C
103 lines
2.8 KiB
C
/* Very simple "bfd" target, for GDB, the GNU debugger.
|
|
|
|
Copyright (C) 2003-2014 Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#include "defs.h"
|
|
#include "target.h"
|
|
#include "bfd-target.h"
|
|
#include "exec.h"
|
|
#include "gdb_bfd.h"
|
|
|
|
/* The object that is stored in the target_ops->to_data field has this
|
|
type. */
|
|
struct target_bfd_data
|
|
{
|
|
/* The BFD we're wrapping. */
|
|
struct bfd *bfd;
|
|
|
|
/* The section table build from the ALLOC sections in BFD. Note
|
|
that we can't rely on extracting the BFD from a random section in
|
|
the table, since the table can be legitimately empty. */
|
|
struct target_section_table table;
|
|
};
|
|
|
|
static LONGEST
|
|
target_bfd_xfer_partial (struct target_ops *ops,
|
|
enum target_object object,
|
|
const char *annex, gdb_byte *readbuf,
|
|
const gdb_byte *writebuf,
|
|
ULONGEST offset, ULONGEST len)
|
|
{
|
|
switch (object)
|
|
{
|
|
case TARGET_OBJECT_MEMORY:
|
|
{
|
|
struct target_bfd_data *data = ops->to_data;
|
|
return section_table_xfer_memory_partial (readbuf, writebuf,
|
|
offset, len,
|
|
data->table.sections,
|
|
data->table.sections_end,
|
|
NULL);
|
|
}
|
|
default:
|
|
return TARGET_XFER_E_IO;
|
|
}
|
|
}
|
|
|
|
static struct target_section_table *
|
|
target_bfd_get_section_table (struct target_ops *ops)
|
|
{
|
|
struct target_bfd_data *data = ops->to_data;
|
|
return &data->table;
|
|
}
|
|
|
|
static void
|
|
target_bfd_xclose (struct target_ops *t)
|
|
{
|
|
struct target_bfd_data *data = t->to_data;
|
|
|
|
gdb_bfd_unref (data->bfd);
|
|
xfree (data->table.sections);
|
|
xfree (data);
|
|
xfree (t);
|
|
}
|
|
|
|
struct target_ops *
|
|
target_bfd_reopen (struct bfd *abfd)
|
|
{
|
|
struct target_ops *t;
|
|
struct target_bfd_data *data;
|
|
|
|
data = XCNEW (struct target_bfd_data);
|
|
data->bfd = abfd;
|
|
gdb_bfd_ref (abfd);
|
|
build_section_table (abfd, &data->table.sections, &data->table.sections_end);
|
|
|
|
t = XCNEW (struct target_ops);
|
|
t->to_shortname = "bfd";
|
|
t->to_longname = _("BFD backed target");
|
|
t->to_doc = _("You should never see this");
|
|
t->to_get_section_table = target_bfd_get_section_table;
|
|
t->to_xfer_partial = target_bfd_xfer_partial;
|
|
t->to_xclose = target_bfd_xclose;
|
|
t->to_data = data;
|
|
t->to_magic = OPS_MAGIC;
|
|
|
|
return t;
|
|
}
|