From 4ac248ca0beb1dfdb56716a440c4558b89fd7b1a Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Mon, 4 Nov 2013 17:53:56 +0800 Subject: [PATCH] Add target_xfer_partial_ftype This patch adds a typedef target_xfer_partial_ftype. When we change the signature of xfer_partial functions (for example, adding a new parameter), we don't have to modify all of their declarations. This patch also updates the type of parameters of target_xfer_partial from "void *" to "gdb_byte *". gdb: 2013-12-18 Yao Qi * target.h (target_xfer_partial_ftype): New typedef. (target_xfer_partial): Update declaration. * auxv.h (memory_xfer_auxv): Likewise. * ia64-hpux-nat.c (super_xfer_partial): Likewise. * ia64-linux-nat.c (super_xfer_partial): Likewise. * linux-nat.c (super_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-full.c (record_full_beneath_to_xfer_partial): (tmp_to_xfer_partial): Likewise. * sparc-nat.c (inf_ptrace_xfer_partial): Likewise. * target.c (default_xfer_partial): Likewise. (current_xfer_partial): Likewise. (target_xfer_partial): Change parameter type to 'gdb_byte *'. --- gdb/ChangeLog | 16 ++++++++++++++++ gdb/auxv.h | 8 +------- gdb/ia64-hpux-nat.c | 4 +--- gdb/ia64-linux-nat.c | 4 +--- gdb/linux-nat.c | 6 +----- gdb/procfs.c | 7 +------ gdb/record-full.c | 17 ++--------------- gdb/sparc-nat.c | 4 +--- gdb/target.c | 16 ++++------------ gdb/target.h | 16 ++++++++++------ 10 files changed, 38 insertions(+), 60 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 196bcb011a..7d9308f515 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,19 @@ +2013-12-18 Yao Qi + + * target.h (target_xfer_partial_ftype): New typedef. + (target_xfer_partial): Update declaration. + * auxv.h (memory_xfer_auxv): Likewise. + * ia64-hpux-nat.c (super_xfer_partial): Likewise. + * ia64-linux-nat.c (super_xfer_partial): Likewise. + * linux-nat.c (super_xfer_partial): Likewise. + * procfs.c (procfs_xfer_partial): Likewise. + * record-full.c (record_full_beneath_to_xfer_partial): + (tmp_to_xfer_partial): Likewise. + * sparc-nat.c (inf_ptrace_xfer_partial): Likewise. + * target.c (default_xfer_partial): Likewise. + (current_xfer_partial): Likewise. + (target_xfer_partial): Change parameter type to 'gdb_byte *'. + 2013-12-18 Yao Qi * linux-nat.c (linux_proc_xfer_partial): Call xsnprintf instead diff --git a/gdb/auxv.h b/gdb/auxv.h index 0244cd82f8..7360fea390 100644 --- a/gdb/auxv.h +++ b/gdb/auxv.h @@ -42,13 +42,7 @@ extern int target_auxv_search (struct target_ops *ops, /* Print the contents of the target's AUXV on the specified file. */ extern int fprint_target_auxv (struct ui_file *file, struct target_ops *ops); -extern LONGEST memory_xfer_auxv (struct target_ops *ops, - enum target_object object, - const char *annex, - gdb_byte *readbuf, - const gdb_byte *writebuf, - ULONGEST offset, - LONGEST len); +extern target_xfer_partial_ftype memory_xfer_auxv; #endif diff --git a/gdb/ia64-hpux-nat.c b/gdb/ia64-hpux-nat.c index e4e1d3278e..48aa6de19e 100644 --- a/gdb/ia64-hpux-nat.c +++ b/gdb/ia64-hpux-nat.c @@ -337,9 +337,7 @@ ia64_hpux_store_registers (struct target_ops *ops, need to be handled manually. So we override this routine and delegate back if we detect that we are not in a special case. */ -static LONGEST (*super_xfer_partial) (struct target_ops *, enum target_object, - const char *, gdb_byte *, - const gdb_byte *, ULONGEST, LONGEST); +static target_xfer_partial_ftype *super_xfer_partial; /* The "xfer_partial" routine for a memory region that is completely outside of the backing-store region. */ diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c index edc1e23913..fd3a8de758 100644 --- a/gdb/ia64-linux-nat.c +++ b/gdb/ia64-linux-nat.c @@ -833,9 +833,7 @@ ia64_linux_store_registers (struct target_ops *ops, } -static LONGEST (*super_xfer_partial) (struct target_ops *, enum target_object, - const char *, gdb_byte *, - const gdb_byte *, ULONGEST, LONGEST); +static target_xfer_partial_ftype *super_xfer_partial; static LONGEST ia64_linux_xfer_partial (struct target_ops *ops, diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index a34b29a116..88af3b5e5b 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -200,11 +200,7 @@ static int (*linux_nat_siginfo_fixup) (siginfo_t *, /* The saved to_xfer_partial method, inherited from inf-ptrace.c. Called by our to_xfer_partial. */ -static LONGEST (*super_xfer_partial) (struct target_ops *, - enum target_object, - const char *, gdb_byte *, - const gdb_byte *, - ULONGEST, LONGEST); +static target_xfer_partial_ftype *super_xfer_partial; static unsigned int debug_linux_nat; static void diff --git a/gdb/procfs.c b/gdb/procfs.c index ef9bb3de40..4ee0fa88cf 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -129,12 +129,7 @@ static ptid_t procfs_wait (struct target_ops *, static int procfs_xfer_memory (CORE_ADDR, gdb_byte *, int, int, struct mem_attrib *attrib, struct target_ops *); -static LONGEST procfs_xfer_partial (struct target_ops *ops, - enum target_object object, - const char *annex, - gdb_byte *readbuf, - const gdb_byte *writebuf, - ULONGEST offset, LONGEST len); +static target_xfer_partial_ftype procfs_xfer_partial; static int procfs_thread_alive (struct target_ops *ops, ptid_t); diff --git a/gdb/record-full.c b/gdb/record-full.c index f9af408e8d..dfb033bcd1 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -228,14 +228,7 @@ static void (*record_full_beneath_to_store_registers) (struct target_ops *, struct regcache *, int regno); static struct target_ops *record_full_beneath_to_xfer_partial_ops; -static LONGEST - (*record_full_beneath_to_xfer_partial) (struct target_ops *ops, - enum target_object object, - const char *annex, - gdb_byte *readbuf, - const gdb_byte *writebuf, - ULONGEST offset, - LONGEST len); +static target_xfer_partial_ftype *record_full_beneath_to_xfer_partial; static int (*record_full_beneath_to_insert_breakpoint) (struct gdbarch *, struct bp_target_info *); @@ -807,13 +800,7 @@ static void (*tmp_to_store_registers) (struct target_ops *, struct regcache *, int regno); static struct target_ops *tmp_to_xfer_partial_ops; -static LONGEST (*tmp_to_xfer_partial) (struct target_ops *ops, - enum target_object object, - const char *annex, - gdb_byte *readbuf, - const gdb_byte *writebuf, - ULONGEST offset, - LONGEST len); +static target_xfer_partial_ftype *tmp_to_xfer_partial; static int (*tmp_to_insert_breakpoint) (struct gdbarch *, struct bp_target_info *); static int (*tmp_to_remove_breakpoint) (struct gdbarch *, diff --git a/gdb/sparc-nat.c b/gdb/sparc-nat.c index d90ef968ba..45a0b54cd6 100644 --- a/gdb/sparc-nat.c +++ b/gdb/sparc-nat.c @@ -313,9 +313,7 @@ sparc_xfer_wcookie (struct target_ops *ops, enum target_object object, return len; } -LONGEST (*inf_ptrace_xfer_partial) (struct target_ops *, enum target_object, - const char *, gdb_byte *, const gdb_byte *, - ULONGEST, LONGEST); +target_xfer_partial_ftype *inf_ptrace_xfer_partial; static LONGEST sparc_xfer_partial (struct target_ops *ops, enum target_object object, diff --git a/gdb/target.c b/gdb/target.c index 85b5037431..04dc06397f 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -70,17 +70,9 @@ static void target_command (char *, int); static struct target_ops *find_default_run_target (char *); -static LONGEST default_xfer_partial (struct target_ops *ops, - enum target_object object, - const char *annex, gdb_byte *readbuf, - const gdb_byte *writebuf, - ULONGEST offset, LONGEST len); - -static LONGEST current_xfer_partial (struct target_ops *ops, - enum target_object object, - const char *annex, gdb_byte *readbuf, - const gdb_byte *writebuf, - ULONGEST offset, LONGEST len); +static target_xfer_partial_ftype default_xfer_partial; + +static target_xfer_partial_ftype current_xfer_partial; static struct gdbarch *default_thread_architecture (struct target_ops *ops, ptid_t ptid); @@ -1695,7 +1687,7 @@ make_show_memory_breakpoints_cleanup (int show) LONGEST target_xfer_partial (struct target_ops *ops, enum target_object object, const char *annex, - void *readbuf, const void *writebuf, + gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len) { LONGEST retval; diff --git a/gdb/target.h b/gdb/target.h index f22e5c6918..5b9b34d7a3 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -238,6 +238,15 @@ enum trace_find_type typedef struct static_tracepoint_marker *static_tracepoint_marker_p; DEF_VEC_P(static_tracepoint_marker_p); +typedef LONGEST + target_xfer_partial_ftype (struct target_ops *ops, + enum target_object object, + const char *annex, + gdb_byte *readbuf, + const gdb_byte *writebuf, + ULONGEST offset, + LONGEST len); + /* Request that OPS transfer up to LEN 8-bit bytes of the target's OBJECT. The OFFSET, for a seekable object, specifies the starting point. The ANNEX can be used to provide additional @@ -319,12 +328,7 @@ extern char *target_read_stralloc (struct target_ops *ops, const char *annex); /* See target_ops->to_xfer_partial. */ - -extern LONGEST target_xfer_partial (struct target_ops *ops, - enum target_object object, - const char *annex, - void *readbuf, const void *writebuf, - ULONGEST offset, LONGEST len); +extern target_xfer_partial_ftype target_xfer_partial; /* Wrappers to target read/write that perform memory transfers. They throw an error if the memory transfer fails. -- 2.34.1