From patchwork Fri Mar 3 16:37:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 65981 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 DDA293858C33 for ; Fri, 3 Mar 2023 16:38:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDA293858C33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677861491; bh=o/ydKC1/NKfsnu2ibhx5JLVACWdPYe6wPjfm09gqqeE=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=hNaa/73bg4DPDKeaz7S/L7wMQU2QleONjN0EuBLY5WDWUeY8mHgtpO5Gyw/e5xAJd jqv/yn+gRO9G1hSEiXtV7mhajYvUS8PA5reFvIZhd23fkJLqtXis706+WMAPj9Qt85 JisHHQ88irid6P2UL4k2ohKOw9HOms8yr5O6gZh0= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id A1FFA3858CDB for ; Fri, 3 Mar 2023 16:37:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A1FFA3858CDB Received: from smarchi-efficios.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 13F371E0D3; Fri, 3 Mar 2023 11:37:44 -0500 (EST) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH] gdb/testsuite: use `kill -FOO` instead of `kill -SIGFOO` Date: Fri, 3 Mar 2023 11:37:44 -0500 Message-Id: <20230303163744.857991-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-3497.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_SOFTFAIL, 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: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" When running gdb.base/bg-exec-sigint-bp-cond.exp when SHELL is dash, rather than bash, I get: c&^M Continuing.^M (gdb) sh: 1: kill: Illegal option -S^M ^M Breakpoint 2, foo () at /home/jenkins/smarchi/binutils-gdb/build/gdb/testsuite/../../../gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.c:23^M 23 return 0;^M FAIL: gdb.base/bg-exec-sigint-bp-cond.exp: no force memory write: SIGINT does not interrupt background execution (timeout) This is because it uses the kill command built-in the dash shell, and using the SIG prefix with kill does not work with dash's kill. The difference is listed in the documentation for bash's POSIX-correct mode [1]: The kill builtin does not accept signal names with a ‘SIG’ prefix. Replace SIGINT with INT in that test. By grepping, I found two other instances (gdb.base/sigwinch-notty.exp and gdb.threads/detach-step-over.exp). Those were not problematic on my system though. Since they are done through remote_exec, they don't go through the shell and therefore invoke /bin/kill. On my Arch Linux, it's: $ /bin/kill --version kill from util-linux 2.38.1 (with: sigqueue, pidfd) and on my Ubuntu: $ /bin/kill --version kill from procps-ng 3.3.17 These two implementations accept "-SIGINT". But according to the POSIX spec [2], the kill utility should recognize the signal name without the SIG prefix (if it recognizes them with the SIG prefix, it's an extension): -s signal_name Specify the signal to send, using one of the symbolic names defined in the header. Values of signal_name shall be recognized in a case-independent fashion, without the SIG prefix. In addition, the symbolic name 0 shall be recognized, representing the signal value zero. The corresponding signal shall be sent instead of SIGTERM. -signal_name [XSI] [Option Start] Equivalent to -s signal_name. [Option End] So, just in case some /bin/kill implementation happens to not recognize the SIG prefixes, change these two other calls to remove the SIG prefix. [1] https://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html [2] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/kill.html Change-Id: I81ccedd6c9428ab63b9261813f1905a18941f8da Reviewed-By: Tom Tromey --- gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp | 2 +- gdb/testsuite/gdb.base/sigwinch-notty.exp | 2 +- gdb/testsuite/gdb.threads/detach-step-over.exp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp b/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp index a8764a4e5ea1..b55c8d305b71 100644 --- a/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp +++ b/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp @@ -51,7 +51,7 @@ proc test { {after_kill_cond ""} } { # emulates pressing Ctrl-C just while GDB is evaluating the breakpoint # condition. gdb_test \ - "break foo if \$hit_count\+\+ == $num_hits || \$_shell(\"kill -SIGINT $gdb_pid\") != 0 $after_kill_cond" \ + "break foo if \$hit_count\+\+ == $num_hits || \$_shell(\"kill -INT $gdb_pid\") != 0 $after_kill_cond" \ "Breakpoint .*" \ "break foo if " diff --git a/gdb/testsuite/gdb.base/sigwinch-notty.exp b/gdb/testsuite/gdb.base/sigwinch-notty.exp index 99fb1c9a99ee..0be07910228f 100644 --- a/gdb/testsuite/gdb.base/sigwinch-notty.exp +++ b/gdb/testsuite/gdb.base/sigwinch-notty.exp @@ -49,7 +49,7 @@ after 1000 { # Note, GDB is started under a shell, so PID is actually the # shell's pid, not GDB's. Use "-PID" to send the signal to the # whole process group and reach GDB, instead of just to the shell. - remote_exec host "kill -SIGWINCH -${gdb_pid}" + remote_exec host "kill -WINCH -${gdb_pid}" } # If GDB mishandles the SIGWINCH and crashes, that happens before we diff --git a/gdb/testsuite/gdb.threads/detach-step-over.exp b/gdb/testsuite/gdb.threads/detach-step-over.exp index bf5ef6b06a1b..345c77e2c690 100644 --- a/gdb/testsuite/gdb.threads/detach-step-over.exp +++ b/gdb/testsuite/gdb.threads/detach-step-over.exp @@ -285,7 +285,7 @@ proc_with_prefix test_detach_command {condition_eval target_non_stop non_stop di # over, then threads of other inferiors should be # re-resumed. Test for that by sending a signal to # inferior 2. - remote_exec target "kill -SIGUSR1 ${pid_inf2}" + remote_exec target "kill -USR1 ${pid_inf2}" gdb_test_multiple "" "stop with SIGUSR1" { -re "received signal SIGUSR1" {