From patchwork Tue May 21 22:55:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 32789 Received: (qmail 127573 invoked by alias); 21 May 2019 22:56:10 -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 127564 invoked by uid 89); 21 May 2019 22:56:10 -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=HX-Languages-Length:2700 X-HELO: mail-wr1-f51.google.com Received: from mail-wr1-f51.google.com (HELO mail-wr1-f51.google.com) (209.85.221.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 May 2019 22:56:08 +0000 Received: by mail-wr1-f51.google.com with SMTP id m3so116345wrv.2 for ; Tue, 21 May 2019 15:56:08 -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=iHd4BeV2ggw5ebULqZueHXy4CsZ7wVmPOI+rmKxDPn8=; b=GUIQwnmMPrvVl6cnSaa86zL7/voay7l3j2bcXw5jkKAJcz5FQQQqP1onKRptHmPAjd P/W55TVQCKnEt3zb/qrN2hhUePzXp8dcyVeE9Xea+9pKBMJVfHQhe0eLIw/Y80DrojZL eng744tBqf1lyzWel+/FVnVI7Z0mG29gbt/EHrESNClFuxEIu+FLGWo/SoEHleU9uv4z tiYXWIvuF7WG16kj1vL+K6Ad0YcfmVeqOX9ii5rAQYQEcmeg9vYoL27skUnaigfeiBu2 KFxetsIVTOg+3iryo+QCt4eqGNBQ3SLxeKAX4z1Ec+85YsKOHsv1p7FYojG+LzHDjzR2 W3uQ== Return-Path: Received: from localhost ([2a00:23c5:3e8d:6c00:9cd0:87cb:29bd:5b8f]) by smtp.gmail.com with ESMTPSA id e14sm4459138wma.41.2019.05.21.15.56.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 May 2019 15:56:05 -0700 (PDT) Date: Tue, 21 May 2019 23:55:59 +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: <20190521225559.GH2568@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> <20190521165324.GF2568@embecosm.com> <87woijeo0r.fsf@tromey.com> <20190521201028.GG2568@embecosm.com> <87pnobef3p.fsf@tromey.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87pnobef3p.fsf@tromey.com> X-Fortune: And on the eighth day, we bulldozed it. 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 16:18:18 -0400]: > >>>>> "Andrew" == Andrew Burgess writes: > > Andrew> Would you like me to push a fix, or do you want to do it? > > Go for it. I pushed the below. Thanks, Andrew --- commit dc42e902cc54af2b7e7b54a1171d562f867342d5 Author: Andrew Burgess Date: Tue May 21 22:14:05 2019 +0100 gdb/fortran: Handle gdbarch_floatformat_for_type returning nullptr In this commit: commit 34d11c682fd96c7dbe3ebd6cd9033e65d51ec7a3 Date: Fri May 3 15:23:55 2019 +0100 gdb/fortran: Use floatformats_ia64_quad for fortran 16-byte floats GDB was changed such that the Fortran's 16-byte float format was obtained by calling gdbarch_floatformat_for_type instead of just using gdbarch_long_double_format as it was before. The problem with this default_floatformat_for_type can return NULL in some cases, and the code introduced in 34d11c682f didn't consider this. This commit introduces several alternative strategies for finding a suitable 16-byte floating point type. First GDB calls gdbarch_floatformat_for_type (this was what 34d11c682f added), if this returns null GDB will use gdbarch_long_double_format if it is the correct size (this was the format used before 34d11c682f). Finally, if neither of the above provides a suitable type then GDB will create a new dummy type. This final dummy type is unlikely to provide an correct debug experience as far as examining the 16-byte floats, but it should prevent GDB crashing. gdb/ChangeLog: PR gdb/18644: * f-lang.c (build_fortran_types): Handle the case where gdbarch_floatformat_for_type returns a nullptr. 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",