From patchwork Thu May 19 14:37:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 12381 Received: (qmail 43099 invoked by alias); 19 May 2016 14:38:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 43084 invoked by uid 89); 19 May 2016 14:38:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-pa0-f66.google.com Received: from mail-pa0-f66.google.com (HELO mail-pa0-f66.google.com) (209.85.220.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 19 May 2016 14:37:50 +0000 Received: by mail-pa0-f66.google.com with SMTP id gh9so8114184pac.0 for ; Thu, 19 May 2016 07:37:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=e9poxFO63iEmEuWFDFjO4CkP5H5+QUxKc2uVHr5UVxQ=; b=NKZ6QOaqHWUm5GyoDvoEOcmwjegvz+JRyaSq0xrBQA6x6eHdxL2E3o7XRkHbSRhaoY 2zIx4wEB8badAoAJ8euJ/4VKw4f7/oSW2OG7mMomNwN3BzXtvoJixAarx9bMuFUNZLZ+ xy25Cbdh/V2qD+4QPk/HToV3SQgds81lMsp3/mHI4ap4FnfuySw3IblMVkDigSE9VQ9I EZSakN1F/1Qu+UL9Gi0klAQaG8XF8ZEO/0TM9ShIbT8OPSf7ys8ex0WrN3BRem547vnI /plFjFbDYl+pAc4a5l4RFKGSZKQOl8vODskU5Q4Pk0+hYavbfy7C8uERDSAaZgzWI06V hFew== X-Gm-Message-State: AOPr4FVOoI0hbBPLF8IusEZQY/Iq38aSya3+sEJW0D3GUwC9j7AqDWa48VGpvSW592EAEQ== X-Received: by 10.66.167.40 with SMTP id zl8mr20310532pab.8.1463668669270; Thu, 19 May 2016 07:37:49 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc113.osuosl.org. [140.211.9.71]) by smtp.gmail.com with ESMTPSA id 28sm20421020pfr.89.2016.05.19.07.37.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 May 2016 07:37:48 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH] Wake up interruptible_select in remote_fileio ctrl-c handler Date: Thu, 19 May 2016 15:37:40 +0100 Message-Id: <1463668660-9205-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes As reported in PR 19998, after type ctrl-c, GDB hang there and does not send interrupt. It causes a fail in gdb.base/interrupt.exp. All targets support remote fileio should be affected. When we type ctrc-c, SIGINT is handled by remote_fileio_sig_set, as shown below, #0 remote_fileio_sig_set (sigint_func=0x4495d0 ) at /home/yao/SourceCode/gnu/gdb/git/gdb/remote-fileio.c:325 #1 0x00000000004495de in remote_fileio_ctrl_c_signal_handler (signo=) at /home/yao/SourceCode/gnu/gdb/git/gdb/remote-fileio.c:349 #2 #3 0x00007ffff647ed83 in __select_nocancel () at ../sysdeps/unix/syscall-template.S:81 #4 0x00000000005530ce in interruptible_select (n=10, readfds=readfds@entry=0x7fffffffd730, writefds=writefds@entry=0x0, exceptfds=exceptfds@entry=0x0, timeout=timeout@entry=0x0) at /home/yao/SourceCode/gnu/gdb/git/gdb/event-top.c:1017 #5 0x000000000061ab20 in stdio_file_read (file=, buf=0x12d02e0 "\n\022-\001", length_buf=16383) at /home/yao/SourceCode/gnu/gdb/git/gdb/ui-file.c:577 #6 0x000000000044a4dc in remote_fileio_func_read (buf=0x12c0360 "") at /home/yao/SourceCode/gnu/gdb/git/gdb/remote-fileio.c:583 #7 0x0000000000449598 in do_remote_fileio_request (uiout=, buf_arg=buf_arg@entry=0x12c0340) at /home/yao/SourceCode/gnu/gdb/git/gdb/remote-fileio.c:1179 we don't set quit_serial_event, do { res = gdb_select (n, readfds, writefds, exceptfds, timeout); } while (res == -1 && errno == EINTR); if (res == 1 && FD_ISSET (fd, readfds)) { errno = EINTR; return -1; } return res; we can't go out of the loop above, and that is why GDB can't send interrupt. Recently, we stop throwing exception from SIGINT handler (remote_fileio_ctrl_c_signal_handler) https://sourceware.org/ml/gdb-patches/2016-03/msg00372.html, which is correct, because gdb_select is interruptible. However, in the same patch series, we add interruptible_select later as a wrapper to gdb_select, https://sourceware.org/ml/gdb-patches/2016-03/msg00375.html and it is not interruptible (because of the loop in it) unless select/poll-able file descriptors are marked. This fix in this patch is to call quit_serial_event_set, so that we can go out of the loop above, return -1 and set errno to EINTR. I don't have the test env to run testsuite against targets support remote fileio. 2016-05-19 Yao Qi PR remote/19998 * remote-fileio.c (remote_fileio_ctrl_c_signal_handler): Call quit_serial_event_set. --- gdb/remote-fileio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index 44817df..29c5ca3 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -348,6 +348,8 @@ remote_fileio_ctrl_c_signal_handler (int signo) { remote_fileio_sig_set (remote_fileio_ctrl_c_signal_handler); remote_fio_ctrl_c_flag = 1; + /* Wake up interruptible_select. */ + quit_serial_event_set (); } static void