* [PATCH 1/3] gdb/coffread: remove unnecessary forward declarations
@ 2026-01-09 19:14 Simon Marchi
2026-01-09 19:14 ` [PATCH 2/3] gdb/coffread: remove unused fields of coff_symfile_info Simon Marchi
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Simon Marchi @ 2026-01-09 19:14 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: Id68fe282654a6fce316d4c58b3007a00a3a94597
---
gdb/coffread.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/gdb/coffread.c b/gdb/coffread.c
index c7b55f37fdb5..c48431efe429 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -161,8 +161,6 @@ static long stringtab_length = 0;
static int symnum;
static bool within_function;
-extern void stabsread_clear_cache (void);
-
static struct type *coff_read_struct_type (int, int, int,
struct objfile *);
@@ -251,9 +249,6 @@ coff_locate_sections (bfd *abfd, asection *sectp, void *csip)
}
}
-/* Return the section_offsets* that CS points to. */
-static int cs_to_section (struct coff_symbol *, struct objfile *);
-
struct coff_find_targ_sec_arg
{
int targ_index;
@@ -295,8 +290,6 @@ cs_to_section (struct coff_symbol *cs, struct objfile *objfile)
/* Return the address of the section of a COFF symbol. */
-static CORE_ADDR cs_section_address (struct coff_symbol *, bfd *);
-
static CORE_ADDR
cs_section_address (struct coff_symbol *cs, bfd *abfd)
{
base-commit: 5a8351167a8b4547d6583a5d713936c1aec39565
--
2.52.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/3] gdb/coffread: remove unused fields of coff_symfile_info
2026-01-09 19:14 [PATCH 1/3] gdb/coffread: remove unnecessary forward declarations Simon Marchi
@ 2026-01-09 19:14 ` 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:24 ` [PATCH 1/3] gdb/coffread: remove unnecessary forward declarations Tom Tromey
2 siblings, 1 reply; 10+ messages in thread
From: Simon Marchi @ 2026-01-09 19:14 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
Change-Id: I34ae3f3ab17764d40e695a61894d155652a708dd
---
gdb/coffread.c | 20 ++------------------
1 file changed, 2 insertions(+), 18 deletions(-)
diff --git a/gdb/coffread.c b/gdb/coffread.c
index c48431efe429..4fbe0fb9e461 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -47,11 +47,7 @@ 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. */
- CORE_ADDR textaddr = 0; /* Addr of .text section. */
- unsigned int textsize = 0; /* Size of .text section. */
std::vector<asection *> *stabsects; /* .stab sections. */
- asection *stabstrsect = nullptr; /* Section pointer for .stab section. */
- char *stabstrdata = nullptr;
};
/* Key for COFF-associated data. */
@@ -222,20 +218,8 @@ coff_locate_sections (bfd *abfd, asection *sectp, void *csip)
csi = (struct coff_symfile_info *) csip;
name = bfd_section_name (sectp);
- if (strcmp (name, ".text") == 0)
- {
- csi->textaddr = bfd_section_vma (sectp);
- csi->textsize += bfd_section_size (sectp);
- }
- else if (startswith (name, ".text"))
- {
- csi->textsize += bfd_section_size (sectp);
- }
- else if (strcmp (name, ".stabstr") == 0)
- {
- csi->stabstrsect = sectp;
- }
- else if (startswith (name, ".stab"))
+
+ if (startswith (name, ".stab"))
{
const char *s;
--
2.52.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 3/3] gdb/coffread: simplify stab section detection
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:14 ` Simon Marchi
2026-01-09 19:29 ` Tom Tromey
2026-01-09 19:41 ` [PATCH v2] " Simon Marchi
2026-01-09 19:24 ` [PATCH 1/3] gdb/coffread: remove unnecessary forward declarations Tom Tromey
2 siblings, 2 replies; 10+ messages in thread
From: Simon Marchi @ 2026-01-09 19:14 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
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 | 21 ++++-----------------
1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 4fbe0fb9e461..5ab2e43a5aa0 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -47,7 +47,8 @@ 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. */
+ /* True if the symfile contains one section that starts with ".stab". */
+ bool found_stab_section = false;
};
/* Key for COFF-associated data. */
@@ -220,17 +221,7 @@ coff_locate_sections (bfd *abfd, asection *sectp, void *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);
- }
+ csi->found_stab_section = true;
}
struct coff_find_targ_sec_arg
@@ -594,10 +585,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 */
@@ -676,7 +663,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
if (!(objfile->flags & OBJF_READNEVER))
bfd_map_over_sections (abfd, coff_locate_sections, (void *) info);
- if (!info->stabsects->empty())
+ if (info->found_stab_section)
warning (_("stabs debug information is not supported."));
if (dwarf2_initialize_objfile (objfile))
--
2.52.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] gdb/coffread: remove unnecessary forward declarations
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:14 ` [PATCH 3/3] gdb/coffread: simplify stab section detection Simon Marchi
@ 2026-01-09 19:24 ` Tom Tromey
2 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey @ 2026-01-09 19:24 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
Thanks. This one is obvious, but anyway
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/3] gdb/coffread: remove unused fields of coff_symfile_info
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
0 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey @ 2026-01-09 19:24 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
Thanks.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] gdb/coffread: simplify stab section detection
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 ` [PATCH v2] " Simon Marchi
1 sibling, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2026-01-09 19:29 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
Simon> We look for stab sections for the sole purpose of emitting a warning if
Simon> we see one. Simplify this by using a boolean to indicate if we saw a
Simon> stab section or not. Simplify the search to just look for sections
Simon> starting with ".stab", it should be enough for this purpose.
Simon> Also, remove the make_scoped_restore that would overwrite the stab
Simon> section vector, I'm not sure why it's there. It seems to me like it
Simon> would cause the warning to never be shown.
Simon> @@ -47,7 +47,8 @@ struct coff_symfile_info
Simon> file_ptr min_lineno_offset = 0; /* Where in file lowest line#s are. */
Simon> file_ptr max_lineno_offset = 0; /* 1+last byte of line#s in file. */
Simon> - std::vector<asection *> *stabsects; /* .stab sections. */
Simon> + /* True if the symfile contains one section that starts with ".stab". */
Simon> + bool found_stab_section = false;
There's not really a reason to keep this in coff_symfile_info. That
said it hardly hurts and this is definitely an improvement regardless.
Simon> if (!(objfile->flags & OBJF_READNEVER))
Simon> bfd_map_over_sections (abfd, coff_locate_sections, (void *) info);
... I'd imagine it's a workaround for mapping over sections like this
rather than just using foreach. The latter makes it easier to do random
checks.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] gdb/coffread: simplify stab section detection
2026-01-09 19:29 ` Tom Tromey
@ 2026-01-09 19:36 ` Simon Marchi
0 siblings, 0 replies; 10+ messages in thread
From: Simon Marchi @ 2026-01-09 19:36 UTC (permalink / raw)
To: Tom Tromey, Simon Marchi; +Cc: gdb-patches
On 1/9/26 2:29 PM, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
>
> Simon> We look for stab sections for the sole purpose of emitting a warning if
> Simon> we see one. Simplify this by using a boolean to indicate if we saw a
> Simon> stab section or not. Simplify the search to just look for sections
> Simon> starting with ".stab", it should be enough for this purpose.
>
> Simon> Also, remove the make_scoped_restore that would overwrite the stab
> Simon> section vector, I'm not sure why it's there. It seems to me like it
> Simon> would cause the warning to never be shown.
>
> Simon> @@ -47,7 +47,8 @@ struct coff_symfile_info
> Simon> file_ptr min_lineno_offset = 0; /* Where in file lowest line#s are. */
> Simon> file_ptr max_lineno_offset = 0; /* 1+last byte of line#s in file. */
>
> Simon> - std::vector<asection *> *stabsects; /* .stab sections. */
> Simon> + /* True if the symfile contains one section that starts with ".stab". */
> Simon> + bool found_stab_section = false;
>
> There's not really a reason to keep this in coff_symfile_info. That
> said it hardly hurts and this is definitely an improvement regardless.
>
> Simon> if (!(objfile->flags & OBJF_READNEVER))
> Simon> bfd_map_over_sections (abfd, coff_locate_sections, (void *) info);
>
> ... I'd imagine it's a workaround for mapping over sections like this
> rather than just using foreach. The latter makes it easier to do random
> checks.
>
> Approved-By: Tom Tromey <tom@tromey.com>
>
> Tom
You're right, I'll simplify this further. I have pushed the first two
patches.
Simon
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2] gdb/coffread: simplify stab section detection
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:41 ` Simon Marchi
2026-01-09 20:49 ` Tom Tromey
1 sibling, 1 reply; 10+ messages in thread
From: Simon Marchi @ 2026-01-09 19:41 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] gdb/coffread: simplify stab section detection
2026-01-09 19:41 ` [PATCH v2] " Simon Marchi
@ 2026-01-09 20:49 ` Tom Tromey
2026-01-09 21:38 ` Simon Marchi
0 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2026-01-09 20:49 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
Simon> We look for stab sections for the sole purpose of emitting a warning if
Simon> we see one. Simplify this by using a boolean to indicate if we saw a
Simon> stab section or not. Simplify the search to just look for sections
Simon> starting with ".stab", it should be enough for this purpose.
Simon> Also, remove the make_scoped_restore that would overwrite the stab
Simon> section vector, I'm not sure why it's there. It seems to me like it
Simon> would cause the warning to never be shown.
Looks nice, thanks.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] gdb/coffread: simplify stab section detection
2026-01-09 20:49 ` Tom Tromey
@ 2026-01-09 21:38 ` Simon Marchi
0 siblings, 0 replies; 10+ messages in thread
From: Simon Marchi @ 2026-01-09 21:38 UTC (permalink / raw)
To: Tom Tromey, Simon Marchi; +Cc: gdb-patches
On 1/9/26 3:49 PM, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
>
> Simon> We look for stab sections for the sole purpose of emitting a warning if
> Simon> we see one. Simplify this by using a boolean to indicate if we saw a
> Simon> stab section or not. Simplify the search to just look for sections
> Simon> starting with ".stab", it should be enough for this purpose.
>
> Simon> Also, remove the make_scoped_restore that would overwrite the stab
> Simon> section vector, I'm not sure why it's there. It seems to me like it
> Simon> would cause the warning to never be shown.
>
> Looks nice, thanks.
> Approved-By: Tom Tromey <tom@tromey.com>
>
> Tom
Thanks, pushed.
Simon
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-01-09 21:39 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v2] " Simon Marchi
2026-01-09 20:49 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox