diff options
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r-- | gcc/dwarf2out.c | 73 |
1 files changed, 70 insertions, 3 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 659b119f4bd..de3d26fcb34 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -2426,6 +2426,22 @@ static unsigned pending_types; be enough for most typical programs. */ #define PENDING_TYPES_INCREMENT 64 +/* A pointer to the base of a list of incomplete types which might be + completed at some later time. */ + +static tree *incomplete_types_list; + +/* Number of elements currently allocated for the incomplete_types_list. */ +static unsigned incomplete_types_allocated; + +/* Number of elements of incomplete_types_list currently in use. */ +static unsigned incomplete_types; + +/* Size (in elements) of increments by which we may expand the incomplete + types list. Actually, a single hunk of space of this size should + be enough for most typical programs. */ +#define INCOMPLETE_TYPES_INCREMENT 64 + /* Record whether the function being analyzed contains inlined functions. */ static int current_function_has_inlines; #if 0 && defined (MIPS_DEBUGGING_INFO) @@ -2728,8 +2744,10 @@ static char debug_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES]; dyn_string_append (STR, NAME + 1); \ else \ { \ + char *newstr; \ + STRIP_NAME_ENCODING (newstr, NAME); \ dyn_string_append (STR, user_label_prefix); \ - dyn_string_append (STR, NAME); \ + dyn_string_append (STR, newstr); \ } \ } \ while (0) @@ -5117,6 +5135,11 @@ output_abbrev_section () fprintf (asm_out_file, "\t%s\t0,0\n", ASM_BYTE_OP); } + + /* We need to properly terminate the abbrev table for this + compilation unit, as per the standard, and not rely on + workarounds in e.g. gdb. */ + fprintf (asm_out_file, "\t%s\t0\n", ASM_BYTE_OP); } /* Output location description stack opcode's operands (if any). */ @@ -7165,7 +7188,8 @@ add_location_or_const_value_attribute (die, decl) rtl = DECL_INCOMING_RTL (decl); else if (! BYTES_BIG_ENDIAN && TREE_CODE (declared_type) == INTEGER_TYPE - && TYPE_SIZE (declared_type) <= TYPE_SIZE (passed_type)) + && (GET_MODE_SIZE (TYPE_MODE (declared_type)) + <= GET_MODE_SIZE (TYPE_MODE (passed_type)))) rtl = DECL_INCOMING_RTL (decl); } @@ -8033,6 +8057,39 @@ output_pending_types_for_scope (context_die) } } +/* Remember a type in the incomplete_types_list. */ + +static void +add_incomplete_type (type) + tree type; +{ + if (incomplete_types == incomplete_types_allocated) + { + incomplete_types_allocated += INCOMPLETE_TYPES_INCREMENT; + incomplete_types_list + = (tree *) xrealloc (incomplete_types_list, + sizeof (tree) * incomplete_types_allocated); + } + + incomplete_types_list[incomplete_types++] = type; +} + +/* Walk through the list of incomplete types again, trying once more to + emit full debugging info for them. */ + +static void +retry_incomplete_types () +{ + register tree type; + + while (incomplete_types) + { + --incomplete_types; + type = incomplete_types_list[incomplete_types]; + gen_type_die (type, comp_unit_die); + } +} + /* Generate a DIE to represent an inlined instance of an enumeration type. */ static void @@ -9024,7 +9081,13 @@ gen_struct_or_union_type_die (type, context_die) } } else - add_AT_flag (type_die, DW_AT_declaration, 1); + { + add_AT_flag (type_die, DW_AT_declaration, 1); + + /* We can't do this for function-local types, and we don't need to. */ + if (TREE_PERMANENT (type)) + add_incomplete_type (type); + } } /* Generate a DIE for a subroutine _type_. */ @@ -9993,6 +10056,10 @@ dwarf2out_finish () free (node); } + /* Walk through the list of incomplete types again, trying once more to + emit full debugging info for them. */ + retry_incomplete_types (); + /* Traverse the DIE tree and add sibling attributes to those DIE's that have children. */ add_sibling_attributes (comp_unit_die); |