From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by sourceware.org (Postfix) with ESMTPS id 5A68C385842B for ; Mon, 7 Mar 2022 14:27:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5A68C385842B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f51.google.com with SMTP id j17so23662704wrc.0 for ; Mon, 07 Mar 2022 06:27:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:references:in-reply-to :content-transfer-encoding; bh=WwK+XqRXSXptTU1z5IQ8RTdrusbj6bPlfXDjqhqUZek=; b=CjzLlJtzoFRT8pSb7LZlA/9dYZ1muMgGrgbhUob3Y+QF95DqkIAHT8OxJ+O7iQq2EP guDzGDgPsHqg8CWTikpWwnv0O2cTU+ulb44EDXXj0Vlll66YFYSNbZ4gMBpiBPdU5+BR FE47zhQLWDLyO29+n9v8yT7ZrelJSzYKgyWVBoM9LHY/iO7SQ6sWtUSd+jKj/Cf9WbtN 3zG4OE2PdDF5dGb93g6WOf/zjRnH5tlu7mBUIa43FscDeYfPnq69MrzY7kgExK61Jx/4 0ZJ3yw58Sz2h4gPBAS6o8Gt4kPKeRPx/v4wH1ypNVN+Ex/frxrYpsxhb6H1gvLRmiHVK CRfQ== X-Gm-Message-State: AOAM530uWD1xfqzX/1ZkQDWkqewfJZGCU1RFH+ZEU8OOdJN+JYtmv993 mUd4p/AvhXcSIUJmrzI558Zl9EvTGj4= X-Google-Smtp-Source: ABdhPJzsRKldS5EpiaksFbWDrdSVDwoQ+lpmRtNykGonpZk8nQteo1D1yQw5OUEeg0DOc2rubuvf9g== X-Received: by 2002:adf:ca08:0:b0:1ed:c0bc:c212 with SMTP id o8-20020adfca08000000b001edc0bcc212mr8326004wrh.577.1646663253230; Mon, 07 Mar 2022 06:27:33 -0800 (PST) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id l7-20020adfe9c7000000b001f06f8ec92dsm8970388wrn.30.2022.03.07.06.27.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Mar 2022 06:27:32 -0800 (PST) Message-ID: Date: Mon, 7 Mar 2022 14:27:31 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH] Make gdb.fortran/{array-slices,lbound-ubound} work against gdbserver Content-Language: en-US From: Pedro Alves To: Keith Seitz , Keith Seitz via Gdb-patches References: <20220224174100.1620375-1-keiths@redhat.com> <87k0dioq6s.fsf@tromey.com> <4f0def89-1a03-3d2c-15a0-572f0bb7566a@polymtl.ca> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, 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: Mon, 07 Mar 2022 14:27:36 -0000 On 2022-03-03 20:02, Pedro Alves wrote: > Well, the change is incorrect, because when testing with gdbserver we do have > inferior output. :-P > > We're not supposed to check whether the target is native. > > Instead, we're supposed to use gdb_test_stdio & gdb_skip_stdio_test. Keith mentioned he might be away this week, so I went ahead and played with this. We can't use gdb_test_stdio here, because that maps to gdb_test, and we want gdb_test_multiple instead. So we use inferior_spawn_id with gdb_test_multiple instead. It took me some head scratching and staring at logs to figure out why the patch wasn't working -- I was hitting a buglet in gdb.fortran/array-slices.f90, argh. With that out of the way, both testcases now pass cleanly with gdbserver too. Here's the proposed patch. Any comments? >From cb3fadb145a5ac6a2ddd5714ec17374ef5254cba Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 4 Mar 2022 17:34:18 +0000 Subject: [PATCH] Make gdb.fortran/{array-slices,lbound-ubound} work against gdbserver gdb.fortran/array-slices.exp and gdb.fortran/lbound-ubound.exp were recently disabled unless testing with the native target, because they rely on inferior I/O. However, when testing against gdbserver using the native-gdbserver/native-extended-gdbserver boards, we do have access to inferior I/O. The right way to check whether the board can do I/O, is via checking the gdb,noinferiorio board variable. Switch to using that. And then, tweak the testcases to expect output to appear in inferior_spawn_id, instead of gdb_spawn_id. When testing against the native target, inferior_spawn_id is the same as gdb_spawn_id. When testing against gdbserver, it maps to gdbserver_spawn_id. This exposed a buglet in gdb.fortran/array-slices.f90's show_1d subroutine -- it was missing printing newline at the end of the "Expected GDB Output" text, leading to a test timeout. All other subroutines end with advance=yes, except this one. Fix it by using advance=yes here too. Change-Id: I4640729f334431cfc24b0917e7d3977b677c6ca5 --- gdb/testsuite/gdb.fortran/array-slices.exp | 30 +++++++++++++++------ gdb/testsuite/gdb.fortran/array-slices.f90 | 2 +- gdb/testsuite/gdb.fortran/lbound-ubound.exp | 28 ++++++++++++++----- 3 files changed, 45 insertions(+), 15 deletions(-) diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp index 8f9c012e399..a38276c67e4 100644 --- a/gdb/testsuite/gdb.fortran/array-slices.exp +++ b/gdb/testsuite/gdb.fortran/array-slices.exp @@ -35,6 +35,11 @@ if {[skip_fortran_tests]} { return -1 } +# This test relies on output from the inferior. +if [target_info exists gdb,noinferiorio] { + return -1 +} + standard_testfile ".f90" load_lib fortran.exp @@ -62,12 +67,6 @@ proc run_test { repack } { return -1 } - # This test relies on output from the inferior and is not supported on - # remote targets. - if {![gdb_is_target_native]} { - return 0 - } - # Avoid libc symbols, in particular the 'array' type. gdb_test_no_output "nosharedlibrary" @@ -97,11 +96,19 @@ proc run_test { repack } { set found_final_breakpoint false set expected_result "" set func_name "" + set found_prompt false gdb_test_multiple "continue" "continue" { + -i $::inferior_spawn_id + -re ".*GDB = (\[^\r\n\]+)\r\n" { set expected_result $expect_out(1,string) - exp_continue + if {!$found_prompt} { + exp_continue + } } + + -i $::gdb_spawn_id + -re "! Display Element" { set func_name "show_elem" exp_continue @@ -119,7 +126,14 @@ proc run_test { repack } { exp_continue } -re "$gdb_prompt $" { - # We're done. + set found_prompt true + + if {$found_final_breakpoint + || ($expected_result != "" && $func_name != "")} { + # We're done. + } else { + exp_continue + } } } diff --git a/gdb/testsuite/gdb.fortran/array-slices.f90 b/gdb/testsuite/gdb.fortran/array-slices.f90 index ff3964ffb6b..1eaee82b7b7 100644 --- a/gdb/testsuite/gdb.fortran/array-slices.f90 +++ b/gdb/testsuite/gdb.fortran/array-slices.f90 @@ -61,7 +61,7 @@ subroutine show_1d (array) end if write(*, fmt="(I0)", advance="no") array (i) end do - write(*, fmt="(A)", advance="no") ")" + write(*, fmt="(A)", advance="yes") ")" print *, "" ! Display Array Slice 1D end subroutine show_1d diff --git a/gdb/testsuite/gdb.fortran/lbound-ubound.exp b/gdb/testsuite/gdb.fortran/lbound-ubound.exp index 671b251c799..709b74a69e8 100644 --- a/gdb/testsuite/gdb.fortran/lbound-ubound.exp +++ b/gdb/testsuite/gdb.fortran/lbound-ubound.exp @@ -32,9 +32,8 @@ if ![fortran_runto_main] { return -1 } -# This test relies on output from the inferior and is not supported on -# remote targets. -if {![gdb_is_target_native]} { +# This test relies on output from the inferior. +if [target_info exists gdb,noinferiorio] { return 0 } @@ -55,15 +54,25 @@ while { $test_count < 500 } { set expected_lbound "" set expected_ubound "" + set found_prompt false gdb_test_multiple "continue" "continue" { + -i $::inferior_spawn_id + -re ".*LBOUND = (\[^\r\n\]+)\r\n" { set expected_lbound $expect_out(1,string) - exp_continue + if {!$found_prompt} { + exp_continue + } } -re ".*UBOUND = (\[^\r\n\]+)\r\n" { set expected_ubound $expect_out(1,string) - exp_continue + if {!$found_prompt} { + exp_continue + } } + + -i $::gdb_spawn_id + -re "! Test Breakpoint" { set func_name "show_elem" exp_continue @@ -73,7 +82,14 @@ while { $test_count < 500 } { exp_continue } -re "$gdb_prompt $" { - # We're done. + set found_prompt true + + if {$found_final_breakpoint + || ($expected_lbound != "" && $expected_ubound != "")} { + # We're done. + } else { + exp_continue + } } } base-commit: 0daa5af85a9b5548a1bd7e8085a326162b41fd6f -- 2.26.2