From patchwork Tue May 21 16:53:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 32786 Received: (qmail 28958 invoked by alias); 21 May 2019 16:53:30 -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 28948 invoked by uid 89); 21 May 2019 16:53:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.0 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= X-HELO: mail-wr1-f54.google.com Received: from mail-wr1-f54.google.com (HELO mail-wr1-f54.google.com) (209.85.221.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 May 2019 16:53:28 +0000 Received: by mail-wr1-f54.google.com with SMTP id w13so8676668wru.11 for ; Tue, 21 May 2019 09:53:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9k8B5gC8u0SwNfX/UOK1WWWiuaiVVIApZmRxnYxw2PI=; b=J2poyT6zPLvJ6a+ZzFVgqzOjoOuodyLYxm+aqknGXdazVgfRMoys8lFU44riQUcBWY Fl+XFeHbiuLbIaSB8BQLe/fOjWPKJTIJ9v0xeqaB4lG7M2G4zfqaQXp9JdWal3osJMcp 6wkW6WouTcuhXX1dtrYGDpktK9R1qrmLMuXmBSl/DNYwlMHqSOgFEGX7gB+K9M9GYQ0/ dRXee7X/F606Lqg31phIyyGKp0qyY/8/lABqjJzAVAbcVVyEFo0CRDgPrOCHN79yUbW+ A6ntJDPXtMefI0GpSxMAamqpjd9s+iM25MpLy5KvzVDs/vvwfu3la96bz0NC5nQfm0Zr I81w== Return-Path: Received: from localhost (cust64-dsl91-135-5.idnet.net. [91.135.5.64]) by smtp.gmail.com with ESMTPSA id 67sm5345395wmd.38.2019.05.21.09.53.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 May 2019 09:53:25 -0700 (PDT) Date: Tue, 21 May 2019 17:53:24 +0100 From: Andrew Burgess To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCHv2] gdb/fortran: Use floatformats_ia64_quad for fortran 16-byte floats Message-ID: <20190521165324.GF2568@embecosm.com> References: <20190504121734.5868-1-andrew.burgess@embecosm.com> <20190516160058.17361-1-andrew.burgess@embecosm.com> <20190518085431.GZ2568@embecosm.com> <8736l7g5bk.fsf@tromey.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <8736l7g5bk.fsf@tromey.com> X-Fortune: Your love life will be... interesting. X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes * Tom Tromey [2019-05-21 12:06:39 -0400]: > >>>>> "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. Sorry for breaking this. > > 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"); Maybe we should switch back to the original code in the else block, which would just make use of long double format? Something like: What do you think? Again, sorry for the breakage. Thanks, Andrew diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 5855c68b38c..b0c57878fec 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -728,8 +728,13 @@ 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_float_type (gdbarch, gdbarch_long_double_bit (gdbarch), + "real*16", gdbarch_long_double_format (gdbarch)); builtin_f_type->builtin_complex_s8 = arch_complex_type (gdbarch, "complex*8", Or maybe we should be even more restrictive, and only use long double format if its the correct length, like: diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 5855c68b38c..e612eeda7f7 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -728,8 +728,16 @@ 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 if (gdbarch_long_double_bit (gdbarch) == 128) + builtin_f_type->builtin_real_s16 + = arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch), + "real*16", gdbarch_long_double_format (gdbarch)); + 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",