8sa1-binutils-gdb/gdb/dwarf2
Andrew Burgess 702cf3f5df gdb: handle invalid DWARF when compilation unit is missing
Replace an abort call in process_psymtab_comp_unit with a real error,
and add a test to cover this case.  The case is question is when badly
formed DWARF is missing a DW_TAG_compile_unit, DW_TAG_partial_unit, or
DW_TAG_type_unit as its top level tag.

I then tested with --target_board=readnow and added additional code to
also validate the top-level tag in this case.

I added an assert that would trigger for the readnow case before I
added the fix.  I suspect there's lots of places where badly formed
DWARF could result in the builder being nullptr when it shouldn't be,
but I only added this one assert, as this is the one that would have
helped me in this case.

gdb/ChangeLog:

	* dwarf2/read.c (process_psymtab_comp_unit): Replace abort with an
	error.
	(process_full_comp_unit): Validate the top-level tag before
	processing the first DIE.
	(read_func_scope): Ensure we have a valid builder.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/dw2-missing-cu-tag.c: New file.
	* gdb.dwarf2/dw2-missing-cu-tag.exp: New file.
2021-03-22 14:34:53 +00:00
..
abbrev.c
abbrev.h
attribute.c
attribute.h
comp-unit.c Reimplement dwarf_unit_type_name 2021-03-18 12:08:41 -06:00
comp-unit.h
die.h
dwz.c
dwz.h
expr.c
expr.h
frame-tailcall.c
frame-tailcall.h
frame.c Introduce dwarf2/public.h 2021-03-20 17:23:40 -06:00
frame.h
index-cache.c
index-cache.h
index-common.c
index-common.h
index-write.c Change how DWARF index writer finds address map 2021-03-20 17:23:43 -06:00
index-write.h Introduce dwarf2/public.h 2021-03-20 17:23:40 -06:00
leb.c
leb.h
line-header.c
line-header.h
loc.c
loc.h
macro.c
macro.h
public.h Allow multiple partial symbol readers per objfile 2021-03-20 17:23:46 -06:00
read.c gdb: handle invalid DWARF when compilation unit is missing 2021-03-22 14:34:53 +00:00
read.h Add partial_symtabs parameter to psymtab construction functions 2021-03-20 17:23:45 -06:00
sect-names.h
section.c
section.h
stringify.c Reimplement dwarf_unit_type_name 2021-03-18 12:08:41 -06:00
stringify.h Reimplement dwarf_unit_type_name 2021-03-18 12:08:41 -06:00