public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Sharma, Alok Kumar" <AlokKumar.Sharma@amd.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: "George, Jini Susan" <JiniSusan.George@amd.com>,
	"Achra, Nitika"	<Nitika.Achra@amd.com>
Subject: [PATCH] gdb/fortran Fixed printing of logical true values for Flang
Date: Mon, 02 Mar 2020 17:00:00 -0000	[thread overview]
Message-ID: <DM6PR12MB31294CF1BEAC6E8CA1CCE27B9EE70@DM6PR12MB3129.namprd12.prod.outlook.com> (raw)

[-- 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


             reply	other threads:[~2020-03-02 17:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-02 17:00 Sharma, Alok Kumar [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM6PR12MB31294CF1BEAC6E8CA1CCE27B9EE70@DM6PR12MB3129.namprd12.prod.outlook.com \
    --to=alokkumar.sharma@amd.com \
    --cc=JiniSusan.George@amd.com \
    --cc=Nitika.Achra@amd.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).