+/* Parse print command format string into *FMTP and update *EXPP.
+ CMDNAME should name the current command. */
+
+void
+print_command_parse_format (const char **expp, const char *cmdname,
+ struct format_data *fmtp)
+{
+ const char *exp = *expp;
+
+ if (exp && *exp == '/')
+ {
+ exp++;
+ *fmtp = decode_format (&exp, last_format, 0);
+ validate_format (*fmtp, cmdname);
+ last_format = fmtp->format;
+ }
+ else
+ {
+ fmtp->count = 1;
+ fmtp->format = 0;
+ fmtp->size = 0;
+ fmtp->raw = 0;
+ }
+
+ *expp = exp;
+}
+
+/* Print VAL to console according to *FMTP, including recording it to
+ the history. */
+
+void
+print_value (struct value *val, const struct format_data *fmtp)
+{
+ struct value_print_options opts;
+ int histindex = record_latest_value (val);
+
+ annotate_value_history_begin (histindex, value_type (val));
+
+ printf_filtered ("$%d = ", histindex);
+
+ annotate_value_history_value ();
+
+ get_formatted_print_options (&opts, fmtp->format);
+ opts.raw = fmtp->raw;
+
+ print_formatted (val, fmtp->size, &opts, gdb_stdout);
+ printf_filtered ("\n");
+
+ annotate_value_history_end ();
+}
+