diff options
author | Tom Tromey <tromey@adacore.com> | 2022-12-19 11:14:02 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-01-04 09:46:58 -0700 |
commit | aa9bd4452873136e7406f68fc51e66ef5951190b (patch) | |
tree | 7ed6ccaf4c055065b09463b2c7083d04366d418a | |
parent | 4b9728bec157796478831972fc8d07306dd9dcde (diff) | |
download | gdb-aa9bd4452873136e7406f68fc51e66ef5951190b.zip gdb-aa9bd4452873136e7406f68fc51e66ef5951190b.tar.gz gdb-aa9bd4452873136e7406f68fc51e66ef5951190b.tar.bz2 |
Convert exp_uses_objfile to a method of expression
This changes the exp_uses_objfile function to be a method of
'expression'.
Reviewed-By: Lancelot Six <lancelot.six@amd.com>
-rw-r--r-- | gdb/eval.c | 9 | ||||
-rw-r--r-- | gdb/expression.h | 5 | ||||
-rw-r--r-- | gdb/parse.c | 12 | ||||
-rw-r--r-- | gdb/parser-defs.h | 2 | ||||
-rw-r--r-- | gdb/printcmd.c | 2 | ||||
-rw-r--r-- | gdb/varobj.c | 3 |
6 files changed, 16 insertions, 17 deletions
@@ -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 2e00da9..c314fc2 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 29d7bf1..2f7d580 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 3b69dee..1780d85 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 67a3400..13b979c 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 8470600..eb47eca 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 |