From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id B7C653858C20 for ; Wed, 16 Feb 2022 15:39:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B7C653858C20 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-586-8driThXTOMGi9JXsMkccig-1; Wed, 16 Feb 2022 10:39:01 -0500 X-MC-Unique: 8driThXTOMGi9JXsMkccig-1 Received: by mail-wr1-f69.google.com with SMTP id c9-20020adfa709000000b001dde29c3202so1214281wrd.22 for ; Wed, 16 Feb 2022 07:39:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=o/NrBDXJHPp7bZFIliBkB0JFSqC1g8OYCBIKk/h94eU=; b=Dqh0qCRX77CKNBMOau5UMRB5Suq1G6jjANZElSaHU18tiOsun3w9Jpr8GAfD4FWiEI 9Fz4VOkbwLNFxovUgjtVKRzEhQ9/VWSKYBB+wClCFFzCLo5LtzMgsnvJjvAeySEwRM2T rr9ntOUxF4j5J/Muxz2i50XlLCuJ9tEOm5Urtprlfpzi2FW5aLgFAi2H6IFec4Ggas7A dFu7FYH6PslfKiz6nBnUekK0Tx8lQMeRiNXLu2ae32Cfz/r41txSSzwMjarkZfODHFSp vwj5x0306cMXZ7ZO6ocaCUp8aIZoOwu+kAisvaLCU8OlbJPGC7e7X0MZaQLlPjhHxEGO KhMQ== X-Gm-Message-State: AOAM530+O7Pt8FJmYsNORlfWSYEhGGLJz/aaOESrCApcLki6WuH31vwb AvP6nbEQha4rUxB+7RpkFHZiZIveQylYh8z/HV7LN2EPR4vyXjxJ81cUk1pVtNyjRNvz93oCq0e buY5j88AUVmmTZkesTNHeBA== X-Received: by 2002:a7b:cd11:0:b0:37c:82e:d742 with SMTP id f17-20020a7bcd11000000b0037c082ed742mr2110967wmj.170.1645025939868; Wed, 16 Feb 2022 07:38:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFYmXnbn66hYh0d+gWGGq2wjnpfbOfuRjTNdRbBkG00YkDL45j4GjyFJZdjsOB1gE4SsXb9g== X-Received: by 2002:a7b:cd11:0:b0:37c:82e:d742 with SMTP id f17-20020a7bcd11000000b0037c082ed742mr2110955wmj.170.1645025939652; Wed, 16 Feb 2022 07:38:59 -0800 (PST) Received: from localhost (host86-134-151-224.range86-134.btcentralplus.com. [86.134.151.224]) by smtp.gmail.com with ESMTPSA id n7sm18055513wmd.30.2022.02.16.07.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 07:38:59 -0800 (PST) Date: Wed, 16 Feb 2022 15:38:57 +0000 From: Andrew Burgess To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 01/18] Fix latent quote char bug in generic_printstr Message-ID: <20220216153857.GE2571@redhat.com> References: <20220216135518.3162480-1-tom@tromey.com> <20220216135518.3162480-2-tom@tromey.com> MIME-Version: 1.0 In-Reply-To: <20220216135518.3162480-2-tom@tromey.com> X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 15:37:33 up 5 days, 5:16, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Feb 2022 15:39:05 -0000 * Tom Tromey [2022-02-16 06:55:01 -0700]: > generic_printstr prints an empty string like: > > fputs_filtered ("\"\"", stream); > > However, this seems wrong to me if the quote character is something > other than double quote. This patch fixes this latent bug, though I'm > not sure how to test it -- I don't know Fortran and in my experiment I > was unable to make a zero-length Fortran string. This change looks good to me. Below is a test case which you are welcome to include with this patch. Thanks, Andrew --- commit 3ede663e51ebeaef24280891ea8dced86571e9e7 Author: Andrew Burgess Date: Wed Feb 16 15:37:15 2022 +0000 A test diff --git a/gdb/testsuite/gdb.fortran/empty-string.exp b/gdb/testsuite/gdb.fortran/empty-string.exp new file mode 100644 index 00000000000..892f189784a --- /dev/null +++ b/gdb/testsuite/gdb.fortran/empty-string.exp @@ -0,0 +1,33 @@ +# Copyright 2022 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test printing of an empty Fortran string. + +if {[skip_fortran_tests]} { return -1 } + +standard_testfile ".f90" +load_lib fortran.exp + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} { + return -1 +} + +if ![fortran_runto_main] { + return -1 +} + +gdb_breakpoint [gdb_get_line_number "Break here"] +gdb_continue_to_breakpoint "run to test location" +gdb_test "print string" " = ''" diff --git a/gdb/testsuite/gdb.fortran/empty-string.f90 b/gdb/testsuite/gdb.fortran/empty-string.f90 new file mode 100644 index 00000000000..574ed7fb7aa --- /dev/null +++ b/gdb/testsuite/gdb.fortran/empty-string.f90 @@ -0,0 +1,30 @@ +! Copyright 2022 Free Software Foundation, Inc. +! +! This program is free software; you can redistribute it and/or modify +! it under the terms of the GNU General Public License as published by +! the Free Software Foundation; either version 3 of the License, or +! (at your option) any later version. +! +! This program is distributed in the hope that it will be useful, +! but WITHOUT ANY WARRANTY; without even the implied warranty of +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +! GNU General Public License for more details. +! +! You should have received a copy of the GNU General Public License +! along with this program. If not, see . + +program empty_string + implicit none + + integer :: ret + + ret = string_length('') + +contains + + integer(kind=4) function string_length(string) + character*(*) :: string + string_length = len(string) ! Break here. + end function string_length + +end program empty_string