summaryrefslogtreecommitdiff
path: root/gcc/dwarf2out.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2012-01-03 14:45:41 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2012-01-03 14:45:41 +0100
commitc067f6cfb3395947b3e01d5df10263cbdf13bb85 (patch)
treed355d49f5e1edd515b954e364af97891615a9371 /gcc/dwarf2out.c
parent5d2eb24bfa271a1ae3f9ec782792e4c39f1166db (diff)
downloadgcc-c067f6cfb3395947b3e01d5df10263cbdf13bb85.tar.gz
re PR pch/51722 (Options "-g3" or "-ggdb3" or "-g3 -gdwarf-2" and other "-g..level3" - internal compiler error)
PR pch/51722 * dwarf2out.c (dwarf2out_start_source_file, dwarf2out_define, dwarf2out_undef): Allocate e.info using ggc_strdup instead of xstrdup. (output_macinfo_op): Don't ggc_strdup fd->filename. (optimize_macinfo_range): Allocate grp_name using XALLOCAVEC, then ggc_strdup it. Don't free inc->info or cur->info. (output_macinfo): Don't free ref->info or file->info. From-SVN: r182845
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r--gcc/dwarf2out.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index b5537752b13..77c021bb00d 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -1,6 +1,6 @@
/* Output Dwarf2 format symbol table information from GCC.
Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+ 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
Contributed by Gary Funck (gary@intrepid.com).
Derived from DWARF 1 implementation of Ron Guilmette (rfg@monkeys.com).
@@ -20549,7 +20549,7 @@ dwarf2out_start_source_file (unsigned int lineno, const char *filename)
macinfo_entry e;
e.code = DW_MACINFO_start_file;
e.lineno = lineno;
- e.info = xstrdup (filename);
+ e.info = ggc_strdup (filename);
VEC_safe_push (macinfo_entry, gc, macinfo_table, &e);
}
}
@@ -20595,7 +20595,7 @@ dwarf2out_define (unsigned int lineno ATTRIBUTE_UNUSED,
}
e.code = DW_MACINFO_define;
e.lineno = lineno;
- e.info = xstrdup (buffer);;
+ e.info = ggc_strdup (buffer);
VEC_safe_push (macinfo_entry, gc, macinfo_table, &e);
}
}
@@ -20622,7 +20622,7 @@ dwarf2out_undef (unsigned int lineno ATTRIBUTE_UNUSED,
}
e.code = DW_MACINFO_undef;
e.lineno = lineno;
- e.info = xstrdup (buffer);
+ e.info = ggc_strdup (buffer);
VEC_safe_push (macinfo_entry, gc, macinfo_table, &e);
}
}
@@ -20662,8 +20662,6 @@ output_macinfo_op (macinfo_entry *ref)
{
case DW_MACINFO_start_file:
fd = lookup_filename (ref->info);
- if (fd->filename == ref->info)
- fd->filename = ggc_strdup (fd->filename);
file_num = maybe_emit_file (fd);
dw2_asm_output_data (1, DW_MACINFO_start_file, "Start new file");
dw2_asm_output_data_uleb128 (ref->lineno,
@@ -20802,8 +20800,8 @@ optimize_macinfo_range (unsigned int idx, VEC (macinfo_entry, gc) *files,
linebuf_len = strlen (linebuf);
/* The group name format is: wmN.[<encoded filename>.]<lineno>.<md5sum> */
- grp_name = XNEWVEC (char, 4 + encoded_filename_len + linebuf_len + 1
- + 16 * 2 + 1);
+ grp_name = XALLOCAVEC (char, 4 + encoded_filename_len + linebuf_len + 1
+ + 16 * 2 + 1);
memcpy (grp_name, DWARF_OFFSET_SIZE == 4 ? "wm4." : "wm8.", 4);
tail = grp_name + 4;
if (encoded_filename_len)
@@ -20824,14 +20822,13 @@ optimize_macinfo_range (unsigned int idx, VEC (macinfo_entry, gc) *files,
inc = VEC_index (macinfo_entry, macinfo_table, idx - 1);
inc->code = DW_MACRO_GNU_transparent_include;
inc->lineno = 0;
- inc->info = grp_name;
+ inc->info = ggc_strdup (grp_name);
if (*macinfo_htab == NULL)
*macinfo_htab = htab_create (10, htab_macinfo_hash, htab_macinfo_eq, NULL);
/* Avoid emitting duplicates. */
slot = htab_find_slot (*macinfo_htab, inc, INSERT);
if (*slot != NULL)
{
- free (CONST_CAST (char *, inc->info));
inc->code = 0;
inc->info = NULL;
/* If such an entry has been used before, just emit
@@ -20846,7 +20843,6 @@ optimize_macinfo_range (unsigned int idx, VEC (macinfo_entry, gc) *files,
i++)
{
cur->code = 0;
- free (CONST_CAST (char *, cur->info));
cur->info = NULL;
}
}
@@ -20909,7 +20905,6 @@ output_macinfo (void)
if (!VEC_empty (macinfo_entry, files))
{
macinfo_entry *file = VEC_last (macinfo_entry, files);
- free (CONST_CAST (char *, file->info));
VEC_pop (macinfo_entry, files);
}
break;
@@ -20939,10 +20934,6 @@ output_macinfo (void)
break;
}
output_macinfo_op (ref);
- /* For DW_MACINFO_start_file ref->info has been copied into files
- vector. */
- if (ref->code != DW_MACINFO_start_file)
- free (CONST_CAST (char *, ref->info));
ref->info = NULL;
ref->code = 0;
}
@@ -20976,7 +20967,6 @@ output_macinfo (void)
ref->lineno);
ASM_OUTPUT_LABEL (asm_out_file, label);
ref->code = 0;
- free (CONST_CAST (char *, ref->info));
ref->info = NULL;
dw2_asm_output_data (2, 4, "DWARF macro version number");
if (DWARF_OFFSET_SIZE == 8)
@@ -20989,7 +20979,6 @@ output_macinfo (void)
case DW_MACINFO_undef:
output_macinfo_op (ref);
ref->code = 0;
- free (CONST_CAST (char *, ref->info));
ref->info = NULL;
break;
default: