public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: RFA: don't emit .debug_pub*
Date: Mon, 21 Jun 2010 22:56:00 -0000	[thread overview]
Message-ID: <m3r5k0f2o9.fsf@fleche.redhat.com> (raw)

Currently, GCC emits .debug_pubnames and .debug_pubtypes.
However, they are not used, except on Darwin.

GCC didn't even generate pubtypes (except on Darwin) until recently (4.5
maybe); and in any case a combination of historical bugginess, GDB
semantics, and lack of name canonicalization means that GDB is unlikely
to ever read these sections.

Also, to the best of my knowledge, no other program reads them.  (And
if a program does read them, it must do so defensively, because (1) they
are not required and (2) have historically been very buggy for C++).

This patch removes these sections.  I left them for Darwin, which does
seem to use them.  I don't have a way to test on Darwin, but this
bootstrapped and regtested on x86-64 Linux (compile farm).

Ok?

Tom

2010-06-21  Tom Tromey  <tromey@redhat.com>

	* config/darwin.h (TARGET_WANT_DEBUG_PUB_SECTIONS): Define.
	* target-def.h (TARGET_INITIALIZER): Update.
	(TARGET_WANT_DEBUG_PUB_SECTIONS): New define.
	* dwarf2out.c (add_pubname_string): Check
	targetm.want_debug_pub_sections.
	(add_pubname): Likewise.
	(add_pubtype): Likewise.
	* target.h (struct gcc_target) <want_debug_pub_sections>: New
	field.

2010-06-21  Tom Tromey  <tromey@redhat.com>

	* g++.dg/debug/dwarf2/pubnames-1.C: Add dg-do compile.

Index: target.h
===================================================================
--- target.h	(revision 160567)
+++ target.h	(working copy)
@@ -1284,6 +1284,11 @@
    */
   bool arm_eabi_unwinder;
 
+  /* True if the target wants .debug_pubtypes and .debug_pubnames.  In
+     most cases these are not interesting, as GDB and other tools do
+     not use them.  */
+  bool want_debug_pub_sections;
+
   /* Leave the boolean fields at the end.  */
 };
 
Index: testsuite/g++.dg/debug/dwarf2/pubnames-1.C
===================================================================
--- testsuite/g++.dg/debug/dwarf2/pubnames-1.C	(revision 160567)
+++ testsuite/g++.dg/debug/dwarf2/pubnames-1.C	(working copy)
@@ -1,5 +1,6 @@
 // Contributed by Dodji Seketeli <dodji@redhat.com>
 // Origin PR debug/39706
+// { dg-do compile { target *-*-darwin* } }
 // { dg-options "-g -dA -fno-merge-debug-strings" }
 // { dg-do compile }
 //
Index: dwarf2out.c
===================================================================
--- dwarf2out.c	(revision 160567)
+++ dwarf2out.c	(working copy)
@@ -11080,17 +11080,20 @@
 static void
 add_pubname_string (const char *str, dw_die_ref die)
 {
-  pubname_entry e;
+  if (targetm.want_debug_pub_sections)
+    {
+      pubname_entry e;
 
-  e.die = die;
-  e.name = xstrdup (str);
-  VEC_safe_push (pubname_entry, gc, pubname_table, &e);
+      e.die = die;
+      e.name = xstrdup (str);
+      VEC_safe_push (pubname_entry, gc, pubname_table, &e);
+    }
 }
 
 static void
 add_pubname (tree decl, dw_die_ref die)
 {
-  if (TREE_PUBLIC (decl))
+  if (targetm.want_debug_pub_sections && TREE_PUBLIC (decl))
     {
       const char *name = dwarf2_name (decl, 1);
       if (name)
@@ -11105,6 +11108,9 @@
 {
   pubname_entry e;
 
+  if (!targetm.want_debug_pub_sections)
+    return;
+
   e.name = NULL;
   if ((TREE_PUBLIC (decl)
        || die->die_parent == comp_unit_die)
Index: target-def.h
===================================================================
--- target-def.h	(revision 160567)
+++ target-def.h	(working copy)
@@ -680,6 +680,8 @@
 
 #define TARGET_ARM_EABI_UNWINDER false
 
+#define TARGET_WANT_DEBUG_PUB_SECTIONS false
+
 #define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode
 #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_false
 
@@ -1085,7 +1087,8 @@
   TARGET_ASM_FILE_START_FILE_DIRECTIVE,		\
   TARGET_HANDLE_PRAGMA_EXTERN_PREFIX,		\
   TARGET_RELAXED_ORDERING,			\
-  TARGET_ARM_EABI_UNWINDER			\
+  TARGET_ARM_EABI_UNWINDER,			\
+  TARGET_WANT_DEBUG_PUB_SECTIONS		\
 }
 
 #define TARGET_HANDLE_C_OPTION default_handle_c_option
Index: config/darwin.h
===================================================================
--- config/darwin.h	(revision 160567)
+++ config/darwin.h	(working copy)
@@ -471,6 +471,8 @@
 #define DEBUG_STR_SECTION	"__DWARF,__debug_str,regular,debug"
 #define DEBUG_RANGES_SECTION	"__DWARF,__debug_ranges,regular,debug"
 
+#define TARGET_WANT_DEBUG_PUB_SECTIONS true
+
 /* When generating stabs debugging, use N_BINCL entries.  */
 
 #define DBX_USE_BINCL

             reply	other threads:[~2010-06-21 22:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-21 22:56 Tom Tromey [this message]
2010-06-23 17:34 ` Mike Stump
2010-06-29  8:37 ` Richard Henderson
2010-06-29 21:08   ` Tom Tromey
2010-06-30  1:58     ` Richard Henderson
2010-07-06 22:45       ` Tom Tromey
2010-07-07  0:16         ` Richard Henderson

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=m3r5k0f2o9.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@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).