Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Remove C/C++ relevant code in Fortran specific file.
@ 2013-09-24 14:44 Christoph Weinmann
  2013-09-24 15:14 ` Weinmann, Christoph T
  2013-09-24 17:39 ` Tom Tromey
  0 siblings, 2 replies; 3+ messages in thread
From: Christoph Weinmann @ 2013-09-24 14:44 UTC (permalink / raw)
  To: tromey; +Cc: gdb-patches

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

2013-09-24  Christoph Weinmann  <christoph.t.weinmann@intel.com>

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

testsuite/
	* gdb.fortran/printing-types.exp: Add test program for
	printing one and two byte sized Integers, character and
	logical type.
	* gdb.fortran/printing-types.exp: Add test case for
	printing one and two byte size Integers, character, and
	logical type.

Change-Id: I9ac9d718b6a65c039b5814938ddb5e42ef225f3d
---
 gdb/f-valprint.c                             |   16 +--------
 gdb/testsuite/gdb.fortran/printing-types.exp |   49 ++++++++++++++++++++++++++
 gdb/testsuite/gdb.fortran/printing-types.f90 |   32 +++++++++++++++++
 3 files changed, 82 insertions(+), 15 deletions(-)
 create mode 100644 gdb/testsuite/gdb.fortran/printing-types.exp
 create mode 100644 gdb/testsuite/gdb.fortran/printing-types.f90

diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index d01d6ec..f267ad1 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -354,21 +354,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 				      original_value, options, 0, stream);
 	}
       else
-	{
-	  val_print_type_code_int (type, valaddr + embedded_offset, 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_type_code_int (type, valaddr + embedded_offset, 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..b72f2ba
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/printing-types.exp
@@ -0,0 +1,49 @@
+# Copyright 2013 Free Software Foundation, Inc.
+
+# Contributed by Intel Corp. <christoph.t.weinmann@intel.com>
+
+# 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 {
+    perror "Could not run to breakpoint MAIN__"
+    continue
+}
+
+set bp_location [gdb_get_line_number "BP1"]
+
+gdb_test "break $bp_location" \
+    "Breakpoint.*at.* file .*$srcfile, line $bp_location\\." \
+    "Breakpoint at BP1"
+
+gdb_continue_to_breakpoint "write"
+
+# Check the printed output of small data types.
+gdb_test "print oneByte" ".* = 1.*" "Print the value of a one byte sized Integer type."
+
+gdb_test "print twobytes" ".*2 = 2.*" "Print the value of a two bytes sized Integer type."
+
+gdb_test "print chvalue" ".*3 = \'a\'.*" "Print the value of a Character type."
+
+gdb_test "print logvalue" ".*4 = \.TRUE\..*" "Print the value of a Logical type."
+
diff --git a/gdb/testsuite/gdb.fortran/printing-types.f90 b/gdb/testsuite/gdb.fortran/printing-types.f90
new file mode 100644
index 0000000..da17dbe
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/printing-types.f90
@@ -0,0 +1,32 @@
+! Test file for printing simple types in Fortran.
+
+! Copyright 2013 Free Software Foundation, Inc.
+
+! Contributed by Intel Corp. <christoph.t.weinmann@intel.com>
+
+! 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.
+  oneByte = 2             !BP1
+end
+
-- 
1.7.0.7


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] Remove C/C++ relevant code in Fortran specific file.
  2013-09-24 14:44 [PATCH] Remove C/C++ relevant code in Fortran specific file Christoph Weinmann
@ 2013-09-24 15:14 ` Weinmann, Christoph T
  2013-09-24 17:39 ` Tom Tromey
  1 sibling, 0 replies; 3+ messages in thread
From: Weinmann, Christoph T @ 2013-09-24 15:14 UTC (permalink / raw)
  To: tromey; +Cc: gdb-patches

Sorry, forgot the example output for:
integer(1) :: i = 1
integer(2) :: j = 2

Printing those Fortran integer(1)and integer(2) before the patch in gdb results in:
i = 1 '\001'
j = 2
	
After the patch, the output in gdb is:
i = 1
j = 2

Sorry again,
Christoph

-----Original Message-----
From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-owner@sourceware.org] On Behalf Of Christoph Weinmann
Sent: Tuesday, September 24, 2013 4:44 PM
To: tromey@redhat.com
Cc: gdb-patches@sourceware.org
Subject: [PATCH] Remove C/C++ relevant code in Fortran specific file.

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

2013-09-24  Christoph Weinmann  <christoph.t.weinmann@intel.com>

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

testsuite/
	* gdb.fortran/printing-types.exp: Add test program for
	printing one and two byte sized Integers, character and
	logical type.
	* gdb.fortran/printing-types.exp: Add test case for
	printing one and two byte size Integers, character, and
	logical type.

