DWARF: Call set_indirect_string on DW_MACINFO_start_file

Message ID 20180822193624.GA22426@intel.com
State New
Headers show
Series
  • DWARF: Call set_indirect_string on DW_MACINFO_start_file
Related show

Commit Message

H.J. Lu Aug. 22, 2018, 7:36 p.m.
Since -gsplit-dwarf -g3 will output filename as indirect string, call
set_indirect_string on DW_MACINFO_start_file for -gsplit-dwarf -g3.

OK for trunk?

H.J.
--
	PR debug/79342
	* dwarf2out.c (save_macinfo_strings): Call set_indirect_string
	on DW_MACINFO_start_file for -gsplit-dwarf -g3
---
 gcc/dwarf2out.c | 6 ++++++
 1 file changed, 6 insertions(+)

-- 
2.17.1

Comments

Richard Biener Aug. 23, 2018, 12:56 p.m. | #1
On Wed, Aug 22, 2018 at 9:36 PM H.J. Lu <hongjiu.lu@intel.com> wrote:
>

> Since -gsplit-dwarf -g3 will output filename as indirect string, call

> set_indirect_string on DW_MACINFO_start_file for -gsplit-dwarf -g3.

>

> OK for trunk?


Can you add a testcase?

Richard.

> H.J.

> --

>         PR debug/79342

>         * dwarf2out.c (save_macinfo_strings): Call set_indirect_string

>         on DW_MACINFO_start_file for -gsplit-dwarf -g3

> ---

>  gcc/dwarf2out.c | 6 ++++++

>  1 file changed, 6 insertions(+)

>

> diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c

> index edf1ac35896..6ae0a4d66b4 100644

> --- a/gcc/dwarf2out.c

> +++ b/gcc/dwarf2out.c

> @@ -28280,6 +28280,12 @@ save_macinfo_strings (void)

>                  && (debug_str_section->common.flags & SECTION_MERGE) != 0)

>                set_indirect_string (find_AT_string (ref->info));

>              break;

> +         case DW_MACINFO_start_file:

> +           /* -gsplit-dwarf -g3 will also output filename as indirect

> +              string.  */

> +           if (!dwarf_split_debug_info)

> +             break;

> +           /* Fall through. */

>           case DW_MACRO_define_strp:

>           case DW_MACRO_undef_strp:

>              set_indirect_string (find_AT_string (ref->info));

> --

> 2.17.1

>
H.J. Lu Aug. 23, 2018, 2:38 p.m. | #2
On Thu, Aug 23, 2018 at 5:56 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Wed, Aug 22, 2018 at 9:36 PM H.J. Lu <hongjiu.lu@intel.com> wrote:

>>

>> Since -gsplit-dwarf -g3 will output filename as indirect string, call

>> set_indirect_string on DW_MACINFO_start_file for -gsplit-dwarf -g3.

>>

>> OK for trunk?

>

> Can you add a testcase?

>

>


Here is the updated patch with a testcase.  Before my fix:

/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/ -m32
-O2 -fno-var-tracking-assignments -gsplit-dwarf -g3 -march=skylake
-mrtm -mabm -S x.c
x.c:14:1: internal compiler error: in output_index_string, at dwarf2out.c:28780
14 | }
   | ^
0xb090e7 output_index_string(indirect_string_node**, unsigned int*)
/export/gnu/import/git/sources/gcc/gcc/dwarf2out.c:28780
0xb09370 output_indirect_strings
/export/gnu/import/git/sources/gcc/gcc/dwarf2out.c:28868
0xb0ed85 dwarf2out_finish
/export/gnu/import/git/sources/gcc/gcc/dwarf2out.c:31563
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

After:

/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/ -m32
-O2 -fno-var-tracking-assignments -gsplit-dwarf -g3 -march=skylake
-mrtm -mabm -S x.c

OK for trunk?

Thanks.

-- 
H.J.
From 65c84b66ff7027a90f2108053427a516575ba78b Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 22 Aug 2018 12:25:17 -0700
Subject: [PATCH] DWARF: Call set_indirect_string on DW_MACINFO_start_file

Since -gsplit-dwarf -g3 will output filename as indirect string, call
set_indirect_string on DW_MACINFO_start_file for -gsplit-dwarf -g3.

