+ /* First see if we have it cached. */
+
+ if (is_ref_attr (attr))
+ {
+ unsigned int offset = dwarf2_get_ref_die_offset (attr);
+
+ this_type = get_die_type_at_offset (offset, cu->per_cu);
+ }
+ else if (attr->form == DW_FORM_sig8)
+ {
+ struct signatured_type *sig_type = DW_SIGNATURED_TYPE (attr);
+ struct dwarf2_cu *sig_cu;
+ unsigned int offset;
+
+ /* sig_type will be NULL if the signatured type is missing from
+ the debug info. */
+ if (sig_type == NULL)
+ error (_("Dwarf Error: Cannot find signatured DIE referenced from DIE "
+ "at 0x%x [in module %s]"),
+ die->offset, cu->objfile->name);
+
+ gdb_assert (sig_type->per_cu.from_debug_types);
+ offset = sig_type->offset + sig_type->type_offset;
+ this_type = get_die_type_at_offset (offset, &sig_type->per_cu);
+ }
+ else
+ {
+ dump_die_for_error (die);
+ error (_("Dwarf Error: Bad type attribute %s [in module %s]"),
+ dwarf_attr_name (attr->name), cu->objfile->name);
+ }
+
+ /* If not cached we need to read it in. */
+
+ if (this_type == NULL)
+ {
+ struct die_info *type_die;
+ struct dwarf2_cu *type_cu = cu;
+
+ type_die = follow_die_ref_or_sig (die, attr, &type_cu);
+ /* If the type is cached, we should have found it above. */
+ gdb_assert (get_die_type (type_die, type_cu) == NULL);
+ this_type = read_type_die_1 (type_die, type_cu);
+ }
+
+ /* If we still don't have a type use an error marker. */
+
+ if (this_type == NULL)