Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb/m2: add builtin procedure function ADR
@ 2024-10-04 14:00 Gaius Mulley
  2024-10-04 14:05 ` Tom Tromey
  2024-10-04 14:25 ` [PATCH] " Eli Zaretskii
  0 siblings, 2 replies; 7+ messages in thread
From: Gaius Mulley @ 2024-10-04 14:00 UTC (permalink / raw)
  To: gdb-patches


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	 },

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-10-04 18:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-04 14:00 [PATCH] gdb/m2: add builtin procedure function ADR Gaius Mulley
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox