diff options
author | Tom Tromey <tromey@adacore.com> | 2021-10-19 13:10:27 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2021-10-21 08:24:40 -0600 |
commit | 4d1795ac4dda0f824eae9fd3f810aeb80a993245 (patch) | |
tree | 62368bcb0292aa6fea105513a1d0bb60765f4713 /gdb/arm-netbsd-tdep.c | |
parent | ced10cb78d01652f9e1bb1d1e465327dfe1debaa (diff) | |
download | gdb-4d1795ac4dda0f824eae9fd3f810aeb80a993245.zip gdb-4d1795ac4dda0f824eae9fd3f810aeb80a993245.tar.gz gdb-4d1795ac4dda0f824eae9fd3f810aeb80a993245.tar.bz2 |
Fix latent Ada bug when accessing field offsets
The "add accessors for field (and call site) location" patch caused a
gdb crash when running the internal AdaCore testsuite. This turned
out to be a latent bug in ada-lang.c.
The immediate cause of the bug is that find_struct_field
unconditionally uses TYPE_FIELD_BITPOS. This causes an assert for a
dynamic type.
This patch fixes the problem by doing two things. First, it changes
find_struct_field to use a dummy value for the field offset in the
situation where the offset is not actually needed by the caller. This
works because the offset isn't used in any other way -- only as a
result.
Second, this patch assures that calls to find_struct_field use a
resolved type when the offset is needed. For
value_tag_from_contents_and_address, this is done by resolving the
type explicitly. In ada_value_struct_elt, this is done by passing
nullptr for the out parameters when they are not needed (the second
call in this function already uses a resolved type).
Note that, while we believe the parent field probably can't occur at a
variable offset, the patch still updates this code path, just in case.
I've updated an existing test case to reproduce the crash.
I'm checking this in.
Diffstat (limited to 'gdb/arm-netbsd-tdep.c')
0 files changed, 0 insertions, 0 deletions