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

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