mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 01:07:52 +00:00
Return references from compunit_symtab iterator
This changes the compunit_symtab iterator to return references rather than pointers, following the style of some other recent changes. Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
@@ -5588,10 +5588,10 @@ add_nonlocal_symbols (std::vector<struct block_symbol> &result,
|
|||||||
{
|
{
|
||||||
map_matching_symbols (&objfile, lookup_name, domain, global, data);
|
map_matching_symbols (&objfile, lookup_name, domain, global, data);
|
||||||
|
|
||||||
for (compunit_symtab *cu : objfile.compunits ())
|
for (compunit_symtab &cu : objfile.compunits ())
|
||||||
{
|
{
|
||||||
const struct block *global_block
|
const struct block *global_block
|
||||||
= cu->blockvector ()->global_block ();
|
= cu.blockvector ()->global_block ();
|
||||||
|
|
||||||
if (ada_add_block_renamings (result, global_block, lookup_name,
|
if (ada_add_block_renamings (result, global_block, lookup_name,
|
||||||
domain))
|
domain))
|
||||||
|
|||||||
@@ -1256,9 +1256,9 @@ coff_symtab_read (minimal_symbol_reader &reader,
|
|||||||
/* Patch up any opaque types (references to types that are not defined
|
/* Patch up any opaque types (references to types that are not defined
|
||||||
in the file where they are referenced, e.g. "struct foo *bar"). */
|
in the file where they are referenced, e.g. "struct foo *bar"). */
|
||||||
{
|
{
|
||||||
for (compunit_symtab *cu : objfile->compunits ())
|
for (compunit_symtab &cu : objfile->compunits ())
|
||||||
{
|
{
|
||||||
for (symtab *s : cu->filetabs ())
|
for (symtab *s : cu.filetabs ())
|
||||||
patch_opaque_types (s);
|
patch_opaque_types (s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -972,12 +972,12 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
|
|||||||
{
|
{
|
||||||
for (objfile &o : current_program_space->objfiles ())
|
for (objfile &o : current_program_space->objfiles ())
|
||||||
{
|
{
|
||||||
for (compunit_symtab *cu : o.compunits ())
|
for (compunit_symtab &cu : o.compunits ())
|
||||||
{
|
{
|
||||||
++nr_compunit_symtabs;
|
++nr_compunit_symtabs;
|
||||||
nr_blocks += cu->blockvector ()->num_blocks ();
|
nr_blocks += cu.blockvector ()->num_blocks ();
|
||||||
nr_symtabs += std::distance (cu->filetabs ().begin (),
|
nr_symtabs += std::distance (cu.filetabs ().begin (),
|
||||||
cu->filetabs ().end ());
|
cu.filetabs ().end ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -548,9 +548,9 @@ objfile_relocate1 (struct objfile *objfile,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* OK, get all the symtabs. */
|
/* OK, get all the symtabs. */
|
||||||
for (compunit_symtab *cust : objfile->compunits ())
|
for (compunit_symtab &cust : objfile->compunits ())
|
||||||
{
|
{
|
||||||
struct blockvector *bv = cust->blockvector ();
|
struct blockvector *bv = cust.blockvector ();
|
||||||
int block_line_section = SECT_OFF_TEXT (objfile);
|
int block_line_section = SECT_OFF_TEXT (objfile);
|
||||||
|
|
||||||
if (bv->map () != nullptr)
|
if (bv->map () != nullptr)
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
#include <forward_list>
|
#include <forward_list>
|
||||||
#include "gdbsupport/unordered_map.h"
|
#include "gdbsupport/unordered_map.h"
|
||||||
#include "gdbsupport/owning_intrusive_list.h"
|
#include "gdbsupport/owning_intrusive_list.h"
|
||||||
#include "gdbsupport/reference-to-pointer-iterator.h"
|
|
||||||
|
|
||||||
struct htab;
|
struct htab;
|
||||||
struct objfile_data;
|
struct objfile_data;
|
||||||
@@ -474,7 +473,7 @@ public:
|
|||||||
program_space *pspace () { return m_pspace; }
|
program_space *pspace () { return m_pspace; }
|
||||||
|
|
||||||
using compunit_symtab_iterator
|
using compunit_symtab_iterator
|
||||||
= reference_to_pointer_iterator<owning_intrusive_list<compunit_symtab>::iterator>;
|
= owning_intrusive_list<compunit_symtab>::iterator;
|
||||||
using compunit_symtab_range = iterator_range<compunit_symtab_iterator>;
|
using compunit_symtab_range = iterator_range<compunit_symtab_iterator>;
|
||||||
|
|
||||||
/* A range adapter that makes it possible to iterate over all
|
/* A range adapter that makes it possible to iterate over all
|
||||||
|
|||||||
@@ -356,9 +356,9 @@ select_source_symtab ()
|
|||||||
|
|
||||||
for (objfile &ofp : current_program_space->objfiles ())
|
for (objfile &ofp : current_program_space->objfiles ())
|
||||||
{
|
{
|
||||||
for (compunit_symtab *cu : ofp.compunits ())
|
for (compunit_symtab &cu : ofp.compunits ())
|
||||||
{
|
{
|
||||||
for (symtab *symtab : cu->filetabs ())
|
for (symtab *symtab : cu.filetabs ())
|
||||||
{
|
{
|
||||||
const char *name = symtab->filename;
|
const char *name = symtab->filename;
|
||||||
int len = strlen (name);
|
int len = strlen (name);
|
||||||
|
|||||||
@@ -152,8 +152,8 @@ objfile::forget_cached_source_info ()
|
|||||||
gdb_printf (gdb_stdlog, "qf->forget_cached_source_info (%s)\n",
|
gdb_printf (gdb_stdlog, "qf->forget_cached_source_info (%s)\n",
|
||||||
objfile_debug_name (this));
|
objfile_debug_name (this));
|
||||||
|
|
||||||
for (compunit_symtab *cu : compunits ())
|
for (compunit_symtab &cu : compunits ())
|
||||||
cu->forget_cached_source_info ();
|
cu.forget_cached_source_info ();
|
||||||
|
|
||||||
for (const auto &iter : qf)
|
for (const auto &iter : qf)
|
||||||
iter->forget_cached_source_info (this);
|
iter->forget_cached_source_info (this);
|
||||||
|
|||||||
@@ -73,9 +73,9 @@ print_objfile_statistics (void)
|
|||||||
OBJSTAT ((&objfile), n_types));
|
OBJSTAT ((&objfile), n_types));
|
||||||
|
|
||||||
i = linetables = 0;
|
i = linetables = 0;
|
||||||
for (compunit_symtab *cu : objfile.compunits ())
|
for (compunit_symtab &cu : objfile.compunits ())
|
||||||
{
|
{
|
||||||
for (symtab *s : cu->filetabs ())
|
for (symtab *s : cu.filetabs ())
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
if (s->linetable () != NULL)
|
if (s->linetable () != NULL)
|
||||||
@@ -123,7 +123,7 @@ dump_objfile (struct objfile *objfile)
|
|||||||
objfile->dump ();
|
objfile->dump ();
|
||||||
|
|
||||||
bool symtabs_printed = false;
|
bool symtabs_printed = false;
|
||||||
for (compunit_symtab *cu : objfile->compunits ())
|
for (compunit_symtab &cu : objfile->compunits ())
|
||||||
{
|
{
|
||||||
if (!symtabs_printed)
|
if (!symtabs_printed)
|
||||||
{
|
{
|
||||||
@@ -131,7 +131,7 @@ dump_objfile (struct objfile *objfile)
|
|||||||
symtabs_printed = true;
|
symtabs_printed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (symtab *symtab : cu->filetabs ())
|
for (symtab *symtab : cu.filetabs ())
|
||||||
{
|
{
|
||||||
gdb_printf ("%s at %s",
|
gdb_printf ("%s at %s",
|
||||||
symtab_to_filename_for_display (symtab),
|
symtab_to_filename_for_display (symtab),
|
||||||
@@ -468,9 +468,9 @@ maintenance_print_symbols (const char *args, int from_tty)
|
|||||||
if (!print_for_objfile)
|
if (!print_for_objfile)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (compunit_symtab *cu : objfile.compunits ())
|
for (compunit_symtab &cu : objfile.compunits ())
|
||||||
{
|
{
|
||||||
for (symtab *s : cu->filetabs ())
|
for (symtab *s : cu.filetabs ())
|
||||||
{
|
{
|
||||||
int print_for_source = 0;
|
int print_for_source = 0;
|
||||||
|
|
||||||
@@ -751,11 +751,11 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
|
|||||||
actually find a symtab whose name matches. */
|
actually find a symtab whose name matches. */
|
||||||
int printed_objfile_start = 0;
|
int printed_objfile_start = 0;
|
||||||
|
|
||||||
for (compunit_symtab *cust : objfile.compunits ())
|
for (compunit_symtab &cust : objfile.compunits ())
|
||||||
{
|
{
|
||||||
int printed_compunit_symtab_start = 0;
|
int printed_compunit_symtab_start = 0;
|
||||||
|
|
||||||
for (symtab *symtab : cust->filetabs ())
|
for (symtab *symtab : cust.filetabs ())
|
||||||
{
|
{
|
||||||
QUIT;
|
QUIT;
|
||||||
|
|
||||||
@@ -773,32 +773,32 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
|
|||||||
if (! printed_compunit_symtab_start)
|
if (! printed_compunit_symtab_start)
|
||||||
{
|
{
|
||||||
gdb_printf (" { ((struct compunit_symtab *) %s)\n",
|
gdb_printf (" { ((struct compunit_symtab *) %s)\n",
|
||||||
host_address_to_string (cust));
|
host_address_to_string (&cust));
|
||||||
gdb_printf (" debugformat %s\n",
|
gdb_printf (" debugformat %s\n",
|
||||||
cust->debugformat ());
|
cust.debugformat ());
|
||||||
gdb_printf (" producer %s\n",
|
gdb_printf (" producer %s\n",
|
||||||
(cust->producer () != nullptr
|
(cust.producer () != nullptr
|
||||||
? cust->producer () : "(null)"));
|
? cust.producer () : "(null)"));
|
||||||
gdb_printf (" name %s\n", cust->name);
|
gdb_printf (" name %s\n", cust.name);
|
||||||
gdb_printf (" dirname %s\n",
|
gdb_printf (" dirname %s\n",
|
||||||
(cust->dirname () != NULL
|
(cust.dirname () != NULL
|
||||||
? cust->dirname () : "(null)"));
|
? cust.dirname () : "(null)"));
|
||||||
gdb_printf (" blockvector"
|
gdb_printf (" blockvector"
|
||||||
" ((struct blockvector *) %s)\n",
|
" ((struct blockvector *) %s)\n",
|
||||||
host_address_to_string
|
host_address_to_string
|
||||||
(cust->blockvector ()));
|
(cust.blockvector ()));
|
||||||
gdb_printf (" user"
|
gdb_printf (" user"
|
||||||
" ((struct compunit_symtab *) %s)\n",
|
" ((struct compunit_symtab *) %s)\n",
|
||||||
cust->user != nullptr
|
cust.user != nullptr
|
||||||
? host_address_to_string (cust->user)
|
? host_address_to_string (cust.user)
|
||||||
: "(null)");
|
: "(null)");
|
||||||
if (cust->includes != nullptr)
|
if (cust.includes != nullptr)
|
||||||
{
|
{
|
||||||
gdb_printf (" ( includes\n");
|
gdb_printf (" ( includes\n");
|
||||||
for (int i = 0; ; ++i)
|
for (int i = 0; ; ++i)
|
||||||
{
|
{
|
||||||
struct compunit_symtab *include
|
struct compunit_symtab *include
|
||||||
= cust->includes[i];
|
= cust.includes[i];
|
||||||
if (include == nullptr)
|
if (include == nullptr)
|
||||||
break;
|
break;
|
||||||
const char *addr
|
const char *addr
|
||||||
@@ -856,14 +856,14 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
|
|||||||
actually find something worth printing. */
|
actually find something worth printing. */
|
||||||
int printed_objfile_start = 0;
|
int printed_objfile_start = 0;
|
||||||
|
|
||||||
for (compunit_symtab *cust : objfile.compunits ())
|
for (compunit_symtab &cust : objfile.compunits ())
|
||||||
{
|
{
|
||||||
int found_something = 0;
|
int found_something = 0;
|
||||||
struct symtab *symtab = cust->primary_filetab ();
|
struct symtab *symtab = cust.primary_filetab ();
|
||||||
|
|
||||||
QUIT;
|
QUIT;
|
||||||
|
|
||||||
if (cust->blockvector () == NULL)
|
if (cust.blockvector () == NULL)
|
||||||
found_something = 1;
|
found_something = 1;
|
||||||
/* Add more checks here. */
|
/* Add more checks here. */
|
||||||
|
|
||||||
@@ -879,7 +879,7 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
|
|||||||
}
|
}
|
||||||
gdb_printf (" { symtab %s\n",
|
gdb_printf (" { symtab %s\n",
|
||||||
symtab_to_filename_for_display (symtab));
|
symtab_to_filename_for_display (symtab));
|
||||||
if (cust->blockvector () == NULL)
|
if (cust.blockvector () == NULL)
|
||||||
gdb_printf (" NULL blockvector\n");
|
gdb_printf (" NULL blockvector\n");
|
||||||
gdb_printf (" }\n");
|
gdb_printf (" }\n");
|
||||||
}
|
}
|
||||||
@@ -1036,9 +1036,9 @@ maintenance_info_line_tables (const char *regexp, int from_tty)
|
|||||||
for (struct program_space *pspace : program_spaces)
|
for (struct program_space *pspace : program_spaces)
|
||||||
for (objfile &objfile : pspace->objfiles ())
|
for (objfile &objfile : pspace->objfiles ())
|
||||||
{
|
{
|
||||||
for (compunit_symtab *cust : objfile.compunits ())
|
for (compunit_symtab &cust : objfile.compunits ())
|
||||||
{
|
{
|
||||||
for (symtab *symtab : cust->filetabs ())
|
for (symtab *symtab : cust.filetabs ())
|
||||||
{
|
{
|
||||||
QUIT;
|
QUIT;
|
||||||
|
|
||||||
|
|||||||
34
gdb/symtab.c
34
gdb/symtab.c
@@ -2251,14 +2251,14 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
|
|||||||
|
|
||||||
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
|
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
|
||||||
best_symbol_tracker accum;
|
best_symbol_tracker accum;
|
||||||
for (compunit_symtab *cust : objfile->compunits ())
|
for (compunit_symtab &cust : objfile->compunits ())
|
||||||
{
|
{
|
||||||
const struct blockvector *bv;
|
const struct blockvector *bv;
|
||||||
const struct block *block;
|
const struct block *block;
|
||||||
|
|
||||||
bv = cust->blockvector ();
|
bv = cust.blockvector ();
|
||||||
block = bv->block (block_index);
|
block = bv->block (block_index);
|
||||||
if (accum.search (cust, block, lookup_name, domain))
|
if (accum.search (&cust, block, lookup_name, domain))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2738,9 +2738,9 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
|
|||||||
|
|
||||||
for (objfile &obj_file : current_program_space->objfiles ())
|
for (objfile &obj_file : current_program_space->objfiles ())
|
||||||
{
|
{
|
||||||
for (compunit_symtab *cust : obj_file.compunits ())
|
for (compunit_symtab &cust : obj_file.compunits ())
|
||||||
{
|
{
|
||||||
const struct blockvector *bv = cust->blockvector ();
|
const struct blockvector *bv = cust.blockvector ();
|
||||||
const struct block *global_block = bv->global_block ();
|
const struct block *global_block = bv->global_block ();
|
||||||
CORE_ADDR start = global_block->start ();
|
CORE_ADDR start = global_block->start ();
|
||||||
CORE_ADDR end = global_block->end ();
|
CORE_ADDR end = global_block->end ();
|
||||||
@@ -2753,7 +2753,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
|
|||||||
if (bv->map ()->find (pc) == nullptr)
|
if (bv->map ()->find (pc) == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return cust;
|
return &cust;
|
||||||
}
|
}
|
||||||
|
|
||||||
CORE_ADDR range = end - start;
|
CORE_ADDR range = end - start;
|
||||||
@@ -2799,7 +2799,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Cust is best found so far, save it. */
|
/* Cust is best found so far, save it. */
|
||||||
best_cust = cust;
|
best_cust = &cust;
|
||||||
best_cust_range = range;
|
best_cust_range = range;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2861,9 +2861,9 @@ find_symbol_at_address (CORE_ADDR address)
|
|||||||
search the symtabs directly. */
|
search the symtabs directly. */
|
||||||
if ((objfile.flags & OBJF_READNOW) != 0)
|
if ((objfile.flags & OBJF_READNOW) != 0)
|
||||||
{
|
{
|
||||||
for (compunit_symtab *symtab : objfile.compunits ())
|
for (compunit_symtab &symtab : objfile.compunits ())
|
||||||
{
|
{
|
||||||
struct symbol *sym = search_symtab (symtab, address);
|
struct symbol *sym = search_symtab (&symtab, address);
|
||||||
if (sym != nullptr)
|
if (sym != nullptr)
|
||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
@@ -3303,9 +3303,9 @@ find_line_symtab (symtab *sym_tab, int line, int *index)
|
|||||||
|
|
||||||
for (objfile &objfile : current_program_space->objfiles ())
|
for (objfile &objfile : current_program_space->objfiles ())
|
||||||
{
|
{
|
||||||
for (compunit_symtab *cu : objfile.compunits ())
|
for (compunit_symtab &cu : objfile.compunits ())
|
||||||
{
|
{
|
||||||
for (symtab *s : cu->filetabs ())
|
for (symtab *s : cu.filetabs ())
|
||||||
{
|
{
|
||||||
const struct linetable *l;
|
const struct linetable *l;
|
||||||
int ind;
|
int ind;
|
||||||
@@ -4537,9 +4537,9 @@ info_sources_worker (struct ui_out *uiout,
|
|||||||
sources_list.emplace (uiout, "sources");
|
sources_list.emplace (uiout, "sources");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (compunit_symtab *cu : objfile.compunits ())
|
for (compunit_symtab &cu : objfile.compunits ())
|
||||||
{
|
{
|
||||||
for (symtab *s : cu->filetabs ())
|
for (symtab *s : cu.filetabs ())
|
||||||
{
|
{
|
||||||
const char *file = symtab_to_filename_for_display (s);
|
const char *file = symtab_to_filename_for_display (s);
|
||||||
const char *fullname = symtab_to_fullname (s);
|
const char *fullname = symtab_to_fullname (s);
|
||||||
@@ -4790,9 +4790,9 @@ global_symbol_searcher::add_matching_symbols
|
|||||||
domain_search_flags kind = m_kind;
|
domain_search_flags kind = m_kind;
|
||||||
|
|
||||||
/* Add matching symbols (if not already present). */
|
/* Add matching symbols (if not already present). */
|
||||||
for (compunit_symtab *cust : objfile->compunits ())
|
for (compunit_symtab &cust : objfile->compunits ())
|
||||||
{
|
{
|
||||||
const struct blockvector *bv = cust->blockvector ();
|
const struct blockvector *bv = cust.blockvector ();
|
||||||
|
|
||||||
for (block_enum block : { GLOBAL_BLOCK, STATIC_BLOCK })
|
for (block_enum block : { GLOBAL_BLOCK, STATIC_BLOCK })
|
||||||
{
|
{
|
||||||
@@ -6221,9 +6221,9 @@ make_source_files_completion_list (const char *text)
|
|||||||
|
|
||||||
for (objfile &objfile : current_program_space->objfiles ())
|
for (objfile &objfile : current_program_space->objfiles ())
|
||||||
{
|
{
|
||||||
for (compunit_symtab *cu : objfile.compunits ())
|
for (compunit_symtab &cu : objfile.compunits ())
|
||||||
{
|
{
|
||||||
for (symtab *s : cu->filetabs ())
|
for (symtab *s : cu.filetabs ())
|
||||||
{
|
{
|
||||||
if (not_interesting_fname (s->filename))
|
if (not_interesting_fname (s->filename))
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user