public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add target_xfer_partial_ftype
@ 2013-12-17 13:17 Yao Qi
  2013-12-17 15:21 ` Pedro Alves
  0 siblings, 1 reply; 4+ messages in thread
From: Yao Qi @ 2013-12-17 13:17 UTC (permalink / raw)
  To: gdb-patches

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 *".

It is obvious to me, but comments are still welcome.

gdb:

2013-12-17  Yao Qi  <yao@codesourcery.com>

	* 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/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 ++++++++++------
 9 files changed, 22 insertions(+), 60 deletions(-)

diff --git a/gdb/auxv.h b/gdb/auxv.h
index 0244cd8..7360fea 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 e4e1d32..48aa6de 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 edc1e23..fd3a8de 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 a34b29a..88af3b5 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 ef9bb3d..4ee0fa8 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 f9af408..dfb033b 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 d90ef96..45a0b54 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 85b5037..04dc063 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 f22e5c6..5b9b34d 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.
-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add target_xfer_partial_ftype
  2013-12-17 13:17 [PATCH] Add target_xfer_partial_ftype Yao Qi
@ 2013-12-17 15:21 ` Pedro Alves
  2013-12-18  2:36   ` Joel Brobecker
  2013-12-18  3:56   ` Yao Qi
  0 siblings, 2 replies; 4+ messages in thread
From: Pedro Alves @ 2013-12-17 15:21 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On 12/17/2013 01:15 PM, Yao Qi wrote:
> 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 *".
> 
> It is obvious to me, but comments are still welcome.
> 

Thanks, looks good to me.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add target_xfer_partial_ftype
  2013-12-17 15:21 ` Pedro Alves
@ 2013-12-18  2:36   ` Joel Brobecker
  2013-12-18  3:56   ` Yao Qi
  1 sibling, 0 replies; 4+ messages in thread
From: Joel Brobecker @ 2013-12-18  2:36 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

> > 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 *".
> > 
> > It is obvious to me, but comments are still welcome.
> > 
> 
> Thanks, looks good to me.

And FWIW, I really like it when we're using function types. These
types are also a good anchor for documenting their intended behavior.

-- 
Joel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add target_xfer_partial_ftype
  2013-12-17 15:21 ` Pedro Alves
  2013-12-18  2:36   ` Joel Brobecker
@ 2013-12-18  3:56   ` Yao Qi
  1 sibling, 0 replies; 4+ messages in thread
From: Yao Qi @ 2013-12-18  3:56 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On 12/17/2013 11:21 PM, Pedro Alves wrote:
> Thanks, looks good to me.

Pushed.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-18  3:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-17 13:17 [PATCH] Add target_xfer_partial_ftype Yao Qi
2013-12-17 15:21 ` Pedro Alves
2013-12-18  2:36   ` Joel Brobecker
2013-12-18  3:56   ` Yao Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).