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.