From patchwork Thu Dec 8 07:50:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 18276 Received: (qmail 17191 invoked by alias); 8 Dec 2016 07:51:00 -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 17070 invoked by uid 89); 8 Dec 2016 07:50:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=traced, H*Ad:U*thomas, H*r:PST, xxx X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 08 Dec 2016 07:50:49 +0000 Received: from svr-orw-fem-04.mgc.mentorg.com ([147.34.97.41]) by relay1.mentorg.com with esmtp id 1cEtTc-0000ug-CO from Thomas_Schwinge@mentor.com ; Wed, 07 Dec 2016 23:50:48 -0800 Received: from tftp-cs (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.3.224.2; Wed, 7 Dec 2016 23:50:48 -0800 Received: by tftp-cs (Postfix, from userid 49978) id AE09BC23E1; Wed, 7 Dec 2016 23:50:47 -0800 (PST) From: Thomas Schwinge To: CC: , Thomas Schwinge Subject: [PATCH 3/5] Hurd, C++: Avoid "const char *" to "char *" casts Date: Thu, 8 Dec 2016 08:50:34 +0100 Message-ID: <20161208075036.1517-4-thomas@codesourcery.com> In-Reply-To: <20161208075036.1517-1-thomas@codesourcery.com> References: <87eg1z93za.fsf@euler.schwinge.homeip.net> <20161208075036.1517-1-thomas@codesourcery.com> MIME-Version: 1.0 ... by a bit of code refactoring: gdb/ * gnu-nat.c (set_task_pause_cmd, set_signals_cmd) (set_exceptions_cmd): Add variants taking an "int arg" instead of a "char *". Make the "char *" variants use the former. (set_noninvasive_cmd): Also use the "int arg" variants. --- gdb/ChangeLog | 5 +++++ gdb/gnu-nat.c | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8b43cd8..b40ac6f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2016-12-08 Thomas Schwinge + * gnu-nat.c (set_task_pause_cmd, set_signals_cmd) + (set_exceptions_cmd): Add variants taking an "int arg" instead of + a "char *". Make the "char *" variants use the former. + (set_noninvasive_cmd): Also use the "int arg" variants. + * gnu-nat.c (gnu_create_inferior): Move nested "trace_me" function... (gnu_ptrace_me): ... here. diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index 34fd6f1..29bd9b9 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2792,12 +2792,12 @@ active_inf (void) static void -set_task_pause_cmd (char *args, int from_tty) +set_task_pause_cmd (int arg, int from_tty) { struct inf *inf = cur_inf (); int old_sc = inf->pause_sc; - inf->pause_sc = parse_bool_arg (args, "set task pause"); + inf->pause_sc = arg; if (old_sc == 0 && inf->pause_sc != 0) /* If the task is currently unsuspended, immediately suspend it, @@ -2806,6 +2806,12 @@ set_task_pause_cmd (char *args, int from_tty) } static void +set_task_pause_cmd (char *args, int from_tty) +{ + set_task_pause_cmd (parse_bool_arg (args, "set task pause"), from_tty); +} + +static void show_task_pause_cmd (char *args, int from_tty) { struct inf *inf = cur_inf (); @@ -2991,11 +2997,11 @@ show_sig_thread_cmd (char *args, int from_tty) static void -set_signals_cmd (char *args, int from_tty) +set_signals_cmd (int arg, int from_tty) { struct inf *inf = cur_inf (); - inf->want_signals = parse_bool_arg (args, "set signals"); + inf->want_signals = arg; if (inf->task && inf->want_signals != inf->traced) /* Make this take effect immediately in a running process. */ @@ -3003,6 +3009,12 @@ set_signals_cmd (char *args, int from_tty) } static void +set_signals_cmd (char *args, int from_tty) +{ + set_signals_cmd(parse_bool_arg (args, "set signals"), from_tty); +} + +static void show_signals_cmd (char *args, int from_tty) { struct inf *inf = cur_inf (); @@ -3015,15 +3027,20 @@ show_signals_cmd (char *args, int from_tty) } static void -set_exceptions_cmd (char *args, int from_tty) +set_exceptions_cmd (int arg, int from_tty) { struct inf *inf = cur_inf (); - int val = parse_bool_arg (args, "set exceptions"); /* Make this take effect immediately in a running process. */ /* XXX */ ; - inf->want_exceptions = val; + inf->want_exceptions = arg; +} + +static void +set_exceptions_cmd (char *args, int from_tty) +{ + set_exceptions_cmd (parse_bool_arg (args, "set exceptions"), from_tty); } static void @@ -3078,11 +3095,11 @@ static void set_noninvasive_cmd (char *args, int from_tty) { /* Invert the sense of the arg for each component. */ - char *inv_args = parse_bool_arg (args, "set noninvasive") ? "off" : "on"; + int inv_arg = parse_bool_arg (args, "set noninvasive") ? 0 : 1; - set_task_pause_cmd (inv_args, from_tty); - set_signals_cmd (inv_args, from_tty); - set_exceptions_cmd (inv_args, from_tty); + set_task_pause_cmd (inv_arg, from_tty); + set_signals_cmd (inv_arg, from_tty); + set_exceptions_cmd (inv_arg, from_tty); }