From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 942443888C57 for ; Sat, 19 Mar 2022 02:11:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 942443888C57 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9DxTxPQOzViFuwLAA--.9558S6; Sat, 19 Mar 2022 10:11:30 +0800 (CST) From: Tiezhu Yang To: gdb-patches@sourceware.org Cc: Simon Marchi , Pedro Alves Subject: [PATCH v4 4/4] gdb: testsuite: use gdb_attach to fix jit-elf.exp Date: Sat, 19 Mar 2022 10:11:27 +0800 Message-Id: <1647655887-13964-5-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1647655887-13964-1-git-send-email-yangtiezhu@loongson.cn> References: <1647655887-13964-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf9DxTxPQOzViFuwLAA--.9558S6 X-Coremail-Antispam: 1UD129KBjvJXoWxWFyDKrWDAryUtw1kury5twb_yoW5Cr48pF yIq34qkF1DXas7XF17ta48J34F9w4kCFy5W3y2qw4avrZ8G3yru3yxG34IyFW5Jr10ya13 u3ZFvrs8u3W5AFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBab7Iv0xC_KF4lb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI 8067AKxVWUAVCq3wA2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28C jxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWUCVW8JwA2z4x0Y4vE2Ix0cI 8IcVCY1x0267AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E 87Iv6xkF7I0E14v26F4UJVW0owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0V AKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxkIecxEwVAFwVW8JwCF04k20x vY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I 3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jrv_JF1lIxkGc2Ij64vIr41lIx AIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAI cVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2js IEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07j4ZXOUUUUU= X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, 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: Sat, 19 Mar 2022 02:11:35 -0000 If /proc/sys/kernel/yama/ptrace_scope is 1, when execute the following command without superuser: make check-gdb TESTS="gdb.base/jit-elf.exp" we can see the following messages in gdb/testsuite/gdb.log: (gdb) attach 1650108 Attaching to program: /home/yangtiezhu/build/gdb/testsuite/outputs/gdb.base/jit-elf/jit-elf-main, process 1650108 ptrace: Operation not permitted. (gdb) FAIL: gdb.base/jit-elf.exp: attach: one_jit_test-2: break here 1: attach use gdb_attach to fix the above issue, at the same time, the clean_reattach proc should return a value to indicate whether it worked, and the callers should return early as well on failure. Signed-off-by: Tiezhu Yang --- gdb/testsuite/gdb.base/jit-elf.exp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/gdb/testsuite/gdb.base/jit-elf.exp b/gdb/testsuite/gdb.base/jit-elf.exp index 8a4c5b7..4b75188 100644 --- a/gdb/testsuite/gdb.base/jit-elf.exp +++ b/gdb/testsuite/gdb.base/jit-elf.exp @@ -38,6 +38,7 @@ set jit_solib_basename jit-elf-solib set jit_solib_srcfile ${srcdir}/${subdir}/${jit_solib_basename}.c # Detach, restart GDB, and re-attach to the program. +# Return 0 if attach failed, otherwise return 1. proc clean_reattach {} { global decimal gdb_prompt global main_binfile main_srcfile @@ -57,18 +58,18 @@ proc clean_reattach {} { clean_restart ${main_binfile} - set test "attach" - gdb_test_multiple "attach $testpid" "$test" { - -re "Attaching to program.*.*main.*at .*$main_srcfile:.*$gdb_prompt $" { - pass "$test" - } + if { ![gdb_attach $testpid \ + -pattern "main.*at .*$::main_srcfile:.*"] } { + return 0 } gdb_test_no_output "set var wait_for_gdb = 0" + return 1 } # Continue to LOCATION in the program. If REATTACH, detach and # re-attach to the program from scratch. +# Return 0 if clean_reattach failed, otherwise return 1. proc continue_to_test_location {location reattach} { global main_srcfile @@ -76,9 +77,12 @@ proc continue_to_test_location {location reattach} { gdb_continue_to_breakpoint $location if {$reattach} { with_test_prefix "$location" { - clean_reattach + if { ![clean_reattach] } { + return 0 + } } } + return 1 } proc one_jit_test {jit_solibs_target match_str reattach} { @@ -114,7 +118,9 @@ proc one_jit_test {jit_solibs_target match_str reattach} { gdb_continue_to_breakpoint "break here 0" - continue_to_test_location "break here 1" $reattach + if { ![continue_to_test_location "break here 1" $reattach] } { + return + } gdb_test "info function ^jit_function" "$match_str" @@ -124,7 +130,9 @@ proc one_jit_test {jit_solibs_target match_str reattach} { gdb_test "maintenance info break" } - continue_to_test_location "break here 2" $reattach + if { ![continue_to_test_location "break here 2" $reattach] } { + return + } # All jit librares must have been unregistered gdb_test "info function jit_function" \ -- 2.1.0