From: Simon Marchi Date: Mon, 26 May 2025 15:33:44 +0000 (-0400) Subject: gdb: make objfile_has_full_symbols and objfile_has_symbols methods of objfile X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=006fb761170a153205f8381fa773fa007120ab5b;p=thirdparty%2Fbinutils-gdb.git gdb: make objfile_has_full_symbols and objfile_has_symbols methods of objfile They seem like good candidates to become methods, just like objfile::has_partial_symbols. Change-Id: Ic6df83012629c1137708b8ceb327f9868d8abcb5 Reviewed-By: Guinevere Larsen --- diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 3c5a554785d..d25d1a02cea 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -673,18 +673,18 @@ objfile_rebase (struct objfile *objfile, CORE_ADDR slide) /* See objfiles.h. */ bool -objfile_has_full_symbols (objfile *objfile) +objfile::has_full_symbols () { - return objfile->compunit_symtabs != nullptr; + return this->compunit_symtabs != nullptr; } /* See objfiles.h. */ bool -objfile_has_symbols (objfile *objfile) +objfile::has_symbols () { - for (::objfile *o : objfile->separate_debug_objfiles ()) - if (o->has_partial_symbols () || objfile_has_full_symbols (o)) + for (::objfile *o : this->separate_debug_objfiles ()) + if (o->has_partial_symbols () || o->has_full_symbols ()) return true; return false; @@ -708,7 +708,7 @@ bool have_full_symbols (program_space *pspace) { for (objfile *ofp : pspace->objfiles ()) - if (objfile_has_full_symbols (ofp)) + if (ofp->has_full_symbols ()) return true; return false; diff --git a/gdb/objfiles.h b/gdb/objfiles.h index bb2f05db277..41aacc372bc 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -515,10 +515,16 @@ public: return per_bfd->gdbarch; } - /* Return true if OBJFILE has partial symbols. */ - + /* Return true if this objfile has partial symbols. */ bool has_partial_symbols (); + /* Return true if this objfile has full symbols. */ + bool has_full_symbols (); + + /* Return true if this objfile has full or partial symbols, either directly + or through a separate debug file. */ + bool has_symbols (); + /* Look for a separate debug symbol file for this objfile, make use of build-id, debug-link, and debuginfod as necessary. If a suitable separate debug symbol file is found then it is loaded using a call to @@ -938,15 +944,6 @@ extern void free_objfile_separate_debug (struct objfile *); extern void objfile_relocate (struct objfile *, const section_offsets &); extern void objfile_rebase (struct objfile *, CORE_ADDR); -/* Return true if OBJFILE has full symbols. */ - -extern bool objfile_has_full_symbols (objfile *objfile); - -/* Return true if OBJFILE has full or partial symbols, either directly - or through a separate debug file. */ - -extern bool objfile_has_symbols (objfile *objfile); - /* Return true if any objfile of PSPACE has partial symbols. */ extern bool have_partial_symbols (program_space *pspace); diff --git a/gdb/solib.c b/gdb/solib.c index 85ec6bb2f1e..0f29edb6bca 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -1085,7 +1085,7 @@ print_solib_list_table (std::vector solib_list, } if (!top_level_interpreter ()->interp_ui_out ()->is_mi_like_p () - && so->symbols_loaded && !objfile_has_symbols (so->objfile)) + && so->symbols_loaded && !so->objfile->has_symbols ()) { so_missing_debug_info = true; uiout->field_string ("syms-read", "Yes (*)"); diff --git a/gdb/symfile.c b/gdb/symfile.c index 9a6322db30b..680c9a54112 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1101,7 +1101,7 @@ symbol_file_add_with_addrs (const gdb_bfd_ref_ptr &abfd, const char *name, no separate debug file. If there is a separate debug file which does not have symbols, we'll have emitted this message for that file, and so printing it twice is just redundant. */ - if (should_print && !objfile_has_symbols (objfile) + if (should_print && !objfile->has_symbols () && objfile->separate_debug_objfile == nullptr) gdb_printf (_("(No debugging symbols found in %ps)\n"), styled_string (file_name_style.style (), name)); @@ -2323,7 +2323,7 @@ add_symbol_file_command (const char *args, int from_tty) objf = symbol_file_add (filename.get (), add_flags, §ion_addrs, flags); - if (!objfile_has_symbols (objf) && objf->per_bfd->minimal_symbol_count <= 0) + if (!objf->has_symbols () && objf->per_bfd->minimal_symbol_count <= 0) warning (_("newly-added symbol file \"%ps\" does not provide any symbols"), styled_string (file_name_style.style (), filename.get ())); @@ -2662,7 +2662,7 @@ reread_symbols (int from_tty) objfile->expand_all_symtabs (); } - if (!objfile_has_symbols (objfile)) + if (!objfile->has_symbols ()) { gdb_stdout->wrap_here (0); gdb_printf (_("(no debugging symbols found)\n")); diff --git a/gdb/symtab.c b/gdb/symtab.c index febd04176db..bbcbb8ae298 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4707,7 +4707,7 @@ info_sources_worker (struct ui_out *uiout, if (uiout->is_mi_like_p ()) { const char *debug_info_state; - if (objfile_has_symbols (objfile)) + if (objfile->has_symbols ()) { if (debug_fully_readin) debug_info_state = "fully-read"; @@ -4723,7 +4723,7 @@ info_sources_worker (struct ui_out *uiout, if (!debug_fully_readin) uiout->text ("(Full debug information has not yet been read " "for this file.)\n"); - if (!objfile_has_symbols (objfile)) + if (!objfile->has_symbols ()) uiout->text ("(Objfile has no debug information.)\n"); uiout->text ("\n"); }