From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 1/3] Remove some uses of "object_files"
Date: Tue, 09 Apr 2019 18:09:00 -0000 [thread overview]
Message-ID: <20190409180945.21621-2-tom@tromey.com> (raw)
In-Reply-To: <20190409180945.21621-1-tom@tromey.com>
The "object_files" macro is sometimes used when iterating over
objfiles. This patch removes a few such uses in favor of the new
range adapter.
gdb/ChangeLog
2019-04-09 Tom Tromey <tom@tromey.com>
* ia64-tdep.c (ia64_get_dyn_info_list): Use foreach.
* minsyms.c (lookup_minimal_symbol): Use foreach.
(lookup_minimal_symbol_text, lookup_minimal_symbol_by_pc_name)
(lookup_minimal_symbol_solib_trampoline): Likewise.
* symfile.c (reread_symbols): Use foreach.
---
gdb/ChangeLog | 8 ++++++++
gdb/ia64-tdep.c | 3 +--
gdb/minsyms.c | 26 ++++++++++----------------
gdb/symfile.c | 3 +--
4 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index 7b4d0a0bfa1..f46673986ba 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -2845,7 +2845,6 @@ ia64_get_dyn_info_list (unw_addr_space_t as,
unw_word_t *dilap, void *arg)
{
struct obj_section *text_sec;
- struct objfile *objfile;
unw_word_t ip, addr;
unw_dyn_info_t di;
int ret;
@@ -2853,7 +2852,7 @@ ia64_get_dyn_info_list (unw_addr_space_t as,
if (!libunwind_is_initialized ())
return -UNW_ENOINFO;
- for (objfile = object_files; objfile; objfile = objfile->next)
+ for (objfile *objfile : current_program_space->objfiles ())
{
void *buf = NULL;
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 51b65f51421..34198d122dc 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -308,7 +308,6 @@ struct bound_minimal_symbol
lookup_minimal_symbol (const char *name, const char *sfile,
struct objfile *objf)
{
- struct objfile *objfile;
found_minimal_symbols found;
unsigned int mangled_hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
@@ -323,10 +322,11 @@ lookup_minimal_symbol (const char *name, const char *sfile,
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
- for (objfile = object_files;
- objfile != NULL && found.external_symbol.minsym == NULL;
- objfile = objfile->next)
+ for (objfile *objfile : current_program_space->objfiles ())
{
+ if (found.external_symbol.minsym != NULL)
+ break;
+
if (objf == NULL || objf == objfile
|| objf == objfile->separate_debug_objfile_backlink)
{
@@ -522,17 +522,17 @@ iterate_over_minimal_symbols
struct bound_minimal_symbol
lookup_minimal_symbol_text (const char *name, struct objfile *objf)
{
- struct objfile *objfile;
struct minimal_symbol *msymbol;
struct bound_minimal_symbol found_symbol = { NULL, NULL };
struct bound_minimal_symbol found_file_symbol = { NULL, NULL };
unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
- for (objfile = object_files;
- objfile != NULL && found_symbol.minsym == NULL;
- objfile = objfile->next)
+ for (objfile *objfile : current_program_space->objfiles ())
{
+ if (found_symbol.minsym != NULL)
+ break;
+
if (objf == NULL || objf == objfile
|| objf == objfile->separate_debug_objfile_backlink)
{
@@ -574,14 +574,11 @@ struct minimal_symbol *
lookup_minimal_symbol_by_pc_name (CORE_ADDR pc, const char *name,
struct objfile *objf)
{
- struct objfile *objfile;
struct minimal_symbol *msymbol;
unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
- for (objfile = object_files;
- objfile != NULL;
- objfile = objfile->next)
+ for (objfile *objfile : current_program_space->objfiles ())
{
if (objf == NULL || objf == objfile
|| objf == objfile->separate_debug_objfile_backlink)
@@ -606,15 +603,12 @@ struct bound_minimal_symbol
lookup_minimal_symbol_solib_trampoline (const char *name,
struct objfile *objf)
{
- struct objfile *objfile;
struct minimal_symbol *msymbol;
struct bound_minimal_symbol found_symbol = { NULL, NULL };
unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
- for (objfile = object_files;
- objfile != NULL;
- objfile = objfile->next)
+ for (objfile *objfile : current_program_space->objfiles ())
{
if (objf == NULL || objf == objfile
|| objf == objfile->separate_debug_objfile_backlink)
diff --git a/gdb/symfile.c b/gdb/symfile.c
index dbfc306c521..ba82f1b83ca 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2427,7 +2427,6 @@ remove_symbol_file_command (const char *args, int from_tty)
void
reread_symbols (void)
{
- struct objfile *objfile;
long new_modtime;
struct stat new_statbuf;
int res;
@@ -2439,7 +2438,7 @@ reread_symbols (void)
This routine should then walk down each partial symbol table
and see if the symbol table that it originates from has been changed. */
- for (objfile = object_files; objfile; objfile = objfile->next)
+ for (objfile *objfile : current_program_space->objfiles ())
{
if (objfile->obfd == NULL)
continue;
--
2.17.2
next prev parent reply other threads:[~2019-04-09 18:09 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-09 18:11 [PATCH 0/3] some minor objfile iteration improvements Tom Tromey
2019-04-09 18:09 ` [PATCH 2/3] Fix a couple of comments Tom Tromey
2019-04-10 1:51 ` Simon Marchi
2019-04-09 18:09 ` [PATCH 3/3] Introduce a separate debug objfile iterator Tom Tromey
2019-04-10 2:01 ` Simon Marchi
2019-04-10 14:08 ` Tom Tromey
2019-04-30 15:44 ` Sandra Loosemore
2019-04-30 15:51 ` Tom Tromey
2019-05-01 18:30 ` Tom Tromey
2019-05-03 18:23 ` Sandra Loosemore
2019-05-03 23:28 ` Tom Tromey
2019-05-15 9:45 ` John Marshall
2019-05-15 15:45 ` Tom Tromey
2019-05-15 20:00 ` John Marshall
2019-04-09 18:09 ` Tom Tromey [this message]
2019-04-10 1:49 ` [PATCH 1/3] Remove some uses of "object_files" Simon Marchi
2019-04-10 2:26 ` Tom Tromey
2019-04-10 2:50 ` Simon Marchi
2019-04-10 14:08 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190409180945.21621-2-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox