From patchwork Fri Nov 11 16:51:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 60438 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7314C3858020 for ; Fri, 11 Nov 2022 16:51:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7314C3858020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668185517; bh=Kl6t2xm9RRgqlYOwjyVzq19VoCIRwFJXcqNl5guofMo=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=KDhRf4NKrgyk+QdMXMtltZB50KJZAl9ClerFnOQnf0hXkCVSmWZ73l4uKPhWTQhtH EUQav/XqGQPowPVTawvAgj5AYupHsCkI4Hs0jBLip6sP5buGeduFHOcQs8H3+8iZ/f XZDOR0hxUcYM+6iYERvk4WOXjqZ99lwPUMu9878Y= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 8FFB93858D20 for ; Fri, 11 Nov 2022 16:51:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8FFB93858D20 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-159-AfqBCV-1PlmRFR_Uo7e6fA-1; Fri, 11 Nov 2022 11:51:32 -0500 X-MC-Unique: AfqBCV-1PlmRFR_Uo7e6fA-1 Received: by mail-qk1-f200.google.com with SMTP id bk30-20020a05620a1a1e00b006fb2378c857so4339305qkb.18 for ; Fri, 11 Nov 2022 08:51:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Kl6t2xm9RRgqlYOwjyVzq19VoCIRwFJXcqNl5guofMo=; b=K9DjT6z1Ac7buWClHb3Q6K5d0+bQyH/pdORhitHsTXK9VzQ6bbd/I7n7mJmfXudNkA 5vtrizfuHdiiAnSVQrBq3thIz/S1a3+z7stRhedZH8ltewKgv1rsMDgUSxBfiZ0dJqPQ q5MdT/lQYfeEhWF83aQgzp+Bku4TN3xGGqJqavkn0sWSojagy6vC/6a8kgWTwW7PN/aS 6cXqSXcchV/DOsIjMQt9Tzm26jJfrPNQmcvV2TwIwpjTp+Yj6cv1ncE0USZ5MjF7UQ+S ZAKEVebd7EM+wRkpqlzz9Xat/vZ32ERLJDb8QnYAmJARlvAK/ubcIBmi9I2Gt0E2fDS1 hwkQ== X-Gm-Message-State: ANoB5pn5q4MFgRbnE82MPpmCFXueQwfAy78zMvoPft9NRoVOj+aE39pR 7XVTrIVFCwOOki/v4/vcuHOSg+l2uR8o10KQnMF7e/QJefymiMVuuCoo1C4IGczres4N415puXV RGuXHXgG46X1BorlOx7X5d/XX75OPtCgHMcdgv2yOaD+KadMytsvGkwgw3RQDr/GTF35KX/KDgw == X-Received: by 2002:ac8:4a8a:0:b0:3a5:44e9:314f with SMTP id l10-20020ac84a8a000000b003a544e9314fmr2054483qtq.630.1668185491437; Fri, 11 Nov 2022 08:51:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf6PeVW0Gg/Ymy9HKGRqYXJp++K98p/GY+ASD9k5Voy7fjKbEE5gLWLmpO1g74ZYoBZppK21DA== X-Received: by 2002:ac8:4a8a:0:b0:3a5:44e9:314f with SMTP id l10-20020ac84a8a000000b003a544e9314fmr2054454qtq.630.1668185491071; Fri, 11 Nov 2022 08:51:31 -0800 (PST) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id i17-20020ac85c11000000b00397e97baa96sm1556582qti.0.2022.11.11.08.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 08:51:30 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH] gdb/fortran/testsuite: print values and types of string variables Date: Fri, 11 Nov 2022 16:51:22 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.6 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_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" While looking through the Fortran tests, I couldn't find a test of GDB printing the value and type of a Fortran string defined using the 'character*SIZE' notation. This works fine in GDB right now, but I thought it wouldn't hurt to have a test for this, so this commit adds such a test. --- gdb/testsuite/gdb.fortran/string-types.exp | 64 ++++++++++++++++++++++ gdb/testsuite/gdb.fortran/string-types.f90 | 36 ++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 gdb/testsuite/gdb.fortran/string-types.exp create mode 100644 gdb/testsuite/gdb.fortran/string-types.f90 base-commit: db2e277d1a840091f56185d94f9d39c6736d2556 diff --git a/gdb/testsuite/gdb.fortran/string-types.exp b/gdb/testsuite/gdb.fortran/string-types.exp new file mode 100644 index 00000000000..73899e00605 --- /dev/null +++ b/gdb/testsuite/gdb.fortran/string-types.exp @@ -0,0 +1,64 @@ +# 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 print the value, and type, of Fortran string variables declared in +# different ways in the test program. + +standard_testfile .f90 +load_lib fortran.exp + +if {[skip_fortran_tests]} { return -1 } + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile \ + {debug f90 quiet}]} { + return -1 +} + +if ![fortran_runto_main] then { + perror "Couldn't run to main" + return +} + +gdb_breakpoint [gdb_get_line_number "First breakpoint"] +gdb_breakpoint [gdb_get_line_number "Second breakpoint"] +gdb_breakpoint [gdb_get_line_number "Third breakpoint"] + +with_test_prefix "first breakpoint" { + # Continue to the first breakpoint. + gdb_continue_to_breakpoint "continue" + gdb_test "print s" " = 'foo'" + gdb_test "ptype s" "type = character\\*3" +} + +with_test_prefix "second breakpoint" { + # Continue to the second breakpoint. + gdb_continue_to_breakpoint "continue" + gdb_test "print s" " = 'foo'" + gdb_test "ptype s" "type = character\\*3" +} + +with_test_prefix "third breakpoint, first time" { + # Continue to the third breakpoint. + gdb_continue_to_breakpoint "continue" + gdb_test "print s" " = 'foo'" + gdb_test "ptype s" "type = character \\(3\\)" +} + +with_test_prefix "third breakpoint, second time" { + # Continue to the third breakpoint again. + gdb_continue_to_breakpoint "continue" + gdb_test "print s" " = 'foobar'" + gdb_test "ptype s" "type = character \\(6\\)" +} diff --git a/gdb/testsuite/gdb.fortran/string-types.f90 b/gdb/testsuite/gdb.fortran/string-types.f90 new file mode 100644 index 00000000000..c689c21e114 --- /dev/null +++ b/gdb/testsuite/gdb.fortran/string-types.f90 @@ -0,0 +1,36 @@ +! 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 . + +subroutine fixed_size_string_v1(s) + character*3 s + print *, "" ! First breakpoint. +end subroutine fixed_size_string_v1 + +subroutine fixed_size_string_v2(s) + character(3) s + print *, "" ! Second breakpoint. +end subroutine fixed_size_string_v2 + +subroutine variable_size_string(s) + character*(*) s + print *, "" ! Third breakpoint. +end subroutine variable_size_string + +program test + call fixed_size_string_v1('foo') + call fixed_size_string_v2('foo') + call variable_size_string('foo') + call variable_size_string('foobar') +end program test