]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb: handle case where type alignment is unknown
authorAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 12 May 2021 12:44:06 +0000 (13:44 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Mon, 7 Jun 2021 15:45:10 +0000 (16:45 +0100)
commita12a15e7c5ff9f3549dd185fa1acd5a9dddd001b
tree71278848c6d52c54c8d85799717efcb248721df9
parentecac8d1c14acba1fd20b99c2481d0cab5887e3b7
gdb: handle case where type alignment is unknown

It was spotted that if type_align returned 0 then it was possible to
trigger a divide by zero exception within GDB.  It turns out this will
only happen in an edge case where GDB is unable to figure out the
alignment of a field within a structure.

The attached test generates some non-standard, probably broken, DWARF,
that triggers this condition, and then fixes this issue by throwing an
exception when this case occurs.

gdb/ChangeLog:

PR gdb/27847
* amd64-tdep.c (amd64_has_unaligned_fields): Move call to
type_align, and spot case where the alignment is unknown.

gdb/testsuite/ChangeLog:

PR gdb/27847
* gdb.dwarf2/dw2-weird-type-len.c: New file.
* gdb.dwarf2/dw2-weird-type-len.exp: New file.
gdb/ChangeLog
gdb/amd64-tdep.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.dwarf2/dw2-weird-type-len.c [new file with mode: 0644]
gdb/testsuite/gdb.dwarf2/dw2-weird-type-len.exp [new file with mode: 0644]