diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-11-08 16:06:06 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-11-16 16:27:33 -0500 |
commit | 7f74204ad972f6c0d0ff846af9f1f2f7e76fa5c5 (patch) | |
tree | 931058a66870fbfcdcde3b48240b2e6beb9f4cc7 /gdb | |
parent | a7fd11862703e45d2774981a4888bc127d473b06 (diff) | |
download | binutils-gdb-7f74204ad972f6c0d0ff846af9f1f2f7e76fa5c5.tar.gz |
gdb: fix length of array view returned by some value_contents functions
In commit 50888e42dcd3 ("gdb: change functions returning value contents
to use gdb::array_view"), I believe I made a mistake with the length of
the array views returned by some functions. All functions return a view
of `TYPE_LENGTH (value_type (type))` length. This is not correct when
the value's enclosing type is larger than the value's type. In that
case, the value's contents buffer is of the size of the enclosing type,
and the value's actual contents is a slice of that (as returned by
value_contents). So, functions value_contents_all_raw,
value_contents_for_printing and value_contents_for_printing_const are
not correct. Since they are meant to return the value's contents buffer
as a whole, they should have the size of the enclosing type.
There is nothing that uses the returned array view size at the moment,
so this didn't cause a problem. But it became apparent when trying to
adjust some callers.
Change-Id: Ib4e8837e1069111d2b2784d3253d5f3002419e68
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/value.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gdb/value.c b/gdb/value.c index 10edf3bb931..7649b029f91 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1164,7 +1164,7 @@ value_contents_all_raw (struct value *value) { allocate_value_contents (value); - ULONGEST length = TYPE_LENGTH (value_type (value)); + ULONGEST length = TYPE_LENGTH (value_enclosing_type (value)); return gdb::make_array_view (value->contents.get (), length); } @@ -1250,7 +1250,7 @@ value_contents_for_printing (struct value *value) if (value->lazy) value_fetch_lazy (value); - ULONGEST length = TYPE_LENGTH (value_type (value)); + ULONGEST length = TYPE_LENGTH (value_enclosing_type (value)); return gdb::make_array_view (value->contents.get (), length); } @@ -1259,7 +1259,7 @@ value_contents_for_printing_const (const struct value *value) { gdb_assert (!value->lazy); - ULONGEST length = TYPE_LENGTH (value_type (value)); + ULONGEST length = TYPE_LENGTH (value_enclosing_type (value)); return gdb::make_array_view (value->contents.get (), length); } |