From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 09A8438654B5 for ; Thu, 29 Jul 2021 02:07:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 09A8438654B5 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 16T27Q2O013713 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jul 2021 22:07:31 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 16T27Q2O013713 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id CB88D1E4A3; Wed, 28 Jul 2021 22:07:26 -0400 (EDT) Subject: Re: [PATCH v2] guile: fix make-value with pointer type To: George Barrett , gdb-patches@sourceware.org References: From: Simon Marchi Message-ID: <5d3cf5e9-41bc-4d69-35b2-73a1256028ed@polymtl.ca> Date: Wed, 28 Jul 2021 22:07:26 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 29 Jul 2021 02:07:27 +0000 X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Thu, 29 Jul 2021 02:07:37 -0000 On 2021-06-06 3:56 p.m., George Barrett via Gdb-patches wrote: > Calling the `make-value' procedure with an integer value and a pointer > type for the #:type argument triggers a failed assertion in > `get_unsigned_type_max', as that function doesn't consider pointers to > be an unsigned type. This commit fixes the issue by adding a separate > code path for pointers. > > As previously suggested, range checking is done using a new helper > function in gdbtypes. Hi George, This LGTM, with a few nits noted below. > @@ -1931,6 +1931,22 @@ get_signed_type_minmax (struct type *type, LONGEST *min, LONGEST *max) > *max = ((ULONGEST) 1 << (n - 1)) - 1; > } > > +/* Store in *MAX the largest value representable by pointer type > + TYPE. */ > + > +void > +get_pointer_type_max (struct type *type, CORE_ADDR *max) > +{ Let's use the function's return value to return the max: CORE_ADDR get_pointer_type_max (struct type *type) I'd suggest changing get_unsigned_type_max the same way, as a separate patch. > @@ -558,6 +557,21 @@ vlscm_convert_typed_number (const char *func_name, int obj_arg_pos, SCM obj, > return value_from_longest (type, gdbscm_scm_to_longest (obj)); > } > } > + else if (type->code () == TYPE_CODE_PTR) > + { > + CORE_ADDR max; > + > + get_pointer_type_max (type, &max); > + if (!scm_is_unsigned_integer (obj, 0, max)) > + { > + *except_scmp > + = gdbscm_make_out_of_range_error (func_name, > + obj_arg_pos, obj, > + _("value out of range for type")); The indentaion of that last line is not correct, but I see that you just copied the code above. Can you make a follow-patch to fix them all? In this case, I would typically do: *except_scmp = gdbscm_make_out_of_range_error (func_name, obj_arg_pos, obj, _("value out of range for type")); Simon