Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PATCH 3/7] Define and use typedefs for bsd_uthread_ops fields
Date: Wed, 08 Mar 2017 16:42:00 -0000	[thread overview]
Message-ID: <20170308164140.7281-4-simon.marchi@ericsson.com> (raw)
In-Reply-To: <20170308164140.7281-1-simon.marchi@ericsson.com>

The next patch modifies the type of the fields of bsd_uthread_ops, and
as a result will require changing parameters of the corresponding types
at different places.  I thought it would be more readable and
maintainable if typedefs were used.

gdb/ChangeLog:

	* bsd-uthread.h (bsd_uthread_supply_register_ftype,
	bsd_uthread_collect_register_ftype): New typedefs.
	(bsd_uthread_set_supply_uthread,
	bsd_uthread_set_collect_uthread): Use typedefs.
	* bsd-uthread.c (struct bsd_uthread_ops)
	<supply_uthread, collect_uthread>: Likewise.
	(bsd_uthread_set_supply_uthread,
	bsd_uthread_set_collect_uthread): Likewise.
---
 gdb/bsd-uthread.c | 20 ++++++++------------
 gdb/bsd-uthread.h | 19 +++++++++++--------
 2 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 20eecd3879..09a9de28ae 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -45,10 +45,10 @@ static struct gdbarch_data *bsd_uthread_data;
 struct bsd_uthread_ops
 {
   /* Supply registers for an inactive thread to a register cache.  */
-  void (*supply_uthread)(struct regcache *, int, CORE_ADDR);
+  bsd_uthread_supply_register_ftype supply_uthread;
 
   /* Collect registers for an inactive thread from a register cache.  */
-  void (*collect_uthread)(const struct regcache *, int, CORE_ADDR);
+  bsd_uthread_collect_register_ftype collect_uthread;
 };
 
 static void *
@@ -60,32 +60,28 @@ bsd_uthread_init (struct obstack *obstack)
   return ops;
 }
 
-/* Set the function that supplies registers from an inactive thread
-   for architecture GDBARCH to SUPPLY_UTHREAD.  */
+/* See bsd-uthread.h.  */
 
 void
 bsd_uthread_set_supply_uthread (struct gdbarch *gdbarch,
-				void (*supply_uthread) (struct regcache *,
-							int, CORE_ADDR))
+				bsd_uthread_supply_register_ftype func)
 {
   struct bsd_uthread_ops *ops
     = (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data);
 
-  ops->supply_uthread = supply_uthread;
+  ops->supply_uthread = func;
 }
 
-/* Set the function that collects registers for an inactive thread for
-   architecture GDBARCH to SUPPLY_UTHREAD.  */
+/* See bsd-uthread.h.  */
 
 void
 bsd_uthread_set_collect_uthread (struct gdbarch *gdbarch,
-			 void (*collect_uthread) (const struct regcache *,
-						  int, CORE_ADDR))
+				 bsd_uthread_collect_register_ftype func)
 {
   struct bsd_uthread_ops *ops
     = (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data);
 
-  ops->collect_uthread = collect_uthread;
+  ops->collect_uthread = func;
 }
 
 /* Magic number to help recognize a valid thread structure.  */
diff --git a/gdb/bsd-uthread.h b/gdb/bsd-uthread.h
index 7e55913a75..4802d019ae 100644
--- a/gdb/bsd-uthread.h
+++ b/gdb/bsd-uthread.h
@@ -20,19 +20,22 @@
 #ifndef BSD_UTHREAD_H
 #define BSD_UTHREAD_H 1
 
+typedef void (*bsd_uthread_supply_register_ftype) (struct regcache *, int,
+						   CORE_ADDR);
+typedef void (*bsd_uthread_collect_register_ftype) (const struct regcache *,
+						    int, CORE_ADDR);
+
 /* Set the function that supplies registers for an inactive thread for
-   architecture GDBARCH to SUPPLY_UTHREAD.  */
+   architecture GDBARCH to FUNC.  */
 
-extern void bsd_uthread_set_supply_uthread (struct gdbarch *gdbarch,
-				    void (*supply_uthread) (struct regcache *,
-							    int, CORE_ADDR));
+extern void bsd_uthread_set_supply_uthread
+  (struct gdbarch *gdbarch, bsd_uthread_supply_register_ftype func);
 
 
 /* Set the function that collects registers for an inactive thread for
-   architecture GDBARCH to SUPPLY_UTHREAD.  */
+   architecture GDBARCH to FUNC.  */
 
-extern void bsd_uthread_set_collect_uthread (struct gdbarch *gdbarch,
-			     void (*collect_uthread) (const struct regcache *,
-						      int, CORE_ADDR));
+extern void bsd_uthread_set_collect_uthread
+  (struct gdbarch *gdbarch, bsd_uthread_collect_register_ftype func);
 
 #endif /* bsd-uthread.h */
-- 
2.11.0


  parent reply	other threads:[~2017-03-08 16:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-08 16:42 [PATCH 0/7] Pass ptid to target_ops register methods Simon Marchi
2017-03-08 16:42 ` [PATCH 7/7] Pass ptid to to_prepare_to_store Simon Marchi
2017-03-08 16:42 ` [PATCH 5/7] Pass ptid to target_fetch_registers Simon Marchi
2017-03-08 21:08   ` Simon Marchi
2017-03-08 16:42 ` [PATCH 2/7] Add overload of s390_inferior_tid with a parameter Simon Marchi
2017-03-08 16:42 ` [PATCH 1/7] windows: Don't use current_thread for register fetch/store Simon Marchi
2017-03-08 16:42 ` [PATCH 6/7] Pass ptid to target_store_registers Simon Marchi
2017-03-08 16:42 ` [PATCH 4/7] Pass down ptid in bsd_uthread_ops layer Simon Marchi
2017-03-08 16:42 ` Simon Marchi [this message]
2017-03-08 17:03 ` [PATCH 0/7] Pass ptid to target_ops register methods Simon Marchi
2017-03-08 23:31 ` Pedro Alves
2017-03-10 16:06   ` Simon Marchi
2017-03-10 17:12     ` Ulrich Weigand
2017-03-10 17:51       ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170308164140.7281-4-simon.marchi@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox