From patchwork Sat May 4 12:17:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 32543 Received: (qmail 106303 invoked by alias); 4 May 2019 12:17:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 106294 invoked by uid 89); 4 May 2019 12:17:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=f-lang.c, sk:printin, HX-Envelope-From:sk:andrew., sk:build_f X-HELO: mail-wr1-f65.google.com Received: from mail-wr1-f65.google.com (HELO mail-wr1-f65.google.com) (209.85.221.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 04 May 2019 12:17:44 +0000 Received: by mail-wr1-f65.google.com with SMTP id h15so5435740wrb.2 for ; Sat, 04 May 2019 05:17:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id; bh=w1s8eFmRtN02wqrNLXaY30xM0olUw9Dszi6r8qnTjUs=; b=QLdzLsUrL9Eqfm0UkXQlOqH+y5qiN137FC5tdtLCzIlU7fdstPw/Ds2RK/PaqjnmlL EgNAOgZOMULENLkjSXS2RMVy3L1haXNbMR1fWTLkKsFKj10Dmw/GnKqiIRr90YLdLWvy FV0xaLxKY/VLsUg9pGLBgHf/GlZl2uo3m0unqg3lDzUzke0jl1T/LzWUCQxWYDURmPzj UnMG8XmGsjO4OuPQVRsPLk5/rWy+DkTUaPF2REsKsZY4m61J7NXbXbcd+rZeXwMXkZeA R8kMAHaPd1ZYXRcZgClYAnUPjXr+e8VAErT5NgYMSJZkVPvGGFHxBAOtqZqNmKS2UwRx RuRg== Return-Path: Received: from localhost (host109-154-100-57.range109-154.btcentralplus.com. [109.154.100.57]) by smtp.gmail.com with ESMTPSA id o16sm6486026wro.63.2019.05.04.05.17.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 04 May 2019 05:17:40 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Richard Bunt , Sergio Durigan Junior , Andrew Burgess Subject: [PATCH] gdb/fortran: Use floatformats_ia64_quad for fortran 16-byte floats Date: Sat, 4 May 2019 13:17:34 +0100 Message-Id: <20190504121734.5868-1-andrew.burgess@embecosm.com> X-IsSubscribed: yes This patch addresses some regressions that Sergio identified in this mail: https://sourceware.org/ml/gdb-patches/2019-05/msg00060.html It turns out these regressions are all related to bug PR gdb/18644 which I've resolved in this patch. I'm posting this as a new thread rather than a reply for more visibility. Thanks, Andrew --- PR gdb/18644 is caused by GDB using the wrong floating point format for gfortran's 16-byte floating point type, including when the 16-byte float is used as the component of a 32-byte complex type. This commit addresses the issue in two places, first in i386-tdep.c there already exists some code to force the use of floatformats_ia64_quad for specific named types. This code is extended to include the type names that gfortran uses for its 16-byte floats. Second, the builtin 16-byte float type (in f-lang.c) is changed to use floatformats_ia64_quad instead of the long double type from gdbarch. On some targets (for example i386) long double is not 16-bytes, and so is inappropriate. This patch was tested on X86-64/GNU-Linux using '--target_board=unix' and '--target_board=unix/-m32', and resolves all of the known failures associated with PR gdb/18644. I've also added the test case from the original bug report. gdb/ChangeLog: PR gdb/18644: * f-lang.c (build_fortran_types): Use floatformats_ia64_quad for 16-byte floats. * i386-tdep.c (i386_floatformat_for_type): Use floatformats_ia64_quad for the 16-byte floating point component within a fortran 32-byte complex number. gdb/testsuite/ChangeLog: PR gdb/18644 * gdb.fortran/complex.exp: Remove setup_kfail calls. * gdb.fortran/printing-types.exp: Add new test. * gdb.fortran/printing-types.f90: Add 16-byte real variable for testing. * gdb.fortran/type-kinds.exp (test_cast_1_to_type_kind): Remove setup_kfail call. --- gdb/ChangeLog | 9 +++++++++ gdb/f-lang.c | 3 +-- gdb/i386-tdep.c | 4 +++- gdb/testsuite/ChangeLog | 10 ++++++++++ gdb/testsuite/gdb.fortran/complex.exp | 2 -- gdb/testsuite/gdb.fortran/printing-types.exp | 1 + gdb/testsuite/gdb.fortran/printing-types.f90 | 2 ++ gdb/testsuite/gdb.fortran/type-kinds.exp | 6 ------ 8 files changed, 26 insertions(+), 11 deletions(-) diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 9da6fdb3e1c..d7b322f759d 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -728,8 +728,7 @@ build_fortran_types (struct gdbarch *gdbarch) = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch), "real*8", gdbarch_double_format (gdbarch)); builtin_f_type->builtin_real_s16 - = arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch), - "real*16", gdbarch_long_double_format (gdbarch)); + = arch_float_type (gdbarch, 128, "real*16", floatformats_ia64_quad); builtin_f_type->builtin_complex_s8 = arch_complex_type (gdbarch, "complex*8", diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 54d9dd873b8..66fc6d679e2 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -8158,7 +8158,9 @@ i386_floatformat_for_type (struct gdbarch *gdbarch, if (len == 128 && name) if (strcmp (name, "__float128") == 0 || strcmp (name, "_Float128") == 0 - || strcmp (name, "complex _Float128") == 0) + || strcmp (name, "complex _Float128") == 0 + || strcmp (name, "complex(kind=16)") == 0 + || strcmp (name, "real(kind=16)") == 0) return floatformats_ia64_quad; return default_floatformat_for_type (gdbarch, name, len); diff --git a/gdb/testsuite/gdb.fortran/complex.exp b/gdb/testsuite/gdb.fortran/complex.exp index 136f1c4df79..94ac53afc70 100644 --- a/gdb/testsuite/gdb.fortran/complex.exp +++ b/gdb/testsuite/gdb.fortran/complex.exp @@ -33,7 +33,6 @@ gdb_test "print c4" " = \\(1000,-50\\)" gdb_test "print c8" " = \\(321,-22\\)" gdb_test "print dc" " = \\(321,-22\\)" -setup_kfail gdb/18644 "*-*-*" gdb_test "print c16" " = \\(-874,19\\)" gdb_test "whatis c" "type = complex\\(kind=4\\)" @@ -53,7 +52,6 @@ gdb_test "print \$_creal (dc)" " = 321" gdb_test "whatis \$" " = real\\*8" gdb_test "whatis c16" "type = complex\\(kind=16\\)" -setup_kfail gdb/18644 "*-*-*" gdb_test "print \$_creal (c16)" " = -874" gdb_test "whatis \$" " = real\\*16" diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp b/gdb/testsuite/gdb.fortran/printing-types.exp index 2f6be4ec249..6394e45f4c3 100644 --- a/gdb/testsuite/gdb.fortran/printing-types.exp +++ b/gdb/testsuite/gdb.fortran/printing-types.exp @@ -33,3 +33,4 @@ gdb_test "print oneByte" " = 1" gdb_test "print twobytes" " = 2" gdb_test "print chvalue" " = \'a\'" gdb_test "print logvalue" " = \.TRUE\." +gdb_test "print rVal" " = 2000" diff --git a/gdb/testsuite/gdb.fortran/printing-types.f90 b/gdb/testsuite/gdb.fortran/printing-types.f90 index b4ff928604f..36b63532c8e 100644 --- a/gdb/testsuite/gdb.fortran/printing-types.f90 +++ b/gdb/testsuite/gdb.fortran/printing-types.f90 @@ -18,10 +18,12 @@ program prog integer(2) :: twoBytes character :: chValue logical(1) :: logValue + real(kind=16) :: rVal oneByte = 1 twoBytes = 2 chValue = 'a' logValue = .true. + rVal = 2000 write(*,*) s end diff --git a/gdb/testsuite/gdb.fortran/type-kinds.exp b/gdb/testsuite/gdb.fortran/type-kinds.exp index 1ae15b96f1a..9d19a9ceb39 100644 --- a/gdb/testsuite/gdb.fortran/type-kinds.exp +++ b/gdb/testsuite/gdb.fortran/type-kinds.exp @@ -27,12 +27,6 @@ if { [skip_fortran_tests] } { continue } proc test_cast_1_to_type_kind {base_type type_kind cast_result size_result} { set type_string "$base_type (kind=$type_kind)" gdb_test "p (($type_string) 1)" " = $cast_result" - - if {($base_type == "real" || $base_type == "complex") - && $type_kind == 16} { - setup_kfail gdb/18644 "*-*-*" - } - gdb_test "p sizeof (($type_string) 1)" " = $size_result" }