struct type *type, struct ui_file *stream,
enum language language)
{
- int first = 1, i;
-
- if (flags->raw)
+ if (flags->raw || TYPE_N_TEMPLATE_ARGUMENTS (type) == 0)
return;
- for (i = 0; i < TYPE_N_TEMPLATE_ARGUMENTS (type); ++i)
+ stream->wrap_here (4);
+ gdb_printf (stream, _("[with "));
+
+ for (int i = 0; i < TYPE_N_TEMPLATE_ARGUMENTS (type); ++i)
{
struct symbol *sym = TYPE_TEMPLATE_ARGUMENT (type, i);
- if (sym->loc_class () != LOC_TYPEDEF)
- continue;
-
- if (first)
- {
- stream->wrap_here (4);
- gdb_printf (stream, _("[with %s = "), sym->linkage_name ());
- first = 0;
- }
- else
+ if (i > 0)
{
gdb_puts (", ", stream);
stream->wrap_here (9);
- gdb_printf (stream, "%s = ", sym->linkage_name ());
}
- c_print_type (sym->type (), "", stream, -1, 0, language, flags);
+ gdb_printf (stream, "%ps = ",
+ styled_string (variable_name_style.style (),
+ sym->linkage_name ()));
+ if (sym->loc_class () == LOC_TYPEDEF)
+ c_print_type (sym->type (), "", stream, -1, 0, language, flags);
+ else
+ print_variable_value (sym, {}, stream, 0, language_def (language));
}
- if (!first)
- gdb_puts (_("] "), stream);
+ gdb_puts (_("] "), stream);
}
/* Use 'print_spaces', but take into consideration the
}
\f
-/* Print the value in stack frame FRAME of a variable specified by a
- struct symbol. NAME is the name to print; if NULL then VAR's print
- name will be used. STREAM is the ui_file on which to print the
- value. INDENT specifies the number of indent levels to print
- before printing the variable name. */
+/* See value.h. */
void
-print_variable_and_value (const char *name, struct symbol *var,
- const frame_info_ptr &frame,
- struct ui_file *stream, int indent)
+print_variable_value (symbol *var, const frame_info_ptr &frame,
+ ui_file *stream, int indent,
+ const language_defn *language)
{
-
- if (!name)
- name = var->print_name ();
-
- gdb_printf (stream, "%*s%ps = ", 2 * indent, "",
- styled_string (variable_name_style.style (), name));
-
try
{
struct value *val;
val = read_var_value (var, NULL, frame);
get_user_print_options (&opts);
opts.deref_ref = true;
- common_val_print_checked (val, stream, indent, &opts, current_language);
+ common_val_print_checked (val, stream, indent, &opts, language);
}
catch (const gdb_exception_error &except)
{
fprintf_styled (stream, metadata_style.style (),
- "<error reading variable %s (%s)>", name,
+ "<error reading variable: %s>",
except.what ());
}
+}
+
+/* See value.h. */
+
+void
+print_variable_and_value (const char *name, symbol *var,
+ const frame_info_ptr &frame,
+ ui_file *stream, int indent)
+{
+ if (name == nullptr)
+ name = var->print_name ();
+
+ gdb_printf (stream, "%*s%ps = ", 2 * indent, "",
+ styled_string (variable_name_style.style (), name));
+
+ print_variable_value (var, frame, stream, indent, current_language);
gdb_printf (stream, "\n");
}
if {!$have_pr_41736_fixed} { setup_xfail *-*-* }
gdb_test "print MP" "&S::f" "test value of MP in base_m"
+gdb_test "ptype/m *this" \
+ "type = struct Base.*with T = double, I = 23, P = $hex <a_global>, MP = &S::f.*" \
+ "print type of Base"
+
#
# Tests in Inner::inner_m.
#
"}"]
gdb_test "ptype var3" [multi_line \
- "type = struct template_var3<0, int, 11, float> \\\[with <unnamed1> = int, <unnamed3> = float\\\] {" \
+ "type = struct template_var3<0, int, 11, float> \\\[with <unnamed0> = 0, <unnamed1> = int, <unnamed2> = 11, <unnamed3> = float\\\] {" \
" <unnamed1> me;" \
" <unnamed3> me2;" \
"}"]
struct ui_file *stream,
const struct value_print_options *options);
+/* Print the value in stack frame FRAME of a variable specified by a
+ struct symbol. STREAM is the ui_file on which to print the value.
+ INDENT specifies the number of indent levels to print before
+ printing the variable name. LANGUAGE is the language to use for
+ printing. */
+
+extern void print_variable_value (symbol *var,
+ const frame_info_ptr &frame,
+ ui_file *stream, int indent,
+ const language_defn *language);
+
+/* Print the value in stack frame FRAME of a variable specified by a
+ struct symbol. NAME is the name to print; if NULL then VAR's print
+ name will be used. STREAM is the ui_file on which to print the
+ value. INDENT specifies the number of indent levels to print
+ before printing the variable name. */
+
extern void print_variable_and_value (const char *name,
- struct symbol *var,
+ symbol *var,
const frame_info_ptr &frame,
- struct ui_file *stream,
+ ui_file *stream,
int indent);
extern void typedef_print (struct type *type, struct symbol *news,