aboutsummaryrefslogtreecommitdiff
path: root/gdb/f-valprint.c
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2020-03-02 18:08:49 +0000
committerAndrew Burgess <andrew.burgess@embecosm.com>2020-03-03 18:20:18 +0000
commit5e5d66b6a46c7b0353308bfb508b96a59f1addbf (patch)
tree6f253eff4c7af4858fcf1bc0f2955a0b6f30f042 /gdb/f-valprint.c
parent584cf46d0ab5960cca76bfaf414cee5641166868 (diff)
downloadgdb-5e5d66b6a46c7b0353308bfb508b96a59f1addbf.zip
gdb-5e5d66b6a46c7b0353308bfb508b96a59f1addbf.tar.gz
gdb-5e5d66b6a46c7b0353308bfb508b96a59f1addbf.tar.bz2
gdb/fortran: Fix 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 the flang compiler uses -1. GDB should accept all the non-zero values as true. This is achieved by handling TYPE_CODE_BOOL in f_val_print and printing any non-zero value as true. gdb/ChangeLog: * f-valprint.c (f_val_print): Handle TYPE_CODE_BOOL, any non-zero value should be printed as true. gdb/testsuite/ChangeLog: * gdb.fortran/logical.exp: Add tests that any non-zero value is printed as true.
Diffstat (limited to 'gdb/f-valprint.c')
-rw-r--r--gdb/f-valprint.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index a25e614..0393ddf 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -357,6 +357,30 @@ f_val_print (struct type *type, int embedded_offset,
fprintf_filtered (stream, " )");
break;
+ case TYPE_CODE_BOOL:
+ if (options->format || options->output_format)
+ {
+ struct value_print_options opts = *options;
+ opts.format = (options->format ? options->format
+ : options->output_format);
+ val_print_scalar_formatted (type, embedded_offset,
+ original_value, &opts, 0, stream);
+ }
+ else
+ {
+ int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
+ LONGEST val
+ = unpack_long (type, valaddr + embedded_offset * unit_size);
+ /* The Fortran standard doesn't specify how logical types are
+ represented. Different compilers use different non zero
+ values to represent logical true. */
+ if (val == 0)
+ fputs_filtered (f_decorations.false_name, stream);
+ else
+ fputs_filtered (f_decorations.true_name, stream);
+ }
+ break;
+
case TYPE_CODE_REF:
case TYPE_CODE_FUNC:
case TYPE_CODE_FLAGS:
@@ -366,7 +390,6 @@ f_val_print (struct type *type, int embedded_offset,
case TYPE_CODE_RANGE:
case TYPE_CODE_UNDEF:
case TYPE_CODE_COMPLEX:
- case TYPE_CODE_BOOL:
case TYPE_CODE_CHAR:
default:
generic_val_print (type, embedded_offset, address,