From patchwork Thu Mar 6 17:29:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 107451 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 98D1D3858D38 for ; Thu, 6 Mar 2025 17:29:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98D1D3858D38 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=fZ20AzSf X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 8AD8B3858403 for ; Thu, 6 Mar 2025 17:29:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8AD8B3858403 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8AD8B3858403 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::12f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741282151; cv=none; b=tJsljLSk04zGVUeIrRQUT34WW9BP/BFV8p4VL4vS3pcbBIT1CMaXHEy4QthTbqCs6VNcjAYZeCCKM+x0wofrXk0BcJcHzdFa000jwl8zYxZu7gc7TCL4MuslfRSHAwfvkWnls5rVK1cpoDwx8yNFcdmP5cO3ca2KcH5iBIMjfcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741282151; c=relaxed/simple; bh=PCK5A4/IYwrak9Yf7rPO/bm80ummJ8tA6Mirww77o+Y=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=gWx+YNB2IFwQIYxdVRhMMHPnyy/FnQ2WTwTOJX8wGxLeuqPIp+Hn1jolXqPnsSGAVUyyfNQ+yPsuN33GICjK7EhCh1xunD8+P6AjQCJfzWREz+3TdkvcPHl78VGIdqsjZTEweFVX2zb94va5yeYOzUkt8B6W3eyguF714srrHTg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8AD8B3858403 Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-3d2b6ed8128so7086265ab.0 for ; Thu, 06 Mar 2025 09:29:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1741282151; x=1741886951; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YFUkExtDx6VDdTR66EwI+8SF+SkhojLgz7j3lkbIO/c=; b=fZ20AzSfk/PvnNAKHB+NvUhsUfNgyNN4cBAD242mgQp5iwBSIltV8wZ4jkKa72HyRZ DKqRvw7+4XN329cRuNm/nMKT2XoEJ09n36a9YGV69TZ4uuiM9GJ/fK8+oiKKjnzehKAj VcD1Wz3vvwxuNj7nV+5JoOmrVsGBcoZ8v7VZ4uG1qBjtFnZhlgY/pQo0FXr1cjZjMw69 0fvgcqpTTCtMaHaInQBJR+SonwSgylZebD7YzUwl7eE3tIKWFf+vNDPhfpnIy7rZk1Uf qWJIC86NUO6aYdVSIUay3McVsF5cWV7xfW4VijKRkfTA2hORZEBuWBrxZFytf/27Q5Dc Maog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741282151; x=1741886951; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YFUkExtDx6VDdTR66EwI+8SF+SkhojLgz7j3lkbIO/c=; b=KvjwclCCNvrTN17vrlpP9yJ4UEbtl9TykvEUumNf42Zga0VzG/S/UiyF+D8aFOpI1A RJCZRT7nI5EFng+z29Zrd4p1Ssnb7yq+kh8nI5gqCgS0mVTYSGSy8cNjNhdOuuUZzmAF Og0hdd4lKvYWQwfnBXFX8tU6B1nzSmPMANVUPC7Ct0WVXkSjxMXZeoK12jOc8N+05XaQ 3QAnQxuxHNn4paBOn96ycJjeKAHky8/6i0ALAkl2TZOEu8Ufkw3ofA1pDFeg0t302xRL WHjwUqmXNbCHWAAJkneGr/LVK4oNqS1+wvxvzxGWLV+34x5py+SSxdwtQgVtXM8IB0Zz rf/A== X-Gm-Message-State: AOJu0YxhfrZy4GF6hHK+BUErkS1tP3Y0ognfJQEDAO9pDa4UL2bojRoH 07uTjRbHkCnddcG/KTehct0ITR2NgPMyk1eZUntMxbXsavg1el85NDWWNnzCPma4qMO0YRRg4rD FKQ== X-Gm-Gg: ASbGnctXt99OHJz00JhSWtYyPZBBVmiomUzWCMRqKOzzbO5ih/onbnvVJDrcfewu5OR gsHuSYrybUzVPU5xjdzjtD8DkelCpHS/QUsCAD6mfP6dJGVmwuIP/T3R0Mn5qeDwY1lqyWK5RNd doQM5F4eh/PA4SAzEBud97IaQf+UGmoTeAY3FuCzL5UABse3VXWCUHsKuezRwrT1mSyZe0RjGNq pkYNZYPpHidNPh99TmbDF0g5dKCAxffX+cS2gpmo8FAMQCTlbpswcGcSM5qoMdH8cm8QvH1yQcc Nf0O7wUuK063D0aTBnbb5RVJ2qjKGwtPZ2GTEZQH9MPDUL7wFzIYjzQIlksDBkZkUH0ABmJei2q wH/LdYg== X-Google-Smtp-Source: AGHT+IGBPnNX/E95nu6gml0QNey5/PnhCruyPkMu3jsxoEdqRPPxLXRtmL62PMZQuhbpK4vzJ9pStQ== X-Received: by 2002:a05:6e02:16ca:b0:3d4:2acc:81fa with SMTP id e9e14a558f8ab-3d44189e3e8mr4783435ab.2.1741282150584; Thu, 06 Mar 2025 09:29:10 -0800 (PST) Received: from localhost.localdomain (97-118-51-80.hlrn.qwest.net. [97.118.51.80]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3d43b4f74b3sm3857525ab.27.2025.03.06.09.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Mar 2025 09:29:09 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Use 'const' in some gdbarch methods Date: Thu, 6 Mar 2025 10:29:00 -0700 Message-ID: <20250306172900.2420475-1-tromey@adacore.com> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_STOCKGEN, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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~patchwork=sourceware.org@sourceware.org This changes a couple of gdbarch methods to use 'const' for an "asymbol *" parameter. These methods shouldn't be modifying the underlying symbol in the BFD. --- gdb/arm-tdep.c | 6 +++--- gdb/gdbarch-gen.c | 4 ++-- gdb/gdbarch-gen.h | 8 ++++---- gdb/gdbarch_components.py | 4 ++-- gdb/m68hc11-tdep.c | 5 +++-- gdb/mips-tdep.c | 5 +++-- gdb/ppc-linux-tdep.c | 5 +++-- gdb/ppc64-tdep.c | 5 +++-- gdb/ppc64-tdep.h | 2 +- 9 files changed, 24 insertions(+), 20 deletions(-) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index bdad0779ca7..879f5cf2447 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -9719,9 +9719,9 @@ coff_sym_is_thumb (int val) symbol to indicate that it does. */ static void -arm_elf_make_msymbol_special(asymbol *sym, struct minimal_symbol *msym) +arm_elf_make_msymbol_special (const asymbol *sym, struct minimal_symbol *msym) { - elf_symbol_type *elfsym = (elf_symbol_type *) sym; + const elf_symbol_type *elfsym = (const elf_symbol_type *) sym; if (ARM_GET_SYM_BRANCH_TYPE (elfsym->internal_elf_sym.st_target_internal) == ST_BRANCH_TO_THUMB) @@ -9737,7 +9737,7 @@ arm_coff_make_msymbol_special(int val, struct minimal_symbol *msym) static void arm_record_special_symbol (struct gdbarch *gdbarch, struct objfile *objfile, - asymbol *sym) + const asymbol *sym) { const char *name = bfd_asymbol_name (sym); struct arm_per_bfd *data; diff --git a/gdb/gdbarch-gen.c b/gdb/gdbarch-gen.c index 8137ece78bc..97d7ed9b069 100644 --- a/gdb/gdbarch-gen.c +++ b/gdb/gdbarch-gen.c @@ -3562,7 +3562,7 @@ gdbarch_elf_make_msymbol_special_p (struct gdbarch *gdbarch) } void -gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch, asymbol *sym, struct minimal_symbol *msym) +gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch, const asymbol *sym, struct minimal_symbol *msym) { gdb_assert (gdbarch != NULL); gdb_assert (gdbarch->elf_make_msymbol_special != NULL); @@ -4575,7 +4575,7 @@ gdbarch_record_special_symbol_p (struct gdbarch *gdbarch) } void -gdbarch_record_special_symbol (struct gdbarch *gdbarch, struct objfile *objfile, asymbol *sym) +gdbarch_record_special_symbol (struct gdbarch *gdbarch, struct objfile *objfile, const asymbol *sym) { gdb_assert (gdbarch != NULL); gdb_assert (gdbarch->record_special_symbol != NULL); diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h index abffcf99fac..7a52f79d762 100644 --- a/gdb/gdbarch-gen.h +++ b/gdb/gdbarch-gen.h @@ -867,8 +867,8 @@ extern void set_gdbarch_stack_frame_destroyed_p (struct gdbarch *gdbarch, gdbarc extern bool gdbarch_elf_make_msymbol_special_p (struct gdbarch *gdbarch); -typedef void (gdbarch_elf_make_msymbol_special_ftype) (asymbol *sym, struct minimal_symbol *msym); -extern void gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch, asymbol *sym, struct minimal_symbol *msym); +typedef void (gdbarch_elf_make_msymbol_special_ftype) (const asymbol *sym, struct minimal_symbol *msym); +extern void gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch, const asymbol *sym, struct minimal_symbol *msym); extern void set_gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch, gdbarch_elf_make_msymbol_special_ftype *elf_make_msymbol_special); typedef void (gdbarch_coff_make_msymbol_special_ftype) (int val, struct minimal_symbol *msym); @@ -1325,8 +1325,8 @@ extern void set_gdbarch_get_siginfo_type (struct gdbarch *gdbarch, gdbarch_get_s extern bool gdbarch_record_special_symbol_p (struct gdbarch *gdbarch); -typedef void (gdbarch_record_special_symbol_ftype) (struct gdbarch *gdbarch, struct objfile *objfile, asymbol *sym); -extern void gdbarch_record_special_symbol (struct gdbarch *gdbarch, struct objfile *objfile, asymbol *sym); +typedef void (gdbarch_record_special_symbol_ftype) (struct gdbarch *gdbarch, struct objfile *objfile, const asymbol *sym); +extern void gdbarch_record_special_symbol (struct gdbarch *gdbarch, struct objfile *objfile, const asymbol *sym); extern void set_gdbarch_record_special_symbol (struct gdbarch *gdbarch, gdbarch_record_special_symbol_ftype *record_special_symbol); /* Function for the 'catch syscall' feature. diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py index e0fd74e80d1..cd0a8947948 100644 --- a/gdb/gdbarch_components.py +++ b/gdb/gdbarch_components.py @@ -1506,7 +1506,7 @@ the main symbol table and DWARF-2 records. """, type="void", name="elf_make_msymbol_special", - params=[("asymbol *", "sym"), ("struct minimal_symbol *", "msym")], + params=[("const asymbol *", "sym"), ("struct minimal_symbol *", "msym")], predicate=True, ) @@ -2126,7 +2126,7 @@ Record architecture-specific information from the symbol table. """, type="void", name="record_special_symbol", - params=[("struct objfile *", "objfile"), ("asymbol *", "sym")], + params=[("struct objfile *", "objfile"), ("const asymbol *", "sym")], predicate=True, ) diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c index 84a44f525c2..234edcf50bf 100644 --- a/gdb/m68hc11-tdep.c +++ b/gdb/m68hc11-tdep.c @@ -1326,11 +1326,12 @@ m68hc11_return_value (struct gdbarch *gdbarch, struct value *function, rti to return. */ static void -m68hc11_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym) +m68hc11_elf_make_msymbol_special (const asymbol *sym, + struct minimal_symbol *msym) { unsigned char flags; - flags = ((elf_symbol_type *)sym)->internal_elf_sym.st_other; + flags = ((const elf_symbol_type *) sym)->internal_elf_sym.st_other; if (flags & STO_M68HC12_FAR) MSYMBOL_SET_RTC (msym); if (flags & STO_M68HC12_INTERRUPT) diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 93f8cd0263a..3613f9bec8d 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -422,9 +422,10 @@ mips_unmake_compact_addr (CORE_ADDR addr) in a minimal symbol. */ static void -mips_elf_make_msymbol_special (asymbol * sym, struct minimal_symbol *msym) +mips_elf_make_msymbol_special (const asymbol * sym, + struct minimal_symbol *msym) { - elf_symbol_type *elfsym = (elf_symbol_type *) sym; + const elf_symbol_type *elfsym = (const elf_symbol_type *) sym; unsigned char st_other; if ((sym->flags & BSF_SYNTHETIC) == 0) diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index 8a5eea765c2..a9f43c43861 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -1638,14 +1638,15 @@ ppc_linux_core_read_description (struct gdbarch *gdbarch, gdbarch.h. This implementation is used for the ELFv2 ABI only. */ static void -ppc_elfv2_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym) +ppc_elfv2_elf_make_msymbol_special (const asymbol *sym, + struct minimal_symbol *msym) { if ((sym->flags & BSF_SYNTHETIC) != 0) /* ELFv2 synthetic symbols (the PLT stubs and the __glink_PLTresolve trampoline) do not have a local entry point. */ return; - elf_symbol_type *elf_sym = (elf_symbol_type *)sym; + const elf_symbol_type *elf_sym = (const elf_symbol_type *)sym; /* If the symbol is marked as having a local entry point, set a target flag in the msymbol. We currently only support local entry point diff --git a/gdb/ppc64-tdep.c b/gdb/ppc64-tdep.c index 79bc4da71e2..5e758003db9 100644 --- a/gdb/ppc64-tdep.c +++ b/gdb/ppc64-tdep.c @@ -793,11 +793,12 @@ ppc64_convert_from_func_ptr_addr (struct gdbarch *gdbarch, from that symbol. */ void -ppc64_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym) +ppc64_elf_make_msymbol_special (const asymbol *sym, + struct minimal_symbol *msym) { if ((sym->flags & BSF_SYNTHETIC) != 0 && sym->udata.p != NULL) { - elf_symbol_type *elf_sym = (elf_symbol_type *) sym->udata.p; + const elf_symbol_type *elf_sym = (const elf_symbol_type *) sym->udata.p; msym->set_size (elf_sym->internal_elf_sym.st_size); } } diff --git a/gdb/ppc64-tdep.h b/gdb/ppc64-tdep.h index 7bea549dda0..5ad8841166d 100644 --- a/gdb/ppc64-tdep.h +++ b/gdb/ppc64-tdep.h @@ -31,6 +31,6 @@ extern CORE_ADDR ppc64_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ); -extern void ppc64_elf_make_msymbol_special (asymbol *, +extern void ppc64_elf_make_msymbol_special (const asymbol *, struct minimal_symbol *); #endif /* GDB_PPC64_TDEP_H */