public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][PR debug/65549] Restore DW_AT_abstract_origin for cross-unit call sites
@ 2015-06-09 21:39 Pierre-Marie de Rodat
  2015-06-10  7:06 ` Richard Biener
  0 siblings, 1 reply; 16+ messages in thread
From: Pierre-Marie de Rodat @ 2015-06-09 21:39 UTC (permalink / raw)
  To: GCC Patches, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 1425 bytes --]

Hello,

With the recent work for PR debug/65549, we observed a regression in the 
generated debugging information. Take the attached reproducer, build it 
and look at the output DWARF:

      $ gcc -c -O1 -g foo.c
      $ objdump --dwarf=info foo.o
      [...]
       <2><4e>: Abbrev Number: 3 (DW_TAG_GNU_call_site)
          <4f>   DW_AT_low_pc      : 0x9
       <2><57>: Abbrev Number: 0

There is no DW_AT_abstract_origin attribute anymore, whereas there used 
to be one.

On PowerPC with -mlongcall, for instance, call instructions are indirect 
and we (at AdaCore) rely on this attribute to determine what function is 
actually called (it's easier this way than interpreting machine 
code...). The DWARF proposal for call sites also say debuggers should be 
able to use this attribute (to build virtual call stacks in the presence 
of tail calls), but I could not observe this in practice with GDB.

The attached patch is an attempt to restore this attribute. The logic 
behind it is: this is what we used to do previously for contexts that 
are alien translation unit (through the call to force_decl_die), so this 
should not harm.

Bootstrapped and regtested on x86_64-linux. Ok to commit?
Thank you in advance!

gcc/ChangeLog
         * dwarf2out.c (lookup_context_die): Return the DIE for the
         current compilation unit when the input context is a
         TRANSLATION_UNIT_DECL.

-- 
Pierre-Marie de Rodat


[-- Attachment #2: foo.c --]
[-- Type: text/x-csrc, Size: 96 bytes --]

extern int bar(int a);

int foo(int a)
{
  a += 1;
  return a;
}

int main(void)
{
  bar(1);
}


[-- Attachment #3: 0001-DWARF-restore-DW_AT_abstract_origin-for-cross-unit-c.patch --]
[-- Type: text/x-patch, Size: 1586 bytes --]

From b2ededa4a5eac77fc0d5d95011de935a1dff7eba Mon Sep 17 00:00:00 2001
From: Pierre-Marie de Rodat <derodat@adacore.com>
Date: Mon, 8 Jun 2015 16:27:04 +0200
Subject: [PATCH] DWARF: restore DW_AT_abstract_origin for cross-unit call
 sites

gcc/ChangeLog
	* dwarf2out.c (lookup_context_die): Return the DIE for the
	current compilation unit when the input context is a
	TRANSLATION_UNIT_DECL.
---
 gcc/dwarf2out.c |   25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index ee2bcb1..4e204df 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -21053,21 +21053,20 @@ is_naming_typedef_decl (const_tree decl)
 static inline dw_die_ref
 lookup_context_die (tree context)
 {
-  if (context)
+  if (context == NULL_TREE || TREE_CODE (context) == TRANSLATION_UNIT_DECL)
+    return comp_unit_die ();
+
+  /* Find die that represents this context.  */
+  if (TYPE_P (context))
     {
-      /* Find die that represents this context.  */
-      if (TYPE_P (context))
-	{
-	  context = TYPE_MAIN_VARIANT (context);
-	  dw_die_ref ctx = lookup_type_die (context);
-	  if (!ctx)
-	    return NULL;
-	  return strip_naming_typedef (context, ctx);
-	}
-      else
-	return lookup_decl_die (context);
+      context = TYPE_MAIN_VARIANT (context);
+      dw_die_ref ctx = lookup_type_die (context);
+      if (!ctx)
+	return NULL;
+      return strip_naming_typedef (context, ctx);
     }
-  return comp_unit_die ();
+  else
+    return lookup_decl_die (context);
 }
 
 /* Returns the DIE for a context.  */
-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: [PATCH][PR debug/65549] Restore DW_AT_abstract_origin for cross-unit call sites
@ 2015-06-12  1:25 David Edelsohn
  2015-06-12  5:45 ` Richard Biener
  0 siblings, 1 reply; 16+ messages in thread
From: David Edelsohn @ 2015-06-12  1:25 UTC (permalink / raw)
  To: Pierre-Marie de Rodat; +Cc: Richard Biener, GCC Patches

This patch broke AIX bootstrap because dbxout.c was not updated for
the XCOFF_DEBUGGING_INFO case.

- David

* dbxout.c (xcoff_debug_hooks): Provide a function for
register_main_translation_unit hook.

Index: dbxout.c
===================================================================
--- dbxout.c    (revision 224402)
+++ dbxout.c    (working copy)
@@ -419,6 +419,7 @@
   xcoffout_end_epilogue,
   debug_nothing_tree,                   /* begin_function */
   xcoffout_end_function,
+  debug_nothing_tree,                   /* register_main_translation_unit */
   debug_nothing_tree,                   /* function_decl */
   dbxout_early_global_decl,             /* early_global_decl */
   dbxout_late_global_decl,              /* late_global_decl */

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

end of thread, other threads:[~2015-06-12 13:46 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-09 21:39 [PATCH][PR debug/65549] Restore DW_AT_abstract_origin for cross-unit call sites Pierre-Marie de Rodat
2015-06-10  7:06 ` Richard Biener
2015-06-10 13:09   ` Pierre-Marie de Rodat
2015-06-10 13:37     ` Richard Biener
2015-06-10 14:31       ` Pierre-Marie de Rodat
2015-06-11  8:02         ` Richard Biener
2015-06-11  9:10         ` Richard Biener
2015-06-11  9:21           ` Pierre-Marie de Rodat
2015-06-11  9:25             ` Richard Biener
2015-06-11 13:49               ` Pierre-Marie de Rodat
2015-06-12  1:25 David Edelsohn
2015-06-12  5:45 ` Richard Biener
2015-06-12 10:15   ` Pierre-Marie de Rodat
2015-06-12 10:32   ` Pierre-Marie de Rodat
2015-06-12 11:17     ` Richard Biener
2015-06-12 13:56       ` Pierre-Marie de Rodat

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