public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* RFA: don't emit .debug_pub*
@ 2010-06-21 22:56 Tom Tromey
  2010-06-23 17:34 ` Mike Stump
  2010-06-29  8:37 ` Richard Henderson
  0 siblings, 2 replies; 7+ messages in thread
From: Tom Tromey @ 2010-06-21 22:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFA: don't emit .debug_pub*
  2010-06-21 22:56 RFA: don't emit .debug_pub* Tom Tromey
@ 2010-06-23 17:34 ` Mike Stump
  2010-06-29  8:37 ` Richard Henderson
  1 sibling, 0 replies; 7+ messages in thread
From: Mike Stump @ 2010-06-23 17:34 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gcc-patches, Jakub Jelinek

On Jun 21, 2010, at 3:20 PM, Tom Tromey wrote:
> Currently, GCC emits .debug_pubnames and .debug_pubtypes.
> However, they are not used, except on Darwin.

> Ok?

I'm ok with this patch.  I've reviewed all the middle end bits, and they look fine.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFA: don't emit .debug_pub*
  2010-06-21 22:56 RFA: don't emit .debug_pub* Tom Tromey
  2010-06-23 17:34 ` Mike Stump
@ 2010-06-29  8:37 ` Richard Henderson
  2010-06-29 21:08   ` Tom Tromey
  1 sibling, 1 reply; 7+ messages in thread
From: Richard Henderson @ 2010-06-29  8:37 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gcc-patches, Jakub Jelinek

On 06/21/2010 03:20 PM, Tom Tromey wrote:
> 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
> +
...
> 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

One of these either needs an undef or an ifdef.


r~

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFA: don't emit .debug_pub*
  2010-06-29  8:37 ` Richard Henderson
@ 2010-06-29 21:08   ` Tom Tromey
  2010-06-30  1:58     ` Richard Henderson
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2010-06-29 21:08 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches, Jakub Jelinek

>>>>> "rth" == Richard Henderson <rth@redhat.com> writes:

rth> One of these either needs an undef or an ifdef.

Thanks -- I think the target-def.h one, though as before I have no way
to test this.

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,10 @@
 
 #define TARGET_ARM_EABI_UNWINDER false
 
+#ifndef TARGET_WANT_DEBUG_PUB_SECTIONS
+#define TARGET_WANT_DEBUG_PUB_SECTIONS false
+#endif
+
 #define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode
 #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_false
 
@@ -1085,7 +1089,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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFA: don't emit .debug_pub*
  2010-06-29 21:08   ` Tom Tromey
@ 2010-06-30  1:58     ` Richard Henderson
  2010-07-06 22:45       ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Henderson @ 2010-06-30  1:58 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gcc-patches, Jakub Jelinek

On 06/29/2010 12:20 PM, Tom Tromey wrote:
>>>>>> "rth" == Richard Henderson <rth@redhat.com> writes:
> 
> rth> One of these either needs an undef or an ifdef.
> 
> Thanks -- I think the target-def.h one, though as before I have no way
> to test this.

Yes, target-def.h needed an ifdef.

But now the patch needs to be re-written, since Joern has
committed a patch that re-works the target hooks.  Which
will also force you to write documentation, which you had
forgotten for this new hook.  ;-)


r~

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFA: don't emit .debug_pub*
  2010-06-30  1:58     ` Richard Henderson
@ 2010-07-06 22:45       ` Tom Tromey
  2010-07-07  0:16         ` Richard Henderson
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2010-07-06 22:45 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches, Jakub Jelinek

>>>>> "rth" == Richard Henderson <rth@redhat.com> writes:

rth> But now the patch needs to be re-written, since Joern has
rth> committed a patch that re-works the target hooks.  Which
rth> will also force you to write documentation, which you had
rth> forgotten for this new hook.  ;-)

Here's a new version, bootstrapped & regtested on x86-64 (compile farm).

As before, I can't actually test this on Darwin.  However, I think any
possible bug would be trivial.

Tom

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

	* doc/tm.texi: Update.
	* doc/tm.texi.in (SDB and DWARF) <TARGET_WANT_DEBUG_PUB_SECTIONS>:
	Add @hook.
	* target.def (want_debug_pub_sections): New hook.
	* config/darwin.h (TARGET_WANT_DEBUG_PUB_SECTIONS): Define.
	* dwarf2out.c (add_pubname_string): Check
	targetm.want_debug_pub_sections.
	(add_pubname): Likewise.
	(add_pubtype): Likewise.

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

	* g++.dg/debug/dwarf2/pubnames-1.C: Make darwin-specific.

Index: gcc/doc/tm.texi
===================================================================
--- gcc/doc/tm.texi	(revision 161742)
+++ gcc/doc/tm.texi	(working copy)
@@ -9276,6 +9276,10 @@
 tables, and hence is desirable if it works.
 @end defmac
 
+@deftypevr {Target Hook} bool TARGET_WANT_DEBUG_PUB_SECTIONS
+True if the @code{.debug_pubtypes} and @code{.debug_pubnames} sections should be emitted.  These sections are not used on most platforms, and in particular GDB does not use them.
+@end deftypevr
+
 @defmac ASM_OUTPUT_DWARF_DELTA (@var{stream}, @var{size}, @var{label1}, @var{label2})
 A C statement to issue assembly directives that create a difference
 @var{lab1} minus @var{lab2}, using an integer of the given @var{size}.
Index: gcc/doc/tm.texi.in
===================================================================
--- gcc/doc/tm.texi.in	(revision 161742)
+++ gcc/doc/tm.texi.in	(working copy)
@@ -9275,6 +9275,8 @@
 tables, and hence is desirable if it works.
 @end defmac
 
+@hook TARGET_WANT_DEBUG_PUB_SECTIONS
+
 @defmac ASM_OUTPUT_DWARF_DELTA (@var{stream}, @var{size}, @var{label1}, @var{label2})
 A C statement to issue assembly directives that create a difference
 @var{lab1} minus @var{lab2}, using an integer of the given @var{size}.
Index: gcc/target.def
===================================================================
--- gcc/target.def	(revision 161742)
+++ gcc/target.def	(working copy)
@@ -2335,6 +2335,13 @@
  "",
  bool, false)
 
+DEFHOOKPOD
+(want_debug_pub_sections,
+ "True if the @code{.debug_pubtypes} and @code{.debug_pubnames} sections\
+ should be emitted.  These sections are not used on most platforms, and\
+ in particular GDB does not use them.",
+ bool, false)
+
 /* Leave the boolean fields at the end.  */
 
 /* Empty macro arguments are undefined in C90, so use an empty macro.  */
Index: gcc/testsuite/g++.dg/debug/dwarf2/pubnames-1.C
===================================================================
--- gcc/testsuite/g++.dg/debug/dwarf2/pubnames-1.C	(revision 161742)
+++ gcc/testsuite/g++.dg/debug/dwarf2/pubnames-1.C	(working copy)
@@ -1,7 +1,7 @@
 // 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 }
 //
 // There should be one debug_pubnames section generated.
 // On Darwin though, there is also a label pointing at the begining of the
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 161742)
+++ gcc/dwarf2out.c	(working copy)
@@ -11238,17 +11238,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)
@@ -11263,6 +11266,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: gcc/config/darwin.h
===================================================================
--- gcc/config/darwin.h	(revision 161742)
+++ gcc/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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFA: don't emit .debug_pub*
  2010-07-06 22:45       ` Tom Tromey
@ 2010-07-07  0:16         ` Richard Henderson
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2010-07-07  0:16 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gcc-patches, Jakub Jelinek

On 07/06/2010 03:45 PM, Tom Tromey wrote:
> 	* doc/tm.texi: Update.
> 	* doc/tm.texi.in (SDB and DWARF) <TARGET_WANT_DEBUG_PUB_SECTIONS>:
> 	Add @hook.
> 	* target.def (want_debug_pub_sections): New hook.
> 	* config/darwin.h (TARGET_WANT_DEBUG_PUB_SECTIONS): Define.
> 	* dwarf2out.c (add_pubname_string): Check
> 	targetm.want_debug_pub_sections.
> 	(add_pubname): Likewise.
> 	(add_pubtype): Likewise.
> 
> 2010-07-06  Tom Tromey  <tromey@redhat.com>
> 
> 	* g++.dg/debug/dwarf2/pubnames-1.C: Make darwin-specific.

Ok.


r~

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-07-07  0:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-21 22:56 RFA: don't emit .debug_pub* Tom Tromey
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

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).