From: Simon Marchi Date: Thu, 7 Apr 2022 12:00:16 +0000 (-0400) Subject: gdb: introduce symtab_create_debug_printf X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2ab317fb8290ea96bdb446957d2e221634fd25c8;p=binutils-gdb.git gdb: introduce symtab_create_debug_printf Introduce symtab_create_debug_printf and symtab_create_debug_printf_v, to print the debug messages enabled by "set debug symtab-create". Change-Id: I442500903f72d4635c2dd9eaef770111f317dc04 --- diff --git a/gdb/elfread.c b/gdb/elfread.c index deed34c35c7..e0de52cd1b9 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -1046,12 +1046,8 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags, asymbol **symbol_table = NULL, **dyn_symbol_table = NULL; asymbol *synthsyms; - if (symtab_create_debug) - { - gdb_printf (gdb_stdlog, - "Reading minimal symbols of objfile %s ...\n", - objfile_name (objfile)); - } + symtab_create_debug_printf ("reading minimal symbols of objfile %s", + objfile_name (objfile)); /* If we already have minsyms, then we can skip some work here. However, if there were stabs or mdebug sections, we go ahead and @@ -1063,9 +1059,7 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags, && ei->mdebugsect == NULL && ei->ctfsect == NULL) { - if (symtab_create_debug) - gdb_printf (gdb_stdlog, - "... minimal symbols previously read\n"); + symtab_create_debug_printf ("minimal symbols were previously read"); return; } @@ -1169,8 +1163,7 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags, reader.install (); - if (symtab_create_debug) - gdb_printf (gdb_stdlog, "Done reading minimal symbols.\n"); + symtab_create_debug_printf ("done reading minimal symbols"); } /* Scan and build partial symbols for a symbol file. diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 4ec62558b69..3f4ad90dbd3 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1184,11 +1184,9 @@ minimal_symbol_reader::record_full (gdb::string_view name, if (ms_type == mst_file_text && startswith (name, "__gnu_compiled")) return (NULL); - if (symtab_create_debug >= 2) - gdb_printf (gdb_stdlog, - "Recording minsym: %-21s %18s %4d %.*s\n", - mst_str (ms_type), hex_string (address), section, - (int) name.size (), name.data ()); + symtab_create_debug_printf_v ("recording minsym: %-21s %18s %4d %.*s", + mst_str (ms_type), hex_string (address), section, + (int) name.size (), name.data ()); if (m_msym_bunch_index == BUNCH_SIZE) { @@ -1389,12 +1387,8 @@ minimal_symbol_reader::install () if (m_msym_count > 0) { - if (symtab_create_debug) - { - gdb_printf (gdb_stdlog, - "Installing %d minimal symbols of objfile %s.\n", - m_msym_count, objfile_name (m_objfile)); - } + symtab_create_debug_printf ("installing %d minimal symbols of objfile %s", + m_msym_count, objfile_name (m_objfile)); /* Allocate enough space, into which we will gather the bunches of new and existing minimal symbols, sort them, and then diff --git a/gdb/psymtab.c b/gdb/psymtab.c index d16c3bb3083..012073d8bbe 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1314,7 +1314,7 @@ partial_symtab::partial_symtab (const char *filename_, filename = objfile_per_bfd->intern (filename_); - if (symtab_create_debug) + if (symtab_create_debug >= 1) { /* Be a bit clever with debugging messages, and don't print objfile every time, only when it changes. */ @@ -1325,13 +1325,13 @@ partial_symtab::partial_symtab (const char *filename_, if (last_bfd_name.empty () || last_bfd_name != this_bfd_name) { last_bfd_name = this_bfd_name; - gdb_printf (gdb_stdlog, - "Creating one or more psymtabs for %s ...\n", - this_bfd_name); + + symtab_create_debug_printf ("creating one or more psymtabs for %s", + this_bfd_name); } - gdb_printf (gdb_stdlog, - "Created psymtab %s for module %s.\n", - host_address_to_string (this), filename); + + symtab_create_debug_printf ("created psymtab %s for module %s", + host_address_to_string (this), filename); } } diff --git a/gdb/symfile.c b/gdb/symfile.c index ec3244269b1..27e95718327 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2794,13 +2794,13 @@ allocate_symtab (struct compunit_symtab *cust, const char *filename) if (last_objfile_name.empty () || last_objfile_name != this_objfile_name) { last_objfile_name = this_objfile_name; - gdb_printf (gdb_stdlog, - "Creating one or more symtabs for objfile %s ...\n", - this_objfile_name); + + symtab_create_debug_printf_v + ("creating one or more symtabs for objfile %s", this_objfile_name); } - gdb_printf (gdb_stdlog, - "Created symtab %s for module %s.\n", - host_address_to_string (symtab), filename); + + symtab_create_debug_printf_v ("created symtab %s for module %s", + host_address_to_string (symtab), filename); } /* Add it to CUST's list of symtabs. */ @@ -2833,13 +2833,9 @@ allocate_compunit_symtab (struct objfile *objfile, const char *name) cu->set_debugformat ("unknown"); - if (symtab_create_debug) - { - gdb_printf (gdb_stdlog, - "Created compunit symtab %s for %s.\n", - host_address_to_string (cu), - cu->name); - } + symtab_create_debug_printf_v ("created compunit symtab %s for %s", + host_address_to_string (cu), + cu->name); return cu; } diff --git a/gdb/symtab.h b/gdb/symtab.h index ac902a4cbbe..4bc86645e2c 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2601,6 +2601,17 @@ void fixup_section (struct general_symbol_info *ginfo, extern unsigned int symtab_create_debug; +/* Print a "symtab-create" debug statement. */ + +#define symtab_create_debug_printf(fmt, ...) \ + debug_prefixed_printf_cond (symtab_create_debug >= 1, "symtab-create", fmt, ##__VA_ARGS__) + +/* Print a verbose "symtab-create" debug statement, only if + "set debug symtab-create" is set to 2 or higher. */ + +#define symtab_create_debug_printf_v(fmt, ...) \ + debug_prefixed_printf_cond (symtab_create_debug >= 2, "symtab-create", fmt, ##__VA_ARGS__) + extern unsigned int symbol_lookup_debug; extern bool basenames_may_differ;