/* Agent expression code for remote server.
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2009-2019 Free Software Foundation, Inc.
This file is part of GDB.
#include "server.h"
#include "ax.h"
-#include "format.h"
+#include "gdbsupport/format.h"
#include "tracepoint.h"
-#include "rsp-low.h"
+#include "gdbsupport/rsp-low.h"
static void ax_vdebug (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
va_start (ap, fmt);
vsprintf (buf, fmt, ap);
+#ifdef IN_PROCESS_AGENT
fprintf (stderr, PROG "/ax: %s\n", buf);
+#else
+ debug_printf (PROG "/ax: %s\n", buf);
+#endif
va_end (ap);
}
{
#define DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE) \
gdb_agent_op_ ## NAME = VALUE,
-#include "ax.def"
+#include "gdbsupport/ax.def"
#undef DEFOP
gdb_agent_op_last
};
{
"?undef?"
#define DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE) , # NAME
-#include "ax.def"
+#include "gdbsupport/ax.def"
#undef DEFOP
};
{
0
#define DEFOP(NAME, SIZE, DATA_SIZE, CONSUMED, PRODUCED, VALUE) , SIZE
-#include "ax.def"
+#include "gdbsupport/ax.def"
#undef DEFOP
};
#endif
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++)
break;
}
+ case size_t_arg:
+ {
+ size_t val = args[i];
+
+ printf (current_substring, val);
+ break;
+ }
+
case literal_piece:
/* Print a portion of the format string that has no
directives. Note that this will not include any
}
/* Maybe advance to the next argument. */
- if (fpieces[fp].argclass != literal_piece)
+ if (piece.argclass != literal_piece)
++i;
}
- free_format_pieces (fpieces);
fflush (stdout);
}