summaryrefslogtreecommitdiff
path: root/gdb/f-valprint.c
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2023-02-10 23:49:19 +0000
committerMaciej W. Rozycki <macro@embecosm.com>2023-02-10 23:49:19 +0000
commita0c07915778486a950952139d27c01d4285b02b4 (patch)
tree4dec76630c699133cf45932f1aa6781bc7255a75 /gdb/f-valprint.c
parenta2fb245a4b81ffdc93a9c6e9ceddbfb323ac9bec (diff)
downloadbinutils-gdb-a0c07915778486a950952139d27c01d4285b02b4.tar.gz
GDB: Introduce limited array lengths while printing values
This commit introduces the idea of loading only part of an array in order to print it, what I call "limited length" arrays. The motivation behind this work is to make it possible to print slices of very large arrays, where very large means bigger than `max-value-size'. Consider this GDB session with the current GDB: (gdb) set max-value-size 100 (gdb) p large_1d_array value requires 400 bytes, which is more than max-value-size (gdb) p -elements 10 -- large_1d_array value requires 400 bytes, which is more than max-value-size notice that the request to print 10 elements still fails, even though 10 elements should be less than the max-value-size. With a patched version of GDB: (gdb) p -elements 10 -- large_1d_array $1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9...} So now the print has succeeded. It also has loaded `max-value-size' worth of data into value history, so the recorded value can be accessed consistently: (gdb) p -elements 10 -- $1 $2 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9...} (gdb) p $1 $3 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, <unavailable> <repeats 75 times>} (gdb) Accesses with other languages work similarly, although for Ada only C-style [] array element/dimension accesses use history. For both Ada and Fortran () array element/dimension accesses go straight to the inferior, bypassing the value history just as with C pointers. Co-Authored-By: Maciej W. Rozycki <macro@embecosm.com>
Diffstat (limited to 'gdb/f-valprint.c')
-rw-r--r--gdb/f-valprint.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 55dbcc8309f..b08613f9153 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -261,10 +261,20 @@ public:
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
- && value_contents_eq (m_val, elt_off_prev, m_val, elt_off,
- elt_type->length ()));
+ bool repeated = false;
+
+ if (m_options->repeat_count_threshold < UINT_MAX
+ && elt_type_prev != nullptr)
+ {
+ struct value *e_val = value_from_component (m_val, elt_type, elt_off);
+ struct value *e_prev = value_from_component (m_val, elt_type,
+ elt_off_prev);
+ repeated = ((value_entirely_available (e_prev)
+ && value_entirely_available (e_val)
+ && value_contents_eq (e_prev, e_val))
+ || (value_entirely_unavailable (e_prev)
+ && value_entirely_unavailable (e_val)));
+ }
if (repeated)
m_nrepeats++;
@@ -333,7 +343,7 @@ private:
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,
+ dimension_contents_eq (struct value *val, struct type *type,
LONGEST offset1, LONGEST offset2)
{
if (type->code () == TYPE_CODE_ARRAY
@@ -362,8 +372,16 @@ private:
return true;
}
else
- return value_contents_eq (val, offset1, val, offset2,
- type->length ());
+ {
+ struct value *e_val1 = value_from_component (val, type, offset1);
+ struct value *e_val2 = value_from_component (val, type, offset2);
+
+ return ((value_entirely_available (e_val1)
+ && value_entirely_available (e_val2)
+ && value_contents_eq (e_val1, e_val2))
+ || (value_entirely_unavailable (e_val1)
+ && value_entirely_unavailable (e_val2)));
+ }
}
/* The number of elements printed so far. */