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

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