From patchwork Fri Mar 10 18:43:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 66249 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 3299838582AB for ; Fri, 10 Mar 2023 18:44:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3299838582AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678473892; bh=lkUq74InijU5uI6bxF5io4SFQ3wE9FjLLt8L0WNXZs8=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=X1hNxpqFDljjkMPYdr6cRhZHp2PG6KN24XyFf/zbJ5CiVNtfU6f4UZaHFQXe13XND fLCU3TlgR8+7INpr7TY92iGi8gLPfraSyyGhzIN8i8J8D8hQWW7eEffwznRuRexxRZ Xie56LngEAs1fX3rxjy7qTtKkWNioOAHaAJ9B4Fc= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 037D23858404 for ; Fri, 10 Mar 2023 18:43:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 037D23858404 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-675-x64ZWaorMtyl8Y0MZ4XX3A-1; Fri, 10 Mar 2023 13:43:30 -0500 X-MC-Unique: x64ZWaorMtyl8Y0MZ4XX3A-1 Received: by mail-wm1-f71.google.com with SMTP id j6-20020a05600c1c0600b003eaf882cb85so2320622wms.9 for ; Fri, 10 Mar 2023 10:43:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678473809; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lkUq74InijU5uI6bxF5io4SFQ3wE9FjLLt8L0WNXZs8=; b=3xhTsekQqdUVbHDtXyCDsCySnrJJnVia79qMTXmuhwLhFJxGngT0UTBS07VvpPrHFs fWHZsOYiGJF2p26B02qHMLLRFvejqW9hB4nSC/pTypfI0zI0XLI8tCG+0XDGHRkTtiOT rCP+HVPQBHt5QkUm/O5pdkwHovSc+aR4xIurMw1Oq/Pcm/jDL6HsxQhN6A/sKb8jPu4/ GebuEnK4DacOftQHxMwO/oifXNdiWn5H9W3HQVyiYzCJ3gPumvVj6U5kcEejvaSH4uOG wcQyDJ47WH81ZZJGDD6SG+bt/l23VZhI3kFtcUZgL0tNBeMVUwD9EktsFFe1VKERISJd /z3Q== X-Gm-Message-State: AO0yUKVJqLUe8BfoSnk7sIRlSHQR3TQJe//up7tln6WsE9DybTKBKz7k tIJRax9HYLKWMY+AJD4oubBNL6lQhMa8aPPzG+WRT8Eeon5e7U3yZbAXQ08OOWupn79eHucfGGk e4uMMk1t+IhHgEh1XV+Jzjq3wM595cl0pMpjMggYRVpvw+XkkNMeOcmqjNQAGRiYqlxWJOPURhf hZ2y2pmQ== X-Received: by 2002:a05:600c:4e0f:b0:3eb:3f2d:f22f with SMTP id b15-20020a05600c4e0f00b003eb3f2df22fmr3890128wmq.21.1678473808921; Fri, 10 Mar 2023 10:43:28 -0800 (PST) X-Google-Smtp-Source: AK7set/XYyiP3rpeC/tRSHVW4ip/fWOi49TMnYpwpJ8p247QeaTMlYBGXuIv5bnNz1CfsWzWfJkzaw== X-Received: by 2002:a05:600c:4e0f:b0:3eb:3f2d:f22f with SMTP id b15-20020a05600c4e0f00b003eb3f2df22fmr3890105wmq.21.1678473808577; Fri, 10 Mar 2023 10:43:28 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id u10-20020a7bcb0a000000b003e11ad0750csm569925wmj.47.2023.03.10.10.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 10:43:28 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv3 5/9] gdbarch: use predefault for more value components within gdbarch Date: Fri, 10 Mar 2023 18:43:14 +0000 Message-Id: <452847af3520c0a0ebad83a9ccf83da1d332abf4.1678473293.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" For some reason the following value components of gdbarch: bfloat16_format half_format float_format double_format long_double_format so_ops All use a postdefault but no predefault to set the default value for the component. As the postdefault values for these components are all constant pointers that don't depend on other fields within the gdbarch, then I don't see any reason why we couldn't use a predefault instead. So lets do that. --- gdb/gdbarch.c | 24 ++++++------------------ gdb/gdbarch_components.py | 12 ++++++------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index efd111eeabc..064afd7c226 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -53,15 +53,15 @@ struct gdbarch int long_bit = 4*TARGET_CHAR_BIT; int long_long_bit = 2*4*TARGET_CHAR_BIT; int bfloat16_bit = 2*TARGET_CHAR_BIT; - const struct floatformat ** bfloat16_format = 0; + const struct floatformat ** bfloat16_format = floatformats_bfloat16; int half_bit = 2*TARGET_CHAR_BIT; - const struct floatformat ** half_format = 0; + const struct floatformat ** half_format = floatformats_ieee_half; int float_bit = 4*TARGET_CHAR_BIT; - const struct floatformat ** float_format = 0; + const struct floatformat ** float_format = floatformats_ieee_single; int double_bit = 8*TARGET_CHAR_BIT; - const struct floatformat ** double_format = 0; + const struct floatformat ** double_format = floatformats_ieee_double; int long_double_bit = 8*TARGET_CHAR_BIT; - const struct floatformat ** long_double_format = 0; + const struct floatformat ** long_double_format = floatformats_ieee_double; int wchar_bit = 4*TARGET_CHAR_BIT; int wchar_signed = -1; gdbarch_floatformat_for_type_ftype *floatformat_for_type = default_floatformat_for_type; @@ -151,7 +151,7 @@ struct gdbarch gdbarch_single_step_through_delay_ftype *single_step_through_delay = nullptr; gdbarch_print_insn_ftype *print_insn = default_print_insn; gdbarch_skip_trampoline_code_ftype *skip_trampoline_code = generic_skip_trampoline_code; - const struct target_so_ops * so_ops = 0; + const struct target_so_ops * so_ops = &solib_target_so_ops; gdbarch_skip_solib_resolver_ftype *skip_solib_resolver = generic_skip_solib_resolver; gdbarch_in_solib_return_trampoline_ftype *in_solib_return_trampoline = generic_in_solib_return_trampoline; gdbarch_in_indirect_branch_thunk_ftype *in_indirect_branch_thunk = default_in_indirect_branch_thunk; @@ -296,24 +296,14 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of long_bit, invalid_p == 0 */ /* Skip verify of long_long_bit, invalid_p == 0 */ /* Skip verify of bfloat16_bit, invalid_p == 0 */ - if (gdbarch->bfloat16_format == 0) - gdbarch->bfloat16_format = floatformats_bfloat16; /* Skip verify of bfloat16_format, invalid_p == 0 */ /* Skip verify of half_bit, invalid_p == 0 */ - if (gdbarch->half_format == 0) - gdbarch->half_format = floatformats_ieee_half; /* Skip verify of half_format, invalid_p == 0 */ /* Skip verify of float_bit, invalid_p == 0 */ - if (gdbarch->float_format == 0) - gdbarch->float_format = floatformats_ieee_single; /* Skip verify of float_format, invalid_p == 0 */ /* Skip verify of double_bit, invalid_p == 0 */ - if (gdbarch->double_format == 0) - gdbarch->double_format = floatformats_ieee_double; /* Skip verify of double_format, invalid_p == 0 */ /* Skip verify of long_double_bit, invalid_p == 0 */ - if (gdbarch->long_double_format == 0) - gdbarch->long_double_format = floatformats_ieee_double; /* Skip verify of long_double_format, invalid_p == 0 */ /* Skip verify of wchar_bit, invalid_p == 0 */ if (gdbarch->wchar_signed == -1) @@ -419,8 +409,6 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of single_step_through_delay, has predicate. */ /* Skip verify of print_insn, invalid_p == 0 */ /* Skip verify of skip_trampoline_code, invalid_p == 0 */ - if (gdbarch->so_ops == 0) - gdbarch->so_ops = &solib_target_so_ops; /* Skip verify of so_ops, invalid_p == 0 */ /* Skip verify of skip_solib_resolver, invalid_p == 0 */ /* Skip verify of in_solib_return_trampoline, invalid_p == 0 */ diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py index 8576ccfaf2b..2cb700309fd 100644 --- a/gdb/gdbarch_components.py +++ b/gdb/gdbarch_components.py @@ -199,7 +199,7 @@ useful). Value( type="const struct floatformat **", name="bfloat16_format", - postdefault="floatformats_bfloat16", + predefault="floatformats_bfloat16", printer="pformat (gdbarch, gdbarch->bfloat16_format)", ) @@ -213,7 +213,7 @@ Value( Value( type="const struct floatformat **", name="half_format", - postdefault="floatformats_ieee_half", + predefault="floatformats_ieee_half", printer="pformat (gdbarch, gdbarch->half_format)", ) @@ -227,7 +227,7 @@ Value( Value( type="const struct floatformat **", name="float_format", - postdefault="floatformats_ieee_single", + predefault="floatformats_ieee_single", printer="pformat (gdbarch, gdbarch->float_format)", ) @@ -241,7 +241,7 @@ Value( Value( type="const struct floatformat **", name="double_format", - postdefault="floatformats_ieee_double", + predefault="floatformats_ieee_double", printer="pformat (gdbarch, gdbarch->double_format)", ) @@ -255,7 +255,7 @@ Value( Value( type="const struct floatformat **", name="long_double_format", - postdefault="floatformats_ieee_double", + predefault="floatformats_ieee_double", printer="pformat (gdbarch, gdbarch->long_double_format)", ) @@ -1316,7 +1316,7 @@ Value( comment="Vtable of solib operations functions.", type="const struct target_so_ops *", name="so_ops", - postdefault="&solib_target_so_ops", + predefault="&solib_target_so_ops", printer="host_address_to_string (gdbarch->so_ops)", )