From: Guinevere Larsen <guinevere@redhat.com>
To: gdb-patches@sourceware.org
Cc: Guinevere Larsen <guinevere@redhat.com>, Tom Tromey <tom@tromey.com>
Subject: [PATCH v2 5/8] gdb: Remove stabs support for COFF files
Date: Mon, 20 Oct 2025 12:28:49 -0300 [thread overview]
Message-ID: <20251020152853.28195-6-guinevere@redhat.com> (raw)
In-Reply-To: <20251020152853.28195-1-guinevere@redhat.com>
This commit continues the removal of stabs by removing support from coff
inferiors. This is trivial for the most part, just a removal of code
setting things only relevant for stabs, with one exception.
The global variables symnum and within_function were introduced to
coffread.c (and within_function was converted to boolean). I looked into
making them parameters to the relevant function, but this would require
changes to several otherwise untouched functions, so I kept them as globals
instead.
Approved-By: Tom Tromey <tom@tromey.com>
---
gdb/coffread.c | 133 +++++--------------------------------------------
1 file changed, 12 insertions(+), 121 deletions(-)
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 0a3be97c8d8..e8ed1e6b8ee 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -30,13 +30,11 @@
#include "libcoff.h"
#include "objfiles.h"
#include "buildsym-legacy.h"
-#include "stabsread.h"
#include "complaints.h"
#include "target.h"
#include "block.h"
#include "dictionary.h"
#include "dwarf2/public.h"
-#include "gdb-stabs.h"
#include "coff-pe-read.h"
@@ -159,6 +157,10 @@ static file_ptr linetab_size;
static char *stringtab = NULL;
static long stringtab_length = 0;
+/* Used when reading coff symbols. */
+static int symnum;
+static bool within_function;
+
extern void stabsread_clear_cache (void);
static struct type *coff_read_struct_type (int, int, int,
@@ -204,99 +206,6 @@ static void read_one_sym (struct coff_symbol *,
static void coff_symtab_read (minimal_symbol_reader &,
file_ptr, unsigned int, struct objfile *);
-/* Scan and build partial symbols for an coff symbol file.
- The coff file has already been processed to get its minimal symbols.
-
- This routine is the equivalent of dbx_symfile_init and dbx_symfile_read
- rolled into one.
-
- OBJFILE is the object file we are reading symbols from.
- ADDR is the address relative to which the symbols are (e.g.
- the base address of the text segment).
- TEXTADDR is the address of the text section.
- TEXTSIZE is the size of the text section.
- STABSECTS is the list of .stab sections in OBJFILE.
- STABSTROFFSET and STABSTRSIZE define the location in OBJFILE where the
- .stabstr section exists.
-
- This routine is mostly copied from dbx_symfile_init and dbx_symfile_read,
- adjusted for coff details. */
-
-void
-coffstab_build_psymtabs (struct objfile *objfile,
- CORE_ADDR textaddr, unsigned int textsize,
- const std::vector<asection *> &stabsects,
- file_ptr stabstroffset, unsigned int stabstrsize)
-{
- int val;
- bfd *sym_bfd = objfile->obfd.get ();
- const char *name = bfd_get_filename (sym_bfd);
- unsigned int stabsize;
-
- stabs_deprecated_warning ();
- /* Allocate struct to keep track of stab reading. */
- dbx_objfile_data_key.emplace (objfile);
- dbx_symfile_info *key = dbx_objfile_data_key.get (objfile);
-
- DBX_TEXT_ADDR (objfile) = textaddr;
- DBX_TEXT_SIZE (objfile) = textsize;
-
-#define COFF_STABS_SYMBOL_SIZE 12 /* XXX FIXME XXX */
- DBX_SYMBOL_SIZE (objfile) = COFF_STABS_SYMBOL_SIZE;
- DBX_STRINGTAB_SIZE (objfile) = stabstrsize;
-
- if (stabstrsize > bfd_get_size (sym_bfd))
- error (_("ridiculous string table size: %d bytes"), stabstrsize);
- DBX_STRINGTAB (objfile) = (char *)
- obstack_alloc (&objfile->objfile_obstack, stabstrsize + 1);
- OBJSTAT (objfile, sz_strtab += stabstrsize + 1);
-
- /* Now read in the string table in one big gulp. */
-
- val = bfd_seek (sym_bfd, stabstroffset, SEEK_SET);
- if (val < 0)
- perror_with_name (name);
- val = bfd_read (DBX_STRINGTAB (objfile), stabstrsize, sym_bfd);
- if (val != stabstrsize)
- perror_with_name (name);
-
- stabsread_new_init ();
- free_header_files ();
- init_header_files ();
-
- key->ctx.processing_acc_compilation = 1;
-
- /* In a coff file, we've already installed the minimal symbols that came
- from the coff (non-stab) symbol table, so always act like an
- incremental load here. */
- scoped_restore save_symbuf_sections
- = make_scoped_restore (&key->ctx.symbuf_sections);
- if (stabsects.size () == 1)
- {
- stabsize = bfd_section_size (stabsects[0]);
- DBX_SYMCOUNT (objfile) = stabsize / DBX_SYMBOL_SIZE (objfile);
- DBX_SYMTAB_OFFSET (objfile) = stabsects[0]->filepos;
- }
- else
- {
- DBX_SYMCOUNT (objfile) = 0;
- for (asection *section : stabsects)
- {
- stabsize = bfd_section_size (section);
- DBX_SYMCOUNT (objfile) += stabsize / DBX_SYMBOL_SIZE (objfile);
- }
-
- DBX_SYMTAB_OFFSET (objfile) = stabsects[0]->filepos;
-
- key->ctx.sect_idx = 1;
- key->ctx.symbuf_sections = &stabsects;
- key->ctx.symbuf_left = bfd_section_size (stabsects[0]);
- key->ctx.symbuf_read = 0;
- }
-
- read_stabs_symtab (objfile, 0);
-}
-
/* 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
@@ -458,7 +367,6 @@ coff_alloc_type (int index)
static void
coff_start_compunit_symtab (struct objfile *objfile, const char *name)
{
- within_function = 0;
start_compunit_symtab (objfile,
name,
/* We never know the directory name for COFF. */
@@ -705,7 +613,6 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
unsigned int num_symbols;
file_ptr symtab_offset;
file_ptr stringtab_offset;
- unsigned int stabstrsize;
info = coff_objfile_data_key.get (objfile);
symfile_bfd = abfd; /* Kludge for swap routines. */
@@ -793,23 +700,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
bfd_map_over_sections (abfd, coff_locate_sections, (void *) info);
if (!info->stabsects->empty())
- {
- if (!info->stabstrsect)
- {
- error (_("The debugging information in `%s' is corrupted.\nThe "
- "file has a `.stabs' section, but no `.stabstr' section."),
- filename);
- }
-
- /* FIXME: dubious. Why can't we use something normal like
- bfd_get_section_contents? */
- stabstrsize = bfd_section_size (info->stabstrsect);
-
- coffstab_build_psymtabs (objfile,
- info->textaddr, info->textsize,
- *info->stabsects,
- info->stabstrsect->filepos, stabstrsize);
- }
+ warning (_("stabs debug information is not supported."));
if (dwarf2_initialize_objfile (objfile))
{
@@ -840,8 +731,6 @@ coff_new_init (struct objfile *ignore)
static void
coff_symfile_finish (struct objfile *objfile)
{
- /* Let stabs reader clean up. */
- stabsread_clear_cache ();
}
\f
@@ -881,6 +770,9 @@ coff_symtab_read (minimal_symbol_reader &reader,
scoped_free_pendings free_pending;
+ within_function = false;
+ symnum = 0;
+
/* Position to read the symbol table. */
val = bfd_seek (objfile->obfd.get (), symtab_offset, 0);
if (val < 0)
@@ -899,7 +791,6 @@ coff_symtab_read (minimal_symbol_reader &reader,
coff_start_compunit_symtab (objfile, "");
- symnum = 0;
while (symnum < nsyms)
{
QUIT; /* Make this command interruptible. */
@@ -1122,7 +1013,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
case C_FCN:
if (strcmp (cs->c_name, ".bf") == 0)
{
- within_function = 1;
+ within_function = true;
/* Value contains address of first non-init type
code. */
@@ -1158,7 +1049,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
complaint (_("`.ef' symbol without matching `.bf' "
"symbol ignored starting at symnum %d"),
cs->c_symnum);
- within_function = 0;
+ within_function = false;
break;
}
@@ -1169,7 +1060,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
complaint (_("Unmatched .ef symbol(s) ignored "
"starting at symnum %d"),
cs->c_symnum);
- within_function = 0;
+ within_function = false;
break;
}
if (cs->c_naux != 1)
@@ -1203,7 +1094,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
fcn_cs_saved.c_value
+ fcn_aux_saved.x_sym.x_misc.x_fsize
+ objfile->text_section_offset ());
- within_function = 0;
+ within_function = false;
}
break;
--
2.51.0
next prev parent reply other threads:[~2025-10-20 15:33 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-20 15:28 [PATCH v2 0/8] Remove stabs support from GDB Guinevere Larsen
2025-10-20 15:28 ` [PATCH v2 1/8] gdb: move some stabs functions to gdb/buildsym-legacy.h Guinevere Larsen
2025-10-20 16:25 ` Tom Tromey
2025-10-20 15:28 ` [PATCH v2 2/8] gdb/mdebug: Remove stabs support from mips inferiors Guinevere Larsen
2025-10-20 15:28 ` [PATCH v2 3/8] gdb: Remove stabs support from ELF files Guinevere Larsen
2025-10-20 15:28 ` [PATCH v2 4/8] gdb: Remove stabs support from dbx Guinevere Larsen
2025-10-20 15:28 ` Guinevere Larsen [this message]
2025-10-20 15:28 ` [PATCH v2 6/8] gdb: Remove stabs support from XCOFF inferiors Guinevere Larsen
2025-11-07 10:46 ` Andrew Burgess
2025-11-07 12:09 ` Guinevere Larsen
2025-11-07 14:46 ` Tom Tromey
2025-10-20 15:28 ` [PATCH v2 7/8] gdb: Fully remove stabs code from GDB Guinevere Larsen
2025-10-20 16:39 ` Eli Zaretskii
2025-10-20 19:12 ` Guinevere Larsen
2025-10-20 15:28 ` [PATCH v2 8/8] gdb: remove support for dbx " Guinevere Larsen
2025-10-21 19:14 ` [PATCH v2 0/8] Remove stabs support " Tom Tromey
2025-10-21 19:42 ` Guinevere Larsen
2025-10-22 9:48 ` Luis
2025-10-22 13:08 ` Tom Tromey
2025-10-22 13:19 ` Guinevere Larsen
2025-10-22 19:19 ` Luis
2025-10-23 0:58 ` Luis
2025-10-23 2:03 ` Andrew Pinski
2025-10-23 18:11 ` Simon Marchi
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=20251020152853.28195-6-guinevere@redhat.com \
--to=guinevere@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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