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
extern int bar(int a);
int foo(int a)
{
a += 1;
return a;
}
int main(void)
{
bar(1);
}
>From b2ededa4a5eac77fc0d5d95011de935a1dff7eba Mon Sep 17 00:00:00 2001
From: Pierre-Marie de Rodat <dero...@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