From patchwork Fri Mar 10 18:43:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 66250 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 BA6E13851C01 for ; Fri, 10 Mar 2023 18:44:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA6E13851C01 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678473892; bh=tfvK7FGWFZB17KYbP/ggqTVHrcnRVlyM5piDvagS5QA=; 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=Ym5/NeLo5x9dE+41R0owzZlDAC5JDwbylzTIBoT3GkZDwCV1W9A/JQRULH3DEdaMd 0NdXSFcTZoyr5Y+6r0ZSk8ai//2D9USiXfmJ2eawEalitJLV7LZTp18zKR9ELNuvMt yyCPRi7yp5KfiUxSlTZAThRBklT1o0IZKwzlBfcc= 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 E648E3858C1F for ; Fri, 10 Mar 2023 18:43:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E648E3858C1F Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-377-klqeu_wWOZWV0-GkP742HQ-1; Fri, 10 Mar 2023 13:43:35 -0500 X-MC-Unique: klqeu_wWOZWV0-GkP742HQ-1 Received: by mail-wm1-f70.google.com with SMTP id 4-20020a05600c024400b003eb2e295c05so2168398wmj.0 for ; Fri, 10 Mar 2023 10:43:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678473814; 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=tfvK7FGWFZB17KYbP/ggqTVHrcnRVlyM5piDvagS5QA=; b=nuo6aXIQBMFXkcf8ScEC0ijwMYzq++7/03U0/rQGTN/v97VbTZ+AplAvY4TsDTj9GA JjI0WoUrN4wk/nAe8nVTsm6l2Q4efbd4LqV2fndFquE1bq0n9lWIpBmTRPhy5tz5Kkjr aCmmQyjG3iI1LEL/RN72Mwc4D8nwxFPapKpqKCuMQ//K7EoHRqBC6TRI1A7NXKxxe1Yq rBN0fhE7VwxzGqXLz66xdN0va9ub/QwRJjGZvkTFNo4oaVg9L4R7axmhLutZ+bubW2KK DlOQmOueTOVfGxM5mcBGy1s7VIh11T/PVc6OtehHSRvEklW6W9eBkKWpA9psPoMDF7E7 pK9w== X-Gm-Message-State: AO0yUKUSGXgVrrFgXWFJQh0TKrwKO4RFk3oXAhbtZP/NDQUbPkzvjylK YOhw5ga5oYHX8Y3m7hupj3vm+xf8DyDJvpSUwqQ7LLf1vvK+yA9oL6frAbKiQAWJXjdNjitBCn1 G4kXq9C4QuvUi0oCZPB4rPCeVrtq4gZ7LXEXcAHC9qcNN/5S5xm5GnDgD6UjIjmGHPLNl+5TNzs JIiEXydQ== X-Received: by 2002:a05:600c:4fd1:b0:3db:15b1:fb28 with SMTP id o17-20020a05600c4fd100b003db15b1fb28mr3959801wmq.19.1678473814067; Fri, 10 Mar 2023 10:43:34 -0800 (PST) X-Google-Smtp-Source: AK7set9oNrJCBBbbQGHcmWfT7tWe3L2R71x+pjJpL1Sml/JMjocX9f8oHWn4cVRv16ZwEv55h3cYng== X-Received: by 2002:a05:600c:4fd1:b0:3db:15b1:fb28 with SMTP id o17-20020a05600c4fd100b003db15b1fb28mr3959781wmq.19.1678473813692; Fri, 10 Mar 2023 10:43:33 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id c3-20020a7bc843000000b003db0bb81b6asm658608wml.1.2023.03.10.10.43.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 10:43:32 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv3 8/9] gdbarch: make invalid=True the default for all Components Date: Fri, 10 Mar 2023 18:43:17 +0000 Message-Id: <8b949fcfa06701ff7188c657952b9c6dc70113ec.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" This commit switches the default value for the 'invalid' field from False to True. All components that previous set the invalid field to True explicitly have had the field removed. I think that True is a good choice for the default, this means that we now get the validity checks by default, and if anyone adds a new Component they need to make a choice to add an 'invalid=False' line and disable the validation. The flip side of this is that 'invalid=False' seems to be far more common than 'invalid=True'. But I don't see a huge problem with this, we shouldn't be aiming to reduce our typing, rather we should choose based on which is least likely to introduce bugs. I think assuming that we should do a validity check will achieve that. Some additional components need to have an 'invalid=False' line added to their definition, these are components that have a predefault value, which is sufficient; the tdep code doesn't need to replace this value if it doesn't want to. Without adding the 'invalid=False' these components would be considered to be invalid if they have not changed from their predefault value -- but the predefault is fine. There's no change in the generated code after this commit, so there will be no user visible changes after this commit. --- gdb/gdbarch_components.py | 27 +++++++++++++++------------ gdb/gdbarch_types.py | 6 +++--- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py index 57bbf8eb7b6..6cdf15b3910 100644 --- a/gdb/gdbarch_components.py +++ b/gdb/gdbarch_components.py @@ -81,10 +81,11 @@ # this string is the expression that should evaluate to true when the # field is invalid. # -# Otherwise, if "invalid" is True, then the generic validation -# function is used: the field is considered invalid it still contains -# its default value. This validation is what is used within the _p -# predicate function if the field has "predicate" set to True. +# Otherwise, if "invalid" is True (the default), then the generic +# validation function is used: the field is considered invalid it +# still contains its default value. This validation is what is used +# within the _p predicate function if the field has "predicate" set to +# True. # # Function and Method share: # @@ -201,6 +202,7 @@ Value( name="bfloat16_format", predefault="floatformats_bfloat16", printer="pformat (gdbarch, gdbarch->bfloat16_format)", + invalid=False, ) Value( @@ -215,6 +217,7 @@ Value( name="half_format", predefault="floatformats_ieee_half", printer="pformat (gdbarch, gdbarch->half_format)", + invalid=False, ) Value( @@ -229,6 +232,7 @@ Value( name="float_format", predefault="floatformats_ieee_single", printer="pformat (gdbarch, gdbarch->float_format)", + invalid=False, ) Value( @@ -243,6 +247,7 @@ Value( name="double_format", predefault="floatformats_ieee_double", printer="pformat (gdbarch, gdbarch->double_format)", + invalid=False, ) Value( @@ -257,6 +262,7 @@ Value( name="long_double_format", predefault="floatformats_ieee_double", printer="pformat (gdbarch, gdbarch->long_double_format)", + invalid=False, ) Value( @@ -278,6 +284,7 @@ One if `wchar_t' is signed, zero if unsigned. name="wchar_signed", predefault="-1", postdefault="1", + invalid=False, ) Method( @@ -320,6 +327,7 @@ addr_bit is the size of a target address as represented in gdb name="addr_bit", predefault="0", postdefault="gdbarch_ptr_bit (gdbarch)", + invalid=False, ) Value( @@ -341,6 +349,7 @@ and if Dwarf versions < 4 need to be supported. type="int", name="dwarf2_addr_size", postdefault="gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT", + invalid=False, ) Value( @@ -351,6 +360,7 @@ One if `char' acts like `signed char', zero if `unsigned char'. name="char_signed", predefault="-1", postdefault="1", + invalid=False, ) Function( @@ -423,7 +433,6 @@ Value( type="int", name="num_regs", predefault="-1", - invalid=True, ) Value( @@ -566,7 +575,6 @@ should never return nullptr. params=[("int", "regnr")], param_checks=["regnr >= 0", "regnr < gdbarch_num_cooked_regs (gdbarch)"], result_checks=["result != nullptr"], - invalid=True, ) Method( @@ -578,7 +586,6 @@ use "register_type". type="struct type *", name="register_type", params=[("int", "reg_nr")], - invalid=True, ) Method( @@ -913,7 +920,6 @@ Method( type="CORE_ADDR", name="skip_prologue", params=[("CORE_ADDR", "ip")], - invalid=True, ) Method( @@ -947,7 +953,6 @@ Function( type="int", name="inner_than", params=[("CORE_ADDR", "lhs"), ("CORE_ADDR", "rhs")], - invalid=True, ) Method( @@ -965,7 +970,6 @@ Return the breakpoint kind for this target based on *PCPTR. type="int", name="breakpoint_kind_from_pc", params=[("CORE_ADDR *", "pcptr")], - invalid=True, ) Method( @@ -1313,6 +1317,7 @@ Value( name="so_ops", predefault="&solib_target_so_ops", printer="host_address_to_string (gdbarch->so_ops)", + invalid=False, ) Method( @@ -1669,7 +1674,6 @@ BFD target to use when generating a core file. name="gcore_bfd_target", predicate=True, printer="pstring (gdbarch->gcore_bfd_target)", - invalid=True, ) Value( @@ -1713,7 +1717,6 @@ The maximum length of an instruction on this architecture in bytes. name="max_insn_length", predefault="0", predicate=True, - invalid=True, ) Method( diff --git a/gdb/gdbarch_types.py b/gdb/gdbarch_types.py index d40851d127f..910ec641bdc 100755 --- a/gdb/gdbarch_types.py +++ b/gdb/gdbarch_types.py @@ -46,7 +46,7 @@ class Component: predicate: bool = False, predefault: Optional[str] = None, postdefault: Optional[str] = None, - invalid: Union[bool, str] = False, + invalid: Union[bool, str] = True, params: Optional[List[Tuple[str, str]]] = None, param_checks: Optional[List[str]] = None, result_checks: Optional[List[str]] = None, @@ -97,7 +97,7 @@ class Value(Component): predicate: bool = False, predefault: Optional[str] = None, postdefault: Optional[str] = None, - invalid: Union[bool, str] = False, + invalid: Union[bool, str] = True, printer: Optional[str] = None, ): super().__init__( @@ -125,7 +125,7 @@ class Function(Component): predicate: bool = False, predefault: Optional[str] = None, postdefault: Optional[str] = None, - invalid: Union[bool, str] = False, + invalid: Union[bool, str] = True, printer: Optional[str] = None, param_checks: Optional[List[str]] = None, result_checks: Optional[List[str]] = None,