[4/4] Remove C/C++ relevant code in Fortran specific file.

Message ID 1503317966-12486-5-git-send-email-tim.wiederhake@intel.com
State New, archived
Headers

Commit Message

Wiederhake, Tim Aug. 21, 2017, 12:19 p.m. UTC
  From: Christoph Weinmann <christoph.t.weinmann@intel.com>

Remove code relevant for printing C/C++ Integer values in a
Fortran specific file to unify printing of Fortran values.

xxxx-yy-zz  Christoph Weinmann  <christoph.t.weinmann@intel.com>

gdb/ChangeLog:

	* f-valprint.c (f_val_print): Remove check for one byte
	sized integers. Remove printing of character type.

gdb/testsuite/ChangeLog:

	* gdb.fortran/printing-types.exp: New file.
	* gdb.fortran/printing-types.exp: New file.


---
 gdb/f-valprint.c                             | 18 ++------------
 gdb/testsuite/gdb.fortran/printing-types.exp | 35 ++++++++++++++++++++++++++++
 gdb/testsuite/gdb.fortran/printing-types.f90 | 27 +++++++++++++++++++++
 3 files changed, 64 insertions(+), 16 deletions(-)
 create mode 100644 gdb/testsuite/gdb.fortran/printing-types.exp
 create mode 100644 gdb/testsuite/gdb.fortran/printing-types.f90
  

Comments

Yao Qi Sept. 4, 2017, 1:31 p.m. UTC | #1
Tim Wiederhake <tim.wiederhake@intel.com> writes:

> Remove code relevant for printing C/C++ Integer values in a
> Fortran specific file to unify printing of Fortran values.

Does this patch affect the output of printing variables in Fortran?
If so, how does it affect the output?  It would be great to mention
these changes in commit log, at least.

>
> xxxx-yy-zz  Christoph Weinmann  <christoph.t.weinmann@intel.com>
>
> gdb/ChangeLog:
>
> 	* f-valprint.c (f_val_print): Remove check for one byte
> 	sized integers. Remove printing of character type.
>
> gdb/testsuite/ChangeLog:
>
> 	* gdb.fortran/printing-types.exp: New file.

gdb.fortran/printing-types.f90.

> 	* gdb.fortran/printing-types.exp: New file.
  
Wiederhake, Tim Sept. 8, 2017, 1:18 p.m. UTC | #2
Thanks!

Clarified in the commit message that the output is unchanged. Pushed as 469412dd9ccc4de5874fd3299b105833f36b34cd.

Tim

> -----Original Message-----

> From: Yao Qi [mailto:qiyaoltc@gmail.com]

> Sent: Monday, September 4, 2017 3:32 PM

> To: Wiederhake, Tim <tim.wiederhake@intel.com>

> Cc: gdb-patches@sourceware.org; Weinmann, Christoph T

> <christoph.t.weinmann@intel.com>

> Subject: Re: [PATCH 4/4] Remove C/C++ relevant code in Fortran specific

> file.

> 

> Tim Wiederhake <tim.wiederhake@intel.com> writes:

> 

> > Remove code relevant for printing C/C++ Integer values in a

> > Fortran specific file to unify printing of Fortran values.

> 

> Does this patch affect the output of printing variables in Fortran?

> If so, how does it affect the output?  It would be great to mention

> these changes in commit log, at least.

> 

> >

> > xxxx-yy-zz  Christoph Weinmann  <christoph.t.weinmann@intel.com>

> >

> > gdb/ChangeLog:

> >

> > 	* f-valprint.c (f_val_print): Remove check for one byte

> > 	sized integers. Remove printing of character type.

> >

> > gdb/testsuite/ChangeLog:

> >

> > 	* gdb.fortran/printing-types.exp: New file.

> 

> gdb.fortran/printing-types.f90.

> 

> > 	* gdb.fortran/printing-types.exp: New file.

> 

> --

> Yao (齐尧)

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
  

Patch

diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 4234447..8fc894a 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -310,22 +310,8 @@  f_val_print (struct type *type, int embedded_offset,
 				      original_value, &opts, 0, stream);
 	}
       else
-	{
-	  val_print_scalar_formatted (type, embedded_offset,
-				      original_value, options, 0, stream);
-	  /* C and C++ has no single byte int type, char is used instead.
-	     Since we don't know whether the value is really intended to
-	     be used as an integer or a character, print the character
-	     equivalent as well.  */
-	  if (TYPE_LENGTH (type) == 1)
-	    {
-	      LONGEST c;
-
-	      fputs_filtered (" ", stream);
-	      c = unpack_long (type, valaddr + embedded_offset);
-	      LA_PRINT_CHAR ((unsigned char) c, type, stream);
-	    }
-	}
+	val_print_scalar_formatted (type, embedded_offset,
+				    original_value, options, 0, stream);
       break;
 
     case TYPE_CODE_STRUCT:
diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp b/gdb/testsuite/gdb.fortran/printing-types.exp
new file mode 100644
index 0000000..085de4f
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/printing-types.exp
@@ -0,0 +1,35 @@ 
+# Copyright 2017 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+if {[skip_fortran_tests]} { return -1 }
+
+standard_testfile .f90
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
+    return -1
+}
+
+if {![runto MAIN__]} then {
+    untested "Could not run to breakpoint MAIN__"
+    return -1
+}
+
+gdb_breakpoint [gdb_get_line_number "write"]
+gdb_continue_to_breakpoint "write"
+
+gdb_test "print oneByte"	" = 1"
+gdb_test "print twobytes"	" = 2"
+gdb_test "print chvalue"	" = \'a\'"
+gdb_test "print logvalue"	" = \.TRUE\."
diff --git a/gdb/testsuite/gdb.fortran/printing-types.f90 b/gdb/testsuite/gdb.fortran/printing-types.f90
new file mode 100644
index 0000000..749aa7c
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/printing-types.f90
@@ -0,0 +1,27 @@ 
+! Copyright 2017 Free Software Foundation, Inc.
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 3 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+program prog
+  integer(1) :: oneByte
+  integer(2) :: twoBytes
+  character  :: chValue
+  logical(1) :: logValue
+
+  oneByte  = 1
+  twoBytes = 2
+  chValue  = 'a'
+  logValue = .true.
+  write(*,*) s
+end