From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id fhOyCgNaYWlqhTcAWB0awg (envelope-from ) for ; Fri, 09 Jan 2026 14:41:55 -0500 Received: by simark.ca (Postfix, from userid 112) id 1A1BB1E0B6; Fri, 09 Jan 2026 14:41:55 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 8C7F01E08D for ; Fri, 09 Jan 2026 14:41:54 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 1A1654BA2E1E for ; Fri, 9 Jan 2026 19:41:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A1654BA2E1E Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 258154BA2E04 for ; Fri, 9 Jan 2026 19:41:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 258154BA2E04 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 258154BA2E04 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1767987690; cv=none; b=ZH02va7LlZS1PdTnAV6pnze1xz+SnGLTs1gOHNzf2Bj047dM0eA6/5e5UmSQRVDwoCUwupR8mfSuUYJ+pllct4lOY0oPFWUBBFEKziJa1MdBsIM9gh/+7BSPRTWrKoHB3TVzhDeTuYHUTpOxirnLre8kI1ajBY6Hr3z1XM2eeAw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1767987690; c=relaxed/simple; bh=quDwXIkc5RY6cHXOLw4JKi2ZGimY4W5TwJ26hBLiQzU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=XywBOcEtFdJ8K0Bjkhpsb8m3eEe3VS9ej9cr11pdJ9nYhks17V4L1S2iNnuuFj1dF3wws2G6GZW3GojXMZCO5TDHzEeln3xLDCmAuBxhCs+bI7xh/58gumDQet7hwQnbHAxmBQOeC+Qm6Un7HsBprPVtACctAHxZX4+D++0Gucc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 258154BA2E04 Received: by simark.ca (Postfix) id 91D491E08D; Fri, 09 Jan 2026 14:41:29 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2] gdb/coffread: simplify stab section detection Date: Fri, 9 Jan 2026 14:41:24 -0500 Message-ID: <20260109194128.525238-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260109191441.486109-3-simon.marchi@efficios.com> References: <20260109191441.486109-3-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org We look for stab sections for the sole purpose of emitting a warning if we see one. Simplify this by using a boolean to indicate if we saw a stab section or not. Simplify the search to just look for sections starting with ".stab", it should be enough for this purpose. Also, remove the make_scoped_restore that would overwrite the stab section vector, I'm not sure why it's there. It seems to me like it would cause the warning to never be shown. Change-Id: I56323189ffdaa2d06a96d457cdd999b23efa5979 --- gdb/coffread.c | 54 +++++++++++--------------------------------------- 1 file changed, 12 insertions(+), 42 deletions(-) diff --git a/gdb/coffread.c b/gdb/coffread.c index 4fbe0fb9e461..f634ef944075 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -46,8 +46,6 @@ struct coff_symfile_info { file_ptr min_lineno_offset = 0; /* Where in file lowest line#s are. */ file_ptr max_lineno_offset = 0; /* 1+last byte of line#s in file. */ - - std::vector *stabsects; /* .stab sections. */ }; /* Key for COFF-associated data. */ @@ -200,39 +198,6 @@ static void read_one_sym (struct coff_symbol *, static void coff_symtab_read (minimal_symbol_reader &, file_ptr, unsigned int, struct objfile *); -/* We are called once per section from coff_symfile_read. We - need to examine each section we are passed, check to see - if it is something we are interested in processing, and - if so, stash away some access information for the section. - - FIXME: The section names should not be hardwired strings (what - should they be? I don't think most object file formats have enough - section flags to specify what kind of debug section it is - -kingdon). */ - -static void -coff_locate_sections (bfd *abfd, asection *sectp, void *csip) -{ - struct coff_symfile_info *csi; - const char *name; - - csi = (struct coff_symfile_info *) csip; - name = bfd_section_name (sectp); - - if (startswith (name, ".stab")) - { - const char *s; - - /* We can have multiple .stab sections if linked with - --split-by-reloc. */ - for (s = name + sizeof ".stab" - 1; *s != '\0'; s++) - if (!c_isdigit (*s)) - break; - if (*s == '\0') - csi->stabsects->push_back (sectp); - } -} - struct coff_find_targ_sec_arg { int targ_index; @@ -594,10 +559,6 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) info = coff_objfile_data_key.get (objfile); symfile_bfd = abfd; /* Kludge for swap routines. */ - std::vector stabsects; - scoped_restore restore_stabsects - = make_scoped_restore (&info->stabsects, &stabsects); - /* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */ num_symbols = bfd_get_symcount (abfd); /* How many syms */ symtab_offset = cdata->sym_filepos; /* Symbol table file offset */ @@ -674,10 +635,19 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) coff_read_minsyms (symtab_offset, num_symbols, objfile); if (!(objfile->flags & OBJF_READNEVER)) - bfd_map_over_sections (abfd, coff_locate_sections, (void *) info); + { + bool found_stab_section = false; - if (!info->stabsects->empty()) - warning (_("stabs debug information is not supported.")); + for (asection *sect : gdb_bfd_sections (abfd)) + if (startswith (bfd_section_name (sect), ".stab")) + { + found_stab_section = true; + break; + } + + if (found_stab_section) + warning (_ ("stabs debug information is not supported.")); + } if (dwarf2_initialize_objfile (objfile)) { base-commit: 49a27f238252c9e836fcc0a95cef5615e8d9adc4 -- 2.52.0