aboutsummaryrefslogtreecommitdiff
path: root/gdb/f-lang.c
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@embecosm.com>2022-01-19 21:55:10 +0000
committerMaciej W. Rozycki <macro@embecosm.com>2022-01-19 21:55:10 +0000
commit5d4c63a635546c77bfa7ebabf944cb1d93f5c6fe (patch)
tree24578c89a2818792cb8ded824abc1118d26edfc7 /gdb/f-lang.c
parent6b4338c868e96a549af44fdf17141f4eac77e225 (diff)
downloadgdb-5d4c63a635546c77bfa7ebabf944cb1d93f5c6fe.zip
gdb-5d4c63a635546c77bfa7ebabf944cb1d93f5c6fe.tar.gz
gdb-5d4c63a635546c77bfa7ebabf944cb1d93f5c6fe.tar.bz2
Respect `set print array-indexes' with Fortran arrays
Add `set print array-indexes' handling for Fortran arrays. Currently the setting is ignored and indices are never shown. Keep track of the most recent index handled so that any outstanding repeated elements printed when the limit set by `set print elements' is hit have the correct index shown. Output now looks like: (gdb) set print array-indexes on (gdb) print array_1d $1 = ((-2) = 1, (-1) = 1, (0) = 1, (1) = 1, (2) = 1) (gdb) set print repeats 4 (gdb) set print elements 12 (gdb) print array_2d $2 = ((-2) = ((-2) = 2, <repeats 5 times>) (-1) = ((-2) = 2, <repeats 5 times>) (0) = ((-2) = 2, (-1) = 2, ...) ...) (gdb) for a 5-element vector and a 5 by 5 array filled with the value of 2.
Diffstat (limited to 'gdb/f-lang.c')
-rw-r--r--gdb/f-lang.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index d181f38..eaeda88 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -263,7 +263,7 @@ public:
will be creating values for each element as we load them and then copy
them into the M_DEST value. Set a value mark so we can free these
temporary values. */
- void start_dimension (LONGEST nelts, bool inner_p)
+ void start_dimension (struct type *index_type, LONGEST nelts, bool inner_p)
{
if (inner_p)
{
@@ -330,7 +330,8 @@ public:
/* Create a lazy value in target memory representing a single element,
then load the element into GDB's memory and copy the contents into the
destination value. */
- void process_element (struct type *elt_type, LONGEST elt_off, bool last_p)
+ void process_element (struct type *elt_type, LONGEST elt_off,
+ LONGEST index, bool last_p)
{
copy_element_to_dest (value_at_lazy (elt_type, m_addr + elt_off));
}
@@ -368,7 +369,8 @@ public:
/* Extract an element of ELT_TYPE at offset (M_BASE_OFFSET + ELT_OFF)
from the content buffer of M_VAL then copy this extracted value into
the repacked destination value. */
- void process_element (struct type *elt_type, LONGEST elt_off, bool last_p)
+ void process_element (struct type *elt_type, LONGEST elt_off,
+ LONGEST index, bool last_p)
{
struct value *elt
= value_from_component (m_val, elt_type, (elt_off + m_base_offset));
@@ -1533,6 +1535,20 @@ fortran_structop_operation::evaluate (struct type *expect_type,
/* See language.h. */
void
+f_language::print_array_index (struct type *index_type, LONGEST index,
+ struct ui_file *stream,
+ const value_print_options *options) const
+{
+ struct value *index_value = value_from_longest (index_type, index);
+
+ fprintf_filtered (stream, "(");
+ value_print (index_value, stream, options);
+ fprintf_filtered (stream, ") = ");
+}
+
+/* See language.h. */
+
+void
f_language::language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const
{