Re: [PATCH 2/2] PR debug/38757 continued. Handle C11, C++11 and C++14.

2014-11-26 Thread Mark Wielaard
On Fri, 2014-11-21 at 21:34 +0100, Mark Wielaard wrote:
 On Fri, Nov 21, 2014 at 09:28:45AM +0100, Jakub Jelinek wrote:
  I think best would be to tweak
if (value  2 || value  4)
  error_at (loc, dwarf version %d is not supported, value);
else
  opts-x_dwarf_version = value;
  so that we accept value 5 too, and for now, until the
  most common consumers are changed, use
if (dwarf_version = 5 /* || !dwarf_strict */)
  so that
  - you can actually use it in the test with -gdwarf-5
  - you can commit it right away
  - people can start playing with what it will mean to support DWARF5
  
  GCC 4.5 also allowed -gdwarf-4 even when DWARF4 has not been released yet.
  When there are consumers that can grok it, we can uncomment the
  || !dwarf_strict.
 
 That makes sense and would be convenient for me.
 
 I made the change in opts.c and added some minimal documentation.
 And made sure we only emit the new DWARFv5 language values, but not yet
 anything else (the table header format has changed for debug_info and
 debug_line in v5, but we don't emit new style headers yet). The testcases
 were updated to explicitly add -gdwarf-5.
 
  else if (strncmp (language_string, GNU C, 5) == 0)
{
  language = DW_LANG_C89;
  if (dwarf_version = 3 || !dwarf_strict)
   - if (strcmp (language_string, GNU C99) == 0)
   -   language = DW_LANG_C99;
   + {
   +   if (strcmp (language_string, GNU C89) != 0)
   + language = DW_LANG_C99;
   +
   +   if (dwarf_version = 5 || !dwarf_strict)
   + if (strcmp (language_string, GNU C11) == 0)
   +   language = DW_LANG_C11;
   + }
  
  Shouldn't we emit at least DW_LANG_C99 for GNU C11 if
  not dwarf_version = 5 /* || !dwarf_strict */ but
  dwarf_version = 3 || !dwarf_strict is true?
 
 Yes, that is the intention. If it is a versioned GNU C then it is
 at least DW_LANG_C89, if we have -gdwarf-3 or higher and it isn't
 GNU C89 then it is at least DW_LANG_C99 and if we have -gdwarf-5
 and it is GNU C11 then we emit DW_LANG_C11.
 
 I added an explicit testcase for this.
 
  BTW, noticed we don't have anything for Fortran 2003 and 2008,
  filed a DWARF Issue for that.
 
 Thanks. I have only focussed on C and C++ because I don't know anything
 about version changes in other language standards.
 
 With the above change everything keeps working fine. You only need a
 patched GDB when explicitly using -gdwarf-5.
 
 OK to commit?

Ping. Rebased patch attached.

I have submitted patches for elfutils, valgrind, gdb and binutils for
this. But they are pending till this patch hits GCC first.

Thanks,

Mark
From a9c0a73bc74a7a25edd449cf42d179c16fbc13f4 Mon Sep 17 00:00:00 2001
From: Mark Wielaard m...@redhat.com
Date: Fri, 21 Nov 2014 21:18:00 +0100
Subject: [PATCH] PR debug/38757 continued. Handle C11, C++11 and C++14.

Add experimental (minimal) DWARFv5 support.

This change depends on the new DWARFv5 constants mentioned in the
following draft: http://dwarfstd.org/doc/dwarf5.20141029.pdf

gcc/ChangeLog

	* doc/invoke.texi (-gdwarf-@{version}): Mention experimental DWARFv5.
	* opts.c (common_handle_option): Accept -gdwarf-5.
	* dwarf2out.c (is_cxx): Add DW_LANG_C_plus_plus_11 and
	DW_LANG_C_plus_plus_14.
	(lower_bound_default): Likewise. Plus DW_LANG_C11.
	(gen_compile_unit_die): Output DW_LANG_C_plus_plus_11,
	DW_LANG_C_plus_plus_14 or DW_LANG_C11.
	(output_compilation_unit_header): Output at most a DWARFv4 header.
	(output_skeleton_debug_sections): Likewise.
	(output_line_info): Likewise.
	(output_aranges): Document header version number.

gcc/testsuite/ChangeLog

	* gcc.dg/debug/dwarf2/lang-c11.c: New test.
	* gcc.dg/debug/dwarf2/lang-c11-d4-strict.c: Likewise.
	* g++.dg/debug/dwarf2/lang-cpp11.C: Likewise.
	* g++.dg/debug/dwarf2/lang-cpp14.C: Likewise.
	* g++.dg/debug/dwarf2/lang-cpp98.C: Likewise.

include/ChangeLog

	* dwarf2.h: Add DW_LANG_C_plus_plus_11, DW_LANG_C11 and
	DW_LANG_C_plus_plus_14.
---
 gcc/ChangeLog  | 14 +++
 gcc/doc/invoke.texi|  4 +-
 gcc/dwarf2out.c| 45 +-
 gcc/opts.c |  2 +-
 gcc/testsuite/ChangeLog|  8 
 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C |  6 +++
 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C |  6 +++
 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C |  6 +++
 .../gcc.dg/debug/dwarf2/lang-c11-d4-strict.c   |  7 
 gcc/testsuite/gcc.dg/debug/dwarf2/lang-c11.c   |  6 +++
 include/ChangeLog  |  5 +++
 include/dwarf2.h   |  4 ++
 12 files changed, 101 insertions(+), 12 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C
 create mode 100644 

Re: [PATCH 2/2] PR debug/38757 continued. Handle C11, C++11 and C++14.

2014-11-26 Thread Jakub Jelinek
On Wed, Nov 26, 2014 at 11:19:42AM +0100, Mark Wielaard wrote:
 Ping. Rebased patch attached.
 
 I have submitted patches for elfutils, valgrind, gdb and binutils for
 this. But they are pending till this patch hits GCC first.

Ok, thanks.

Jakub


Re: [PATCH 2/2] PR debug/38757 continued. Handle C11, C++11 and C++14.

2014-11-21 Thread Jakub Jelinek
On Thu, Nov 20, 2014 at 11:30:12PM +0100, Mark Wielaard wrote:
 @@ -19592,13 +19597,28 @@ gen_compile_unit_die (const char *filename)
  
language = DW_LANG_C;
if (strncmp (language_string, GNU C++, 7) == 0)
 -language = DW_LANG_C_plus_plus;
 +{
 +  language = DW_LANG_C_plus_plus;
 +  if (dwarf_version = 5 || !dwarf_strict)
 + {
 +   if (strcmp (language_string, GNU C++11) == 0)
 + language = DW_LANG_C_plus_plus_11;
 +   else if (strcmp (language_string, GNU C++14) == 0)
 + language = DW_LANG_C_plus_plus_14;
 + }
 +}

I think best would be to tweak
  if (value  2 || value  4)
error_at (loc, dwarf version %d is not supported, value);
  else
opts-x_dwarf_version = value;
so that we accept value 5 too, and for now, until the
most common consumers are changed, use
  if (dwarf_version = 5 /* || !dwarf_strict */)
so that
- you can actually use it in the test with -gdwarf-5
- you can commit it right away
- people can start playing with what it will mean to support DWARF5

GCC 4.5 also allowed -gdwarf-4 even when DWARF4 has not been released yet.
When there are consumers that can grok it, we can uncomment the
|| !dwarf_strict.

Jason, do you agree?

else if (strncmp (language_string, GNU C, 5) == 0)
  {
language = DW_LANG_C89;
if (dwarf_version = 3 || !dwarf_strict)
 - if (strcmp (language_string, GNU C99) == 0)
 -   language = DW_LANG_C99;
 + {
 +   if (strcmp (language_string, GNU C89) != 0)
 + language = DW_LANG_C99;
 +
 +   if (dwarf_version = 5 || !dwarf_strict)
 + if (strcmp (language_string, GNU C11) == 0)
 +   language = DW_LANG_C11;
 + }

Shouldn't we emit at least DW_LANG_C99 for GNU C11 if
not dwarf_version = 5 /* || !dwarf_strict */ but
dwarf_version = 3 || !dwarf_strict is true?

BTW, noticed we don't have anything for Fortran 2003 and 2008,
filed a DWARF Issue for that.

Jakub


Re: [PATCH 2/2] PR debug/38757 continued. Handle C11, C++11 and C++14.

2014-11-21 Thread Mark Wielaard
On Fri, Nov 21, 2014 at 09:28:45AM +0100, Jakub Jelinek wrote:
 I think best would be to tweak
   if (value  2 || value  4)
 error_at (loc, dwarf version %d is not supported, value);
   else
 opts-x_dwarf_version = value;
 so that we accept value 5 too, and for now, until the
 most common consumers are changed, use
   if (dwarf_version = 5 /* || !dwarf_strict */)
 so that
 - you can actually use it in the test with -gdwarf-5
 - you can commit it right away
 - people can start playing with what it will mean to support DWARF5
 
 GCC 4.5 also allowed -gdwarf-4 even when DWARF4 has not been released yet.
 When there are consumers that can grok it, we can uncomment the
 || !dwarf_strict.

That makes sense and would be convenient for me.

I made the change in opts.c and added some minimal documentation.
And made sure we only emit the new DWARFv5 language values, but not yet
anything else (the table header format has changed for debug_info and
debug_line in v5, but we don't emit new style headers yet). The testcases
were updated to explicitly add -gdwarf-5.

 else if (strncmp (language_string, GNU C, 5) == 0)
   {
 language = DW_LANG_C89;
 if (dwarf_version = 3 || !dwarf_strict)
  -   if (strcmp (language_string, GNU C99) == 0)
  - language = DW_LANG_C99;
  +   {
  + if (strcmp (language_string, GNU C89) != 0)
  +   language = DW_LANG_C99;
  +
  + if (dwarf_version = 5 || !dwarf_strict)
  +   if (strcmp (language_string, GNU C11) == 0)
  + language = DW_LANG_C11;
  +   }
 
 Shouldn't we emit at least DW_LANG_C99 for GNU C11 if
 not dwarf_version = 5 /* || !dwarf_strict */ but
 dwarf_version = 3 || !dwarf_strict is true?

Yes, that is the intention. If it is a versioned GNU C then it is
at least DW_LANG_C89, if we have -gdwarf-3 or higher and it isn't
GNU C89 then it is at least DW_LANG_C99 and if we have -gdwarf-5
and it is GNU C11 then we emit DW_LANG_C11.

I added an explicit testcase for this.

 BTW, noticed we don't have anything for Fortran 2003 and 2008,
 filed a DWARF Issue for that.

Thanks. I have only focussed on C and C++ because I don't know anything
about version changes in other language standards.

With the above change everything keeps working fine. You only need a
patched GDB when explicitly using -gdwarf-5.

OK to commit?

Thanks,

Mark
PR debug/38757 continued. Handle C11, C++11 and C++14.

Add experimental (minimal) DWARFv5 support.

This change depends on the new DWARFv5 constants mentioned in the
following draft: http://dwarfstd.org/doc/dwarf5.20141029.pdf

gcc/ChangeLog

* doc/invoke.texi (-gdwarf-@{version}): Mention experimental DWARFv5.
* opts.c (common_handle_option): Accept -gdwarf-5.
* dwarf2out.c (is_cxx): Add DW_LANG_C_plus_plus_11 and
DW_LANG_C_plus_plus_14.
(lower_bound_default): Likewise. Plus DW_LANG_C11.
(gen_compile_unit_die): Output DW_LANG_C_plus_plus_11,
DW_LANG_C_plus_plus_14 or DW_LANG_C11.
(output_compilation_unit_header): Output at most a DWARFv4 header.
(output_skeleton_debug_sections): Likewise.
(output_line_info): Likewise.
(output_aranges): Document header version number.

gcc/testsuite/ChangeLog

* gcc.dg/debug/dwarf2/lang-c11.c: New test.
* gcc.dg/debug/dwarf2/lang-c11-d4-strict.c: Likewise.
* g++.dg/debug/dwarf2/lang-cpp11.C: Likewise.
* g++.dg/debug/dwarf2/lang-cpp14.C: Likewise.
* g++.dg/debug/dwarf2/lang-cpp98.C: Likewise.

include/ChangeLog

* dwarf2.h: Add DW_LANG_C_plus_plus_11, DW_LANG_C11 and
DW_LANG_C_plus_plus_14.

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 89edddb..d7bce2a 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -5407,8 +5407,8 @@ assembler (GAS) to fail with an error.
 @item -gdwarf-@var{version}
 @opindex gdwarf-@var{version}
 Produce debugging information in DWARF format (if that is supported).
-The value of @var{version} may be either 2, 3 or 4; the default version
-for most targets is 4.
+The value of @var{version} may be either 2, 3, 4 or 5; the default version
+for most targets is 4.  DWARF Version 5 is only experimental.
 
 Note that with DWARF Version 2, some ports require and always
 use some non-conflicting DWARF 3 extensions in the unwind tables.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 3d50ac9..d0eaaf1 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -4684,7 +4684,8 @@ is_cxx (void)
 {
   unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
 
-  return lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus;
+  return (lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus
+ || lang == DW_LANG_C_plus_plus_11 || lang == DW_LANG_C_plus_plus_14);
 }
 
 /* Return TRUE if the language is Java.  */
@@ -8966,7 +8967,9 @@ output_die (dw_die_ref die)
 static void
 

[PATCH 2/2] PR debug/38757 continued. Handle C11, C++11 and C++14.

2014-11-20 Thread Mark Wielaard
This change depends on the new DWARFv5 constants mentioned in the
following draft: http://dwarfstd.org/doc/dwarf5.20141029.pdf

gcc/ChangeLog

* dwarf2out.c (is_cxx): Add DW_LANG_C_plus_plus_11 and
DW_LANG_C_plus_plus_14.
(lower_bound_default): Likewise. Plus DW_LANG_C11.
(gen_compile_unit_die): Output DW_LANG_C_plus_plus_11,
DW_LANG_C_plus_plus_14 or DW_LANG_C11.

gcc/testsuite/ChangeLog

* gcc.dg/debug/dwarf2/lang-c11.c: New test.
* g++.dg/debug/dwarf2/lang-cpp11.C: Likewise.
* g++.dg/debug/dwarf2/lang-cpp14.C: Likewise.
* g++.dg/debug/dwarf2/lang-cpp98.C: Likewise.

include/ChangeLog

* dwarf2.h: Add DW_LANG_C_plus_plus_11, DW_LANG_C11 and
DW_LANG_C_plus_plus_14.
---
 gcc/ChangeLog  |  8 
 gcc/dwarf2out.c| 28 ++
 gcc/testsuite/ChangeLog|  7 +++
 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C |  6 ++
 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C |  6 ++
 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C |  6 ++
 gcc/testsuite/gcc.dg/debug/dwarf2/lang-c11.c   |  6 ++
 include/ChangeLog  |  5 +
 include/dwarf2.h   |  4 
 9 files changed, 72 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C
 create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/lang-c11.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 222558d..f7fabdf 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
 2014-11-20  Mark Wielaard  m...@redhat.com
 
+   * dwarf2out.c (is_cxx): Add DW_LANG_C_plus_plus_11 and
+   DW_LANG_C_plus_plus_14.
+   (lower_bound_default): Likewise. Plus DW_LANG_C11.
+   (gen_compile_unit_die): Output DW_LANG_C_plus_plus_11,
+   DW_LANG_C_plus_plus_14 or DW_LANG_C11.
+
+2014-11-20  Mark Wielaard  m...@redhat.com
+
PR debug/38757
* config/avr/avr-c.c (avr_cpu_cpp_builtins): Use strncmp to
check lang_hooks.name.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 7844f33..c28deec 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -4684,7 +4684,8 @@ is_cxx (void)
 {
   unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
 
-  return lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus;
+  return (lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus
+ || lang == DW_LANG_C_plus_plus_11 || lang == DW_LANG_C_plus_plus_14);
 }
 
 /* Return TRUE if the language is Java.  */
@@ -16402,7 +16403,10 @@ lower_bound_default (void)
 case DW_LANG_C:
 case DW_LANG_C89:
 case DW_LANG_C99:
+case DW_LANG_C11:
 case DW_LANG_C_plus_plus:
+case DW_LANG_C_plus_plus_11:
+case DW_LANG_C_plus_plus_14:
 case DW_LANG_ObjC:
 case DW_LANG_ObjC_plus_plus:
 case DW_LANG_Java:
@@ -16746,6 +16750,7 @@ add_prototyped_attribute (dw_die_ref die, tree 
func_type)
 case DW_LANG_C:
 case DW_LANG_C89:
 case DW_LANG_C99:
+case DW_LANG_C11:
 case DW_LANG_ObjC:
   if (prototype_p (func_type))
add_AT_flag (die, DW_AT_prototyped, 1);
@@ -19592,13 +19597,28 @@ gen_compile_unit_die (const char *filename)
 
   language = DW_LANG_C;
   if (strncmp (language_string, GNU C++, 7) == 0)
-language = DW_LANG_C_plus_plus;
+{
+  language = DW_LANG_C_plus_plus;
+  if (dwarf_version = 5 || !dwarf_strict)
+   {
+ if (strcmp (language_string, GNU C++11) == 0)
+   language = DW_LANG_C_plus_plus_11;
+ else if (strcmp (language_string, GNU C++14) == 0)
+   language = DW_LANG_C_plus_plus_14;
+   }
+}
   else if (strncmp (language_string, GNU C, 5) == 0)
 {
   language = DW_LANG_C89;
   if (dwarf_version = 3 || !dwarf_strict)
-   if (strcmp (language_string, GNU C99) == 0)
- language = DW_LANG_C99;
+   {
+ if (strcmp (language_string, GNU C89) != 0)
+   language = DW_LANG_C99;
+
+ if (dwarf_version = 5 || !dwarf_strict)
+   if (strcmp (language_string, GNU C11) == 0)
+ language = DW_LANG_C11;
+   }
 }
   else if (strcmp (language_string, GNU F77) == 0)
 language = DW_LANG_Fortran77;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9b29745..59f68ae 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,12 @@
 2014-11-20  Mark Wielaard  m...@redhat.com
 
+   * gcc.dg/debug/dwarf2/lang-c11.c: New test.
+   * g++.dg/debug/dwarf2/lang-cpp11.C: Likewise.
+   * g++.dg/debug/dwarf2/lang-cpp14.C: Likewise.
+   * g++.dg/debug/dwarf2/lang-cpp98.C: Likewise.
+
+2014-11-20  Mark Wielaard  m...@redhat.com
+
PR debug/38757
*