Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 19/23] gdb/dwarf: define type aliases for dwarf2_frame_ops function types
Date: Wed, 11 Mar 2026 14:05:44 -0400	[thread overview]
Message-ID: <20260311180825.720803-20-simon.marchi@efficios.com> (raw)
In-Reply-To: <20260311180825.720803-1-simon.marchi@efficios.com>

This makes the code less verbose, and I think more readable.

Change-Id: I715669281d341bd15547e3eba82c716a953f2274
---
 gdb/dwarf2/frame.c | 40 +++++++++++++---------------------------
 gdb/dwarf2/frame.h | 45 +++++++++++++++++++++++----------------------
 2 files changed, 36 insertions(+), 49 deletions(-)

diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index 7012a7a4f12c..0566fd516f5a 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -590,16 +590,14 @@ static void dwarf2_frame_default_init_reg (struct gdbarch *gdbarch,
 struct dwarf2_frame_ops
 {
   /* Pre-initialize the register state REG for register REGNUM.  */
-  void (*init_reg) (struct gdbarch *, int, struct dwarf2_frame_state_reg *,
-		    const frame_info_ptr &)
-    = dwarf2_frame_default_init_reg;
+  init_reg_ftype *init_reg = dwarf2_frame_default_init_reg;
 
   /* Check whether the THIS_FRAME is a signal trampoline.  */
-  int (*signal_frame_p) (struct gdbarch *, const frame_info_ptr &) = nullptr;
+  signal_frame_p_ftype *signal_frame_p = nullptr;
 
   /* Convert .eh_frame register number to DWARF register number, or
      adjust .debug_frame register number.  */
-  int (*adjust_regnum) (struct gdbarch *, int, int) = nullptr;
+  adjust_regnum_ftype *adjust_regnum = nullptr;
 };
 
 /* Per-architecture data key.  */
@@ -656,14 +654,9 @@ dwarf2_frame_default_init_reg (struct gdbarch *gdbarch, int regnum,
    function for GDBARCH to INIT_REG.  */
 
 void
-dwarf2_frame_set_init_reg (struct gdbarch *gdbarch,
-			   void (*init_reg) (struct gdbarch *, int,
-					     struct dwarf2_frame_state_reg *,
-					     const frame_info_ptr &))
+dwarf2_frame_set_init_reg (gdbarch *gdbarch, init_reg_ftype *init_reg)
 {
-  struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch);
-
-  ops->init_reg = init_reg;
+  get_frame_ops (gdbarch)->init_reg = init_reg;
 }
 
 /* Pre-initialize the register state REG for register REGNUM.  */
@@ -673,22 +666,17 @@ dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
 		       struct dwarf2_frame_state_reg *reg,
 		       const frame_info_ptr &this_frame)
 {
-  struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch);
-
-  ops->init_reg (gdbarch, regnum, reg, this_frame);
+  get_frame_ops (gdbarch)->init_reg (gdbarch, regnum, reg, this_frame);
 }
 
 /* Set the architecture-specific signal trampoline recognition
    function for GDBARCH to SIGNAL_FRAME_P.  */
 
 void
-dwarf2_frame_set_signal_frame_p (struct gdbarch *gdbarch,
-				 int (*signal_frame_p) (struct gdbarch *,
-							const frame_info_ptr &))
+dwarf2_frame_set_signal_frame_p (gdbarch *gdbarch,
+				 signal_frame_p_ftype *signal_frame_p)
 {
-  struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch);
-
-  ops->signal_frame_p = signal_frame_p;
+  get_frame_ops (gdbarch)->signal_frame_p = signal_frame_p;
 }
 
 /* Query the architecture-specific signal frame recognizer for
@@ -710,13 +698,10 @@ dwarf2_frame_signal_frame_p (struct gdbarch *gdbarch,
    register numbers.  */
 
 void
-dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch,
-				int (*adjust_regnum) (struct gdbarch *,
-						      int, int))
+dwarf2_frame_set_adjust_regnum (gdbarch *gdbarch,
+				adjust_regnum_ftype *adjust_regnum)
 {
-  struct dwarf2_frame_ops *ops = get_frame_ops (gdbarch);
-
-  ops->adjust_regnum = adjust_regnum;
+  get_frame_ops (gdbarch)->adjust_regnum = adjust_regnum;
 }
 
 /* Translate a .eh_frame register to DWARF register, or adjust a .debug_frame
@@ -730,6 +715,7 @@ dwarf2_frame_adjust_regnum (struct gdbarch *gdbarch,
 
   if (ops->adjust_regnum == NULL)
     return regnum;
+
   return ops->adjust_regnum (gdbarch, regnum, eh_frame_p);
 }
 
diff --git a/gdb/dwarf2/frame.h b/gdb/dwarf2/frame.h
index 47f9ed88f7c5..c3bbfcc03f59 100644
--- a/gdb/dwarf2/frame.h
+++ b/gdb/dwarf2/frame.h
@@ -198,6 +198,11 @@ struct dwarf2_frame_state
   bool armcc_cfa_offsets_reversed = false;
 };
 
+using init_reg_ftype = void (gdbarch *, int, dwarf2_frame_state_reg *,
+			     const frame_info_ptr &);
+using signal_frame_p_ftype = int (gdbarch *, const frame_info_ptr &);
+using adjust_regnum_ftype = int (gdbarch *, int, int);
+
 /* If DWARF supoprt was requested, create the real prototype for the
    append_unwinders function.  Otherwise, create a fake inline function.
 
@@ -210,25 +215,19 @@ struct dwarf2_frame_state
 /* Set the architecture-specific register state initialization
    function for GDBARCH to INIT_REG.  */
 
-extern void dwarf2_frame_set_init_reg (
-  gdbarch *gdbarch, void (*init_reg) (struct gdbarch *, int,
-				      dwarf2_frame_state_reg *,
-				      const frame_info_ptr &));
+void dwarf2_frame_set_init_reg (gdbarch *gdbarch, init_reg_ftype *init_reg);
 
 /* Set the architecture-specific signal trampoline recognition
    function for GDBARCH to SIGNAL_FRAME_P.  */
 
-extern void dwarf2_frame_set_signal_frame_p
-  (gdbarch *gdbarch, int (*signal_frame_p) (struct gdbarch *,
-			  const frame_info_ptr &));
+void dwarf2_frame_set_signal_frame_p (gdbarch *gdbarch,
+				      signal_frame_p_ftype *signal_frame_p);
 
 /* Set the architecture-specific adjustment of .eh_frame and .debug_frame
    register numbers.  */
 
-extern void
-  dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch,
-				  int (*adjust_regnum) (struct gdbarch *,
-							int, int));
+void dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch,
+				     adjust_regnum_ftype *adjust_regnum);
 
 /* Append the DWARF-2 frame unwinders to GDBARCH's list.  */
 
@@ -300,10 +299,10 @@ extern void *dwarf2_frame_get_fn_data (const frame_info_ptr &this_frame,
 
 static inline void dwarf2_append_unwinders (struct gdbarch *gdbarch) { }
 
-static inline void dwarf2_frame_set_init_reg (
-  gdbarch *gdbarch, void (*init_reg) (struct gdbarch *,int,
-				      dwarf2_frame_state_reg *,
-				      const frame_info_ptr &)) { }
+static inline void
+dwarf2_frame_set_init_reg (gdbarch *gdbarch, init_reg_ftype *init_reg)
+{
+}
 
 static inline const struct frame_base *
   dwarf2_frame_base_sniffer (const frame_info_ptr &this_frame)
@@ -312,9 +311,11 @@ static inline const struct frame_base *
   return nullptr;
 }
 
