r346165 introduced a bug, where we would fail to parse the size of an
array if that size happened to match an existing die offset.
The logic was:
if (DWARFDIE count = die.GetReferencedDie(DW_AT_count))
num_elements = compute_vla_size(count);
else
num_elements = die.GetUsigned(DW_AT_count); // a fixed-size array
The problem with this logic was that GetReferencedDie did not take the
form class of the attribute into account, and would happily return a die
reference for any form, if its value happened to match some die.
As this behavior is inconsistent with how llvm's DWARFFormValue class
operates, I chose to fix the problem by making our version of this class
match the llvm behavior. For this to work, I had to add an explicit form
class check to the .apple_XXX tables parsing code, because they do
(incorrectly?) use data forms as die references.
DW_FORM_ref_sig8 is a type signature and shouldn't be returned as a valid DWARF DIE reference. In the .debug_types patch, this uses m_cu to get to the debug info and uses the type signature to DWARF offset map to return a valid .debug_info offset. If the DWARF is older where we have both .debug_info and .debug_types. we add the size of the .debug_info to the result since we concatenate the .debug_info and .debug_types and treat it as one large DWARF section