Blame SOURCES/gdb-vla-intel-fix-print-char-array.patch

b2f73e
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
b2f73e
From: Sergio Durigan Junior <sergiodj@redhat.com>
b2f73e
Date: Thu, 7 Dec 2017 16:20:31 -0500
b2f73e
Subject: gdb-vla-intel-fix-print-char-array.patch
b2f73e
b2f73e
;; Revert upstream commit 469412dd9ccc4de5874fd3299b105833f36b34cd
b2f73e
b2f73e
Revert commit (only the part touching gdb/f-valprint.c):
b2f73e
b2f73e
  commit 469412dd9ccc4de5874fd3299b105833f36b34cd
b2f73e
  Author: Christoph Weinmann <christoph.t.weinmann@intel.com>
b2f73e
  Date:   Fri Sep 8 15:11:47 2017 +0200
b2f73e
b2f73e
      Remove C/C++ relevant code in Fortran specific file.
b2f73e
b2f73e
      Remove code relevant for printing C/C++ Integer values in a
b2f73e
      Fortran specific file to unify printing of Fortran values.
b2f73e
      This does not change the output.
b2f73e
b2f73e
And adjust its testcase.
b2f73e
b2f73e
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
b2f73e
--- a/gdb/f-valprint.c
b2f73e
+++ b/gdb/f-valprint.c
b2f73e
@@ -319,8 +319,22 @@ f_val_print (struct type *type, int embedded_offset,
b2f73e
 				      original_value, &opts, 0, stream);
b2f73e
 	}
b2f73e
       else
b2f73e
-	val_print_scalar_formatted (type, embedded_offset,
b2f73e
-				    original_value, options, 0, stream);
b2f73e
+	{
b2f73e
+	  val_print_scalar_formatted (type, embedded_offset,
b2f73e
+				      original_value, options, 0, stream);
b2f73e
+	  /* C and C++ has no single byte int type, char is used instead.
b2f73e
+	     Since we don't know whether the value is really intended to
b2f73e
+	     be used as an integer or a character, print the character
b2f73e
+	     equivalent as well.  */
b2f73e
+	  if (TYPE_LENGTH (type) == 1)
b2f73e
+	    {
b2f73e
+	      LONGEST c;
b2f73e
+
b2f73e
+	      fputs_filtered (" ", stream);
b2f73e
+	      c = unpack_long (type, valaddr + embedded_offset);
b2f73e
+	      LA_PRINT_CHAR ((unsigned char) c, type, stream);
b2f73e
+	    }
b2f73e
+	}
b2f73e
       break;
b2f73e
 
b2f73e
     case TYPE_CODE_STRUCT:
b2f73e
diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp b/gdb/testsuite/gdb.fortran/printing-types.exp
b2f73e
--- a/gdb/testsuite/gdb.fortran/printing-types.exp
b2f73e
+++ b/gdb/testsuite/gdb.fortran/printing-types.exp
b2f73e
@@ -29,7 +29,7 @@ if {![runto MAIN__]} then {
b2f73e
 gdb_breakpoint [gdb_get_line_number "write"]
b2f73e
 gdb_continue_to_breakpoint "write"
b2f73e
 
b2f73e
-gdb_test "print oneByte"	" = 1"
b2f73e
+gdb_test "print oneByte"	" = 1 \'\\\\001\'"
b2f73e
 gdb_test "print twobytes"	" = 2"
b2f73e
 gdb_test "print chvalue"	" = \'a\'"
b2f73e
 gdb_test "print logvalue"	" = \.TRUE\."