From patchwork Fri Oct 4 14:00:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaius Mulley X-Patchwork-Id: 98391 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 BA558386D626 for ; Fri, 4 Oct 2024 14:01:19 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id 59F82385E011 for ; Fri, 4 Oct 2024 14:00:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 59F82385E011 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 59F82385E011 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::630 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728050461; cv=none; b=LMsKMTczoF5yt1S8znkwRemXGI6hzESCo6+TVJRY05Eqd3r/8g3OZYkJQuDtb51EPVuHhOz/kP8JWSYIJ/EO832RSuX6U6bN+vU74Qxi6xXG3dj2o85VSr2d5qX/Hb1K7WT9YZXTlzH2W8YyRb0kh3ndgScQwyCZORR/+pprxvM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728050461; c=relaxed/simple; bh=8/kbOrvUzshvEv+6iWAv/SltXJG+OjhbNhrEbUeHtBU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=RvxF8KfDHf4sfDMKS7xMObsfxYkyWtfPNuBLimZFZue6fPSx1UvEBTw5UoWfOLeQQrbel9ugl0AYgHYUltAoJNHPkZfUfIS2FLm4TiGD/R2Ni3mFKMOHJS8807k6o5BwKDB6O+5iyLZ7AueEVKsNpI/fMuPHIYcuLvPkJ5A3Oe4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a8a6d1766a7so325609666b.3 for ; Fri, 04 Oct 2024 07:00:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728050457; x=1728655257; darn=sourceware.org; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=LgSfUc6taJwO/YwTCOaxM0eeYg6lrObdZyOoGaXBn7I=; b=nQ4ArRUDVtEeurrkKwd8EcESPsLDQvXzFO/gI231mkge5t/9PtM/Yl0ihmWa+Pgp/K oh9LtdUH4bf301xWxpwsIOD5tyfTALD8xwAXJDccLs02J4JpIBzYjjJLnr6vo32/GPHx D1ESo95ouObC1P2FQx5EpkkrOXDaKKK602CAQMGLT1+C8U7RBxszMJxxp4705CViQunt NDHfakncadXXW1KodinquotEMk8WOgABpf0ui3ftRie5vv0P4LVp8eBsJALlmhPhW53x h7Yjd0FSiQvx08o4LJpeXxLBE9JIrEDerHZyD/WYihh8FZF2x79oMTGyfQgPX8LRz1Ss liBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728050457; x=1728655257; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LgSfUc6taJwO/YwTCOaxM0eeYg6lrObdZyOoGaXBn7I=; b=nTrg8Gzbk5G19j9tm4Qm9t3k2LmjTshemdHZazTGb4aJJwnVYO+WjPydcNNDpGk2bA W09RMlkVDgTAm2o5ft1EUgItj0F3htWXKC+d8hLEl9loueyFp7QYjXsFh283k4UaTaN0 IcUrbkIz/ljGcYyck3xDrB6OLF1IyVwnhajbwD8Ub70SQx6LtHKK74wIZvbQisLMSxr7 pg6kWzVQ8oXs82dSp+9INiHFxoAUu4YlujATe6+vIIGv/tAKpIAw6VbDGgANqXhwrg6x iLlBfkFldRf/bqn/C2xXzN09pDAxBs0INU976eLWSyPW/Po9SbmdedoZ3zeMvjcdBV4k aTnw== X-Gm-Message-State: AOJu0YxPvlHBFfbjhYN2kvV+TJOeL9SS8CqVxqkq6PmIdus9lTpR+u5P v8WcDtE2oHZfPQ5+BU5k1jDi80oCfOnshLZq+dKf725MHY0bL/mGNd4nrA== X-Google-Smtp-Source: AGHT+IGr1xFlJWo1sWpgf1Tgo5C2b9i5oVQOEB5X+dI2kFtvKkl6f41fnR2dyvSdDB3rPbtYIaH44Q== X-Received: by 2002:a17:907:e89:b0:a80:f6a9:c311 with SMTP id a640c23a62f3a-a991baaa055mr296886066b.0.1728050456610; Fri, 04 Oct 2024 07:00:56 -0700 (PDT) Received: from lancelot (dsl89-213-70-133.as15444.net. [89.213.70.133]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99104d5a27sm229793166b.213.2024.10.04.07.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 07:00:56 -0700 (PDT) Received: from gaius by lancelot with local (Exim 4.96) (envelope-from ) id 1swirX-005wnW-0T; Fri, 04 Oct 2024 15:00:55 +0100 From: Gaius Mulley To: gdb-patches@sourceware.org Subject: [PATCH] gdb/m2: add builtin procedure function ADR Date: Fri, 04 Oct 2024 15:00:55 +0100 Message-ID: <875xq8x90o.fsf@localhost> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org This patch introduces the procedure function ADR to the expression handling parser for the Modula-2 language interface. The procedure takes a parameter and returns the address of the parameter supplied. Tested on x86_64-linux. ChangeLog: * gdb/m2-exp.y (%token): Add ADR. (exp): New rule for ADR. (keytab): New entry for ADR. * gdb/doc/gdb.texinfo (Built-in Functions and Procedures): Add description for procedure function ADR. Reviewed-By: Eli Zaretskii 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 },