From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id hAiVGEYIAGcvLwEAWB0awg (envelope-from ) for ; Fri, 04 Oct 2024 11:22:46 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=fmdr21rN; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4D43D1E355; Fri, 4 Oct 2024 11:22:46 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,URIBL_BLOCKED,URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 6CE891E05C for ; Fri, 4 Oct 2024 11:22:45 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AE6C23842584 for ; Fri, 4 Oct 2024 15:22:44 +0000 (GMT) Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id D4B323842FEB for ; Fri, 4 Oct 2024 15:21:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D4B323842FEB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D4B323842FEB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728055319; cv=none; b=r4FNmBaonP1XQElMes5KGFspO92fGHf0aM+6N7JVcUK2mU4utkLlr8NRddjzGAT9Bi+u7USkEhro+dNsrdQyEQqWYyDnF6BKE2AW6XpR7p8ayTtSzxYJx0YHznQHOzYbh/3djPgxvB6oRyLhEAYF7Y7WV/BG3kBo1+LCAo0L7DI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728055319; c=relaxed/simple; bh=6DIVbb2Ukajyuu8snlf8hT9YdiwERwQWjr/6c3u1CUg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=DfE9Veo8wTQwcH5xcxFThZ/Zyh5HrXL9DUSA9dEOKoseWxWrm9TrY4+HFE9yryt7NkHArGNKEkHHsfaPrnBZzgqq8uJb3pTSEtXMQTtXj1AHzo8XJgMLTHLeaXpg2q0CbJ0G1H6Bwde8pefgOW+wuhF6dbzZvaSgHhhBVCM5ULA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5c89bdb9019so2622291a12.0 for ; Fri, 04 Oct 2024 08:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728055315; x=1728660115; darn=sourceware.org; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=FVbOcukXPzpmCONlB82J9WXmg0LL2JdtyHRkQU3Oj5w=; b=fmdr21rN3eHoJizoqIfzmvF+QBl/obPTrQqSU0ukciSKW2gGaJzS4ocbCfWypSU4Eh pPeJRnm+gB+Ij8y69aFRT0bAFZl+INJkXV1KA1900+hKghYEcOmDLl4dJpIk0PCyouwL v0VQDp0kIXy0PHCtD0Cr9gZYfyoXps2/6MsxX88glVi9fUEDfMXX29s/hRkE/Q1Owh4T xFK560X90JTRHRVR1e0/X6uNeylBcPR669QWr2mfb7zFu9iJ0guh7TyOAcDCTtdJBc6P XADsSSu4ZTKEDSlMrrADLBIxaEGMucjsqNOKqiN8plZBrIPgsfOD1p77IyRY3fRnySL7 1UvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728055315; x=1728660115; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=FVbOcukXPzpmCONlB82J9WXmg0LL2JdtyHRkQU3Oj5w=; b=IlAcjFhACmSKs402L7251X2WTvONCB7q1H3mi31HXpJz+22Cmbda2zYN+XRRvrdXSU Hc1HfMD4abbxTFi6aElGqkp1hGYsilHYsD+i5uw5Bi8jPdKaQN/9ALf8/NUOu7RRCMG+ +JTUTuUMROE6P39SDUEplYLDSu+7EBPYPbI7vzdPsm/AQI+ymqsLpPk0kcEdi0FdTLFt AiCu1AnZz1Or86/YRTlsyxiCEW8t0qKmkiUtlzrVRnwk5iU7IuBABqozpLAYOd1PajYN l6wli9lvSjcQcrktZHZ8sPM5FtZ34pMb7Dg+Hb55DXrM5INHGSypHsoKs4ahuvTNxxYP AolA== X-Gm-Message-State: AOJu0YxEhizfhv87ejOkeH9+pKPfSzDPdE6wvjPSVWgOC5r+LoVtWbJa jqyKpIHKaw1g4xKkrohnvbXmIvZQzDS8CPGDid9txTfuprQmPnjFHfPvfw== X-Google-Smtp-Source: AGHT+IEcM/XH2peCJydVBUbTxte6bY+ZBOsXgisMu04olu6TWculAN0pTm5oSocDX+AaSQTG/s72nA== X-Received: by 2002:a17:907:268e:b0:a8a:58c5:78f1 with SMTP id a640c23a62f3a-a991bd0571fmr298664466b.11.1728055315100; Fri, 04 Oct 2024 08:21:55 -0700 (PDT) Received: from lancelot (dsl89-213-70-133.as15444.net. [89.213.70.133]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a992e80fea7sm3498366b.224.2024.10.04.08.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 08:21:54 -0700 (PDT) Received: from gaius by lancelot with local (Exim 4.96) (envelope-from ) id 1swk7t-00BREP-2q; Fri, 04 Oct 2024 16:21:53 +0100 From: Gaius Mulley To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v2] gdb/m2: add builtin procedure function ADR References: <875xq8x90o.fsf@localhost> <87v7y8ge0f.fsf@tromey.com> Date: Fri, 04 Oct 2024 16:21:53 +0100 In-Reply-To: <87v7y8ge0f.fsf@tromey.com> (Tom Tromey's message of "Fri, 04 Oct 2024 08:05:04 -0600") Message-ID: <87o73zq4fi.fsf_-_@localhost> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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~public-inbox=simark.ca@sourceware.org Tom Tromey writes: > I think a test case -- even just a single line in an existing test -- > would probably be good to have. Hi Tom, Many thanks for the review, here is v2 with a testcase. In v2 the only change is the new file gdb/testsuite/gdb.modula2/builtin-procedure-adr.exp. --- This patch introduces ADR to the Modula-2 language interface. It return the address of the parameter supplied. The patch also contains a dejagnu test for ADR. --- diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index cc1b69c6978..a175cde911a 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -18298,6 +18298,9 @@ All Modula-2 built-in procedures also return a result, described below. @item ABS(@var{n}) Returns the absolute value of @var{n}. +@item ADR(@var{n}) +Returns the memory address of @var{n}. + @item CAP(@var{c}) If @var{c} is a lower case letter, it returns its upper case equivalent, otherwise it returns its argument. diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index c12767533a8..db63aa5eb03 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -117,7 +117,7 @@ using namespace expr; %token TYPENAME %token SIZE CAP ORD HIGH ABS MIN_FUNC MAX_FUNC FLOAT_FUNC VAL CHR ODD TRUNC -%token TSIZE +%token TSIZE ADR %token INC DEC INCL EXCL /* The GDB scope operator */ @@ -191,6 +191,10 @@ exp : ABS '(' exp ')' { error (_("ABS function is not implemented")); } ; +exp : ADR '(' exp ')' + { pstate->wrap (); } + ; + exp : HIGH '(' exp ')' { pstate->wrap (); } ; @@ -699,6 +703,7 @@ static struct keyword keytab[] = {"IN", IN },/* Note space after IN */ {"AND", LOGICAL_AND}, {"ABS", ABS }, + {"ADR", ADR }, {"CHR", CHR }, {"DEC", DEC }, {"NOT", NOT }, diff --git a/gdb/testsuite/gdb.modula2/builtin-procedure-adr.exp b/gdb/testsuite/gdb.modula2/builtin-procedure-adr.exp new file mode 100644 index 00000000000..6588020cfc2 --- /dev/null +++ b/gdb/testsuite/gdb.modula2/builtin-procedure-adr.exp @@ -0,0 +1,32 @@ +# Copyright 2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the gdb testsuite. It contains tests for printing +# the elements of an unbounded array using the Modula-2 language mode of +# gdb. + +standard_testfile unbounded1.c + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug quiet}]} { + return -1 +} + +if {![runto main]} { + return +} + +gdb_test "set lang modula-2" ".*does not match.*" "switch to modula-2" + +gdb_test "print ADR(i)" ".*0x.*" "print the address of local variable i"