From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id AeA/EquwsWnABSQAWB0awg (envelope-from ) for ; Wed, 11 Mar 2026 14:12:59 -0400 Received: by simark.ca (Postfix, from userid 112) id 478301E09A; Wed, 11 Mar 2026 14:12:59 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id F2DEF1E09A for ; Wed, 11 Mar 2026 14:12:55 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 775924BB5921 for ; Wed, 11 Mar 2026 18:12:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 775924BB5921 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 2156C4BB3BED for ; Wed, 11 Mar 2026 18:12:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2156C4BB3BED Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2156C4BB3BED Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773252750; cv=none; b=RVgDXbtUtwMML3pDFzjTI9YRzrjliSUJ1TJyCwSpMwI/itq9ib1mEFD5QUwQMFKBTh48HF7SkgpB7d3LKDdwcSobvtCdh0lv+ngBDY6OFil8jKZ7s6rSu3YtCqH75xwdJO6av3QYuxqQ4v/zOcEetX6KtsL26Xifayd+0Btw1Vk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773252750; c=relaxed/simple; bh=LCqAhlwr/A9HURD92SjJQdHZwyHmge93XUyWBSt3qU0=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=fjQJyy44ftuKBVr67kUwlfpM/VGqymv9wgwouV9Sp1Ty5mrau0e1L+jQMddFVj2mqyl2XfhWqPwI3I92XMD4Hj81VHidr1hbZikmE4kci/SCRZhX4mex2i2Hd6qXu4C/Hp8UBi0Dk7XcxOlzhEo+RvNd9T6XlLwbTNc+4wB4Uk0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2156C4BB3BED Received: by simark.ca (Postfix) id 82B2E1E0E1; Wed, 11 Mar 2026 14:12:29 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 19/23] gdb/dwarf: define type aliases for dwarf2_frame_ops function types Date: Wed, 11 Mar 2026 14:05:44 -0400 Message-ID: <20260311180825.720803-20-simon.marchi@efficios.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260311180825.720803-1-simon.marchi@efficios.com> References: <20260311180825.720803-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org 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