* [PATCH] PR debug/49047 (linkage name missing for cdtors)
@ 2011-05-26 15:45 Dodji Seketeli
2011-05-26 16:38 ` Jason Merrill
0 siblings, 1 reply; 6+ messages in thread
From: Dodji Seketeli @ 2011-05-26 15:45 UTC (permalink / raw)
To: GCC Patches; +Cc: Jason Merrill, Tom Tromey
Hello,
The constructors (resp. destructors) of a given class K are cloned.
For each constructor (resp. destructor) There is thus an abstract
version of the function and (at least) a concrete version that
actually contains the code of the abstract version.
The debug info generated for a constructor (resp. destructor) lacks
linkage name (DWARF attribute DW_AT_MIPS_linkage_name), making the job
of GDB slow and difficult when it tries to get the actual concrete
function that contains the constructor's code to, e.g, set a
breakpoint.
The patch below emits that linkage name for those concrete versions of
cloned public functions.
Tested on x86-64-unknown-linux-gnu against trunk.
gcc/
* dwarf2out.c (gen_subprogram_die): Emit linkage name attribute
for functions containing actual code for public cloned abstract
functions.
gcc/testsuite/
* g++.dg/debug/dwarf2/cdtor-1.C: New test.
---
gcc/dwarf2out.c | 11 +++++++++++
gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C | 17 +++++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 55453a3..85c01b1 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -19601,6 +19601,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
dw_die_ref old_die = lookup_decl_die (decl);
int declaration = (current_function_decl != decl
|| class_or_namespace_scope_p (context_die));
+ bool fn_has_code_addr_p = false;
premark_used_types ();
@@ -19769,6 +19770,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
/* We have already generated the labels. */
add_AT_lbl_id (subr_die, DW_AT_low_pc, fde->dw_fde_begin);
add_AT_lbl_id (subr_die, DW_AT_high_pc, fde->dw_fde_end);
+ fn_has_code_addr_p = true;
}
else
{
@@ -19780,6 +19782,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_END_LABEL,
current_function_funcdef_no);
add_AT_lbl_id (subr_die, DW_AT_high_pc, label_id);
+ fn_has_code_addr_p = true;
}
#if VMS_DEBUGGING_INFO
@@ -19929,6 +19932,14 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
if (cfun->static_chain_decl)
add_AT_location_description (subr_die, DW_AT_static_link,
loc_list_from_tree (cfun->static_chain_decl, 2));
+
+ if (fn_has_code_addr_p && origin && TREE_PUBLIC (origin))
+ /* So this is where the actual code for a publicly accessible
+ cloned function is. Let's emit linkage name attribute for
+ it. This helps debuggers to e.g, set breakpoints into
+ constructors/destructors when the user asks "break
+ K::K". */
+ add_linkage_name (subr_die, decl);
}
/* Generate child dies for template paramaters. */
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C
new file mode 100644
index 0000000..6d39e54
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C
@@ -0,0 +1,17 @@
+// origin PR debug/49047
+// { dg-options "-g -dA" }
+// { dg-do compile }
+
+struct K
+{
+ K () { }
+ ~K () { }
+};
+
+int
+main()
+{
+ K k;
+}
+
+// { dg-final {scan-assembler-times "\[^\n\r\]*DW_AT_MIPS_linkage_name:" 2 } }
--
1.7.3.4
--
Dodji
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PR debug/49047 (linkage name missing for cdtors)
2011-05-26 15:45 [PATCH] PR debug/49047 (linkage name missing for cdtors) Dodji Seketeli
@ 2011-05-26 16:38 ` Jason Merrill
2011-05-26 22:02 ` Dodji Seketeli
0 siblings, 1 reply; 6+ messages in thread
From: Jason Merrill @ 2011-05-26 16:38 UTC (permalink / raw)
To: GCC Patches, Tom Tromey
Why not just call add_linkage_name after add_abstract_origin_attribute?
Jason
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PR debug/49047 (linkage name missing for cdtors)
2011-05-26 16:38 ` Jason Merrill
@ 2011-05-26 22:02 ` Dodji Seketeli
2011-05-27 8:31 ` Jason Merrill
0 siblings, 1 reply; 6+ messages in thread
From: Dodji Seketeli @ 2011-05-26 22:02 UTC (permalink / raw)
To: Jason Merrill; +Cc: GCC Patches, Tom Tromey
Jason Merrill <jason@redhat.com> a écrit:
> Why not just call add_linkage_name after add_abstract_origin_attribute?
That is what I first did and it worked for this case. But then I wasn't
sure if there could be cases where a function DIE would have the
DW_AT_abstract_origin set, but won't have any actual code? For instance
if the function has DECL_EXTERNAL set. That's why I wanted to call
add_linkage_name only if the function has DW_AT_{low,high}_pc so that I
am sure it contains actual code.
If my concern is not justified then I guess the patch below should be
enough then.
gcc/
* dwarf2out.c (gen_subprogram_die): Emit linkage name attribute
for functions containing actual code for public cloned abstract
functions.
gcc/testsuite/
* g++.dg/debug/dwarf2/cdtor-1.C: New test.
---
gcc/dwarf2out.c | 7 +++++++
gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C | 17 +++++++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 55453a3..0cf782f 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -19636,6 +19636,13 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
subr_die = new_die (DW_TAG_subprogram, context_die, decl);
add_abstract_origin_attribute (subr_die, origin);
+ if (TREE_PUBLIC (origin))
+ /* So this is where the actual code for a publicly accessible
+ cloned function is. Let's emit linkage name attribute for
+ it. This helps debuggers to e.g, set breakpoints into
+ constructors/destructors when the user asks "break
+ K::K". */
+ add_linkage_name (subr_die, decl);
}
else if (old_die)
{
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C
new file mode 100644
index 0000000..6d39e54
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C
@@ -0,0 +1,17 @@
+// origin PR debug/49047
+// { dg-options "-g -dA" }
+// { dg-do compile }
+
+struct K
+{
+ K () { }
+ ~K () { }
+};
+
+int
+main()
+{
+ K k;
+}
+
+// { dg-final {scan-assembler-times "\[^\n\r\]*DW_AT_MIPS_linkage_name:" 2 } }
--
1.7.3.4
--
Dodji
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PR debug/49047 (linkage name missing for cdtors)
2011-05-26 22:02 ` Dodji Seketeli
@ 2011-05-27 8:31 ` Jason Merrill
2011-05-30 15:17 ` Dodji Seketeli
0 siblings, 1 reply; 6+ messages in thread
From: Jason Merrill @ 2011-05-27 8:31 UTC (permalink / raw)
To: GCC Patches, Tom Tromey
On 05/26/2011 04:03 PM, Dodji Seketeli wrote:
> That is what I first did and it worked for this case. But then I wasn't
> sure if there could be cases where a function DIE would have the
> DW_AT_abstract_origin set, but won't have any actual code? For instance
> if the function has DECL_EXTERNAL set. That's why I wanted to call
> add_linkage_name only if the function has DW_AT_{low,high}_pc so that I
> am sure it contains actual code.
I think that we only generate debug info for a function if we emit it,
so it should always have pc attributes. But you could try adding an
assert to see if I'm right.
> + if (TREE_PUBLIC (origin))
> + /* So this is where the actual code for a publicly accessible
> + cloned function is. Let's emit linkage name attribute for
> + it. This helps debuggers to e.g, set breakpoints into
> + constructors/destructors when the user asks "break
> + K::K". */
> + add_linkage_name (subr_die, decl);
add_name_and_src_coords_attributes doesn't check TREE_PUBLIC, so I don't
think we should here, either; we want the debugger to be able to find
cloned constructors in anonymous namespaces, too.
Jason
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PR debug/49047 (linkage name missing for cdtors)
2011-05-27 8:31 ` Jason Merrill
@ 2011-05-30 15:17 ` Dodji Seketeli
2011-05-31 12:18 ` Jason Merrill
0 siblings, 1 reply; 6+ messages in thread
From: Dodji Seketeli @ 2011-05-30 15:17 UTC (permalink / raw)
To: Jason Merrill; +Cc: GCC Patches, Tom Tromey
Jason Merrill <jason@redhat.com> a écrit:
> I think that we only generate debug info for a function if we emit it,
> so it should always have pc attributes. But you could try adding an
> assert to see if I'm right.
Indeed. I have put the exploratory assert there and it did bootstrap
fine.
>
>> + if (TREE_PUBLIC (origin))
>> + /* So this is where the actual code for a publicly accessible
>> + cloned function is. Let's emit linkage name attribute for
>> + it. This helps debuggers to e.g, set breakpoints into
>> + constructors/destructors when the user asks "break
>> + K::K". */
>> + add_linkage_name (subr_die, decl);
>
> add_name_and_src_coords_attributes doesn't check TREE_PUBLIC, so I
> don't think we should here, either; we want the debugger to be able to
> find cloned constructors in anonymous namespaces, too.
Right. I removed that check.
Tested on x86_64-unknown-linux-gnu against trunk.
gcc/
* dwarf2out.c (gen_subprogram_die): Emit linkage name attribute
for concrete functions containing the code of cloned functions.
gcc/testsuite/
* g++.dg/debug/dwarf2/cdtor-1.C: New test.
---
gcc/dwarf2out.c | 6 ++++++
gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C | 17 +++++++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 55453a3..bc3f976 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -19636,6 +19636,12 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
subr_die = new_die (DW_TAG_subprogram, context_die, decl);
add_abstract_origin_attribute (subr_die, origin);
+ /* This is where the actual code for a cloned function is.
+ Let's emit linkage name attribute for it. This helps
+ debuggers to e.g, set breakpoints into
+ constructors/destructors when the user asks "break
+ K::K". */
+ add_linkage_name (subr_die, decl);
}
else if (old_die)
{
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C
new file mode 100644
index 0000000..6d39e54
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C
@@ -0,0 +1,17 @@
+// origin PR debug/49047
+// { dg-options "-g -dA" }
+// { dg-do compile }
+
+struct K
+{
+ K () { }
+ ~K () { }
+};
+
+int
+main()
+{
+ K k;
+}
+
+// { dg-final {scan-assembler-times "\[^\n\r\]*DW_AT_MIPS_linkage_name:" 2 } }
--
1.7.3.4
--
Dodji
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PR debug/49047 (linkage name missing for cdtors)
2011-05-30 15:17 ` Dodji Seketeli
@ 2011-05-31 12:18 ` Jason Merrill
0 siblings, 0 replies; 6+ messages in thread
From: Jason Merrill @ 2011-05-31 12:18 UTC (permalink / raw)
To: GCC Patches, Tom Tromey
OK.
Jason
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-05-31 9:12 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-26 15:45 [PATCH] PR debug/49047 (linkage name missing for cdtors) Dodji Seketeli
2011-05-26 16:38 ` Jason Merrill
2011-05-26 22:02 ` Dodji Seketeli
2011-05-27 8:31 ` Jason Merrill
2011-05-30 15:17 ` Dodji Seketeli
2011-05-31 12:18 ` Jason Merrill
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).