public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Two minor expression changes
@ 2022-12-19 18:17 Tom Tromey
  2022-12-19 18:17 ` [PATCH 1/2] Convert exp_uses_objfile to a method of expression Tom Tromey
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Tom Tromey @ 2022-12-19 18:17 UTC (permalink / raw)
  To: gdb-patches

I found a couple of spots where the expression code could be slightly
modernized.

Tom



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

* [PATCH 1/2] Convert exp_uses_objfile to a method of expression
  2022-12-19 18:17 [PATCH 0/2] Two minor expression changes Tom Tromey
@ 2022-12-19 18:17 ` Tom Tromey
  2022-12-19 18:17 ` [PATCH 2/2] Use first_opcode in another spot Tom Tromey
  2023-01-03 22:50 ` [PATCH 0/2] Two minor expression changes Lancelot SIX
  2 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2022-12-19 18:17 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes the exp_uses_objfile function to be a method of
'expression'.
---
 gdb/eval.c        |  9 +++++++++
 gdb/expression.h  |  5 +++++
 gdb/parse.c       | 12 ------------
 gdb/parser-defs.h |  2 --
 gdb/printcmd.c    |  2 +-
 gdb/varobj.c      |  3 +--
 6 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/gdb/eval.c b/gdb/eval.c
index d0a4a16ceb5..a43eda54411 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -89,6 +89,15 @@ parse_to_comma_and_eval (const char **expp)
 
 /* See expression.h.  */
 
+bool
+expression::uses_objfile (struct objfile *objfile) const
+{
+  gdb_assert (objfile->separate_debug_objfile_backlink == nullptr);
+  return op->uses_objfile (objfile);
+}
+
+/* See expression.h.  */
+
 struct value *
 expression::evaluate (struct type *expect_type, enum noside noside)
 {
diff --git a/gdb/expression.h b/gdb/expression.h
index a56b1856cda..47626b3cb8e 100644
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -214,6 +214,11 @@ struct expression
     op->dump (stream, 0);
   }
 
+  /* Return true if this expression uses OBJFILE (and will become
+     dangling when OBJFILE is unloaded), otherwise return false.
+     OBJFILE must not be a separate debug info file.  */
+  bool uses_objfile (struct objfile *objfile) const;
+
   /* Evaluate the expression.  EXPECT_TYPE is the context type of the
      expression; normally this should be nullptr.  NOSIDE controls how
      evaluation is performed.  */
diff --git a/gdb/parse.c b/gdb/parse.c
index bfd9de09a10..cccdb8f98d9 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -667,18 +667,6 @@ parser_fprintf (FILE *x, const char *y, ...)
   va_end (args);
 }
 
-/* Return rue if EXP uses OBJFILE (and will become dangling when
-   OBJFILE is unloaded), otherwise return false.  OBJFILE must not be
-   a separate debug info file.  */
-
-bool
-exp_uses_objfile (struct expression *exp, struct objfile *objfile)
-{
-  gdb_assert (objfile->separate_debug_objfile_backlink == NULL);
-
-  return exp->op->uses_objfile (objfile);
-}
-
 void _initialize_parse ();
 void
 _initialize_parse ()
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index ade3039ebb0..5fda49ce72c 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -421,7 +421,5 @@ extern bool fits_in_type (int n_sign, ULONGEST n, int type_bits,
 
 extern void parser_fprintf (FILE *, const char *, ...) ATTRIBUTE_PRINTF (2, 3);
 
-extern bool exp_uses_objfile (struct expression *exp, struct objfile *objfile);
-
 #endif /* PARSER_DEFS_H */
 
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 60921415abd..bbe8d6eb4b2 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2360,7 +2360,7 @@ clear_dangling_display_expressions (struct objfile *objfile)
 	}
 
       if (bl_objf == objfile
-	  || (d->exp != NULL && exp_uses_objfile (d->exp.get (), objfile)))
+	  || (d->exp != nullptr && d->exp->uses_objfile (objfile)))
 	{
 	  d->exp.reset ();
 	  d->block = NULL;
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 6ed5b7049bc..599dd3013a7 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -2412,8 +2412,7 @@ varobj_invalidate_if_uses_objfile (struct objfile *objfile)
 	    }
 	}
 
-      if (var->root->exp != nullptr
-	  && exp_uses_objfile (var->root->exp.get (), objfile))
+      if (var->root->exp != nullptr && var->root->exp->uses_objfile (objfile))
 	{
 	  /* The varobj's current expression references the objfile.  For
 	     globals and floating, it is possible that when we try to
-- 
2.38.1


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

* [PATCH 2/2] Use first_opcode in another spot
  2022-12-19 18:17 [PATCH 0/2] Two minor expression changes Tom Tromey
  2022-12-19 18:17 ` [PATCH 1/2] Convert exp_uses_objfile to a method of expression Tom Tromey
@ 2022-12-19 18:17 ` Tom Tromey
  2023-01-03 22:50 ` [PATCH 0/2] Two minor expression changes Lancelot SIX
  2 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2022-12-19 18:17 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I found one place that could use expression::first_opcode.
---
 gdb/printcmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index bbe8d6eb4b2..19bdcf28639 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1500,7 +1500,7 @@ set_command (const char *exp, int from_tty)
 {
   expression_up expr = parse_expression (exp);
 
-  switch (expr->op->opcode ())
+  switch (expr->first_opcode ())
     {
     case UNOP_PREINCREMENT:
     case UNOP_POSTINCREMENT:
-- 
2.38.1


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

* Re: [PATCH 0/2] Two minor expression changes
  2022-12-19 18:17 [PATCH 0/2] Two minor expression changes Tom Tromey
  2022-12-19 18:17 ` [PATCH 1/2] Convert exp_uses_objfile to a method of expression Tom Tromey
  2022-12-19 18:17 ` [PATCH 2/2] Use first_opcode in another spot Tom Tromey
@ 2023-01-03 22:50 ` Lancelot SIX
  2023-01-04 16:47   ` Tom Tromey
  2 siblings, 1 reply; 5+ messages in thread
From: Lancelot SIX @ 2023-01-03 22:50 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Hi,

I went through both patches and for what it is worth, they look good to
me.

Feel free to add
Reviewed-By: Lancelot Six <lancelot.six@amd.com>

Best,
Lancelot.

On Mon, Dec 19, 2022 at 11:17:30AM -0700, Tom Tromey via Gdb-patches wrote:
> I found a couple of spots where the expression code could be slightly
> modernized.
> 
> Tom
> 
> 

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

* Re: [PATCH 0/2] Two minor expression changes
  2023-01-03 22:50 ` [PATCH 0/2] Two minor expression changes Lancelot SIX
@ 2023-01-04 16:47   ` Tom Tromey
  0 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2023-01-04 16:47 UTC (permalink / raw)
  To: Lancelot SIX; +Cc: Tom Tromey, gdb-patches

Lancelot> I went through both patches and for what it is worth, they look good to
Lancelot> me.

Thank you.

Lancelot> Feel free to add
Lancelot> Reviewed-By: Lancelot Six <lancelot.six@amd.com>

I did this & I'm checking this in.

Tom

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

end of thread, other threads:[~2023-01-04 16:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-19 18:17 [PATCH 0/2] Two minor expression changes Tom Tromey
2022-12-19 18:17 ` [PATCH 1/2] Convert exp_uses_objfile to a method of expression Tom Tromey
2022-12-19 18:17 ` [PATCH 2/2] Use first_opcode in another spot Tom Tromey
2023-01-03 22:50 ` [PATCH 0/2] Two minor expression changes Lancelot SIX
2023-01-04 16:47   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).