aboutsummaryrefslogtreecommitdiff
path: root/gdb/printcmd.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2011-02-24 07:39:48 +0000
committerJoel Brobecker <brobecker@gnat.com>2011-02-24 07:39:48 +0000
commita04b0428abc8564638c910f80b68a1cc7f14d3b2 (patch)
treebd34ea0a6e12ba8af1f16dcafebda64166737547 /gdb/printcmd.c
parent633ff500c5d9c76c0097985c4f6d83acdaaf08cb (diff)
downloadgdb-a04b0428abc8564638c910f80b68a1cc7f14d3b2.zip
gdb-a04b0428abc8564638c910f80b68a1cc7f14d3b2.tar.gz
gdb-a04b0428abc8564638c910f80b68a1cc7f14d3b2.tar.bz2
Revert the following change (not approved yet):
2011-02-21 Hui Zhu <teawater@gmail.com> * Makefile.in (HFILES_NO_SRCDIR): Add printcmd.h. * ax-gdb.c (gen_printf_expr_callback): New function. * ax-gdb.h (gen_printf_expr_callback): Forward declare. * ax-general.c (ax_memcpy): New function. (ax_print): Handle "printf". (ax_reqs): Ditto. * ax.h (ax_memcpy): Forward declare. * common/ax.def (invalid2): Removed. (printf): New entry. * printcmd.c (printcmd.h): New include. (string_printf): New function. (ui_printf): Removed. (printf_command): Remove static. Call string_printf. (eval_command): Call string_printf. * printcmd.h: New file. * tracepoint.c (validate_actionline, encode_actions_1): handle printf_command.
Diffstat (limited to 'gdb/printcmd.c')
-rw-r--r--gdb/printcmd.c38
1 files changed, 9 insertions, 29 deletions
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index ebca5a3..39ac8a8 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -49,7 +49,6 @@
#include "parser-defs.h"
#include "charset.h"
#include "arch-utils.h"
-#include "printcmd.h"
#include "cli/cli-utils.h"
#ifdef TUI
@@ -1962,9 +1961,10 @@ print_variable_and_value (const char *name, struct symbol *var,
fprintf_filtered (stream, "\n");
}
-void
-string_printf (char *arg, struct ui_file *stream, printf_callback callback,
- void *loc_v, void *aexpr_v)
+/* printf "printf format string" ARG to STREAM. */
+
+static void
+ui_printf (char *arg, struct ui_file *stream)
{
char *f = NULL;
char *s = arg;
@@ -1975,8 +1975,6 @@ string_printf (char *arg, struct ui_file *stream, printf_callback callback,
int nargs = 0;
int allocated_args = 20;
struct cleanup *old_cleanups;
- struct bp_location *loc = loc_v;
- struct agent_expr *aexpr = aexpr_v;
val_args = xmalloc (allocated_args * sizeof (struct value *));
old_cleanups = make_cleanup (free_current_contents, &val_args);
@@ -2295,42 +2293,26 @@ string_printf (char *arg, struct ui_file *stream, printf_callback callback,
/* Now, parse all arguments and evaluate them.
Store the VALUEs in VAL_ARGS. */
- if (callback)
- current_substring = substrings;
while (*s != '\0')
{
char *s1;
- s1 = s;
if (nargs == allocated_args)
val_args = (struct value **) xrealloc ((char *) val_args,
(allocated_args *= 2)
* sizeof (struct value *));
- if (callback)
- {
- if (nargs >= nargs_wanted)
- error (_("Wrong number of arguments for specified "
- "format-string"));
- callback (current_substring, &s1, loc, aexpr);
- current_substring += strlen (current_substring) + 1;
- }
- else
- val_args[nargs] = parse_to_comma_and_eval (&s1);
+ s1 = s;
+ val_args[nargs] = parse_to_comma_and_eval (&s1);
nargs++;
s = s1;
if (*s == ',')
s++;
}
- if (callback)
- callback (last_arg, NULL, loc, aexpr);
if (nargs != nargs_wanted)
error (_("Wrong number of arguments for specified format-string"));
- if (!stream)
- goto after_print;
-
/* Now actually print them. */
current_substring = substrings;
for (i = 0; i < nargs; i++)
@@ -2685,17 +2667,15 @@ string_printf (char *arg, struct ui_file *stream, printf_callback callback,
by default, which will warn here if there is no argument. */
fprintf_filtered (stream, last_arg, 0);
}
-
-after_print:
do_cleanups (old_cleanups);
}
/* Implement the "printf" command. */
-void
+static void
printf_command (char *arg, int from_tty)
{
- string_printf (arg, gdb_stdout, NULL, NULL, NULL);
+ ui_printf (arg, gdb_stdout);
}
/* Implement the "eval" command. */
@@ -2707,7 +2687,7 @@ eval_command (char *arg, int from_tty)
struct cleanup *cleanups = make_cleanup_ui_file_delete (ui_out);
char *expanded;
- string_printf (arg, ui_out, NULL, NULL, NULL);
+ ui_printf (arg, ui_out);
expanded = ui_file_xstrdup (ui_out, NULL);
make_cleanup (xfree, expanded);