-static inline void dwarf2_frame_set_signal_frame_p
-  (gdbarch *gdbarch, int (*signal_frame_p) (struct gdbarch *,
-			  const frame_info_ptr &)) { }
+static inline void
+dwarf2_frame_set_signal_frame_p (gdbarch *gdbarch,
+				 signal_frame_p_ftype *signal_frame_p)
+{
+}
 
 static inline void *dwarf2_frame_get_fn_data (const frame_info_ptr &this_frame,
 					      void **this_cache,
@@ -341,10 +342,10 @@ dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
 }
 
 static inline void
-  dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch,
-				  int (*adjust_regnum) (struct gdbarch *,
-							int, int))
-{}
+dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch,
+				adjust_regnum_ftype *adjust_regnum)
+{
+}
 
 #endif /* DWARF_FORMAT_AVAILABLE */
 
-- 
2.53.0


  parent reply	other threads:[~2026-03-11 18:12 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
2026-03-11 18:05 ` [PATCH 01/23] gdb/dwarf: change die_needs_namespace to return bool Simon Marchi
2026-03-11 18:05 ` [PATCH 02/23] gdb/dwarf: change dwarf2_flag_true_p " Simon Marchi
2026-03-11 18:05 ` [PATCH 03/23] gdb/dwarf: change die_is_declaration " Simon Marchi
2026-03-11 18:05 ` [PATCH 04/23] gdb/dwarf: change need_gnat_info " Simon Marchi
2026-03-11 18:05 ` [PATCH 05/23] gdb/dwarf: change attr_to_dynamic_prop " Simon Marchi
2026-03-11 18:05 ` [PATCH 06/23] gdb/dwarf: change dwarf2_is_constructor " Simon Marchi
2026-03-11 18:05 ` [PATCH 07/23] gdb/dwarf: change is_vtable_name " Simon Marchi
2026-03-11 18:05 ` [PATCH 08/23] gdb/dwarf: change prototyped_function_p " Simon Marchi
2026-03-11 18:05 ` [PATCH 09/23] gdb/dwarf: change dwarf2_ranges_process " Simon Marchi
2026-03-11 18:05 ` [PATCH 10/23] gdb/dwarf: change dwarf2_ranges_read " Simon Marchi
2026-03-12 12:44   ` Tom Tromey
2026-03-12 14:21     ` Simon Marchi
2026-03-11 18:05 ` [PATCH 11/23] gdb/dwarf: change unavailable_retaddr and undefined_retaddr to bool Simon Marchi
2026-03-11 18:05 ` [PATCH 12/23] gdb/dwarf: change frame_is_tailcall to return bool Simon Marchi
2026-03-11 18:05 ` [PATCH 13/23] gdb/dwarf: change call_site_parameter_matches " Simon Marchi
2026-03-11 18:05 ` [PATCH 14/23] gdb/dwarf: change dwarf2_fetch_cfa_info " Simon Marchi
2026-03-11 18:05 ` [PATCH 15/23] gdb/dwarf: change dwarf2_locexpr_baton_eval " Simon Marchi
2026-03-11 18:05 ` [PATCH 16/23] gdb/dwarf: change base_types_equal_p " Simon Marchi
2026-03-11 18:05 ` [PATCH 17/23] gdb/dwarf: change dwarf2_frame_signal_frame_p " Simon Marchi
2026-03-11 18:05 ` [PATCH 18/23] gdb/dwarf: change piece_end_p " Simon Marchi
2026-03-11 18:05 ` Simon Marchi [this message]
2026-03-11 18:05 ` [PATCH 20/23] gdb/dwarf: change dwarf2_frame_ops " Simon Marchi
2026-03-11 18:05 ` [PATCH 21/23] gdb/dwarf: use true/false in read_gdb_index_from_buffer Simon Marchi
2026-03-11 18:05 ` [PATCH 22/23] gdb/dwarf: change dwarf_block_to_sp_offset to return bool Simon Marchi
2026-03-11 18:05 ` [PATCH 23/23] gdb/dwarf: change dwarf_block_to_fb_offset " Simon Marchi
2026-03-12 12:59 ` [PATCH 00/23] int -> bool in dwarf2/ Tom Tromey
2026-03-12 14:21   ` 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=20260311180825.720803-20-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.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