/* Agent expression code for remote server.
- Copyright (C) 2009-2015 Free Software Foundation, Inc.
+ Copyright (C) 2009-2018 Free Software Foundation, Inc.
This file is part of GDB.
of bytes in expression, a comma, and then the bytes. */
struct agent_expr *
-gdb_parse_agent_expr (char **actparm)
+gdb_parse_agent_expr (const char **actparm)
{
- char *act = *actparm;
+ const char *act = *actparm;
ULONGEST xlen;
struct agent_expr *aexpr;
/* Scan an agent expression for any evidence that the given PC is the
target of a jump bytecode in the expression. */
-int
+static int
is_goto_target (struct agent_expr *aexpr, int pc)
{
int i;
int nargs, ULONGEST *args)
{
const char *f = format;
- struct format_piece *fpieces;
- int i, fp;
- char *current_substring;
+ int i;
+ const char *current_substring;
int nargs_wanted;
ax_debug ("Printf of \"%s\" with %d args", format, nargs);
- fpieces = parse_format_string (&f);
+ format_pieces fpieces (&f);
nargs_wanted = 0;
- for (fp = 0; fpieces[fp].string != NULL; fp++)
- if (fpieces[fp].argclass != literal_piece)
+ for (auto &&piece : fpieces)
+ if (piece.argclass != literal_piece)
++nargs_wanted;
if (nargs != nargs_wanted)
error (_("Wrong number of arguments for specified format-string"));
i = 0;
- for (fp = 0; fpieces[fp].string != NULL; fp++)
+ for (auto &&piece : fpieces)
{
- current_substring = fpieces[fp].string;
+ current_substring = piece.string;
ax_debug ("current substring is '%s', class is %d",
- current_substring, fpieces[fp].argclass);
- switch (fpieces[fp].argclass)
+ current_substring, piece.argclass);
+ switch (piece.argclass)
{
case string_arg:
{
int j;
tem = args[i];
+ if (tem == 0)
+ {
+ printf (current_substring, "(null)");
+ break;
+ }
/* This is a %s argument. Find the length of the string. */
for (j = 0;; j++)
}
/* Maybe advance to the next argument. */
- if (fpieces[fp].argclass != literal_piece)
+ if (piece.argclass != literal_piece)
++i;
}
- free_format_pieces (fpieces);
fflush (stdout);
}