From patchwork Tue May 21 16:06:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 32785 Received: (qmail 38934 invoked by alias); 21 May 2019 16:06:43 -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 38925 invoked by uid 89); 21 May 2019 16:06:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=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=sk:floatfo, f-lang.c, sk:gdbarch, sk:build_f X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 May 2019 16:06:41 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id BEA2311633C; Tue, 21 May 2019 12:06:39 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id WZ8bipeqKbD6; Tue, 21 May 2019 12:06:39 -0400 (EDT) Received: from murgatroyd (unknown [IPv6:2620:20:4000:40:60aa:25d0:ef41:54b6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id AA310116337; Tue, 21 May 2019 12:06:39 -0400 (EDT) From: Tom Tromey To: Andrew Burgess Cc: gdb-patches@sourceware.org Subject: Re: [PATCHv2] gdb/fortran: Use floatformats_ia64_quad for fortran 16-byte floats References: <20190504121734.5868-1-andrew.burgess@embecosm.com> <20190516160058.17361-1-andrew.burgess@embecosm.com> <20190518085431.GZ2568@embecosm.com> Date: Tue, 21 May 2019 12:06:39 -0400 In-Reply-To: <20190518085431.GZ2568@embecosm.com> (Andrew Burgess's message of "Sat, 18 May 2019 09:54:31 +0100") Message-ID: <8736l7g5bk.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 >>>>> "Andrew" == Andrew Burgess writes: >> This new version moves the use of floatformats_ia64_quad out of >> f-lang.c, which I think is an improvement. With this done I plan to >> push this patch shortly unless anyone complains. Andrew> This has now been pushed. This caused a crash while testing gdb master using the internal AdaCore test suite. In particular what happened is that the ARM target (in fact many targets) uses default_floatformat_for_type, returns NULL. Then, if build_fortran_types is called, it will crash gdb in arch_float_type: (top) bt #0 0x0000000000b4e3b1 in arch_float_type (gdbarch=0x32ef480, bit=128, name=0x1617675 "real*16", floatformats=0x0) at ../../binutils-gdb/gdb/gdbtypes.c:5169 #1 0x0000000000b14b11 in build_fortran_types (gdbarch=0x32ef480) at ../../binutils-gdb/gdb/f-lang.c:735 #2 0x0000000000b40d64 in gdbarch_data (gdbarch=0x32ef480, data=0x2d84bc0) at ../../binutils-gdb/gdb/gdbarch.c:5269 #3 0x0000000000b14bb5 in builtin_f_type (gdbarch=0x32ef480) at ../../binutils-gdb/gdb/f-lang.c:755 #4 0x0000000000b1378e in f_language_arch_info (gdbarch=0x32ef480, lai=0x33155e8) at ../../binutils-gdb/gdb/f-lang.c:171 #5 0x0000000000be010d in language_gdbarch_post_init (gdbarch=0x32ef480) at ../../binutils-gdb/gdb/language.c:978 #6 0x0000000000b40d64 in gdbarch_data (gdbarch=0x32ef480, data=0x31a43d0) at ../../binutils-gdb/gdb/gdbarch.c:5269 #7 0x0000000000be0140 in language_string_char_type (la=0x15a20e0 , gdbarch=0x32ef480) at ../../binutils-gdb/gdb/language.c:990 #8 0x00000000008ac86c in type_char (par_state=0x7fffffffd400) at ../../binutils-gdb/gdb/ada-exp.y:1453 #9 0x00000000008a7d85 in ada_yylex () at ../../binutils-gdb/gdb/ada-lex.l:151 In this case it happens via the Ada parser, but it can happen in many ways, I think. I'm testing the appended but I'm not really sure this is the best approach. Tom diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 097e8906d1f..5c8eeab6f6b 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -731,8 +731,12 @@ build_fortran_types (struct gdbarch *gdbarch) = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch), "real*8", gdbarch_double_format (gdbarch)); auto fmt = gdbarch_floatformat_for_type (gdbarch, "real(kind=16)", 128); - builtin_f_type->builtin_real_s16 - = arch_float_type (gdbarch, 128, "real*16", fmt); + if (fmt != nullptr) + builtin_f_type->builtin_real_s16 + = arch_float_type (gdbarch, 128, "real*16", fmt); + else + builtin_f_type->builtin_real_s16 + = arch_type (gdbarch, TYPE_CODE_ERROR, 128, "real*16"); builtin_f_type->builtin_complex_s8 = arch_complex_type (gdbarch, "complex*8",