aboutsummaryrefslogtreecommitdiff
path: root/gdb/ax-gdb.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-11-22 20:17:28 -0700
committerTom Tromey <tom@tromey.com>2017-12-08 10:23:43 -0700
commit8e481c3ba86e512b39b16b41de24e87a17f7d968 (patch)
treebfad22d6b383d85c5b82aa4356af50c81e7bd959 /gdb/ax-gdb.c
parent10af2a65c8891435d0d63411a3e694cc74c9447c (diff)
downloadgdb-8e481c3ba86e512b39b16b41de24e87a17f7d968.zip
gdb-8e481c3ba86e512b39b16b41de24e87a17f7d968.tar.gz
gdb-8e481c3ba86e512b39b16b41de24e87a17f7d968.tar.bz2
C++-ify parse_format_string
This replaces parse_format_string with a class, removing some constructors along the way. While doing this, I found that one argument to gen_printf is unused, so I removed it. Also, I am not completely sure, but the use of `release' in maint_agent_printf_command and parse_cmd_to_aexpr seems like it may leak expressions. Regression tested by the buildbot. ChangeLog 2017-12-08 Tom Tromey <tom@tromey.com> * printcmd.c (ui_printf): Update. Use std::vector. * common/format.h (struct format_piece): Add constructor. <string>: Now const. (class format_pieces): New class. (parse_format_string, free_format_pieces) (free_format_pieces_cleanup): Remove. * common/format.c (format_pieces::format_pieces): Rename from parse_format_string. Update. (free_format_pieces, free_format_pieces_cleanup): Remove. * breakpoint.c (parse_cmd_to_aexpr): Update. Use std::vector. * ax-gdb.h (gen_printf): Remove argument. * ax-gdb.c (gen_printf): Remove "frags" argument. (maint_agent_printf_command): Update. Use std::vector. gdbserver/ChangeLog 2017-12-08 Tom Tromey <tom@tromey.com> * ax.c (ax_printf): Update.
Diffstat (limited to 'gdb/ax-gdb.c')
-rw-r--r--gdb/ax-gdb.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 5027f6a..5a2a0a0 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -2541,7 +2541,6 @@ agent_expr_up
gen_printf (CORE_ADDR scope, struct gdbarch *gdbarch,
CORE_ADDR function, LONGEST channel,
const char *format, int fmtlen,
- struct format_piece *frags,
int nargs, struct expression **exprs)
{
agent_expr_up ax (new agent_expr (gdbarch, scope));
@@ -2681,12 +2680,8 @@ agent_eval_command (const char *exp, int from_tty)
static void
maint_agent_printf_command (const char *cmdrest, int from_tty)
{
- struct cleanup *old_chain = 0;
- struct expression *argvec[100];
struct frame_info *fi = get_current_frame (); /* need current scope */
const char *format_start, *format_end;
- struct format_piece *fpieces;
- int nargs;
/* We don't deal with overlay debugging at the moment. We need to
think more carefully about this. If you copy this code into
@@ -2705,9 +2700,7 @@ maint_agent_printf_command (const char *cmdrest, int from_tty)
format_start = cmdrest;
- fpieces = parse_format_string (&cmdrest);
-
- old_chain = make_cleanup (free_format_pieces_cleanup, &fpieces);
+ format_pieces fpieces (&cmdrest);
format_end = cmdrest;
@@ -2723,15 +2716,14 @@ maint_agent_printf_command (const char *cmdrest, int from_tty)
cmdrest++;
cmdrest = skip_spaces (cmdrest);
- nargs = 0;
+ std::vector<struct expression *> argvec;
while (*cmdrest != '\0')
{
const char *cmd1;
cmd1 = cmdrest;
expression_up expr = parse_exp_1 (&cmd1, 0, (struct block *) 0, 1);
- argvec[nargs] = expr.release ();
- ++nargs;
+ argvec.push_back (expr.release ());
cmdrest = cmd1;
if (*cmdrest == ',')
++cmdrest;
@@ -2742,14 +2734,13 @@ maint_agent_printf_command (const char *cmdrest, int from_tty)
agent_expr_up agent = gen_printf (get_frame_pc (fi), get_current_arch (),
0, 0,
format_start, format_end - format_start,
- fpieces, nargs, argvec);
+ argvec.size (), argvec.data ());
ax_reqs (agent.get ());
ax_print (gdb_stdout, agent.get ());
/* It would be nice to call ax_reqs here to gather some general info
about the expression, and then print out the result. */
- do_cleanups (old_chain);
dont_repeat ();
}