Change-Id: I9ac9d718b6a65c039b5814938ddb5e42ef225f3d
---
 gdb/f-valprint.c                             |   16 +--------
 gdb/testsuite/gdb.fortran/printing-types.exp |   49 ++++++++++++++++++++++++++
 gdb/testsuite/gdb.fortran/printing-types.f90 |   32 +++++++++++++++++
 3 files changed, 82 insertions(+), 15 deletions(-)  create mode 100644 gdb/testsuite/gdb.fortran/printing-types.exp
 create mode 100644 gdb/testsuite/gdb.fortran/printing-types.f90

diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index d01d6ec..f267ad1 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -354,21 +354,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 				      original_value, options, 0, stream);
 	}
       else
-	{
-	  val_print_type_code_int (type, valaddr + embedded_offset, 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_type_code_int (type, valaddr + embedded_offset, 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..b72f2ba
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/printing-types.exp
@@ -0,0 +1,49 @@
+# Copyright 2013 Free Software Foundation, Inc.
+
+# Contributed by Intel Corp. <christoph.t.weinmann@intel.com>
+
+# 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 {
+    perror "Could not run to breakpoint MAIN__"
+    continue
+}
+
+set bp_location [gdb_get_line_number "BP1"]
+
+gdb_test "break $bp_location" \
+    "Breakpoint.*at.* file .*$srcfile, line $bp_location\\." \
+    "Breakpoint at BP1"
+
+gdb_continue_to_breakpoint "write"
+
+# Check the printed output of small data types.
+gdb_test "print oneByte" ".* = 1.*" "Print the value of a one byte sized Integer type."
+
+gdb_test "print twobytes" ".*2 = 2.*" "Print the value of a two bytes sized Integer type."
+
+gdb_test "print chvalue" ".*3 = \'a\'.*" "Print the value of a Character type."
+
+gdb_test "print logvalue" ".*4 = \.TRUE\..*" "Print the value of a Logical type."
+
diff --git a/gdb/testsuite/gdb.fortran/printing-types.f90 b/gdb/testsuite/gdb.fortran/printing-types.f90
new file mode 100644
index 0000000..da17dbe
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/printing-types.f90
@@ -0,0 +1,32 @@
+! Test file for printing simple types in Fortran.
+
+! Copyright 2013 Free Software Foundation, Inc.
+
+! Contributed by Intel Corp. <christoph.t.weinmann@intel.com>
+
+! 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.
+  oneByte = 2             !BP1
+end
+
--
1.7.0.7

Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Remove C/C++ relevant code in Fortran specific file.
  2013-09-24 14:44 [PATCH] Remove C/C++ relevant code in Fortran specific file Christoph Weinmann
  2013-09-24 15:14 ` Weinmann, Christoph T
@ 2013-09-24 17:39 ` Tom Tromey
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2013-09-24 17:39 UTC (permalink / raw)
  To: Christoph Weinmann; +Cc: gdb-patches

>>>>> "Christoph" == Christoph Weinmann <christoph.t.weinmann@intel.com> writes:

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

Looks good.  A question below, and a minor nit.

Christoph> --- a/gdb/f-valprint.c
Christoph> +++ b/gdb/f-valprint.c
Christoph> @@ -354,21 +354,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
Christoph>  				      original_value, options, 0, stream);
Christoph>  	}
Christoph>        else
Christoph> -	{
Christoph> -	  val_print_type_code_int (type, valaddr + embedded_offset, stream);
Christoph> -	  /* C and C++ has no single byte int type, char is used instead.
Christoph> -	     Since we don't know whether the value is really intended to
Christoph> -	     be used as an integer or a character, print the character
Christoph> -	     equivalent as well.  */
Christoph> -	  if (TYPE_LENGTH (type) == 1)
Christoph> -	    {
Christoph> -	      LONGEST c;
Christoph> -
Christoph> -	      fputs_filtered (" ", stream);
Christoph> -	      c = unpack_long (type, valaddr + embedded_offset);
Christoph> -	      LA_PRINT_CHAR ((unsigned char) c, type, stream);
Christoph> -	    }
Christoph> -	}
Christoph> +	val_print_type_code_int (type, valaddr + embedded_offset, stream);
Christoph>        break;
 
I wonder whether the whole "if" can be removed and simply call
val_print_scalar_formatted.

It's not that important, though.  This part is fine as-is.

Christoph> +# Check the printed output of small data types.
Christoph> +gdb_test "print oneByte" ".* = 1.*" "Print the value of a one byte sized Integer type."
Christoph> +
Christoph> +gdb_test "print twobytes" ".*2 = 2.*" "Print the value of a two bytes sized Integer type."
Christoph> +
Christoph> +gdb_test "print chvalue" ".*3 = \'a\'.*" "Print the value of a Character type."
Christoph> +
Christoph> +gdb_test "print logvalue" ".*4 = \.TRUE\..*" "Print the value of a Logical type."

These lines go over the line length limit and should be split.

The patch is ok with this fixed.

Tom


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-09-24 17:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-24 14:44 [PATCH] Remove C/C++ relevant code in Fortran specific file Christoph Weinmann
2013-09-24 15:14 ` Weinmann, Christoph T
2013-09-24 17:39 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox