From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3855 invoked by alias); 30 Sep 2014 23:20:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 3845 invoked by uid 89); 30 Sep 2014 23:20:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 30 Sep 2014 23:20:41 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8UNKbCR023918 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 30 Sep 2014 19:20:37 -0400 Received: from localhost (dhcp-10-15-16-169.yyz.redhat.com [10.15.16.169]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8UNKaKj029205 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Tue, 30 Sep 2014 19:20:37 -0400 From: Sergio Durigan Junior To: "Jose E. Marchesi" Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 3/9] New commands `enable probe' and `disable probe'. References: <1411724905-31234-1-git-send-email-jose.marchesi@oracle.com> <1411724905-31234-4-git-send-email-jose.marchesi@oracle.com> <87mw9g4s8q.fsf@redhat.com> X-URL: http://blog.sergiodj.net Date: Tue, 30 Sep 2014 23:20:00 -0000 In-Reply-To: <87mw9g4s8q.fsf@redhat.com> (Sergio Durigan Junior's message of "Tue, 30 Sep 2014 19:13:09 -0400") Message-ID: <87iok44rwb.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-09/txt/msg00914.txt.bz2 On Tuesday, September 30 2014, I wrote: >> +/* Implementation of the `enable probes' command. */ >> + >> +static void >> +enable_probes_command (char *arg, int from_tty) >> +{ >> + char *provider, *probe_name = NULL, *objname = NULL; >> + struct cleanup *cleanup = make_cleanup (null_cleanup, NULL); >> + VEC (bound_probe_s) *probes; >> + struct bound_probe *probe; >> + int i; >> + >> + /* Do we have a `provider:probe:objfile' style of linespec? */ >> + provider = extract_arg (&arg); >> + if (provider) >> + { >> + make_cleanup (xfree, provider); >> + >> + probe_name = extract_arg (&arg); >> + if (probe_name) >> + { >> + make_cleanup (xfree, probe_name); >> + >> + objname = extract_arg (&arg); >> + if (objname) >> + make_cleanup (xfree, objname); >> + } >> + } > > This construct has become useful enough that it can be put in a > function, probably. Would you mind doing that? > >> + probes = collect_probes (objname, provider, probe_name, NULL /* pops */); > > When I code, I try not to put comments inside the parentheses. You can > put a comment above the function, or just remove it at all (there is > another call to collect_probes that doesn't have a comment). > >> + if (VEC_empty (bound_probe_s, probes)) >> + { >> + ui_out_message (current_uiout, 0, _("No probes matched.\n")); >> + return; >> + } > > You should call do_cleanups before returning here (and in other places). > >> + /* Enable the selected probes, provided their backends support the >> + notion of enabling a probe. */ >> + for (i = 0; VEC_iterate (bound_probe_s, probes, i, probe); ++i) >> + { >> + const struct probe_ops *pops = probe->probe->pops; >> + if (pops->enable_probe) > > Newline between variable declaration and code. You are also comparing > things implicitly, and we do it explicitly: > > if (pops->enable_probe != NULL) > >> + { >> + pops->enable_probe (probe->probe); >> + ui_out_message (current_uiout, 0, >> + _("Probe %s:%s enabled.\n"), >> + probe->probe->provider, probe->probe->name); >> + } >> + } > > I would appreciate a warning here if pops->enable_probe == NULL, saying > that the probe cannot be enabled/disabled. BTW, I forgot to say, but you should call do_cleanups before the function ends as well (the same applies for disable_probes_command). -- Sergio GPG key ID: 0x65FC5E36 Please send encrypted e-mail if possible http://sergiodj.net/