From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id AKNGFhcMamL0AwMAWB0awg (envelope-from ) for ; Wed, 27 Apr 2022 23:37:59 -0400 Received: by simark.ca (Postfix, from userid 112) id 55E8A1E058; Wed, 27 Apr 2022 23:37:59 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=cw9eNpWK; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D927E1E00E for ; Wed, 27 Apr 2022 23:37:58 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 313133858C2C for ; Thu, 28 Apr 2022 03:37:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 313133858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1651117078; bh=6Jy/6Z1l4cxvqNkn2QxKgwu4akH5HpPtO/pdKhVIS0A=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=cw9eNpWKTxs+4iDWx1SmEZYU77sfSGKJRJAae2aQCP7cT2g9lQUCn+zlCGTnGTzfr DIf1/kJsr3fY5bzYStd4Kg5fcFOHc/8U0of9mcGjmZv1m3mdp4ArQTM6Wg9GSn3/yY AnG1hVnxlOlNu4+Q+NsyW5P0+NgHn11nsNct2TPw= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id F04C0385742B for ; Thu, 28 Apr 2022 03:35:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F04C0385742B X-ASG-Debug-ID: 1651116943-0c856e06abd07b80001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id 9yGHyxsmFjgiDnci (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 27 Apr 2022 23:35:43 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) by smtp.ebox.ca (Postfix) with ESMTP id 83C25441D64; Wed, 27 Apr 2022 23:35:43 -0400 (EDT) X-Barracuda-RBL-IP: 192.222.157.6 X-Barracuda-Effective-Source-IP: 192-222-157-6.qc.cable.ebox.net[192.222.157.6] X-Barracuda-Apparent-Source-IP: 192.222.157.6 To: gdb-patches@sourceware.org Subject: [PATCH v3 1/7] gdb: introduce symtab_create_debug_printf Date: Wed, 27 Apr 2022 23:35:36 -0400 X-ASG-Orig-Subj: [PATCH v3 1/7] gdb: introduce symtab_create_debug_printf Message-Id: <20220428033542.1636284-2-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220428033542.1636284-1-simon.marchi@polymtl.ca> References: <20220428033542.1636284-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1651116943 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 6488 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.97646 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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 --- 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 b136c605b1ae..b6dea7ece2be 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -1047,12 +1047,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 @@ -1064,9 +1060,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; } @@ -1170,8 +1164,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 cbd0ad223928..f4cb89590ff0 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 402d6085fe61..57703fe215e6 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1384,7 +1384,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. */ @@ -1395,13 +1395,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 6f546f5b0591..b9ecef045377 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 8c2837cfa8b0..854167dde452 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2600,6 +2600,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; -- 2.35.2