From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11776 invoked by alias); 29 Sep 2014 17:48:29 -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 11727 invoked by uid 89); 29 Sep 2014 17:48:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: sesbmg23.ericsson.net Received: from sesbmg23.ericsson.net (HELO sesbmg23.ericsson.net) (193.180.251.37) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 29 Sep 2014 17:48:24 +0000 Received: from EUSAAHC006.ericsson.se (Unknown_Domain [153.88.253.124]) by sesbmg23.ericsson.net (Symantec Mail Security) with SMTP id E0.61.24955.36B99245; Mon, 29 Sep 2014 19:48:19 +0200 (CEST) Received: from [142.133.110.254] (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.90) with Microsoft SMTP Server (TLS) id 14.3.174.1; Mon, 29 Sep 2014 13:48:17 -0400 Message-ID: <54299B61.7030107@ericsson.com> Date: Mon, 29 Sep 2014 17:48:00 -0000 From: Simon Marchi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 To: Doug Evans CC: gdb-patches Subject: Re: [PATCH] Add call to prune_program_spaces in mi_cmd_remove_inferior References: <1411593539-6507-1-git-send-email-simon.marchi@ericsson.com> <54242FBD.7030408@ericsson.com> In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2014-09/txt/msg00842.txt.bz2 On 2014-09-28 04:54 PM, Doug Evans wrote: > On Sun, Sep 28, 2014 at 1:16 PM, Doug Evans wrote: >> [...] >> btw #2, There's also the invariant "There's always (at least) one >> program space." >> One is left with the question of whether they could be unrelated. >> IOW could there be an inferior without a program space or a program >> space without an inferior? >> [At least in general. There are special cases where we do temporary >> hacks to get through forks and such.] >> Another cleanup could be to make this clearer. > > One thought I had, and I'm just thinking out loud here, is to rephrase > this invariant as "An inferior always has a program space." Then, > given that there is always an inferior, it falls out that there will > also always be a program space. > > But, at least to this reader, program spaces can't ever be thought of > as being created on their own, they are only created when an inferior > is created, and deleted when the last inferior using it is deleted. > That includes the initial program space, which leads to the thought of > merging the creation of the initial program space and initial > inferior. > Doing that feels clearer to me than initializing them separately, > given that we're going to be actively deleting program spaces when the > last-using inferior is deleted. It makes sense to me. If we tie the creation/deletion of program spaces with the creation/deletion of inferiors, could we go further and tie the concept of current program space and current inferior? I see very often a set_current_inferior (inf) followed by a set_current_program_space (inf->pspace). I don't really know when we would want a current program space that is not the program space of our current inferior. >From what I can see, the only times set_current_program_space is called alone is in constructs like this: old_chain = save_current_program_space (); ALL_PSPACES (ss) { set_current_program_space (ss); clear_section_table (current_target_sections); exec_close (); } do_cleanups (old_chain); where exec_close accesses the global "current_program_space". So in reality, it is passing a parameter indirectly using a global variable. I suppose we should rather see: ALL_PSPACES (ss) { clear_section_table (current_target_sections); exec_close (ss); } I realize that there is a lot of such indirect parameter passing in gdb. It wouldn't be easy do to such a change, but I think it would help in many regards.