[binutils-gdb] gdb/dwarf: make dw2_search_one a method of dwarf2_base_index_functions
Simon Marchi via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=414930db7a644bd95fa9e710731015e92429e656 commit 414930db7a644bd95fa9e710731015e92429e656 Author: Simon Marchi <[email protected]> Date: Sat Feb 21 15:07:23 2026 -0500 gdb/dwarf: make dw2_search_one a method of dwarf2_base_index_functions This function is used as a helper for readnow_functions::search and cooked_index_functions::search. Just to better organize things, make it a protected static method in the base class, dwarf2_base_index_functions. Change-Id: I0273c92379bf2337df16d28e21586125716e7de6 Approved-By: Tom Tromey <[email protected]> Diff: --- gdb/dwarf2/read.c | 26 ++++++++--------------- gdb/dwarf2/read.h | 63 +++++++++++++++++++++++++++++++------------------------ 2 files changed, 45 insertions(+), 44 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 39991c8de91..11b9eea25d6 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -937,13 +937,6 @@ static void queue_comp_unit (dwarf2_per_cu *per_cu, static void process_queue (dwarf2_per_objfile *per_objfile); -static bool dw2_search_one (dwarf2_per_cu *per_cu, - dwarf2_per_objfile *per_objfile, - auto_bool_vector &cus_to_skip, - search_symtabs_file_matcher file_matcher, - search_symtabs_expansion_listener listener, - search_symtabs_lang_matcher lang_matcher); - /* Class, the destructor of which frees all allocated queue entries. This will only have work to do if an error was thrown while processing the dwarf. If no error was thrown then the queue entries should have all @@ -1518,8 +1511,8 @@ struct readnow_functions : public dwarf2_base_index_functions || per_cu->unit_type (false) == 0 || per_objfile->get_compunit_symtab (per_cu.get ()) == nullptr) continue; - if (!dw2_search_one (per_cu.get (), per_objfile, cus_to_skip, - file_matcher, listener, lang_matcher)) + if (!search_one (per_cu.get (), per_objfile, cus_to_skip, file_matcher, + listener, lang_matcher)) return false; } return true; @@ -1976,11 +1969,10 @@ dwarf2_base_index_functions::expand_all_symtabs (struct objfile *objfile) } } -/* If FILE_MATCHER is NULL and if CUS_TO_SKIP does not include the - CU's index, expand the CU and call LISTENER on it. */ +/* See read.h. */ -static bool -dw2_search_one +bool +dwarf2_base_index_functions::search_one (dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile, auto_bool_vector &cus_to_skip, @@ -14108,8 +14100,8 @@ cooked_index_functions::search { QUIT; - if (!dw2_search_one (per_cu, per_objfile, cus_to_skip, file_matcher, - listener, lang_matcher)) + if (!search_one (per_cu, per_objfile, cus_to_skip, file_matcher, + listener, lang_matcher)) return false; } return true; @@ -14277,8 +14269,8 @@ cooked_index_functions::search else if (!symbol_matcher (full_name)) continue; - if (!dw2_search_one (entry->per_cu, per_objfile, cus_to_skip, - file_matcher, listener, nullptr)) + if (!search_one (entry->per_cu, per_objfile, cus_to_skip, + file_matcher, listener, nullptr)) return false; } } diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 960f03a8d53..1883f7b30d8 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -1243,6 +1243,34 @@ extern void dwarf2_get_section_info (struct objfile *, asection **, const gdb_byte **, bfd_size_type *); +/* This is used to track whether a CU has already been visited during + symbol expansion. It is an auto-resizing bool vector. */ +class auto_bool_vector +{ +public: + + auto_bool_vector () = default; + + /* Return true if element I is set. */ + bool is_set (size_t i) const + { + if (i < m_vec.size ()) + return m_vec[i]; + return false; + } + + /* Set a value in this vector, growing it automatically. */ + void set (size_t i, bool value) + { + if (m_vec.size () < i + 1) + m_vec.resize (i + 1); + m_vec[i] = value; + } + +private: + std::vector<bool> m_vec; +}; + /* Interface for DWARF indexing methods. */ struct dwarf2_base_index_functions : public quick_symbol_functions @@ -1281,34 +1309,15 @@ struct dwarf2_base_index_functions : public quick_symbol_functions void map_symbol_filenames (objfile *objfile, symbol_filename_listener fun, bool need_fullname) override; -}; - -/* This is used to track whether a CU has already been visited during - symbol expansion. It is an auto-resizing bool vector. */ -class auto_bool_vector -{ -public: - auto_bool_vector () = default; - - /* Return true if element I is set. */ - bool is_set (size_t i) const - { - if (i < m_vec.size ()) - return m_vec[i]; - return false; - } - - /* Set a value in this vector, growing it automatically. */ - void set (size_t i, bool value) - { - if (m_vec.size () < i + 1) - m_vec.resize (i + 1); - m_vec[i] = value; - } - -private: - std::vector<bool> m_vec; +protected: + /* If FILE_MATCHER is NULL and if CUS_TO_SKIP does not include the CU's index, + expand the CU and call LISTENER on it. */ + bool search_one (dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile, + auto_bool_vector &cus_to_skip, + search_symtabs_file_matcher file_matcher, + search_symtabs_expansion_listener listener, + search_symtabs_lang_matcher lang_matcher); }; /* Return pointer to string at .debug_str offset STR_OFFSET. */