From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH v2] gdb/coffread: simplify stab section detection
Date: Fri, 9 Jan 2026 14:41:24 -0500 [thread overview]
Message-ID: <20260109194128.525238-1-simon.marchi@efficios.com> (raw)
In-Reply-To: <20260109191441.486109-3-simon.marchi@efficios.com>
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<asection *> *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<asection *> 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
next prev parent reply other threads:[~2026-01-09 19:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 19:14 [PATCH 1/3] gdb/coffread: remove unnecessary forward declarations Simon Marchi
2026-01-09 19:14 ` [PATCH 2/3] gdb/coffread: remove unused fields of coff_symfile_info Simon Marchi
2026-01-09 19:24 ` Tom Tromey
2026-01-09 19:14 ` [PATCH 3/3] gdb/coffread: simplify stab section detection Simon Marchi
2026-01-09 19:29 ` Tom Tromey
2026-01-09 19:36 ` Simon Marchi
2026-01-09 19:41 ` Simon Marchi [this message]
2026-01-09 20:49 ` [PATCH v2] " Tom Tromey
2026-01-09 21:38 ` Simon Marchi
2026-01-09 19:24 ` [PATCH 1/3] gdb/coffread: remove unnecessary forward declarations Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260109194128.525238-1-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox