From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wUyZIlNW9miTVAAAWB0awg (envelope-from ) for ; Mon, 20 Oct 2025 11:33:39 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Yocby75P; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 89AB21E0BC; Mon, 20 Oct 2025 11:33:39 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,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 server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 B843F1E047 for ; Mon, 20 Oct 2025 11:33:38 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 63D673858406 for ; Mon, 20 Oct 2025 15:33:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63D673858406 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Yocby75P Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id EFF893858C62 for ; Mon, 20 Oct 2025 15:31:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EFF893858C62 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EFF893858C62 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1760974273; cv=none; b=i2jGQ7BzooT2xQq6dnCoIURTajxZwEMjwRaxlu40OpiQPQQ5/IaFO/72s8ydphZbDEgOM13oGwu4aPQE+9HPogkU36AkrKBBRwqBw2gRoioTSpSuHT5mQyuwYNtjKd3OO+JmSTI3Bc6xT9HClPaJQLG0YQiY6QG7N8fAwgXmohU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1760974273; c=relaxed/simple; bh=4h0HTCatXkeTpqurDscKsWLI7vHqdQSscCwVE0nuLyQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=D2YRSyFZ26+ROmKrmzggleTjf7OTFgdXsXYFxg6ORRtq0pelyZSz+LYvGyrvHk6MS/KChJkEGtVJ7ifZHW2p2YyPOSNxolZF7/n7Kis7jZorJQKGtCpVhvbulnFgCa2edZ0hqqokYItRNpWtkwEKeaO7FPzudGd9UiPca+kyEwM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EFF893858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760974272; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R2Es4GFMR9cZhnWzdj3Iw4e21046V8fk2CAIWErcYqY=; b=Yocby75PVsj3FxR6R6gD0qMpbNANq5Toby47DNCK/QTvZ36KAz2qLu2+iqi7o29u44TXcs jJEYhW2JtIca8FAkTwIc8mwfVkrO9KcqoJCn748dEcbO30M93G1WK2ETDHBlr1Dg1juaSG fH8Z80cDbB8BePPc5TdTKMJ3GnTgYHk= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-634-lygWtIajPPGi3cKhtCRn7g-1; Mon, 20 Oct 2025 11:31:08 -0400 X-MC-Unique: lygWtIajPPGi3cKhtCRn7g-1 X-Mimecast-MFC-AGG-ID: lygWtIajPPGi3cKhtCRn7g_1760974267 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C813618002DD; Mon, 20 Oct 2025 15:31:07 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.96.134.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9081318003FC; Mon, 20 Oct 2025 15:31:06 +0000 (UTC) From: Guinevere Larsen To: gdb-patches@sourceware.org Cc: Guinevere Larsen , Tom Tromey Subject: [PATCH v2 5/8] gdb: Remove stabs support for COFF files Date: Mon, 20 Oct 2025 12:28:49 -0300 Message-ID: <20251020152853.28195-6-guinevere@redhat.com> In-Reply-To: <20251020152853.28195-1-guinevere@redhat.com> References: <20251020152853.28195-1-guinevere@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 9-sJm_zPKnj6pDMrscqR4tl7u6MIRwQCfTf5z_KdSwQ_1760974267 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 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 --- 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 &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 (); } @@ -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