]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Fix crash in value_print_array_elements
authorTom Tromey <tromey@adacore.com>
Tue, 27 Sep 2022 18:53:25 +0000 (12:53 -0600)
committerTom Tromey <tromey@adacore.com>
Fri, 21 Oct 2022 15:40:59 +0000 (09:40 -0600)
commite379f6521a9fbc65de8cd90a950e28d0ca522ae3
treead535756dd30530414241d77a7af18527068a7f6
parent6c849804cff9e251876f3edb64d44dabeadaa711
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.
gdb/testsuite/gdb.ada/packed_array.exp
gdb/valprint.c
gdb/value.c
gdb/value.h