gcc/

	PR debug/79342
	* dwarf2out.c (save_macinfo_strings): Call set_indirect_string
	on DW_MACINFO_start_file for -gsplit-dwarf -g3

gcc/testsuite/

	PR debug/79342
	* gcc.dg/pr79342.: New test.
---
 gcc/dwarf2out.c                |  6 ++++++
 gcc/testsuite/gcc.dg/pr79342.c | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/pr79342.c

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 91af4e8fc4e..77317ed2575 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -28287,6 +28287,12 @@ save_macinfo_strings (void)
                 && (debug_str_section->common.flags & SECTION_MERGE) != 0)
               set_indirect_string (find_AT_string (ref->info));
             break;
+	  case DW_MACINFO_start_file:
+	    /* -gsplit-dwarf -g3 will also output filename as indirect
+	       string.  */
+	    if (!dwarf_split_debug_info)
+	      break;
+	    /* Fall through. */
 	  case DW_MACRO_define_strp:
 	  case DW_MACRO_undef_strp:
             set_indirect_string (find_AT_string (ref->info));
diff --git a/gcc/testsuite/gcc.dg/pr79342.c b/gcc/testsuite/gcc.dg/pr79342.c
new file mode 100644
index 00000000000..958de55d09b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr79342.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -gsplit-dwarf -g3" } */
+/* { dg-additional-options "-march=skylake -mrtm -mabm" { target x86_64-*-* i?86-*-* } } */
+
+int a;
+void b(void);
+
+void e(int *);
+int f(void);
+
+void 
+c(void)
+{
+  int d;
+  e(&d);
+  if (f())
+    b();
+}
Richard Biener Aug. 24, 2018, 9:02 a.m. | #3
On Thu, Aug 23, 2018 at 4:38 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>

> On Thu, Aug 23, 2018 at 5:56 AM, Richard Biener

> <richard.guenther@gmail.com> wrote:

> > On Wed, Aug 22, 2018 at 9:36 PM H.J. Lu <hongjiu.lu@intel.com> wrote:

> >>

> >> Since -gsplit-dwarf -g3 will output filename as indirect string, call

> >> set_indirect_string on DW_MACINFO_start_file for -gsplit-dwarf -g3.

> >>

> >> OK for trunk?

> >

> > Can you add a testcase?

> >

> >

>

> Here is the updated patch with a testcase.  Before my fix:

>

> /export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/xgcc

> -B/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/ -m32

> -O2 -fno-var-tracking-assignments -gsplit-dwarf -g3 -march=skylake

> -mrtm -mabm -S x.c

> x.c:14:1: internal compiler error: in output_index_string, at dwarf2out.c:28780

> 14 | }

>    | ^

> 0xb090e7 output_index_string(indirect_string_node**, unsigned int*)

> /export/gnu/import/git/sources/gcc/gcc/dwarf2out.c:28780

> 0xb09370 output_indirect_strings

> /export/gnu/import/git/sources/gcc/gcc/dwarf2out.c:28868

> 0xb0ed85 dwarf2out_finish

> /export/gnu/import/git/sources/gcc/gcc/dwarf2out.c:31563

> Please submit a full bug report,

> with preprocessed source if appropriate.

> Please include the complete backtrace with any bug report.

> See <https://gcc.gnu.org/bugs/> for instructions.

>

> After:

>

> /export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/xgcc

> -B/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/ -m32

> -O2 -fno-var-tracking-assignments -gsplit-dwarf -g3 -march=skylake

> -mrtm -mabm -S x.c

>

> OK for trunk?


OK.

Richard.

> Thanks.

>

> --

> H.J.

Patch

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index edf1ac35896..6ae0a4d66b4 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -28280,6 +28280,12 @@  save_macinfo_strings (void)
                 && (debug_str_section->common.flags & SECTION_MERGE) != 0)
               set_indirect_string (find_AT_string (ref->info));
             break;
+	  case DW_MACINFO_start_file:
+	    /* -gsplit-dwarf -g3 will also output filename as indirect
+	       string.  */
+	    if (!dwarf_split_debug_info)
+	      break;
+	    /* Fall through. */
 	  case DW_MACRO_define_strp:
 	  case DW_MACRO_undef_strp:
             set_indirect_string (find_AT_string (ref->info));