From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 6A33F384B833; Sat, 30 Jul 2022 00:55:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A33F384B833 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: introduce symtab_create_debug_printf X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 017772c826f15704c5326ac35daf00f223daff5c X-Git-Newrev: 2ab317fb8290ea96bdb446957d2e221634fd25c8 Message-Id: <20220730005509.6A33F384B833@sourceware.org> Date: Sat, 30 Jul 2022 00:55:09 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jul 2022 00:55:09 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D2ab317fb8290= ea96bdb446957d2e221634fd25c8 commit 2ab317fb8290ea96bdb446957d2e221634fd25c8 Author: Simon Marchi Date: Thu Apr 7 08:00:16 2022 -0400 gdb: introduce symtab_create_debug_printf =20 Introduce symtab_create_debug_printf and symtab_create_debug_printf_v, to print the debug messages enabled by "set debug symtab-create". =20 Change-Id: I442500903f72d4635c2dd9eaef770111f317dc04 Diff: --- gdb/elfread.c | 15 ++++----------- gdb/minsyms.c | 16 +++++----------- gdb/psymtab.c | 14 +++++++------- gdb/symfile.c | 22 +++++++++------------- gdb/symtab.h | 11 +++++++++++ 5 files changed, 36 insertions(+), 42 deletions(-) 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, i= nt symfile_flags, asymbol **symbol_table =3D NULL, **dyn_symbol_table =3D NULL; asymbol *synthsyms; =20 - 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)); =20 /* 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, in= t symfile_flags, && ei->mdebugsect =3D=3D NULL && ei->ctfsect =3D=3D NULL) { - if (symtab_create_debug) - gdb_printf (gdb_stdlog, - "... minimal symbols previously read\n"); + symtab_create_debug_printf ("minimal symbols were previously read"); return; } =20 @@ -1169,8 +1163,7 @@ elf_read_minimal_symbols (struct objfile *objfile, in= t symfile_flags, =20 reader.install (); =20 - if (symtab_create_debug) - gdb_printf (gdb_stdlog, "Done reading minimal symbols.\n"); + symtab_create_debug_printf ("done reading minimal symbols"); } =20 /* 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 =3D=3D mst_file_text && startswith (name, "__gnu_compiled")) return (NULL); =20 - if (symtab_create_debug >=3D 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 ()); =20 if (m_msym_bunch_index =3D=3D BUNCH_SIZE) { @@ -1389,12 +1387,8 @@ minimal_symbol_reader::install () =20 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 objfil= e %s", + m_msym_count, objfile_name (m_objfile)); =20 /* 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_, =20 filename =3D objfile_per_bfd->intern (filename_); =20 - if (symtab_create_debug) + if (symtab_create_debug >=3D 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 *filenam= e_, if (last_bfd_name.empty () || last_bfd_name !=3D this_bfd_name) { last_bfd_name =3D 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); } } =20 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, cons= t char *filename) if (last_objfile_name.empty () || last_objfile_name !=3D this_objfil= e_name) { last_objfile_name =3D 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); } =20 /* Add it to CUST's list of symtabs. */ @@ -2833,13 +2833,9 @@ allocate_compunit_symtab (struct objfile *objfile, c= onst char *name) =20 cu->set_debugformat ("unknown"); =20 - 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); =20 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 *ginf= o, =20 extern unsigned int symtab_create_debug; =20 +/* Print a "symtab-create" debug statement. */ + +#define symtab_create_debug_printf(fmt, ...) \ + debug_prefixed_printf_cond (symtab_create_debug >=3D 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 >=3D 2, "symtab-create",= fmt, ##__VA_ARGS__) + extern unsigned int symbol_lookup_debug; =20 extern bool basenames_may_differ;