Convert c-exp.y to use operations

This converts the C parser to generate operations rather than
exp_elements.

One test needed a tweak in order to handle the different debugging
output.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* objc-lang.c (end_msglist): Create operations.
	* c-exp.y: Change parser to create operations.
	(write_destructor_name): Remove.
	(c_parse): Update.

gdb/testsuite/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

	* gdb.base/debug-expr.exp: Update expected dump output.
This commit is contained in:
Tom Tromey 2021-03-08 07:27:57 -07:00
parent c1299a2344
commit d182f27979
5 changed files with 371 additions and 310 deletions

View File

@ -1,3 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
* objc-lang.c (end_msglist): Create operations.
* c-exp.y: Change parser to create operations.
(write_destructor_name): Remove.
(c_parse): Update.
2021-03-08 Tom Tromey <tom@tromey.com>
* rust-exp.y: Create operations.

File diff suppressed because it is too large Load Diff

View File

@ -43,6 +43,7 @@
#include "infcall.h"
#include "valprint.h"
#include "cli/cli-utils.h"
#include "c-exp.h"
#include <ctype.h>
#include <algorithm>
@ -507,15 +508,20 @@ end_msglist (struct parser_state *ps)
char *p = msglist_sel;
CORE_ADDR selid;
std::vector<expr::operation_up> args = ps->pop_vector (val);
expr::operation_up target = ps->pop ();
selname_chain = sel->next;
msglist_len = sel->msglist_len;
msglist_sel = sel->msglist_sel;
selid = lookup_child_selector (ps->gdbarch (), p);
if (!selid)
error (_("Can't find selector \"%s\""), p);
write_exp_elt_longcst (ps, selid);
ps->push_new<expr::objc_msgcall_operation> (selid, std::move (target),
std::move (args));
xfree(p);
write_exp_elt_longcst (ps, val); /* Number of args */
xfree(sel);
return val;

View File

@ -1,3 +1,7 @@
2021-03-08 Tom Tromey <tom@tromey.com>
* gdb.base/debug-expr.exp: Update expected dump output.
2021-03-06 Tom Tromey <tom@tromey.com>
* lib/dwarf.exp (_handle_DW_FORM): Treat DW_FORM_GNU_ref_alt and

View File

@ -45,10 +45,10 @@ gdb_test_debug_expr "print /x {char\[4\]} array" \
# This caused gdb to output garbage and possibly segfault
gdb_test_debug_expr "print \"hello\"" \
".*OP_STRING\[^\r\n\]*Language-specific string type: 0.*\[\r\n\]\\$$decimal = \"hello\"" \
".*OP_STRING\[^\r\n\]*.*: ordinary string.*\[\r\n\]\\$$decimal = \"hello\"" \
"string evaluation with debug expr"
# An expression using a function call.
gdb_test_debug_expr "print call_me ( &val )" \
".*OP_FUNCALL\[^\r\n\]*Number of args: 1.*\[\r\n\]\\$$decimal = 0.*" \
".*OP_FUNCALL\[^\r\n\]*.*UNOP_ADDR.*\[\r\n\]\\$$decimal = 0.*" \
"function call expression"