This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 3/7] Define and use typedefs for bsd_uthread_ops fields
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: <gdb-patches at sourceware dot org>
- Cc: Simon Marchi <simon dot marchi at ericsson dot com>
- Date: Wed, 8 Mar 2017 11:41:36 -0500
- Subject: [PATCH 3/7] Define and use typedefs for bsd_uthread_ops fields
- Authentication-results: sourceware.org; auth=none
- Authentication-results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=ericsson.com;
- References: <20170308164140.7281-1-simon.marchi@ericsson.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
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