From patchwork Fri Apr 12 17:51:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 88442 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 3DFD1385841F for ; Fri, 12 Apr 2024 17:51:33 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 354493861021 for ; Fri, 12 Apr 2024 17:50:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 354493861021 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 354493861021 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712944261; cv=none; b=WXSfr0OcDsBPnpvxiia6bIgE75xgbJg9B2fNXofhlCWEpQxqcHJFLandJ5b8JmPBiGLYCTdvRxPocJZyQsypDS7ssnnCBYXczVFwI9S8GfJ9SVVLujo7bBddOjkxLNy2Z2la4mFao2cAdE0ZHuJWVpHXcQ9kCiz3CE2HuiGL0YE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712944261; c=relaxed/simple; bh=IWDaysP/QuVdLv1HglKAO0soudKs0mJy51Zi6E9ftP0=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=MOsAJJQuJEUKBhXALW59Kr5jc+8A4oY826QitovbR1m1bfqg2X9s/GU2NWe/aTnRXBADeoiYNyT034HNSXHSiIbKAC+shZ5GRgcWIqHYkE4V7LThAyZ81kQ69ZNlxiQCitKfo6PaJQx2r2wp/vQf3bs1ca6hNtB3IoCKhuWQDeQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EE3471F7F5 for ; Fri, 12 Apr 2024 17:50:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712944258; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=h9JVZg2JPGhxPe1fgNDj5WvHVxq/UXrKApM5nmAbMV8=; b=wr6BYyLmzJT37aIG/JqBAEAtQJgyP3PcQOWhPp2no29M6+Tn0mT6W/rF6kbwwyYY5atdS2 QmRkoQ3ONIKvNRcq4XmtK2+JZBprmnyWI4jtzWAqRnCfjlWyAWfsjSaTbWZ7/oFdGFj1ZP IQ7C2Dj5LOoKzTOxSqjss1FT49YjRvw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712944258; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=h9JVZg2JPGhxPe1fgNDj5WvHVxq/UXrKApM5nmAbMV8=; b=ek6r9Wuhf8NW6ffjBSMo7QLyvqGitK2q7qrfJitO71Z3yh0BaF1Qvhw2kY+kE3BCfajwJy M4A1WvV7BmoPnNCw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712944256; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=h9JVZg2JPGhxPe1fgNDj5WvHVxq/UXrKApM5nmAbMV8=; b=pPsogWQE+hIcB6CJa4U/I62zxlZfvF/7U8OF/U0YexhTJ4XEZP7oy97Ny3WUz3pOWheMum 8JEn5ftfYGI3CdlukrnShJfiie+Jq3H651XpIBfAZgATbfZRHFxYBIdNjykwnzESlOZnew KOZ5aZwP9SsTcn4vPRPvH8dHzQpnfYE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712944256; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=h9JVZg2JPGhxPe1fgNDj5WvHVxq/UXrKApM5nmAbMV8=; b=zh1w2JST2pX6drYDaETNm9xNGzMfSl97cAPQWkZnCEWE34wH1RMxVO9/EpW91EI53e7C6j idzcQO9mHOuwwsBw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D28D61377F for ; Fri, 12 Apr 2024 17:50:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id iOupMYB0GWYtMQAAD6G6ig (envelope-from ) for ; Fri, 12 Apr 2024 17:50:56 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 1/2] [gdb/testsuite] Simplify gdb.server/server-kill-python.exp Date: Fri, 12 Apr 2024 19:51:00 +0200 Message-Id: <20240412175101.9154-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org In test-case gdb.server/server-kill-python.exp we have: ... if {[gdb_spawn_with_cmdline_opts \ "-quiet -iex \"set height 0\" -iex \"set width 0\" -ex \"source $host_file1\""] != 0} { fail "spawn" return } ... I reproduced the problem by reverting the fix at the commit adding both the fix and the test-case, and the reproduced the same problem using: ... (gdb) source $host_file1 ... so there doesn't seem to be a specific need to source the python file using "-ex". Simplify the test-case by sourcing the python file using send_gdb. This also allow us to simplify the python script. Tested on x86_64-linux. --- gdb/testsuite/gdb.server/server-kill-python.exp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) base-commit: 3d67591c6ff0443e36cbc38ece082cc240e87bf6 diff --git a/gdb/testsuite/gdb.server/server-kill-python.exp b/gdb/testsuite/gdb.server/server-kill-python.exp index ebf6176ebba..87f9b56bd39 100644 --- a/gdb/testsuite/gdb.server/server-kill-python.exp +++ b/gdb/testsuite/gdb.server/server-kill-python.exp @@ -48,8 +48,6 @@ puts $fd \ "import gdb def do_gdb_stuff (): - gdb.execute ('file $host_binfile') - gdb.execute ('target $gdbserver_protocol $gdbserver_gdbport') gdb.execute ('break $srcfile:$break_linenr') gdb.execute ('continue') gdb.execute ('p server_pid') @@ -63,11 +61,15 @@ set host_file1 [gdb_remote_download host $file1] # Now start GDB, sourcing the python command file we generated above. # Set the height and width so we don't end up at a paging prompt. if {[gdb_spawn_with_cmdline_opts \ - "-quiet -iex \"set height 0\" -iex \"set width 0\" -ex \"source $host_file1\""] != 0} { + "-quiet -iex \"set height 0\" -iex \"set width 0\""] != 0} { fail "spawn" return } +gdb_load $binfile +gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport +send_gdb "source $host_file1\n" + # Get the gdbserver PID. set gdbserver_pid 0 From patchwork Fri Apr 12 17:51:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 88444 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 1FC7B385842A for ; Fri, 12 Apr 2024 17:52:40 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 351873857C4F for ; Fri, 12 Apr 2024 17:50:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 351873857C4F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 351873857C4F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712944261; cv=none; b=ukQbuvkgpGpdRIE3EQgAuuf/dGMHDrF7WDTXVVNrAItrNUnVlY/90P5qWnDK1dUwSwCEJPg4CBQUa6flnhQpIw3KWLJ49atRfgqnzcKFFUr9ZrE90wgBiqCXb9BZ9JvyMU/jcpFt7YyQOmFaLXI9/cg3sBLIzCT4xsyjzE4Fep0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712944261; c=relaxed/simple; bh=QPO4pXCPcMNxqyF3K5iqdhq/mBWOUAAGEcTTlRb3RDg=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=JkcYD2sF4TF69xQ19w1u06TX78FgqUkG/ntFXp9BPPMreeKNKypPO4RfEWaOKE6q5Ox/fxTh+ALrl99bWVewZXBvPO4VvIFdoObnGe6cN3fR4qwW5QZgN3TNeCKmt69hgGDSsiijJyOqiUOOvypd0vS7hCXlyic1eMfdstY0D84= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 182E51F7F6 for ; Fri, 12 Apr 2024 17:50:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712944258; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zbLKXH77oAHTxIn1oyZEkAIoeUHzqN0K9CEBW4eTG8k=; b=J2QcVSxU/Q9PXR2I41JAV8wSG6dTDJXvmAW738eCGA/JgM/veEsJoqi1DCgzzkXh92ekVr plrR0zy0ZF1pum2Zu6sKqcKWCroKeTSbNHFlL5Uk7msGMsag7P/NcW5ZtwGzNbvC36Y9vd 2MFX8BgStWn82XFQ9k/kruaXqDeT12g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712944258; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zbLKXH77oAHTxIn1oyZEkAIoeUHzqN0K9CEBW4eTG8k=; b=Jnn69bNrVaqWe/F2uYm/AzEXa66ZyfaJknRpw3Ym9b9cLQmjlCsPCjVcnV2ARkZbiSZ4qw qZ5tcOuqPr3vylAQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712944257; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zbLKXH77oAHTxIn1oyZEkAIoeUHzqN0K9CEBW4eTG8k=; b=k+iVKgRpDbqmBY3Rz5NrMfylUXWrUXwPr/dKYCvcx6js6aiJaaRMevofcQQMjmBXr3awRL XG7fD/sRxKL7SZkpvy0bLX7Bmf6El5yHMYnxIYmB3L9rRYHI8VaR0l0NsSDL7XVcjSkk9y 1AL2yl8p9FJhNDTLGUgG3+ES6GlavW4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712944257; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zbLKXH77oAHTxIn1oyZEkAIoeUHzqN0K9CEBW4eTG8k=; b=Zd2repbCV3j1pjXKc+sPlqjzemDvUxNlUv2m/9s+1ikyPC0hTHL006VxmQThqHf1wz1ZXo YB17ZOy7Q4OWBGCw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id F0B42137B8 for ; Fri, 12 Apr 2024 17:50:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id kC1UOYB0GWYtMQAAD6G6ig (envelope-from ) for ; Fri, 12 Apr 2024 17:50:56 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 2/2] [gdb/testsuite] Fix gdbserver pid in gdb.server/server-kill-python.exp Date: Fri, 12 Apr 2024 19:51:01 +0200 Message-Id: <20240412175101.9154-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240412175101.9154-1-tdevries@suse.de> References: <20240412175101.9154-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,sourceware.org:url]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org The commit ed32754a8c7 ("[gdb/testsuite] Fix gdb.server/multi-ui-errors.exp for remote target") intended to addresss the problem that this command: ... set gdbserver_pid [exp_pid -i $server_spawn_id] ... does not return the pid of the gdbserver for remote target, but rather the one of the ssh client session. To fix this, it added another way of getting the gdbserver_pid. For the trivial case of non-remote target, the PID found by either method should be identical, but if we compare those by adding "puts [exec ps -p $gdbserver_pid]" we get: ... PID TTY TIME CMD 31711 pts/8 00:00:00 gdbserver PID TTY TIME CMD 31718 pts/8 00:00:00 server-kill-pyt ... The problem is that while the gdbserver PID is supposed to be read from the result of "gdb.execute ('p server_pid')" in the python script, instead it's taken from: ... Process server-kill-python created; pid = 31718^M ... Fix this by moving the printing of the gdbserver PID out of the python script. Also double-check the two methods against each other, in the cases that they should match. Tested on x86_64-linux. PR testsuite/31633 https://sourceware.org/bugzilla/show_bug.cgi?id=31633 --- .../gdb.server/server-kill-python.exp | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/gdb/testsuite/gdb.server/server-kill-python.exp b/gdb/testsuite/gdb.server/server-kill-python.exp index 87f9b56bd39..f02c69c502f 100644 --- a/gdb/testsuite/gdb.server/server-kill-python.exp +++ b/gdb/testsuite/gdb.server/server-kill-python.exp @@ -37,7 +37,7 @@ set host_binfile [gdb_remote_download host $binfile] set res [gdbserver_spawn "${target_binfile}"] set gdbserver_protocol [lindex $res 0] set gdbserver_gdbport [lindex $res 1] -set gdbserver_pid [exp_pid -i $server_spawn_id] +set gdbserver_pid_check [exp_pid -i $server_spawn_id] set break_linenr [gdb_get_line_number "@@XX@@ Inferior Starting @@XX@@"] @@ -48,9 +48,6 @@ puts $fd \ "import gdb def do_gdb_stuff (): - gdb.execute ('break $srcfile:$break_linenr') - gdb.execute ('continue') - gdb.execute ('p server_pid') gdb.execute ('continue') do_gdb_stuff()" @@ -68,24 +65,32 @@ if {[gdb_spawn_with_cmdline_opts \ gdb_load $binfile gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport -send_gdb "source $host_file1\n" + +gdb_test "break $srcfile:$break_linenr" # Get the gdbserver PID. set gdbserver_pid 0 - -# Wait for the inferior to start up. -with_spawn_id $server_spawn_id { - gdb_test_multiple "" "get gdbserver PID" { - -re " = ($decimal)\r\n" { - set gdbserver_pid $expect_out(1,string) - pass $gdb_test_name - } +gdb_test "continue" +gdb_test_multiple "print server_pid" "get gdbserver PID" { + -re -wrap " = ($decimal)" { + set gdbserver_pid $expect_out(1,string) + pass $gdb_test_name } +} - if { $gdbserver_pid == 0 } { - return - } +if { $gdbserver_pid == 0 } { + return +} + +if { ![is_remote target] && $gdbserver_pid != $gdbserver_pid_check } { + error "Failed to get correct gdbserver pid" +} +send_gdb "source $host_file1\n" + + +# Wait for the inferior to start up. +with_spawn_id $server_spawn_id { gdb_test_multiple "" "ensure inferior is running" { -re "@@XX@@ Inferior Starting @@XX@@" { pass $gdb_test_name