From patchwork Thu Nov 2 15:12:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 24035 Received: (qmail 124877 invoked by alias); 2 Nov 2017 15:12:14 -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 124820 invoked by uid 89); 2 Nov 2017 15:12:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Tell, UD:mit.edu, randy X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 02 Nov 2017 15:12:08 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1243F5F15C for ; Thu, 2 Nov 2017 15:12:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1243F5F15C Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com Received: from cascais.lan (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D7255C670 for ; Thu, 2 Nov 2017 15:12:06 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 3/3] Eliminate STOP_SIGNAL, use SIGTSTP directly Date: Thu, 2 Nov 2017 15:12:02 +0000 Message-Id: <1509635522-16945-4-git-send-email-palves@redhat.com> In-Reply-To: <1509635522-16945-1-git-send-email-palves@redhat.com> References: <1509635522-16945-1-git-send-email-palves@redhat.com> The STOP_SIGNAL macro was originally added for Convex Unix [1]: In: git show 7a67dd45ca1c:gdb/m-convex.h we see: ~~~ /* Use SIGCONT rather than SIGTSTP because convex Unix occasionally turkeys SIGTSTP. I think. */ #define STOP_SIGNAL SIGCONT ~~~ That's gdb-3.5, 1990... In gdb/ChangeLog-3.x we see: ~~~ Tue Apr 18 13:43:37 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) Various changes involved in 1) getting gdb to work on the convex, [...] Made whatever signal indicates a stop configurable (via macro STOP_SIGNAL). (main): Setup use of above as a signal handler. Added check for "-nw" in args already processed. (command_line_input): SIGTSTP ==>STOP_SIGNAL. ~~~ Support for Convex Unix is long gone, and nothing else overrides STOP_SIGNAL. So just use SIGTSTP directly, removing a little obfuscation. (I don't really understand why we override [1] readline's SIGTSTP handler (only) when reading scripts (and then fail to restore it properly, assuming SIG_DFL...), but I'll leave that for another pass. [1] - Actually, starting with readline 6.3, readline is no longer installing its handlers while GDB is in control...) gdb/ChangeLog: yyyy-mm-dd Pedro Alves * event-top.c: Check SIGTSTP instead of STOP_SIGNAL thoughout. (async_init_signals): Adjust. (handle_stop_sig): Rename to ... (handle_sigtstp): ... this. (async_stop_sig): Rename to ... (async_sigtstp_handler): ... this, and delete STOP_SIGNAL != SIGTSTP path. * event-top.h: Move signal.h include to the top. Check SIGTSTP instead of STOP_SIGNAL thoughout. (handle_stop_sig): Rename to ... (handle_sigtstp): ... this. * top.c (command_line_input): Replace STOP_SIGNAL -> SIGTSTP. --- gdb/event-top.c | 26 +++++++++++--------------- gdb/event-top.h | 10 ++++------ gdb/top.c | 8 ++++---- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/gdb/event-top.c b/gdb/event-top.c index 43e2a27..7377189 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -68,8 +68,8 @@ static void async_do_nothing (gdb_client_data); static void async_disconnect (gdb_client_data); #endif static void async_float_handler (gdb_client_data); -#ifdef STOP_SIGNAL -static void async_stop_sig (gdb_client_data); +#ifdef SIGTSTP +static void async_sigtstp_handler (gdb_client_data); #endif static void async_sigterm_handler (gdb_client_data arg); @@ -111,7 +111,7 @@ static struct async_signal_handler *sighup_token; static struct async_signal_handler *sigquit_token; #endif static struct async_signal_handler *sigfpe_token; -#ifdef STOP_SIGNAL +#ifdef SIGTSTP static struct async_signal_handler *sigtstp_token; #endif static struct async_signal_handler *async_sigterm_token; @@ -912,9 +912,9 @@ async_init_signals (void) sigfpe_token = create_async_signal_handler (async_float_handler, NULL); -#ifdef STOP_SIGNAL +#ifdef SIGTSTP sigtstp_token = - create_async_signal_handler (async_stop_sig, NULL); + create_async_signal_handler (async_sigtstp_handler, NULL); #endif } @@ -1112,20 +1112,19 @@ async_disconnect (gdb_client_data arg) } #endif -#ifdef STOP_SIGNAL +#ifdef SIGTSTP void -handle_stop_sig (int sig) +handle_sigtstp (int sig) { mark_async_signal_handler (sigtstp_token); - signal (sig, handle_stop_sig); + signal (sig, handle_sigtstp); } static void -async_stop_sig (gdb_client_data arg) +async_sigtstp_handler (gdb_client_data arg) { char *prompt = get_prompt (); -#if STOP_SIGNAL == SIGTSTP signal (SIGTSTP, SIG_DFL); #if HAVE_SIGPROCMASK { @@ -1138,10 +1137,7 @@ async_stop_sig (gdb_client_data arg) sigsetmask (0); #endif raise (SIGTSTP); - signal (SIGTSTP, handle_stop_sig); -#else - signal (STOP_SIGNAL, handle_stop_sig); -#endif + signal (SIGTSTP, handle_sigtstp); printf_unfiltered ("%s", prompt); gdb_flush (gdb_stdout); @@ -1149,7 +1145,7 @@ async_stop_sig (gdb_client_data arg) nothing. */ dont_repeat (); } -#endif /* STOP_SIGNAL */ +#endif /* SIGTSTP */ /* Tell the event loop what to do if SIGFPE is received. See event-signal.c. */ diff --git a/gdb/event-top.h b/gdb/event-top.h index 05241ad..d069c56 100644 --- a/gdb/event-top.h +++ b/gdb/event-top.h @@ -22,6 +22,8 @@ #ifndef EVENT_TOP_H #define EVENT_TOP_H +#include + struct cmd_list_element; /* Exported functions from event-top.c. @@ -36,14 +38,10 @@ extern void change_line_handler (int); extern void command_line_handler (char *rl); extern void command_handler (char *command); -/* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT. */ -#ifndef STOP_SIGNAL -#include #ifdef SIGTSTP -#define STOP_SIGNAL SIGTSTP -extern void handle_stop_sig (int sig); -#endif +extern void handle_sigtstp (int sig); #endif + extern void handle_sigint (int sig); extern void handle_sigterm (int sig); extern void async_request_quit (void *arg); diff --git a/gdb/top.c b/gdb/top.c index 9f5dd58..f006c66 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1184,9 +1184,9 @@ command_line_input (const char *prompt_arg, int repeat, /* Starting a new command line. */ cmd_line_buffer.used_size = 0; -#ifdef STOP_SIGNAL +#ifdef SIGTSTP if (job_control) - signal (STOP_SIGNAL, handle_stop_sig); + signal (SIGTSTP, handle_sigtstp); #endif while (1) @@ -1244,9 +1244,9 @@ command_line_input (const char *prompt_arg, int repeat, prompt = NULL; } -#ifdef STOP_SIGNAL +#ifdef SIGTSTP if (job_control) - signal (STOP_SIGNAL, SIG_DFL); + signal (SIGTSTP, SIG_DFL); #endif return cmd;