From: Jakub Jelinek <jakub@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: "Joseph S. Myers" <joseph@codesourcery.com>,
Richard Henderson <rth@redhat.com>,
Tom Tromey <tromey@redhat.com>,
Jan Kratochvil <jkratoch@redhat.com>,
gcc-patches@gcc.gnu.org,
Roland McGrath <roland@redhat.com>
Subject: Re: [RFC PATCH] -grecord-gcc-switches (PR other/32998)
Date: Thu, 14 Jul 2011 09:48:00 -0000 [thread overview]
Message-ID: <20110714094148.GB2687@tyan-ft48-01.lab.bos.redhat.com> (raw)
In-Reply-To: <4E1DAC22.1050709@redhat.com>
On Wed, Jul 13, 2011 at 10:30:58AM -0400, Jason Merrill wrote:
> On 07/13/2011 10:06 AM, Jakub Jelinek wrote:
> >>>--- gcc/testsuite/lib/dg-pch.exp.jj 2011-01-03 18:58:03.000000000 +0100
> >>>+++ gcc/testsuite/lib/dg-pch.exp 2011-07-12 23:13:50.943670171 +0200
> >>>- dg-test -keep-output "./$bname$suffix" "$otherflags $flags" ""
> >>>+ dg-test -keep-output "./$bname$suffix" "-gno-record-gcc-switches $otherflags $flags" ""
> >>
> >It is only necessary if somebody wants to make -grecord-gcc-switches
> >the default (for bootstrap/regtest I've tweaked common.opt to do that
> >to test it better). PCH is a big mess and screws debuginfo in many ways,
> >in this case it was just small differences in DW_AT_producer, but
> >we have e.g. ICEs with PCH and -feliminate-dwarf-dups etc.
>
> Why would PCH change DW_AT_producer? Because we're restoring
> single_comp_unit_die from the PCH? Then perhaps we should set
> DW_AT_producer in output_comp_unit rather than gen_compile_unit_die.
output_comp_unit is too late, because at that point has the form been
finalized and sizes calculated etc. But at the start of dwarf2out_finish
it is possible.
Here is a PCH friendly variant of the patch which tries to set right
producer from the start, but early in dwarf2out_finish double checks
if PCH hasn't changed it and if it did, updates it back to the expected
string.
2011-07-14 Jakub Jelinek <jakub@redhat.com>
PR other/32998
* common.opt (grecord-gcc-switches, gno-record-gcc-switches): New
options.
* dwarf2out.c: Include opts.h.
(dchar_p): New typedef. Define heap VEC for it.
(producer_string): New variable.
(gen_producer_string): New function.
(gen_compile_unit_die): Use it.
(dwarf2out_finish): Fix up comp_unit_die () DW_AT_producer
if needed.
* Makefile.in (dwarf2out.o): Depend on $(OPTS_H).
--- gcc/common.opt.jj 2011-07-13 17:31:09.000000000 +0200
+++ gcc/common.opt 2011-07-14 10:36:40.000000000 +0200
@@ -2184,6 +2184,14 @@ ggdb
Common JoinedOrMissing
Generate debug information in default extended format
+gno-record-gcc-switches
+Common RejectNegative Var(dwarf_record_gcc_switches,0) Init(0)
+Don't record gcc command line switches in DWARF DW_AT_producer.
+
+grecord-gcc-switches
+Common RejectNegative Var(dwarf_record_gcc_switches,1)
+Record gcc command line switches in DWARF DW_AT_producer.
+
gstabs
Common JoinedOrMissing Negative(gstabs+)
Generate debug information in STABS format
--- gcc/dwarf2out.c.jj 2011-07-13 17:31:18.000000000 +0200
+++ gcc/dwarf2out.c 2011-07-14 11:04:50.000000000 +0200
@@ -94,6 +94,7 @@ along with GCC; see the file COPYING3.
#include "tree-pass.h"
#include "tree-flow.h"
#include "cfglayout.h"
+#include "opts.h"
static void dwarf2out_source_line (unsigned int, const char *, int, bool);
static rtx last_var_location_insn;
@@ -18108,13 +18109,125 @@ gen_ptr_to_mbr_type_die (tree type, dw_d
add_type_attribute (ptr_die, TREE_TYPE (type), 0, 0, context_die);
}
+typedef const char *dchar_p; /* For DEF_VEC_P. */
+DEF_VEC_P(dchar_p);
+DEF_VEC_ALLOC_P(dchar_p,heap);
+
+static char *producer_string;
+
+/* Return a heap allocated producer string including command line options
+ if -grecord-gcc-switches. */
+
+static char *
+gen_producer_string (void)
+{
+ size_t j;
+ VEC(dchar_p, heap) *switches = NULL;
+ const char *language_string = lang_hooks.name;
+ char *producer, *tail;
+ const char *p;
+ size_t len = dwarf_record_gcc_switches ? 0 : 3;
+ size_t plen = strlen (language_string) + 1 + strlen (version_string);
+
+ for (j = 1; dwarf_record_gcc_switches && j < save_decoded_options_count; j++)
+ switch (save_decoded_options[j].opt_index)
+ {
+ case OPT_o:
+ case OPT_d:
+ case OPT_dumpbase:
+ case OPT_dumpdir:
+ case OPT_auxbase:
+ case OPT_auxbase_strip:
+ case OPT_quiet:
+ case OPT_version:
+ case OPT_v:
+ case OPT_w:
+ case OPT_L:
+ case OPT_D:
+ case OPT_I:
+ case OPT_U:
+ case OPT_SPECIAL_unknown:
+ case OPT_SPECIAL_ignore:
+ case OPT_SPECIAL_program_name:
+ case OPT_SPECIAL_input_file:
+ case OPT_grecord_gcc_switches:
+ case OPT_gno_record_gcc_switches:
+ case OPT__output_pch_:
+ case OPT_fdiagnostics_show_location_:
+ case OPT_fdiagnostics_show_option:
+ case OPT____:
+ case OPT__sysroot_:
+ /* Ignore these. */
+ continue;
+ default:
+ if (save_decoded_options[j].orig_option_with_args_text[0] != '-')
+ continue;
+ switch (save_decoded_options[j].orig_option_with_args_text[1])
+ {
+ case 'M':
+ case 'i':
+ case 'W':
+ continue;
+ case 'n':
+ if (save_decoded_options[j].orig_option_with_args_text[2] == 'o')
+ continue;
+ break;
+ case 'f':
+ if (strncmp (save_decoded_options[j].orig_option_with_args_text
+ + 2, "dump", 4) == 0)
+ continue;
+ break;
+ default:
+ break;
+ }
+ VEC_safe_push (dchar_p, heap, switches,
+ save_decoded_options[j].orig_option_with_args_text);
+ len += strlen (save_decoded_options[j].orig_option_with_args_text) + 1;
+ break;
+ }
+
+ producer = XNEWVEC (char, plen + 1 + len + 1);
+ tail = producer;
+ sprintf (tail, "%s %s", language_string, version_string);
+ tail += plen;
+
+ if (!dwarf_record_gcc_switches)
+ {
+#ifdef MIPS_DEBUGGING_INFO
+ /* The MIPS/SGI compilers place the 'cc' command line options in the
+ producer string. The SGI debugger looks for -g, -g1, -g2, or -g3;
+ if they do not appear in the producer string, the debugger reaches
+ the conclusion that the object file is stripped and has no debugging
+ information. To get the MIPS/SGI debugger to believe that there is
+ debugging information in the object file, we add a -g to the producer
+ string. */
+ if (debug_info_level > DINFO_LEVEL_TERSE)
+ {
+ memcpy (tail, " -g", 3);
+ tail += 3;
+ }
+#endif
+ }
+
+ FOR_EACH_VEC_ELT (dchar_p, switches, j, p)
+ {
+ len = strlen (p);
+ *tail = ' ';
+ memcpy (tail + 1, p, len);
+ tail += len + 1;
+ }
+
+ *tail = '\0';
+ VEC_free (dchar_p, heap, switches);
+ return producer;
+}
+
/* Generate the DIE for the compilation unit. */
static dw_die_ref
gen_compile_unit_die (const char *filename)
{
dw_die_ref die;
- char producer[250];
const char *language_string = lang_hooks.name;
int language;
@@ -18128,20 +18241,9 @@ gen_compile_unit_die (const char *filena
add_comp_dir_attribute (die);
}
- sprintf (producer, "%s %s", language_string, version_string);
-
-#ifdef MIPS_DEBUGGING_INFO
- /* The MIPS/SGI compilers place the 'cc' command line options in the producer
- string. The SGI debugger looks for -g, -g1, -g2, or -g3; if they do
- not appear in the producer string, the debugger reaches the conclusion
- that the object file is stripped and has no debugging information.
- To get the MIPS/SGI debugger to believe that there is debugging
- information in the object file, we add a -g to the producer string. */
- if (debug_info_level > DINFO_LEVEL_TERSE)
- strcat (producer, " -g");
-#endif
-
- add_AT_string (die, DW_AT_producer, producer);
+ if (producer_string == NULL)
+ producer_string = gen_producer_string ();
+ add_AT_string (die, DW_AT_producer, producer_string);
/* If our producer is LTO try to figure out a common language to use
from the global list of translation units. */
@@ -21774,6 +21876,15 @@ dwarf2out_finish (const char *filename)
htab_t comdat_type_table;
unsigned int i;
+ /* PCH might result in DW_AT_producer string being restored from the
+ header compilation, fix it up if needed. */
+ dw_attr_ref producer = get_AT (comp_unit_die (), DW_AT_producer);
+ if (strcmp (AT_string (producer), producer_string) != 0)
+ {
+ struct indirect_string_node *node = find_AT_string (producer_string);
+ producer->dw_attr_val.v.val_str = node;
+ }
+
gen_scheduled_generic_parms_dies ();
gen_remaining_tmpl_value_param_die_attribute ();
--- gcc/Makefile.in.jj 2011-07-13 17:31:18.000000000 +0200
+++ gcc/Makefile.in 2011-07-14 10:36:40.000000000 +0200
@@ -2953,7 +2953,7 @@ dwarf2out.o : dwarf2out.c $(CONFIG_H) $(
$(GGC_H) $(EXCEPT_H) dwarf2asm.h $(TM_P_H) langhooks.h $(HASHTAB_H) \
gt-dwarf2out.h $(TARGET_H) $(CGRAPH_H) $(MD5_H) $(INPUT_H) $(FUNCTION_H) \
$(GIMPLE_H) $(TREE_PASS_H) $(TREE_FLOW_H) $(CFGLAYOUT_H) \
- tree-pretty-print.h $(COMMON_TARGET_H)
+ tree-pretty-print.h $(COMMON_TARGET_H) $(OPTS_H)
dwarf2cfi.o : dwarf2cfi.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
version.h $(RTL_H) $(FUNCTION_H) $(DWARF2_H) dwarf2asm.h dwarf2out.h \
$(GGC_H) $(TM_P_H) $(TARGET_H) $(TREE_PASS_H)
Jakub
next prev parent reply other threads:[~2011-07-14 9:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-13 0:17 Jakub Jelinek
2011-07-13 14:04 ` Jason Merrill
2011-07-13 14:34 ` Jakub Jelinek
2011-07-13 14:35 ` Jason Merrill
2011-07-14 9:48 ` Jakub Jelinek [this message]
2011-07-14 16:31 ` Jason Merrill
2011-07-14 16:32 ` Jakub Jelinek
2011-07-14 16:40 ` Jason Merrill
2011-07-21 20:22 ` Joseph S. Myers
2011-07-21 20:50 ` Jakub Jelinek
2011-07-21 21:01 ` Joseph S. Myers
2011-07-22 13:27 ` [PATCH] -grecord-gcc-switches (PR other/32998, take 2) Jakub Jelinek
2011-07-22 14:06 ` Joseph S. Myers
2011-07-22 14:11 ` [PATCH] -grecord-gcc-switches (PR other/32998, take 3) Jakub Jelinek
2011-07-22 20:43 ` Jason Merrill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110714094148.GB2687@tyan-ft48-01.lab.bos.redhat.com \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=jkratoch@redhat.com \
--cc=joseph@codesourcery.com \
--cc=roland@redhat.com \
--cc=rth@redhat.com \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).