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 5BD38385801E for ; Thu, 17 Mar 2022 14:01:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5BD38385801E 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 AQAAf9DxbxMePzNiJPYKAA--.8489S6; Thu, 17 Mar 2022 22:01:05 +0800 (CST) From: Tiezhu Yang To: gdb-patches@sourceware.org Cc: Simon Marchi , Pedro Alves Subject: [PATCH v3 4/4] gdb: testsuite: use gdb_attach to fix jit-elf.exp Date: Thu, 17 Mar 2022 22:01:01 +0800 Message-Id: <1647525661-8607-5-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1647525661-8607-1-git-send-email-yangtiezhu@loongson.cn> References: <1647525661-8607-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf9DxbxMePzNiJPYKAA--.8489S6 X-Coremail-Antispam: 1UD129KBjvJXoWxWFyDKrWDAryUtw1kury5twb_yoW5CF1xpF ySq34vkF1DXas7XF17ta48J34F9w1kCFy5G3y2gw4avFs8G3yru3yxK34IyFW5Jry0ya13 uanFvrs8u3W5AFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUB2b7Iv0xC_KF4lb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI 8067AKxVWUAVCq3wA2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28C jxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI 8IcVCY1x0267AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2 jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4 CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r4j6F4UMcvj eVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCY02Avz4vE14v_Xryl42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1Y6r17MIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6x kF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUsdgWDUUUU 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: Thu, 17 Mar 2022 14:01:11 -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 | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/gdb/testsuite/gdb.base/jit-elf.exp b/gdb/testsuite/gdb.base/jit-elf.exp index 8a4c5b7..e63f086 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,21 @@ 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" - } + set attach_opts { + "pattern" "main.*at .*$::main_srcfile:.*" + } + + if { ![gdb_attach $testpid $attach_opts] } { + 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 +80,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 +121,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 +133,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