diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2024-07-11 12:07:00 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2024-11-11 11:28:24 -0500 |
commit | fa15972b68a6745eea5f7c1dfe8b6b0c3bd3bc45 (patch) | |
tree | 41a846effbe604a60fe3f5ab261f2b6fb3266d81 /gdb/progspace.c | |
parent | 427cc3b541e65b24b78bddb5c0672e871947132c (diff) | |
download | binutils-fa15972b68a6745eea5f7c1dfe8b6b0c3bd3bc45.zip binutils-fa15972b68a6745eea5f7c1dfe8b6b0c3bd3bc45.tar.gz binutils-fa15972b68a6745eea5f7c1dfe8b6b0c3bd3bc45.tar.bz2 |
gdb/progspace: link objfiles using owning_intrusive_list
This simplifies things a little bit, removing some `find_if` when
inserting or removing objfiles, and the whole
unwrapping_objfile_iterator thing.
Change-Id: Idd1851d36c7834820c9c1639a6a252de643eafba
Diffstat (limited to 'gdb/progspace.c')
-rw-r--r-- | gdb/progspace.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/gdb/progspace.c b/gdb/progspace.c index 28198c1..94175d3 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -124,6 +124,15 @@ program_space::~program_space () /* See progspace.h. */ +bool +program_space::multi_objfile_p () const +{ + return (!objfiles_list.empty () + && std::next (objfiles_list.begin ()) != objfiles_list.end ()); +} + +/* See progspace.h. */ + void program_space::free_all_objfiles () { @@ -132,7 +141,7 @@ program_space::free_all_objfiles () gdb_assert (so.objfile == NULL); while (!objfiles_list.empty ()) - objfiles_list.front ()->unlink (); + this->remove_objfile (&objfiles_list.front ()); } /* See progspace.h. */ @@ -145,13 +154,9 @@ program_space::add_objfile (std::unique_ptr<objfile> &&objfile, objfiles_list.push_back (std::move (objfile)); else { - auto iter = std::find_if (objfiles_list.begin (), objfiles_list.end (), - [=] (const std::unique_ptr<::objfile> &objf) - { - return objf.get () == before; - }); - gdb_assert (iter != objfiles_list.end ()); - objfiles_list.insert (iter, std::move (objfile)); + gdb_assert (before->is_linked ()); + objfiles_list.insert (objfiles_list.iterator_to (*before), + std::move (objfile)); } } @@ -166,16 +171,11 @@ program_space::remove_objfile (struct objfile *objfile) reference stale info. */ reinit_frame_cache (); - auto iter = std::find_if (objfiles_list.begin (), objfiles_list.end (), - [=] (const std::unique_ptr<::objfile> &objf) - { - return objf.get () == objfile; - }); - gdb_assert (iter != objfiles_list.end ()); - objfiles_list.erase (iter); - if (objfile == symfile_object_file) symfile_object_file = NULL; + + gdb_assert (objfile->is_linked ()); + objfiles_list.erase (objfiles_list.iterator_to (*objfile)); } /* See progspace.h. */ |