From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30731 invoked by alias); 24 Sep 2014 22:48: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 30721 invoked by uid 89); 24 Sep 2014 22:48:41 -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,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-vc0-f170.google.com Received: from mail-vc0-f170.google.com (HELO mail-vc0-f170.google.com) (209.85.220.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 24 Sep 2014 22:48:40 +0000 Received: by mail-vc0-f170.google.com with SMTP id ij19so4837874vcb.15 for ; Wed, 24 Sep 2014 15:48:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=NCZfDxoPSdUrCaNy5Ma81j6FpIExpN23E0q995Wdbz4=; b=mjK44uwaMK1lzsVjdj+4NDcocasWzkUC4/pOtSfKtOvo1VKOPbkCZ1L43i40s4AXjU DvPlHy2hlqDUbJwlcda7XKz22UIb+vuIMJbwbNmNpHepRa+3yrV0yhIDAIFyx3VeyzLk H58UogSC1emlgPMYQPiWD4Mfm+BTTYyP58bXf+0Rb/ZvrLB4k1jWGuzAfcHvCQhjCStZ 1kDxbqsi159GmrTSWcb844gcHojTPcUBgRDt5pABizYiAj3H42fsh4ybLZlNf5F2PyAw RX3web0Hex1ZLoV63msPBttCJMd16XprIu67UcPVakd4TYV734BkZC59rWSMt+dAUSe7 yXeQ== X-Gm-Message-State: ALoCoQm9fU5CCiCatCYdTKXx+VDv093VKTxVEzSFl7aW6v91Z2a2lUo9PF/pd2gkBV++PR3WCmZj MIME-Version: 1.0 X-Received: by 10.220.44.80 with SMTP id z16mr8063222vce.7.1411598918467; Wed, 24 Sep 2014 15:48:38 -0700 (PDT) Received: by 10.52.181.65 with HTTP; Wed, 24 Sep 2014 15:48:38 -0700 (PDT) In-Reply-To: <1411582288-20967-1-git-send-email-simon.marchi@ericsson.com> References: <1411582288-20967-1-git-send-email-simon.marchi@ericsson.com> Date: Wed, 24 Sep 2014 22:48:00 -0000 Message-ID: Subject: Re: [PATCH] Don't prune program spaces when doing "maintenance info program-spaces" From: Doug Evans To: Simon Marchi Cc: gdb-patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-09/txt/msg00720.txt.bz2 On Wed, Sep 24, 2014 at 11:11 AM, Simon Marchi wrote: > While debugging a program spaces issue, I found that "maintenance info > program-spaces" pruned the program spaces prior to printing them. I > don't think a command to inspect the state of the program (especially > a maintenance one) should modify the state. All it can do is potentially > hide bugs. > > gdb/Changelog: > > * progspace.c (print_program_space): Add "prune" parameter. > (maintenance_info_program_spaces_command): Update call to > print_program_space with new parameter. > --- > gdb/progspace.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/gdb/progspace.c b/gdb/progspace.c > index a74b6ab..aef2d4e 100644 > --- a/gdb/progspace.c > +++ b/gdb/progspace.c > @@ -272,18 +272,19 @@ prune_program_spaces (void) > > /* Prints the list of program spaces and their details on UIOUT. If > REQUESTED is not -1, it's the ID of the pspace that should be > - printed. Otherwise, all spaces are printed. */ > + printed. Otherwise, all spaces are printed. If PRUNE is true, > + prune the unused program spaces prior to printing them, so they > + won't be displayed. */ > > static void > -print_program_space (struct ui_out *uiout, int requested) > +print_program_space (struct ui_out *uiout, int requested, int prune) > { > struct program_space *pspace; > int count = 0; > struct cleanup *old_chain; > > - /* Might as well prune away unneeded ones, so the user doesn't even > - seem them. */ > - prune_program_spaces (); > + if (prune) > + prune_program_spaces (); > > /* Compute number of pspaces we will print. */ > ALL_PSPACES (pspace) > @@ -385,7 +386,7 @@ maintenance_info_program_spaces_command (char *args, int from_tty) > error (_("program space ID %d not known."), requested); > } > > - print_program_space (current_uiout, requested); > + print_program_space (current_uiout, requested, 0 /* prune */); > } > > /* Simply returns the count of program spaces. */ Hi. I agree we want to, in general, avoid side-effects in info commands (even more so in maint info commands). OTOH, as a reader of this code I wouldn't expect a print routine to have side-effects either. IOW, how about move the call to prune_program_spaces to whatever caller wants it. btw, is part of this patch missing? Is there intended to be another caller of print_program_spaces that passes prune = 1?