From: Gaius Mulley <gaiusmod2@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] gdb/m2: add builtin procedure function ADR
Date: Fri, 04 Oct 2024 15:00:55 +0100 [thread overview]
Message-ID: <875xq8x90o.fsf@localhost> (raw)
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.
---
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 <sval> 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<unop_addr_operation> (); }
+ ;
+
exp : HIGH '(' exp ')'
{ pstate->wrap<m2_unop_high_operation> (); }
;
@@ -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 },
next reply other threads:[~2024-10-04 14:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-04 14:00 Gaius Mulley [this message]
2024-10-04 14:05 ` Tom Tromey
2024-10-04 15:21 ` [PATCH v2] " Gaius Mulley
2024-10-04 18:14 ` Tom Tromey
2024-10-04 18:52 ` Gaius Mulley
2024-10-04 14:25 ` [PATCH] " Eli Zaretskii
2024-10-04 15:45 ` Gaius Mulley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875xq8x90o.fsf@localhost \
--to=gaiusmod2@gmail.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox