public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/fortran Fixed printing of logical true values for Flang
@ 2020-03-02 17:00 Sharma, Alok Kumar
  2020-03-02 18:21 ` [PATCHv2] gdb/fortran: Fix " Andrew Burgess
  0 siblings, 1 reply; 9+ messages in thread
From: Sharma, Alok Kumar @ 2020-03-02 17:00 UTC (permalink / raw)
  To: gdb-patches; +Cc: George, Jini Susan, Achra, Nitika

[-- Attachment #1: Type: text/plain, Size: 983 bytes --]

Hi all,

I request you all to please review the patch. Below are the details.

Problem Description:

gdb is not able to print logical true values for Flang compiler.
    actual result
    --------------
    (gdb) p l
    $1 = 4294967295
    --------------
    expected result
    --------------
    (gdb) p l
    $1 = .TRUE.
    --------------

Root cause:

    This is due to GDB expecting representation of true value being 1.
    The fortran standard doesnt specify how LOGICAL types are represented.
    Different compilers use different non zero values to represent LOGICAL
    TRUE. The gfortran compiler uses 1 to represent LOGICAL TRUE and flang
    compiler uses -1. GDB should accept all the non zero values as TRUE.

Resolution:

    Now function 'generic_val_print_bool' is modified to be able to print
    true logical value for the Flang compiler.

Testing:

- No regression seen

Please let me know your comments.

Regards,
Alok

[-- Attachment #2: 0001-gdb-fortran-Fixed-printing-of-logical-true-values-fo.patch --]
[-- Type: application/octet-stream, Size: 1883 bytes --]

From f8a7a8070df398a143e49ed6f8d2702583689342 Mon Sep 17 00:00:00 2001
From: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
Date: Mon, 2 Mar 2020 21:49:50 +0530
Subject: [PATCH] gdb/fortran Fixed printing of logical true values for Flang

gdb is not able to print logical true values for Flang compiler.
actual result
--------------
(gdb) p l
$1 = 4294967295
--------------
expected result
--------------
(gdb) p l
$1 = .TRUE.
--------------
This is due to GDB expecting representation of true value being 1.
The fortran standard doesnt specify how LOGICAL types are represented.
Different compilers use different non zero values to represent LOGICAL
TRUE. The gfortran compiler uses 1 to represent LOGICAL TRUE and flang
compiler uses -1. GDB should accept all the non zero values as TRUE.
Now function 'generic_val_print_bool' is modified to be able to print
true logical value for the Flang compiler.

gdb/ChangeLog:

	* valprint.c (generic_val_print_bool): Changed to treat any
	non-zero value as TRUE for fortran LOGICAL type.

Change-Id: I0509c5b50bf3481b9fca2aad46fb17742ec9aae3
---
 gdb/valprint.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdb/valprint.c b/gdb/valprint.c
index 8adbb3df45..1de0ebd3df 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -793,7 +793,10 @@ generic_val_print_bool (struct type *type,
       val = unpack_long (type, valaddr + embedded_offset * unit_size);
       if (val == 0)
 	fputs_filtered (decorations->false_name, stream);
-      else if (val == 1)
+      /* The fortran standard doesnt specify how LOGICAL types are represented.
+         Different compilers use different non zero values to represent LOGICAL
+         TRUE.  */
+      else if (current_language == &f_language_defn || val == 1)
 	fputs_filtered (decorations->true_name, stream);
       else
 	print_longest (stream, 'd', 0, val);
-- 
2.17.1


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

end of thread, other threads:[~2020-03-11 12:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-02 17:00 [PATCH] gdb/fortran Fixed printing of logical true values for Flang Sharma, Alok Kumar
2020-03-02 18:21 ` [PATCHv2] gdb/fortran: Fix " Andrew Burgess
2020-03-03  4:47   ` Sharma, Alok Kumar
2020-03-03 18:21     ` Andrew Burgess
2020-03-04  8:48       ` [gdb/testsuite] Fix missing uint8_t in gdb.fortran/logical.exp Tom de Vries
2020-03-11 10:24         ` Andrew Burgess
2020-03-11 12:00           ` Tom de Vries
2020-03-03 16:32   ` [PATCHv2] gdb/fortran: Fix printing of logical true values for Flang Tom Tromey
2020-03-03 17:24     ` Andrew Burgess

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).