aboutsummaryrefslogtreecommitdiff
path: root/gdb/f-valprint.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/f-valprint.c')
-rw-r--r--gdb/f-valprint.c138
1 files changed, 62 insertions, 76 deletions
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 55dbcc8..a193de2 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -44,7 +44,7 @@ LONGEST
f77_get_lowerbound (struct type *type)
{
if (type->bounds ()->low.kind () != PROP_CONST)
- error (_("Lower bound may not be '*' in F77"));
+ error (_ ("Lower bound may not be '*' in F77"));
return type->bounds ()->low.const_val ();
}
@@ -112,17 +112,16 @@ struct dimension_stats
class fortran_array_printer_impl : public fortran_array_walker_base_impl
{
public:
+
/* Constructor. TYPE is the array type being printed, ADDRESS is the
address in target memory for the object of TYPE being printed. VAL is
the GDB value (of TYPE) being printed. STREAM is where to print to,
RECOURSE is passed through (and prevents infinite recursion), and
OPTIONS are the printing control options. */
- explicit fortran_array_printer_impl (struct type *type,
- CORE_ADDR address,
- struct value *val,
- struct ui_file *stream,
- int recurse,
- const struct value_print_options *options)
+ explicit fortran_array_printer_impl (
+ struct type *type, CORE_ADDR address, struct value *val,
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
: m_elts (0),
m_val (val),
m_stream (stream),
@@ -131,7 +130,8 @@ public:
m_dimension (0),
m_nrepeats (0),
m_stats (0)
- { /* Nothing. */ }
+ { /* Nothing. */
+ }
/* Called while iterating over the array bounds. When SHOULD_CONTINUE is
false then we must return false, as we have reached the end of the
@@ -184,21 +184,19 @@ public:
index in the dimension currently being walked and LAST_P is true
only when this is the last element that will be processed in this
dimension. */
- void process_dimension (gdb::function_view<void (struct type *,
- int, bool)> walk_1,
- struct type *elt_type, LONGEST elt_off,
- LONGEST index, bool last_p)
+ void process_dimension (
+ gdb::function_view<void (struct type *, int, bool)> walk_1,
+ struct type *elt_type, LONGEST elt_off, LONGEST index, bool last_p)
{
size_t dim_indx = m_dimension - 1;
struct type *elt_type_prev = m_elt_type_prev;
LONGEST elt_off_prev = m_elt_off_prev;
- bool repeated = (m_options->repeat_count_threshold < UINT_MAX
- && elt_type_prev != nullptr
- && (m_elts + ((m_nrepeats + 1)
- * m_stats[dim_indx + 1].nelts)
- <= m_options->print_max)
- && dimension_contents_eq (m_val, elt_type,
- elt_off_prev, elt_off));
+ bool repeated
+ = (m_options->repeat_count_threshold < UINT_MAX
+ && elt_type_prev != nullptr
+ && (m_elts + ((m_nrepeats + 1) * m_stats[dim_indx + 1].nelts)
+ <= m_options->print_max)
+ && dimension_contents_eq (m_val, elt_type, elt_off_prev, elt_off));
if (repeated)
m_nrepeats++;
@@ -212,8 +210,7 @@ public:
annotate_elt_rep (nrepeats + 1);
gdb_printf (m_stream, "%p[<repeats %s times>%p]",
metadata_style.style ().ptr (),
- plongest (nrepeats + 1),
- nullptr);
+ plongest (nrepeats + 1), nullptr);
annotate_elt_rep_end ();
if (!repeated)
gdb_puts (" ", m_stream);
@@ -223,8 +220,8 @@ public:
for (LONGEST i = nrepeats; i > 0; i--)
{
maybe_print_array_index (m_stats[dim_indx].index_type,
- index - nrepeats + repeated,
- m_stream, m_options);
+ index - nrepeats + repeated, m_stream,
+ m_options);
walk_1 (elt_type_prev, elt_off_prev, repeated && i == 1);
}
@@ -255,8 +252,8 @@ public:
start of the parent object, where INDEX is the value of the element's
index in the dimension currently being walked and LAST_P is true only
when this is the last element to be processed in this dimension. */
- void process_element (struct type *elt_type, LONGEST elt_off,
- LONGEST index, bool last_p)
+ void process_element (struct type *elt_type, LONGEST elt_off, LONGEST index,
+ bool last_p)
{
size_t dim_indx = m_dimension - 1;
struct type *elt_type_prev = m_elt_type_prev;
@@ -281,8 +278,7 @@ public:
annotate_elt_rep (nrepeats + 1);
gdb_printf (m_stream, "%p[<repeats %s times>%p]",
metadata_style.style ().ptr (),
- plongest (nrepeats + 1),
- nullptr);
+ plongest (nrepeats + 1), nullptr);
annotate_elt_rep_end ();
}
else
@@ -294,8 +290,8 @@ public:
for (LONGEST i = nrepeats; i > 0; i--)
{
maybe_print_array_index (m_stats[dim_indx].index_type,
- index - i + 1,
- m_stream, m_options);
+ index - i + 1, m_stream,
+ m_options);
common_val_print (e_val, m_stream, m_recurse, m_options,
current_language);
if (i > 1)
@@ -328,13 +324,13 @@ public:
}
private:
+
/* Called to compare two VAL elements of ELT_TYPE at offsets OFFSET1
and OFFSET2 each. Handle subarrays recursively, because they may
have been sliced and we do not want to compare any memory contents
present between the slices requested. */
- bool
- dimension_contents_eq (const struct value *val, struct type *type,
- LONGEST offset1, LONGEST offset2)
+ bool dimension_contents_eq (const struct value *val, struct type *type,
+ LONGEST offset1, LONGEST offset2)
{
if (type->code () == TYPE_CODE_ARRAY
&& type->target_type ()->code () != TYPE_CODE_CHAR)
@@ -362,8 +358,7 @@ private:
return true;
}
else
- return value_contents_eq (val, offset1, val, offset2,
- type->length ());
+ return value_contents_eq (val, offset1, val, offset2, type->length ());
}
/* The number of elements printed so far. */
@@ -405,25 +400,17 @@ fortran_print_array (struct type *type, CORE_ADDR address,
const struct value *val,
const struct value_print_options *options)
{
- fortran_array_walker<fortran_array_printer_impl> p
- (type, address, (struct value *) val, stream, recurse, options);
+ fortran_array_walker<fortran_array_printer_impl> p (type, address,
+ (struct value *) val,
+ stream, recurse,
+ options);
p.walk ();
}
-
/* Decorations for Fortran. */
-static const struct generic_val_print_decorations f_decorations =
-{
- "(",
- ",",
- ")",
- ".TRUE.",
- ".FALSE.",
- "void",
- "{",
- "}"
-};
+static const struct generic_val_print_decorations f_decorations
+ = { "(", ",", ")", ".TRUE.", ".FALSE.", "void", "{", "}" };
/* See f-lang.h. */
@@ -458,8 +445,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
f77_get_dynamic_length_of_aggregate (type);
printstr (stream, ch_type, valaddr,
- type->length () / ch_type->length (), NULL, 0,
- options);
+ type->length () / ch_type->length (), NULL, 0, options);
}
break;
@@ -494,15 +480,13 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
/* For a pointer to char or unsigned char, also print the string
pointed to, unless pointer is null. */
- if (elttype->length () == 1
- && elttype->code () == TYPE_CODE_INT
- && (options->format == 0 || options->format == 's')
- && addr != 0)
+ if (elttype->length () == 1 && elttype->code () == TYPE_CODE_INT
+ && (options->format == 0 || options->format == 's') && addr != 0)
{
if (want_space)
gdb_puts (" ", stream);
- val_print_string (type->target_type (), NULL, addr, -1,
- stream, options);
+ val_print_string (type->target_type (), NULL, addr, -1, stream,
+ options);
}
return;
}
@@ -532,8 +516,9 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
= lookup_symbol (field_name, get_selected_block (nullptr),
VAR_DOMAIN, nullptr);
if (sym.symbol == nullptr)
- error (_("failed to find symbol for name list component %s"),
- field_name);
+ error (
+ _ ("failed to find symbol for name list component %s"),
+ field_name);
field = value_of_variable (sym.symbol, sym.block);
}
else
@@ -549,21 +534,21 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
gdb_puts (" = ", stream);
}
- common_val_print (field, stream, recurse + 1,
- options, current_language);
+ common_val_print (field, stream, recurse + 1, options,
+ current_language);
++printed_field;
}
- }
+ }
gdb_printf (stream, " )");
- break;
+ break;
case TYPE_CODE_BOOL:
if (options->format || options->output_format)
{
struct value_print_options opts = *options;
- opts.format = (options->format ? options->format
- : options->output_format);
+ opts.format
+ = (options->format ? options->format : options->output_format);
value_print_scalar_formatted (val, &opts, 0, stream);
}
else
@@ -614,8 +599,9 @@ info_common_command_for_block (const struct block *block, const char *comname,
gdb_assert (sym->aclass () == LOC_COMMON_BLOCK);
- if (comname && (!sym->linkage_name ()
- || strcmp (comname, sym->linkage_name ()) != 0))
+ if (comname
+ && (!sym->linkage_name ()
+ || strcmp (comname, sym->linkage_name ()) != 0))
continue;
if (*any_printed)
@@ -623,17 +609,16 @@ info_common_command_for_block (const struct block *block, const char *comname,
else
*any_printed = 1;
if (sym->print_name ())
- gdb_printf (_("Contents of F77 COMMON block '%s':\n"),
+ gdb_printf (_ ("Contents of F77 COMMON block '%s':\n"),
sym->print_name ());
else
- gdb_printf (_("Contents of blank COMMON block:\n"));
-
+ gdb_printf (_ ("Contents of blank COMMON block:\n"));
+
for (index = 0; index < common->n_entries; index++)
{
struct value *val = NULL;
- gdb_printf ("%s = ",
- common->contents[index]->print_name ());
+ gdb_printf ("%s = ", common->contents[index]->print_name ());
try
{
@@ -669,7 +654,7 @@ info_common_command (const char *comname, int from_tty)
first make sure that it is visible and if so, let
us display its contents. */
- fi = get_selected_frame (_("No frame selected"));
+ fi = get_selected_frame (_ ("No frame selected"));
/* The following is generally ripped off from stack.c's routine
print_frame_info(). */
@@ -677,7 +662,7 @@ info_common_command (const char *comname, int from_tty)
block = get_frame_block (fi, 0);
if (block == NULL)
{
- gdb_printf (_("No symbol table info available.\n"));
+ gdb_printf (_ ("No symbol table info available.\n"));
return;
}
@@ -694,16 +679,17 @@ info_common_command (const char *comname, int from_tty)
if (!values_printed)
{
if (comname)
- gdb_printf (_("No common block '%s'.\n"), comname);
+ gdb_printf (_ ("No common block '%s'.\n"), comname);
else
- gdb_printf (_("No common blocks.\n"));
+ gdb_printf (_ ("No common blocks.\n"));
}
}
void _initialize_f_valprint ();
+
void
_initialize_f_valprint ()
{
add_info ("common", info_common_command,
- _("Print out the values contained in a Fortran COMMON block."));
+ _ ("Print out the values contained in a Fortran COMMON block."));
}