From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D818B385842C for ; Wed, 5 Jan 2022 11:57:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D818B385842C Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-132-g50PVDWkMau0YlaRSKz-1Q-1; Wed, 05 Jan 2022 06:57:03 -0500 X-MC-Unique: g50PVDWkMau0YlaRSKz-1Q-1 Received: by mail-wr1-f69.google.com with SMTP id h12-20020adfa4cc000000b001a22dceda69so12484772wrb.16 for ; Wed, 05 Jan 2022 03:57:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=K2Wbi8SHuJjS1G4xjLNYew5WLuOuzHnOrMBu7XTTfjA=; b=eu/OAPr1Yn5h0RrRSwdkXTbDq07yrKShR/eRm6837uhpHDMAkn7Y0F5AdAMYn6rXUH yRCth/FcaSbAIwjFfsLCkILctrWcaLgWklLRblKV0tKmDZd9Lk0zja4sKU0Tdl1K+7DL fGr4ifmNojI8RVhTZDlJxNuLeBimctDMMq1AInSiYcjQV2jFeSHz4s41hUbHj8l8QxrQ TC3cOsF7T6Ku9b0WmmWFzuEp7nGJA+okY/MtLjRrkHIepvVvqIpblqlWYeMDK9n+THHe jcbLEZcWgPMRQRlXGhwLxWnJrwBhWufAjHPwJbuDR0EUcDjuqHpy6gVzxr7VLATknY4Z BsUQ== X-Gm-Message-State: AOAM532HohtcjI9V6mKp9dkUR36LomCsylJMS7z1bOVXgm+45zE6pk+T 4LYsjzaRax4D/q57X8RMHc9A3wBIKkO1zVNqnM4mRB151oQrJ1y1ff0KCtzJ9EX0GufQo+ms5rh 38+IkILUpmm0dxT8TIWEn0g== X-Received: by 2002:a5d:6c63:: with SMTP id r3mr45739661wrz.678.1641383822364; Wed, 05 Jan 2022 03:57:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWP8l2KDhZKLyJlcQuPww37zTQJXAHUNTpKIxQSkGoAe0LL4e3ZePOy6RRaL89IPWLxonEjw== X-Received: by 2002:a5d:6c63:: with SMTP id r3mr45739648wrz.678.1641383822101; Wed, 05 Jan 2022 03:57:02 -0800 (PST) Received: from localhost (host109-154-163-67.range109-154.btcentralplus.com. [109.154.163.67]) by smtp.gmail.com with ESMTPSA id m15sm1106203wmq.6.2022.01.05.03.57.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 03:57:01 -0800 (PST) Date: Wed, 5 Jan 2022 11:57:00 +0000 From: Andrew Burgess To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 10/12] Use filtered output in gnu-nat.c commands Message-ID: <20220105115700.GC621762@redhat.com> References: <20220101175520.351628-1-tom@tromey.com> <20220101175520.351628-11-tom@tromey.com> MIME-Version: 1.0 In-Reply-To: <20220101175520.351628-11-tom@tromey.com> X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 11:54:18 up 3 days, 20:48, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Wed, 05 Jan 2022 11:57:06 -0000 * Tom Tromey [2022-01-01 10:55:18 -0700]: > gnu-nat.c has a number of ordinary commands that should use filtered > output. In a few cases, I changed the output to use gdb_stderr as > well. I can't compile this file, so this patch is split out as a > "best effort". > --- > gdb/gnu-nat.c | 102 ++++++++++++++++++++++++++------------------------ > 1 file changed, 53 insertions(+), 49 deletions(-) > > diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c > index 4b22e21bb8e..b7b486904e8 100644 > --- a/gdb/gnu-nat.c > +++ b/gdb/gnu-nat.c > @@ -2704,29 +2704,33 @@ struct cmd_list_element *show_thread_default_cmd_list = NULL; > static void > set_thread_cmd (const char *args, int from_tty) > { > - printf_unfiltered ("\"set thread\" must be followed by the " > - "name of a thread property, or \"default\".\n"); > + fprintf_filtered (gdb_stderr, > + "\"set thread\" must be followed by the " > + "name of a thread property, or \"default\".\n"); I'd be tempted to suggest that these should all be replaced with calls to error. If the user runs one of these from a command script, it feels like hitting one of these cases should be something that stops the script running due to the incorrectly formed command, rather than just printing a message and continuing... Thanks, Andrew > } > > static void > show_thread_cmd (const char *args, int from_tty) > { > - printf_unfiltered ("\"show thread\" must be followed by the " > - "name of a thread property, or \"default\".\n"); > + fprintf_unfiltered (gdb_stderr, > + "\"show thread\" must be followed by the " > + "name of a thread property, or \"default\".\n"); > } > > static void > set_thread_default_cmd (const char *args, int from_tty) > { > - printf_unfiltered ("\"set thread default\" must be followed " > - "by the name of a thread property.\n"); > + fprintf_unfiltered (gdb_stderr, > + "\"set thread default\" must be followed " > + "by the name of a thread property.\n"); > } > > static void > show_thread_default_cmd (const char *args, int from_tty) > { > - printf_unfiltered ("\"show thread default\" must be followed " > - "by the name of a thread property.\n"); > + fprintf_unfiltered (gdb_stderr, > + "\"show thread default\" must be followed " > + "by the name of a thread property.\n"); > } > > static int > @@ -2818,10 +2822,10 @@ show_task_pause_cmd (const char *args, int from_tty) > struct inf *inf = cur_inf (); > > check_empty (args, "show task pause"); > - printf_unfiltered ("The inferior task %s suspended while gdb has control.\n", > - inf->task > - ? (inf->pause_sc == 0 ? "isn't" : "is") > - : (inf->pause_sc == 0 ? "won't be" : "will be")); > + printf_filtered ("The inferior task %s suspended while gdb has control.\n", > + inf->task > + ? (inf->pause_sc == 0 ? "isn't" : "is") > + : (inf->pause_sc == 0 ? "won't be" : "will be")); > } > > static void > @@ -2835,9 +2839,9 @@ static void > show_task_detach_sc_cmd (const char *args, int from_tty) > { > check_empty (args, "show task detach-suspend-count"); > - printf_unfiltered ("The inferior task will be left with a " > - "suspend count of %d when detaching.\n", > - cur_inf ()->detach_sc); > + printf_filtered ("The inferior task will be left with a " > + "suspend count of %d when detaching.\n", > + cur_inf ()->detach_sc); > } > > > @@ -2857,9 +2861,9 @@ show_thread_default_pause_cmd (const char *args, int from_tty) > int sc = inf->default_thread_pause_sc; > > check_empty (args, "show thread default pause"); > - printf_unfiltered ("New threads %s suspended while gdb has control%s.\n", > - sc ? "are" : "aren't", > - !sc && inf->pause_sc ? " (but the task is)" : ""); > + printf_filtered ("New threads %s suspended while gdb has control%s.\n", > + sc ? "are" : "aren't", > + !sc && inf->pause_sc ? " (but the task is)" : ""); > } > > static void > @@ -2877,8 +2881,8 @@ show_thread_default_run_cmd (const char *args, int from_tty) > struct inf *inf = cur_inf (); > > check_empty (args, "show thread default run"); > - printf_unfiltered ("New threads %s allowed to run.\n", > - inf->default_thread_run_sc == 0 ? "are" : "aren't"); > + printf_filtered ("New threads %s allowed to run.\n", > + inf->default_thread_run_sc == 0 ? "are" : "aren't"); > } > > static void > @@ -2892,8 +2896,8 @@ static void > show_thread_default_detach_sc_cmd (const char *args, int from_tty) > { > check_empty (args, "show thread default detach-suspend-count"); > - printf_unfiltered ("New threads will get a detach-suspend-count of %d.\n", > - cur_inf ()->default_thread_detach_sc); > + printf_filtered ("New threads will get a detach-suspend-count of %d.\n", > + cur_inf ()->default_thread_detach_sc); > } > > > @@ -2956,8 +2960,8 @@ show_stopped_cmd (const char *args, int from_tty) > struct inf *inf = active_inf (); > > check_empty (args, "show stopped"); > - printf_unfiltered ("The inferior process %s stopped.\n", > - inf->stopped ? "is" : "isn't"); > + printf_filtered ("The inferior process %s stopped.\n", > + inf->stopped ? "is" : "isn't"); > } > > static void > @@ -2985,10 +2989,10 @@ show_sig_thread_cmd (const char *args, int from_tty) > > check_empty (args, "show signal-thread"); > if (inf->signal_thread) > - printf_unfiltered ("The signal thread is %s.\n", > - proc_string (inf->signal_thread)); > + printf_filtered ("The signal thread is %s.\n", > + proc_string (inf->signal_thread)); > else > - printf_unfiltered ("There is no signal thread.\n"); > + printf_filtered ("There is no signal thread.\n"); > } > > > @@ -3016,10 +3020,10 @@ show_signals_cmd (const char *args, int from_tty) > struct inf *inf = cur_inf (); > > check_empty (args, "show signals"); > - printf_unfiltered ("The inferior process's signals %s intercepted.\n", > - inf->task > - ? (inf->traced ? "are" : "aren't") > - : (inf->want_signals ? "will be" : "won't be")); > + printf_filtered ("The inferior process's signals %s intercepted.\n", > + inf->task > + ? (inf->traced ? "are" : "aren't") > + : (inf->want_signals ? "will be" : "won't be")); > } > > static void > @@ -3045,18 +3049,18 @@ show_exceptions_cmd (const char *args, int from_tty) > struct inf *inf = cur_inf (); > > check_empty (args, "show exceptions"); > - printf_unfiltered ("Exceptions in the inferior %s trapped.\n", > - inf->task > - ? (inf->want_exceptions ? "are" : "aren't") > - : (inf->want_exceptions ? "will be" : "won't be")); > + printf_filtered ("Exceptions in the inferior %s trapped.\n", > + inf->task > + ? (inf->want_exceptions ? "are" : "aren't") > + : (inf->want_exceptions ? "will be" : "won't be")); > } > > > static void > set_task_cmd (const char *args, int from_tty) > { > - printf_unfiltered ("\"set task\" must be followed by the name" > - " of a task property.\n"); > + printf_filtered ("\"set task\" must be followed by the name" > + " of a task property.\n"); > } > > static void > @@ -3320,10 +3324,10 @@ show_thread_pause_cmd (const char *args, int from_tty) > int sc = thread->pause_sc; > > check_empty (args, "show task pause"); > - printf_unfiltered ("Thread %s %s suspended while gdb has control%s.\n", > - proc_string (thread), > - sc ? "is" : "isn't", > - !sc && thread->inf->pause_sc ? " (but the task is)" : ""); > + printf_filtered ("Thread %s %s suspended while gdb has control%s.\n", > + proc_string (thread), > + sc ? "is" : "isn't", > + !sc && thread->inf->pause_sc ? " (but the task is)" : ""); > } > > static void > @@ -3340,9 +3344,9 @@ show_thread_run_cmd (const char *args, int from_tty) > struct proc *thread = cur_thread (); > > check_empty (args, "show thread run"); > - printf_unfiltered ("Thread %s %s allowed to run.", > - proc_string (thread), > - thread->run_sc == 0 ? "is" : "isn't"); > + printf_filtered ("Thread %s %s allowed to run.", > + proc_string (thread), > + thread->run_sc == 0 ? "is" : "isn't"); > } > > static void > @@ -3358,10 +3362,10 @@ show_thread_detach_sc_cmd (const char *args, int from_tty) > struct proc *thread = cur_thread (); > > check_empty (args, "show thread detach-suspend-count"); > - printf_unfiltered ("Thread %s will be left with a suspend count" > - " of %d when detaching.\n", > - proc_string (thread), > - thread->detach_sc); > + printf_filtered ("Thread %s will be left with a suspend count" > + " of %d when detaching.\n", > + proc_string (thread), > + thread->detach_sc); > } > > static void > @@ -3403,7 +3407,7 @@ thread_takeover_sc_cmd (const char *args, int from_tty) > error (("%s."), safe_strerror (err)); > thread->sc = info->suspend_count; > if (from_tty) > - printf_unfiltered ("Suspend count was %d.\n", thread->sc); > + printf_filtered ("Suspend count was %d.\n", thread->sc); > if (info != &_info) > vm_deallocate (mach_task_self (), (vm_address_t) info, > info_len * sizeof (int)); > -- > 2.31.1 > >