diff options
author | Tom Tromey <tromey@adacore.com> | 2022-09-27 12:53:25 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2022-10-21 09:40:59 -0600 |
commit | e379f6521a9fbc65de8cd90a950e28d0ca522ae3 (patch) | |
tree | ad535756dd30530414241d77a7af18527068a7f6 /gdb/value.h | |
parent | 6c849804cff9e251876f3edb64d44dabeadaa711 (diff) | |
download | gdb-e379f6521a9fbc65de8cd90a950e28d0ca522ae3.zip gdb-e379f6521a9fbc65de8cd90a950e28d0ca522ae3.tar.gz gdb-e379f6521a9fbc65de8cd90a950e28d0ca522ae3.tar.bz2 |
Fix crash in value_print_array_elements
A user noticed that gdb would crash when printing a packed array after
doing "set lang c". Packed arrays don't exist in C, but it's
occasionally useful to print things in C mode when working in a non-C
language -- this lets you see under the hood a little bit.
The bug here is that generic value printing does not handle packed
arrays at all. This patch fixes the bug by introducing a new function
to extract a value from a bit offset and width.
The new function includes a hack to avoid problems with some existing
test cases when using -fgnat-encodings=all. Cleaning up this code
looked difficult, and since "all" is effectively deprecated, I thought
it made sense to simply work around the problems.
Diffstat (limited to 'gdb/value.h')
-rw-r--r-- | gdb/value.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gdb/value.h b/gdb/value.h index d4b4f95..2d148ce 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -599,6 +599,12 @@ extern bool value_contents_eq (const struct value *val1, LONGEST offset1, const struct value *val2, LONGEST offset2, LONGEST length); +/* An overload of value_contents_eq that compares the entirety of both + values. */ + +extern bool value_contents_eq (const struct value *val1, + const struct value *val2); + /* Read LENGTH addressable memory units starting at MEMADDR into BUFFER, which is (or will be copied to) VAL's contents buffer offset by BIT_OFFSET bits. Marks value contents ranges as unavailable if @@ -687,6 +693,21 @@ extern struct value *value_from_history_ref (const char *, const char **); extern struct value *value_from_component (struct value *, struct type *, LONGEST); + +/* Create a new value by extracting it from WHOLE. TYPE is the type + of the new value. BIT_OFFSET and BIT_LENGTH describe the offset + and field width of the value to extract from WHOLE -- BIT_LENGTH + may differ from TYPE's length in the case where WHOLE's type is + packed. + + When the value does come from a non-byte-aligned offset or field + width, it will be marked non_lval. */ + +extern struct value *value_from_component_bitsize (struct value *whole, + struct type *type, + LONGEST bit_offset, + LONGEST bit_length); + extern struct value *value_at (struct type *type, CORE_ADDR addr); extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr); |