aboutsummaryrefslogtreecommitdiff
path: root/gdb/m2-exp.y
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-02-05 07:11:01 -0700
committerTom Tromey <tom@tromey.com>2021-02-05 07:11:01 -0700
commit1b30f42106cfd50ef1c020db2ca31f2fbe51ef8a (patch)
treef22193895e3e5c0683504ccc7a525459fccee6da /gdb/m2-exp.y
parente37d88e5e5666304d94b705af4301867df9bdab0 (diff)
downloadgdb-1b30f42106cfd50ef1c020db2ca31f2fbe51ef8a.zip
gdb-1b30f42106cfd50ef1c020db2ca31f2fbe51ef8a.tar.gz
gdb-1b30f42106cfd50ef1c020db2ca31f2fbe51ef8a.tar.bz2
Extract symbol-writing function from parsers
I noticed that several parsers shared the same code to write a symbol reference to an expression. This patch factors this code out into a new function. Regression tested on x86-64 Fedora 32. gdb/ChangeLog 2021-02-05 Tom Tromey <tom@tromey.com> * parser-defs.h (write_exp_symbol_reference): Declare. * parse.c (write_exp_symbol_reference): New function. * p-exp.y (variable): Use write_exp_symbol_reference. * m2-exp.y (variable): Use write_exp_symbol_reference. * f-exp.y (variable): Use write_exp_symbol_reference. * d-exp.y (PrimaryExpression): Use write_exp_symbol_reference. * c-exp.y (variable): Use write_exp_symbol_reference.
Diffstat (limited to 'gdb/m2-exp.y')
-rw-r--r--gdb/m2-exp.y30
1 files changed, 4 insertions, 26 deletions
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
index 717c6e6..68bae48 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp.y
@@ -561,37 +561,15 @@ variable: NAME
{ struct block_symbol sym;
struct field_of_this_result is_a_field_of_this;
+ std::string name = copy_name ($1);
sym
- = lookup_symbol (copy_name ($1).c_str (),
+ = lookup_symbol (name.c_str (),
pstate->expression_context_block,
VAR_DOMAIN,
&is_a_field_of_this);
- if (sym.symbol)
- {
- if (symbol_read_needs_frame (sym.symbol))
- pstate->block_tracker->update (sym);
-
- write_exp_elt_opcode (pstate, OP_VAR_VALUE);
- write_exp_elt_block (pstate, sym.block);
- write_exp_elt_sym (pstate, sym.symbol);
- write_exp_elt_opcode (pstate, OP_VAR_VALUE);
- }
- else
- {
- struct bound_minimal_symbol msymbol;
- std::string arg = copy_name ($1);
-
- msymbol =
- lookup_bound_minimal_symbol (arg.c_str ());
- if (msymbol.minsym != NULL)
- write_exp_msymbol (pstate, msymbol);
- else if (!have_full_symbols () && !have_partial_symbols ())
- error (_("No symbol table is loaded. Use the \"symbol-file\" command."));
- else
- error (_("No symbol \"%s\" in current context."),
- arg.c_str ());
- }
+ write_exp_symbol_reference (pstate, name.c_str (),
+ sym);
}
;