Commit c067f6cf by Jakub Jelinek Committed by Jakub Jelinek

re PR pch/51722 (Options "-g3" or "-ggdb3" or "-g3 -gdwarf-2" and other…

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
parent 5d2eb24b
2012-01-03 Jakub Jelinek <jakub@redhat.com>
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.
2012-01-03 Ira Rosen <irar@il.ibm.com> 2012-01-03 Ira Rosen <irar@il.ibm.com>
PR tree-optimization/51269 PR tree-optimization/51269
/* Output Dwarf2 format symbol table information from GCC. /* Output Dwarf2 format symbol table information from GCC.
Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 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. Free Software Foundation, Inc.
Contributed by Gary Funck (gary@intrepid.com). Contributed by Gary Funck (gary@intrepid.com).
Derived from DWARF 1 implementation of Ron Guilmette (rfg@monkeys.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) ...@@ -20549,7 +20549,7 @@ dwarf2out_start_source_file (unsigned int lineno, const char *filename)
macinfo_entry e; macinfo_entry e;
e.code = DW_MACINFO_start_file; e.code = DW_MACINFO_start_file;
e.lineno = lineno; e.lineno = lineno;
e.info = xstrdup (filename); e.info = ggc_strdup (filename);
VEC_safe_push (macinfo_entry, gc, macinfo_table, &e); VEC_safe_push (macinfo_entry, gc, macinfo_table, &e);
} }
} }
...@@ -20595,7 +20595,7 @@ dwarf2out_define (unsigned int lineno ATTRIBUTE_UNUSED, ...@@ -20595,7 +20595,7 @@ dwarf2out_define (unsigned int lineno ATTRIBUTE_UNUSED,
} }
e.code = DW_MACINFO_define; e.code = DW_MACINFO_define;
e.lineno = lineno; e.lineno = lineno;
e.info = xstrdup (buffer);; e.info = ggc_strdup (buffer);
VEC_safe_push (macinfo_entry, gc, macinfo_table, &e); VEC_safe_push (macinfo_entry, gc, macinfo_table, &e);
} }
} }
...@@ -20622,7 +20622,7 @@ dwarf2out_undef (unsigned int lineno ATTRIBUTE_UNUSED, ...@@ -20622,7 +20622,7 @@ dwarf2out_undef (unsigned int lineno ATTRIBUTE_UNUSED,
} }
e.code = DW_MACINFO_undef; e.code = DW_MACINFO_undef;
e.lineno = lineno; e.lineno = lineno;
e.info = xstrdup (buffer); e.info = ggc_strdup (buffer);
VEC_safe_push (macinfo_entry, gc, macinfo_table, &e); VEC_safe_push (macinfo_entry, gc, macinfo_table, &e);
} }
} }
...@@ -20662,8 +20662,6 @@ output_macinfo_op (macinfo_entry *ref) ...@@ -20662,8 +20662,6 @@ output_macinfo_op (macinfo_entry *ref)
{ {
case DW_MACINFO_start_file: case DW_MACINFO_start_file:
fd = lookup_filename (ref->info); fd = lookup_filename (ref->info);
if (fd->filename == ref->info)
fd->filename = ggc_strdup (fd->filename);
file_num = maybe_emit_file (fd); file_num = maybe_emit_file (fd);
dw2_asm_output_data (1, DW_MACINFO_start_file, "Start new file"); dw2_asm_output_data (1, DW_MACINFO_start_file, "Start new file");
dw2_asm_output_data_uleb128 (ref->lineno, dw2_asm_output_data_uleb128 (ref->lineno,
...@@ -20802,8 +20800,8 @@ optimize_macinfo_range (unsigned int idx, VEC (macinfo_entry, gc) *files, ...@@ -20802,8 +20800,8 @@ optimize_macinfo_range (unsigned int idx, VEC (macinfo_entry, gc) *files,
linebuf_len = strlen (linebuf); linebuf_len = strlen (linebuf);
/* The group name format is: wmN.[<encoded filename>.]<lineno>.<md5sum> */ /* The group name format is: wmN.[<encoded filename>.]<lineno>.<md5sum> */
grp_name = XNEWVEC (char, 4 + encoded_filename_len + linebuf_len + 1 grp_name = XALLOCAVEC (char, 4 + encoded_filename_len + linebuf_len + 1
+ 16 * 2 + 1); + 16 * 2 + 1);
memcpy (grp_name, DWARF_OFFSET_SIZE == 4 ? "wm4." : "wm8.", 4); memcpy (grp_name, DWARF_OFFSET_SIZE == 4 ? "wm4." : "wm8.", 4);
tail = grp_name + 4; tail = grp_name + 4;
if (encoded_filename_len) if (encoded_filename_len)
...@@ -20824,14 +20822,13 @@ optimize_macinfo_range (unsigned int idx, VEC (macinfo_entry, gc) *files, ...@@ -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 = VEC_index (macinfo_entry, macinfo_table, idx - 1);
inc->code = DW_MACRO_GNU_transparent_include; inc->code = DW_MACRO_GNU_transparent_include;
inc->lineno = 0; inc->lineno = 0;
inc->info = grp_name; inc->info = ggc_strdup (grp_name);
if (*macinfo_htab == NULL) if (*macinfo_htab == NULL)
*macinfo_htab = htab_create (10, htab_macinfo_hash, htab_macinfo_eq, NULL); *macinfo_htab = htab_create (10, htab_macinfo_hash, htab_macinfo_eq, NULL);
/* Avoid emitting duplicates. */ /* Avoid emitting duplicates. */
slot = htab_find_slot (*macinfo_htab, inc, INSERT); slot = htab_find_slot (*macinfo_htab, inc, INSERT);
if (*slot != NULL) if (*slot != NULL)
{ {
free (CONST_CAST (char *, inc->info));
inc->code = 0; inc->code = 0;
inc->info = NULL; inc->info = NULL;
/* If such an entry has been used before, just emit /* 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, ...@@ -20846,7 +20843,6 @@ optimize_macinfo_range (unsigned int idx, VEC (macinfo_entry, gc) *files,
i++) i++)
{ {
cur->code = 0; cur->code = 0;
free (CONST_CAST (char *, cur->info));
cur->info = NULL; cur->info = NULL;
} }
} }
...@@ -20909,7 +20905,6 @@ output_macinfo (void) ...@@ -20909,7 +20905,6 @@ output_macinfo (void)
if (!VEC_empty (macinfo_entry, files)) if (!VEC_empty (macinfo_entry, files))
{ {
macinfo_entry *file = VEC_last (macinfo_entry, files); macinfo_entry *file = VEC_last (macinfo_entry, files);
free (CONST_CAST (char *, file->info));
VEC_pop (macinfo_entry, files); VEC_pop (macinfo_entry, files);
} }
break; break;
...@@ -20939,10 +20934,6 @@ output_macinfo (void) ...@@ -20939,10 +20934,6 @@ output_macinfo (void)
break; break;
} }
output_macinfo_op (ref); 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->info = NULL;
ref->code = 0; ref->code = 0;
} }
...@@ -20976,7 +20967,6 @@ output_macinfo (void) ...@@ -20976,7 +20967,6 @@ output_macinfo (void)
ref->lineno); ref->lineno);
ASM_OUTPUT_LABEL (asm_out_file, label); ASM_OUTPUT_LABEL (asm_out_file, label);
ref->code = 0; ref->code = 0;
free (CONST_CAST (char *, ref->info));
ref->info = NULL; ref->info = NULL;
dw2_asm_output_data (2, 4, "DWARF macro version number"); dw2_asm_output_data (2, 4, "DWARF macro version number");
if (DWARF_OFFSET_SIZE == 8) if (DWARF_OFFSET_SIZE == 8)
...@@ -20989,7 +20979,6 @@ output_macinfo (void) ...@@ -20989,7 +20979,6 @@ output_macinfo (void)
case DW_MACINFO_undef: case DW_MACINFO_undef:
output_macinfo_op (ref); output_macinfo_op (ref);
ref->code = 0; ref->code = 0;
free (CONST_CAST (char *, ref->info));
ref->info = NULL; ref->info = NULL;
break; break;
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment