From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 10/12] Remove ALL_OBJFILES and ALL_FILETABS
Date: Sun, 25 Nov 2018 16:54:00 -0000 [thread overview]
Message-ID: <20181125165439.13773-11-tom@tromey.com> (raw)
In-Reply-To: <20181125165439.13773-1-tom@tromey.com>
This removes the ALL_OBJFILES and ALL_FILETABS macros, replacing them
with ranged for loops.
gdb/ChangeLog
2018-11-25 Tom Tromey <tom@tromey.com>
* symtab.c (find_line_symtab, info_sources_command)
(make_source_files_completion_list): Use objfile_compunits.
* source.c (select_source_symtab): Use objfile_compunits.
* objfiles.h (struct objfile): Update comment.
(ALL_OBJFILES): Remove.
(ALL_FILETABS): Remove.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Use
objfile_compunits.
---
gdb/ChangeLog | 11 ++++
gdb/mi/mi-cmd-file.c | 17 +++---
gdb/objfiles.h | 18 +------
gdb/source.c | 24 ++++-----
gdb/symtab.c | 121 ++++++++++++++++++++++---------------------
5 files changed, 95 insertions(+), 96 deletions(-)
diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c
index a74846e21b..9fabdb9d71 100644
--- a/gdb/mi/mi-cmd-file.c
+++ b/gdb/mi/mi-cmd-file.c
@@ -84,7 +84,6 @@ void
mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc)
{
struct ui_out *uiout = current_uiout;
- struct objfile *objfile;
if (!mi_valid_noargs ("-file-list-exec-source-files", argc, argv))
error (_("-file-list-exec-source-files: Usage: No args"));
@@ -93,15 +92,17 @@ mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc)
uiout->begin (ui_out_type_list, "files");
/* Look at all of the file symtabs. */
- ALL_FILETABS (objfile, cu, s)
- {
- uiout->begin (ui_out_type_tuple, NULL);
+ for (struct objfile *objfile : all_objfiles (current_program_space))
+ for (struct compunit_symtab *cu : objfile_compunits (objfile))
+ for (struct symtab *s : compunit_filetabs (cu))
+ {
+ uiout->begin (ui_out_type_tuple, NULL);
- uiout->field_string ("file", symtab_to_filename_for_display (s));
- uiout->field_string ("fullname", symtab_to_fullname (s));
+ uiout->field_string ("file", symtab_to_filename_for_display (s));
+ uiout->field_string ("fullname", symtab_to_fullname (s));
- uiout->end (ui_out_type_tuple);
- }
+ uiout->end (ui_out_type_tuple);
+ }
map_symbol_filenames (print_partial_file_name, NULL,
1 /*need_fullname*/);
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 94394e79ae..9d00a55ce5 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -430,7 +430,7 @@ struct objfile
Although this is a tree structure, GDB only support one level
(ie a separate debug for a separate debug is not supported). Note that
separate debug object are in the main chain and therefore will be
- visited by ALL_OBJFILES & co iterators. Separate debug objfile always
+ visited by all_objfiles & co iterators. Separate debug objfile always
has a non-nul separate_debug_objfile_backlink. */
/* Link to the first separate debug object, if any. */
@@ -604,14 +604,6 @@ public:
}
};
-
-/* Traverse all object files in the current program space. */
-
-#define ALL_OBJFILES(obj) \
- for ((obj) = current_program_space->objfiles; \
- (obj) != NULL; \
- (obj) = (obj)->next)
-
/* A range adapter that makes it possible to iterate over all
compunits in one objfile. */
@@ -705,14 +697,6 @@ private:
struct objfile *m_objfile;
};
-/* Traverse all symtabs in all objfiles in the current symbol
- space. */
-
-#define ALL_FILETABS(objfile, ps, s) \
- ALL_OBJFILES (objfile) \
- for (struct compunit_symtab *ps : objfile_compunits (objfile)) \
- for (struct symtab *s : compunit_filetabs (cu))
-
#define ALL_OBJFILE_OSECTIONS(objfile, osect) \
for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
if (osect->the_bfd_section == NULL) \
diff --git a/gdb/source.c b/gdb/source.c
index 6111453eb0..c0ea866d92 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -243,8 +243,6 @@ clear_current_source_symtab_and_line (void)
void
select_source_symtab (struct symtab *s)
{
- struct objfile *ofp;
-
if (s)
{
current_source_symtab = s;
@@ -276,18 +274,20 @@ select_source_symtab (struct symtab *s)
current_source_line = 1;
- ALL_FILETABS (ofp, cu, symtab)
- {
- const char *name = symtab->filename;
- int len = strlen (name);
-
- if (!(len > 2 && (strcmp (&name[len - 2], ".h") == 0
- || strcmp (name, "<<C++-namespaces>>") == 0)))
+ for (struct objfile *ofp : all_objfiles (current_program_space))
+ for (struct compunit_symtab *cu : objfile_compunits (ofp))
+ for (struct symtab *symtab : compunit_filetabs (cu))
{
- current_source_pspace = current_program_space;
- current_source_symtab = symtab;
+ const char *name = symtab->filename;
+ int len = strlen (name);
+
+ if (!(len > 2 && (strcmp (&name[len - 2], ".h") == 0
+ || strcmp (name, "<<C++-namespaces>>") == 0)))
+ {
+ current_source_pspace = current_program_space;
+ current_source_symtab = symtab;
+ }
}
- }
if (current_source_symtab)
return;
diff --git a/gdb/symtab.c b/gdb/symtab.c
index c16fc307ad..145971f1b9 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3353,37 +3353,38 @@ find_line_symtab (struct symtab *symtab, int line,
(objfile, symtab_to_fullname (symtab));
}
- struct objfile *objfile;
- ALL_FILETABS (objfile, cu, s)
- {
- struct linetable *l;
- int ind;
+ for (struct objfile *objfile : all_objfiles (current_program_space))
+ for (struct compunit_symtab *cu : objfile_compunits (objfile))
+ for (struct symtab *s : compunit_filetabs (cu))
+ {
+ struct linetable *l;
+ int ind;
- if (FILENAME_CMP (symtab->filename, s->filename) != 0)
- continue;
- if (FILENAME_CMP (symtab_to_fullname (symtab),
- symtab_to_fullname (s)) != 0)
- continue;
- l = SYMTAB_LINETABLE (s);
- ind = find_line_common (l, line, &exact, 0);
- if (ind >= 0)
- {
- if (exact)
- {
- best_index = ind;
- best_linetable = l;
- best_symtab = s;
- goto done;
- }
- if (best == 0 || l->item[ind].line < best)
- {
- best = l->item[ind].line;
- best_index = ind;
- best_linetable = l;
- best_symtab = s;
- }
- }
- }
+ if (FILENAME_CMP (symtab->filename, s->filename) != 0)
+ continue;
+ if (FILENAME_CMP (symtab_to_fullname (symtab),
+ symtab_to_fullname (s)) != 0)
+ continue;
+ l = SYMTAB_LINETABLE (s);
+ ind = find_line_common (l, line, &exact, 0);
+ if (ind >= 0)
+ {
+ if (exact)
+ {
+ best_index = ind;
+ best_linetable = l;
+ best_symtab = s;
+ goto done;
+ }
+ if (best == 0 || l->item[ind].line < best)
+ {
+ best = l->item[ind].line;
+ best_index = ind;
+ best_linetable = l;
+ best_symtab = s;
+ }
+ }
+ }
}
done:
if (best_index < 0)
@@ -4174,7 +4175,6 @@ output_partial_symbol_filename (const char *filename, const char *fullname,
static void
info_sources_command (const char *ignore, int from_tty)
{
- struct objfile *objfile;
struct output_source_filename_data data;
if (!have_full_symbols () && !have_partial_symbols ())
@@ -4189,12 +4189,14 @@ info_sources_command (const char *ignore, int from_tty)
printf_filtered ("Source files for which symbols have been read in:\n\n");
data.first = 1;
- ALL_FILETABS (objfile, cu, s)
- {
- const char *fullname = symtab_to_fullname (s);
+ for (struct objfile *objfile : all_objfiles (current_program_space))
+ for (struct compunit_symtab *cu : objfile_compunits (objfile))
+ for (struct symtab *s : compunit_filetabs (cu))
+ {
+ const char *fullname = symtab_to_fullname (s);
- output_source_filename (fullname, &data);
- }
+ output_source_filename (fullname, &data);
+ }
printf_filtered ("\n\n");
printf_filtered ("Source files for which symbols "
@@ -5563,7 +5565,6 @@ maybe_add_partial_symtab_filename (const char *filename, const char *fullname,
completion_list
make_source_files_completion_list (const char *text, const char *word)
{
- struct objfile *objfile;
size_t text_len = strlen (text);
completion_list list;
const char *base_name;
@@ -5574,30 +5575,32 @@ make_source_files_completion_list (const char *text, const char *word)
filename_seen_cache filenames_seen;
- ALL_FILETABS (objfile, cu, s)
- {
- if (not_interesting_fname (s->filename))
- continue;
- if (!filenames_seen.seen (s->filename)
- && filename_ncmp (s->filename, text, text_len) == 0)
- {
- /* This file matches for a completion; add it to the current
- list of matches. */
- add_filename_to_list (s->filename, text, word, &list);
- }
- else
+ for (struct objfile *objfile : all_objfiles (current_program_space))
+ for (struct compunit_symtab *cu : objfile_compunits (objfile))
+ for (struct symtab *s : compunit_filetabs (cu))
{
- /* NOTE: We allow the user to type a base name when the
- debug info records leading directories, but not the other
- way around. This is what subroutines of breakpoint
- command do when they parse file names. */
- base_name = lbasename (s->filename);
- if (base_name != s->filename
- && !filenames_seen.seen (base_name)
- && filename_ncmp (base_name, text, text_len) == 0)
- add_filename_to_list (base_name, text, word, &list);
+ if (not_interesting_fname (s->filename))
+ continue;
+ if (!filenames_seen.seen (s->filename)
+ && filename_ncmp (s->filename, text, text_len) == 0)
+ {
+ /* This file matches for a completion; add it to the current
+ list of matches. */
+ add_filename_to_list (s->filename, text, word, &list);
+ }
+ else
+ {
+ /* NOTE: We allow the user to type a base name when the
+ debug info records leading directories, but not the other
+ way around. This is what subroutines of breakpoint
+ command do when they parse file names. */
+ base_name = lbasename (s->filename);
+ if (base_name != s->filename
+ && !filenames_seen.seen (base_name)
+ && filename_ncmp (base_name, text, text_len) == 0)
+ add_filename_to_list (base_name, text, word, &list);
+ }
}
- }
datum.filename_seen_cache = &filenames_seen;
datum.text = text;
--
2.17.2
next prev parent reply other threads:[~2018-11-25 16:54 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-25 16:54 [PATCH 00/12] Remove some ALL_* iteration macros Tom Tromey
2018-11-25 16:54 ` [PATCH 03/12] Remove most uses of ALL_OBJFILES Tom Tromey
2018-11-25 16:54 ` [PATCH 09/12] Remove ALL_OBJFILE_FILETABS Tom Tromey
2018-11-25 16:54 ` [PATCH 05/12] Remove ALL_MSYMBOLS and ALL_OBJFILE_MSYMBOLS Tom Tromey
2018-11-25 16:54 ` [PATCH 04/12] Remove ALL_OBJFILES_SAFE Tom Tromey
2018-11-25 16:54 ` [PATCH 12/12] Remove ALL_OBJFILE_PSYMTABS Tom Tromey
2018-11-25 16:54 ` [PATCH 01/12] Introduce all_objfiles and next_iterator Tom Tromey
2018-11-25 16:54 ` [PATCH 08/12] Remove ALL_COMPUNIT_FILETABS Tom Tromey
2018-11-25 16:54 ` [PATCH 11/12] Remove ALL_OBJSECTIONS Tom Tromey
2018-11-25 16:54 ` [PATCH 07/12] Remove ALL_COMPUNITS Tom Tromey
2018-11-25 16:54 ` Tom Tromey [this message]
2018-11-25 16:55 ` [PATCH 02/12] Remove ALL_PSPACE_OBJFILES Tom Tromey
2018-11-25 16:55 ` [PATCH 06/12] Remove ALL_OBJFILE_COMPUNITS Tom Tromey
2018-12-23 7:00 ` [PATCH 00/12] Remove some ALL_* iteration macros Joel Brobecker
2018-12-24 20:54 ` Tom Tromey
2018-12-26 17:30 ` Simon Marchi
2018-12-26 22:28 ` Tom Tromey
2018-12-26 22:32 ` Tom Tromey
2018-12-26 22:35 ` Simon Marchi
2018-12-26 22:52 ` Tom Tromey
2018-12-26 23:45 ` Tom Tromey
2018-12-27 0:46 ` Simon Marchi
2018-12-27 6:22 ` Tom Tromey
2018-12-27 1:52 ` Simon Marchi
2019-01-03 21:46 ` Tom Tromey
2019-01-03 22:45 ` Simon Marchi
2019-01-06 20:10 ` Tom Tromey
2019-01-09 19:49 ` Simon Marchi
2019-01-10 1:29 ` Tom Tromey
2019-01-10 16:45 ` Pedro Alves
2019-01-10 18:10 ` Tom Tromey
2019-01-10 19:58 ` Pedro Alves
2019-01-10 16:44 ` Pedro Alves
2019-01-10 18:06 ` Tom Tromey
2019-01-10 18:09 ` Pedro Alves
2019-01-10 22:53 ` 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=20181125165439.13773-11-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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).