From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id EC2193858D20 for ; Fri, 20 Jan 2023 12:51:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EC2193858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674219107; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kkMfxO7BHr1AX6Ri9nYLF1MctPASMR6AeANDocOXkoo=; b=MRd0NpDzfZ3t8eO+9x7DwQ7wMp+VIrCKWxUVS7lAiMpBpGVzqhqW/C7jrCbqr4htGUUVyM DKjUli3jp95T5ccNK3/jn5Nl4p64I9ExHYK6/Dm6vBQJlXfkyDOwe6ZuY3Z/c//SYtkQ7a HQlb7Az1fhbk0V/ULYwo0VcNhXbyUdQ= Received: from mail-ua1-f71.google.com (mail-ua1-f71.google.com [209.85.222.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-316-gtOkaSq6Nqu0PjHhidQyqw-1; Fri, 20 Jan 2023 07:51:46 -0500 X-MC-Unique: gtOkaSq6Nqu0PjHhidQyqw-1 Received: by mail-ua1-f71.google.com with SMTP id p25-20020ab05859000000b006001ac8d2efso1597042uac.11 for ; Fri, 20 Jan 2023 04:51:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kkMfxO7BHr1AX6Ri9nYLF1MctPASMR6AeANDocOXkoo=; b=7iXm/WFgPBmQp2Pd3djniKVUVhvizo33HWcPJpfFdHM7yMqVr0dza6eZWP3F1d1vp8 aShLWf32YPXo3qd6DuItKw7rjEtLADDMuKIeqJvNY4BeX8oHCxVmreVA03f7Tkkdjg9V i+GVy3KJrPFXqpzTg3ZH6k+vdx3+oyarrGgFalko1U6bN2FVKshK66XwLHb11/+FJRkq IqRk/gg3CSHYBFwEp5V2EY2bzRPsAO8UfhPfWCeOWiJ6H1sqsD/fMzhVNvYmUTf3wjvu QyYwhjuo9mg98gqDyyJ7yi02C4NnJHxe/JBG46BrcmT6auJ1GSvqnfdJ4F6yvso/l0xd zgTg== X-Gm-Message-State: AFqh2krV0ROeDjLTRP5NFaVKWZjav5GPRbVQSMI95qoMSy29xpEMIT7F zP97hUqzfUnvXSGGEMbPoqyLkS7A3eN8ZNytxaSz2U4XINwTHqyokgBfVSfwd+/udUnBhfBlIYb yfVQoLWquRU2aZ2Ijj3Z5Mra6ewDCDAvnQ49/+PcsTFcAZwu3kvvN2vY/rT2PWsQlYndhbySQ4Q == X-Received: by 2002:ac5:cd42:0:b0:3da:6212:69b2 with SMTP id n2-20020ac5cd42000000b003da621269b2mr9417308vkm.14.1674219105941; Fri, 20 Jan 2023 04:51:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXuOpiKicqSqlTO2Zt+UyFfXbaGm3VI0RnizXjZo+Pf69R6nCciGS26wzDaeaRzW8llrGx+E2w== X-Received: by 2002:ac5:cd42:0:b0:3da:6212:69b2 with SMTP id n2-20020ac5cd42000000b003da621269b2mr9417284vkm.14.1674219105567; Fri, 20 Jan 2023 04:51:45 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id u24-20020a37ab18000000b006f9c2be0b4bsm9854747qke.135.2023.01.20.04.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 04:51:45 -0800 (PST) From: Andrew Burgess To: Simon Marchi via Gdb-patches , gdb-patches@sourceware.org Cc: Simon Marchi Subject: Re: [PATCH 1/2] gdb/testsuite: add test for negative subrange bounds with unsigned form In-Reply-To: <20230120050824.306976-1-simon.marchi@efficios.com> References: <20230120050824.306976-1-simon.marchi@efficios.com> Date: Fri, 20 Jan 2023 12:51:43 +0000 Message-ID: <87ilh1e5cw.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.8 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 List-Id: Simon Marchi via Gdb-patches writes: > I am looking at this code [1]: > > /* Normally, the DWARF producers are expected to use a signed > constant form (Eg. DW_FORM_sdata) to express negative bounds. > But this is unfortunately not always the case, as witnessed > with GCC, for instance, where the ambiguous DW_FORM_dataN form > is used instead. To work around that ambiguity, we treat > the bounds as signed, and thus sign-extend their values, when > the base type is signed. */ > negative_mask = > -((ULONGEST) 1 << (base_type->length () * TARGET_CHAR_BIT - 1)); > if (low.kind () == PROP_CONST > && !base_type->is_unsigned () && (low.const_val () & negative_mask)) > low.set_const_val (low.const_val () | negative_mask); > if (high.kind () == PROP_CONST > && !base_type->is_unsigned () && (high.const_val () & negative_mask)) > high.set_const_val (high.const_val () | negative_mask); > > Nothing in the testsuite seems to exercise it, as when I remove it, all > of gdb.dwarf2 still passes. And tests in other directories would be > compiler-dependent, so would rely on having a buggy compiler. > > Update gdb.dwarf2/subrange.exp to have a test for it. When removing the > code above, the new test fails with: > > ptype array_with_buggy_negative_bounds_type^M > type = array [240..244] of signed_byte^M > (gdb) FAIL: gdb.dwarf2/subrange.exp: ptype array_with_buggy_negative_bounds_type > > instead of the expected: > > ptype array_with_buggy_negative_bounds_type^M > type = array [-16..-12] of signed_byte^M > (gdb) PASS: gdb.dwarf2/subrange.exp: ptype array_with_buggy_negative_bounds_type > > [1] https://gitlab.com/gnutools/binutils-gdb/-/blob/5ea14aa4e53fa37f4ba4517497ed2c1e4c60dee2/gdb/dwarf2/read.c#L17681-17695 > > Change-Id: I1992a3ff0cb1e90fa8a9114dae6c591792f059c2 > --- > gdb/testsuite/gdb.dwarf2/subrange.exp | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/gdb/testsuite/gdb.dwarf2/subrange.exp b/gdb/testsuite/gdb.dwarf2/subrange.exp > index 72d7babc88e..8a8443f31a8 100644 > --- a/gdb/testsuite/gdb.dwarf2/subrange.exp > +++ b/gdb/testsuite/gdb.dwarf2/subrange.exp > @@ -28,6 +28,7 @@ Dwarf::assemble $asm_file { > compile_unit {{language @DW_LANG_Pascal83}} { > declare_labels byte_label typedef_label array_label > > + # A subrange's underlying type that is a typedef. > byte_label: base_type { > {name byte} > {encoding @DW_ATE_unsigned} > @@ -54,6 +55,28 @@ Dwarf::assemble $asm_file { > {name TByteArray} > {type :$array_label} > } > + > + # This subrange's underlying type is signed, but the bounds are > + # specified using a non-signed form. > + declare_labels signed_byte_label subrange_with_buggy_negative_bounds_label > + > + signed_byte_label: base_type { > + {name signed_byte} > + {encoding @DW_ATE_signed} > + {byte_size 1 DW_FORM_sdata} > + } > + > + # The bounds mean -16 to -12. > + subrange_with_buggy_negative_bounds_label: subrange_type { > + {lower_bound 0xf0 DW_FORM_udata} > + {upper_bound 0xf4 DW_FORM_udata} > + {type :$signed_byte_label} > + } > + > + DW_TAG_variable { > + {name subrange_with_buggy_negative_bounds_variable} > + {type :$subrange_with_buggy_negative_bounds_label} > + } > } > } > } > @@ -67,3 +90,5 @@ gdb_test_no_output "set language pascal" > > gdb_test "ptype TByteArray" \ > "type = array \\\[0\\.\\.191\\\] of byte" > +gdb_test "ptype subrange_with_buggy_negative_bounds_variable" \ > + "type = -16..-12" Should be "type = -16\\.\\.-12" Otherwise, looks good. Thanks, Andrew > -- > 2.39.1