From patchwork Thu Dec 12 23:50:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 36812 Received: (qmail 101751 invoked by alias); 12 Dec 2019 23:50:28 -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 101397 invoked by uid 89); 12 Dec 2019 23:50:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=6186 X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Dec 2019 23:50:23 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 1771320480; Thu, 12 Dec 2019 18:50:21 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id 19D9A20C52; Thu, 12 Dec 2019 18:50:11 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id ACFC325BB4; Thu, 12 Dec 2019 18:50:10 -0500 (EST) X-Gerrit-PatchSet: 2 Date: Thu, 12 Dec 2019 18:50:10 -0500 From: "Sourceware to Gerrit sync (Code Review)" To: Tom Tromey , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: merged Subject: [pushed] Move free_all_objfiles to program_space X-Gerrit-Change-Id: I908b549d2981b6005f7ca181fc0e6d24fc8b7b6f X-Gerrit-Change-Number: 500 X-Gerrit-ChangeURL: X-Gerrit-Commit: 343cc95202fce70383551053f2efab09c5e02366 In-Reply-To: References: Reply-To: noreply@gnutoolchain-gerrit.osci.io, tromey@sourceware.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20191212235010.ACFC325BB4@gnutoolchain-gerrit.osci.io> Sourceware to Gerrit sync has submitted this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/500 ...................................................................... Move free_all_objfiles to program_space This changes free_all_objfiles to be a method on program_space, in line with the other changes to treat program_space as a container for objfiles. gdb/ChangeLog 2019-12-12 Tom Tromey * symfile.c (symbol_file_clear): Update. * progspace.h (struct program_space) : Declare method. * progspace.c (program_space::free_all_objfiles): New method. * objfiles.h (free_all_objfiles): Don't declare. * objfiles.c (free_all_objfiles): Move to program_space. Change-Id: I908b549d2981b6005f7ca181fc0e6d24fc8b7b6f --- M gdb/ChangeLog M gdb/objfiles.c M gdb/objfiles.h M gdb/progspace.c M gdb/progspace.h M gdb/symfile.c 6 files changed, 31 insertions(+), 18 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9b96f3d..9c1322d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,14 @@ 2019-12-12 Tom Tromey + * symfile.c (symbol_file_clear): Update. + * progspace.h (struct program_space) : Declare + method. + * progspace.c (program_space::free_all_objfiles): New method. + * objfiles.h (free_all_objfiles): Don't declare. + * objfiles.c (free_all_objfiles): Move to program_space. + +2019-12-12 Tom Tromey + * progspace.c (program_space::add_objfile) (program_space::remove_objfile): Update. (program_space::multi_objfile_p): Remove. diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 31265c1..56854cc 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -618,21 +618,6 @@ get_objfile_pspace_data (pspace)->section_map_dirty = 1; } -/* Free all the object files at once and clean up their users. */ - -void -free_all_objfiles (void) -{ - struct so_list *so; - - /* Any objfile reference would become stale. */ - for (so = master_so_list (); so; so = so->next) - gdb_assert (so->objfile == NULL); - - for (objfile *objfile : current_program_space->objfiles_safe ()) - objfile->unlink (); - clear_symtab_users (0); -} /* A helper function for objfile_relocate1 that relocates a single symbol. */ diff --git a/gdb/objfiles.h b/gdb/objfiles.h index f9bf102..3424055 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -662,8 +662,6 @@ extern void free_objfile_separate_debug (struct objfile *); -extern void free_all_objfiles (void); - extern void objfile_relocate (struct objfile *, const struct section_offsets *); extern void objfile_rebase (struct objfile *, CORE_ADDR); diff --git a/gdb/progspace.c b/gdb/progspace.c index d1bf0c6..3cb0d4c 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -23,6 +23,7 @@ #include "arch-utils.h" #include "gdbcore.h" #include "solib.h" +#include "solist.h" #include "gdbthread.h" #include "inferior.h" #include @@ -157,6 +158,23 @@ /* See progspace.h. */ void +program_space::free_all_objfiles () +{ + struct so_list *so; + + /* Any objfile reference would become stale. */ + for (so = master_so_list (); so; so = so->next) + gdb_assert (so->objfile == NULL); + + while (!objfiles_list.empty ()) + objfiles_list.front ()->unlink (); + + clear_symtab_users (0); +} + +/* See progspace.h. */ + +void program_space::add_objfile (struct objfile *objfile, struct objfile *before) { if (before == nullptr) diff --git a/gdb/progspace.h b/gdb/progspace.h index a731eb6..6945e38 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -179,6 +179,9 @@ return objfiles_list.size () > 1; } + /* Free all the objfiles associated with this program space. */ + void free_all_objfiles (); + /* Pointer to next in linked list. */ struct program_space *next = NULL; diff --git a/gdb/symfile.c b/gdb/symfile.c index 9652371..8852e28 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1251,7 +1251,7 @@ objfiles get stale by free_all_objfiles. */ no_shared_libraries (NULL, from_tty); - free_all_objfiles (); + current_program_space->free_all_objfiles (); gdb_assert (symfile_objfile == NULL); if (from_tty)