* [PATCH] c++, debug: Fix up locus of DW_TAG_imported_module [PR108716]
@ 2023-02-09 8:41 Jakub Jelinek
2023-03-02 16:49 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2023-02-09 8:41 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
Hi!
Before IMPORTED_DECL has been introduced in PR37410, we used to emit correct
DW_AT_decl_line on DW_TAG_imported_module on the testcase below, after that
change we haven't emitted it at all for a while and after some time
started emitting incorrect locus, in particular the location of } closing
the function.
The problem is that while we have correct EXPR_LOCATION on the USING_STMT,
when genericizing that USING_STMT into IMPORTED_DECL we don't copy the
location to DECL_SOURCE_LOCATION, so it gets whatever input_location happens
to be when it is created.
The following patch fixes that, bootstrapped/regtested on x86_64-linux and
i686-linux, ok for trunk?
2023-02-09 Jakub Jelinek <jakub@redhat.com>
PR debug/108716
* cp-gimplify.cc (cp_genericize_r) <case USING_STMT>: Set
DECL_SOURCE_LOCATION on IMPORTED_DECL to expression location
of USING_STMT or input_location.
* g++.dg/debug/dwarf2/pr108716.C: New test.
--- gcc/cp/cp-gimplify.cc.jj 2023-02-01 10:19:43.038140336 +0100
+++ gcc/cp/cp-gimplify.cc 2023-02-08 10:36:00.301501540 +0100
@@ -1514,6 +1514,8 @@ cp_genericize_r (tree *stmt_p, int *walk
tree using_directive = make_node (IMPORTED_DECL);
TREE_TYPE (using_directive) = void_type_node;
DECL_CONTEXT (using_directive) = current_function_decl;
+ DECL_SOURCE_LOCATION (using_directive)
+ = cp_expr_loc_or_input_loc (stmt);
IMPORTED_DECL_ASSOCIATED_DECL (using_directive) = decl;
DECL_CHAIN (using_directive) = BLOCK_VARS (block);
--- gcc/testsuite/g++.dg/debug/dwarf2/pr108716.C.jj 2023-02-08 11:48:39.667385750 +0100
+++ gcc/testsuite/g++.dg/debug/dwarf2/pr108716.C 2023-02-08 11:48:57.998115610 +0100
@@ -0,0 +1,14 @@
+// PR debug/108716
+// { dg-options "-O0 -gdwarf-5 -dA -fno-merge-debug-strings" }
+// { dg-final { scan-assembler "DIE \\(\[^\n\r\]*\\) DW_TAG_imported_module\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_decl_file\[^\n\r\]*\[\n\r]*\[^\n\r\]*0xc\[^\n\r\]* DW_AT_decl_line\[^\n\r\]*\[\n\r]*(\[^\n\r\]*0x13\[^\n\r\]* DW_AT_decl_column\[^\n\r\]*\[\n\r]*)?" } }
+
+namespace M {
+ int x = 1;
+}
+
+int
+main ()
+{
+ using namespace M;
+ return 0;
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] c++, debug: Fix up locus of DW_TAG_imported_module [PR108716]
2023-02-09 8:41 [PATCH] c++, debug: Fix up locus of DW_TAG_imported_module [PR108716] Jakub Jelinek
@ 2023-03-02 16:49 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2023-03-02 16:49 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On 2/9/23 03:41, Jakub Jelinek wrote:
> Hi!
>
> Before IMPORTED_DECL has been introduced in PR37410, we used to emit correct
> DW_AT_decl_line on DW_TAG_imported_module on the testcase below, after that
> change we haven't emitted it at all for a while and after some time
> started emitting incorrect locus, in particular the location of } closing
> the function.
>
> The problem is that while we have correct EXPR_LOCATION on the USING_STMT,
> when genericizing that USING_STMT into IMPORTED_DECL we don't copy the
> location to DECL_SOURCE_LOCATION, so it gets whatever input_location happens
> to be when it is created.
>
> The following patch fixes that, bootstrapped/regtested on x86_64-linux and
> i686-linux, ok for trunk?
OK.
> 2023-02-09 Jakub Jelinek <jakub@redhat.com>
>
> PR debug/108716
> * cp-gimplify.cc (cp_genericize_r) <case USING_STMT>: Set
> DECL_SOURCE_LOCATION on IMPORTED_DECL to expression location
> of USING_STMT or input_location.
>
> * g++.dg/debug/dwarf2/pr108716.C: New test.
>
> --- gcc/cp/cp-gimplify.cc.jj 2023-02-01 10:19:43.038140336 +0100
> +++ gcc/cp/cp-gimplify.cc 2023-02-08 10:36:00.301501540 +0100
> @@ -1514,6 +1514,8 @@ cp_genericize_r (tree *stmt_p, int *walk
> tree using_directive = make_node (IMPORTED_DECL);
> TREE_TYPE (using_directive) = void_type_node;
> DECL_CONTEXT (using_directive) = current_function_decl;
> + DECL_SOURCE_LOCATION (using_directive)
> + = cp_expr_loc_or_input_loc (stmt);
>
> IMPORTED_DECL_ASSOCIATED_DECL (using_directive) = decl;
> DECL_CHAIN (using_directive) = BLOCK_VARS (block);
> --- gcc/testsuite/g++.dg/debug/dwarf2/pr108716.C.jj 2023-02-08 11:48:39.667385750 +0100
> +++ gcc/testsuite/g++.dg/debug/dwarf2/pr108716.C 2023-02-08 11:48:57.998115610 +0100
> @@ -0,0 +1,14 @@
> +// PR debug/108716
> +// { dg-options "-O0 -gdwarf-5 -dA -fno-merge-debug-strings" }
> +// { dg-final { scan-assembler "DIE \\(\[^\n\r\]*\\) DW_TAG_imported_module\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_decl_file\[^\n\r\]*\[\n\r]*\[^\n\r\]*0xc\[^\n\r\]* DW_AT_decl_line\[^\n\r\]*\[\n\r]*(\[^\n\r\]*0x13\[^\n\r\]* DW_AT_decl_column\[^\n\r\]*\[\n\r]*)?" } }
> +
> +namespace M {
> + int x = 1;
> +}
> +
> +int
> +main ()
> +{
> + using namespace M;
> + return 0;
> +}
>
> Jakub
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-02 16:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09 8:41 [PATCH] c++, debug: Fix up locus of DW_TAG_imported_module [PR108716] Jakub Jelinek
2023-03-02 16:49 ` 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).