From patchwork Sun Nov 25 16:54:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 30281 Received: (qmail 92857 invoked by alias); 25 Nov 2018 16:54:50 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 92746 invoked by uid 89); 25 Nov 2018 16:54:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=opaque, UD:source.c, source.c, sourcec X-HELO: gateway22.websitewelcome.com Received: from gateway22.websitewelcome.com (HELO gateway22.websitewelcome.com) (192.185.47.168) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 25 Nov 2018 16:54:46 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 994007B92 for ; Sun, 25 Nov 2018 10:54:45 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id QxgDgQZdmBcCXQxgDgWUpP; Sun, 25 Nov 2018 10:54:45 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=YWIyEAGp+1/coT2sISW6lmTkkFfmZp8OzfEqkABs3P0=; b=nMc9VdWrfVkoe75TaRA1gpSo2i 5Yr2cgMxlb/hcFj5H9xEly6l87sClTiCqZZKR04NVHTbKHgFab8Ir0HvLNfx2qaiRa3uTFogqxrzW bnHyhE3Te25mR9Fx0JHEhOPOb; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:51592 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gQxgD-0013GF-D7; Sun, 25 Nov 2018 10:54:45 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 09/12] Remove ALL_OBJFILE_FILETABS Date: Sun, 25 Nov 2018 09:54:36 -0700 Message-Id: <20181125165439.13773-10-tom@tromey.com> In-Reply-To: <20181125165439.13773-1-tom@tromey.com> References: <20181125165439.13773-1-tom@tromey.com> This removes ALL_OBJFILE_FILETABS, replacing its uses with ranged for loops. gdb/ChangeLog 2018-11-25 Tom Tromey * symmisc.c (print_objfile_statistics, dump_objfile) (maintenance_print_symbols): Use compunit_filetabs. * source.c (forget_cached_source_info_for_objfile): Use compunit_filetabs. * objfiles.h (ALL_OBJFILE_FILETABS): Remove. (ALL_FILETABS): Use compunit_filetabs. * objfiles.c (objfile_relocate1): Use compunit_filetabs. * coffread.c (coff_symtab_read): Use compunit_filetabs. --- gdb/ChangeLog | 11 +++++++++ gdb/coffread.c | 5 ++-- gdb/objfiles.c | 25 ++++++++++--------- gdb/objfiles.h | 13 +++------- gdb/source.c | 27 ++++++++++---------- gdb/symmisc.c | 67 ++++++++++++++++++++++++++------------------------ 6 files changed, 80 insertions(+), 68 deletions(-) diff --git a/gdb/coffread.c b/gdb/coffread.c index 82e6767ae1..741fad69fa 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1201,8 +1201,9 @@ coff_symtab_read (minimal_symbol_reader &reader, /* Patch up any opaque types (references to types that are not defined in the file where they are referenced, e.g. "struct foo *bar"). */ { - ALL_OBJFILE_FILETABS (objfile, cu, s) - patch_opaque_types (s); + for (struct compunit_symtab *cu : objfile_compunits (objfile)) + for (struct symtab *s : compunit_filetabs (cu)) + patch_opaque_types (s); } coffread_objfile = NULL; diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 3429fdc9d8..9f54b8edf5 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -788,20 +788,21 @@ objfile_relocate1 (struct objfile *objfile, /* OK, get all the symtabs. */ { - ALL_OBJFILE_FILETABS (objfile, cust, s) - { - struct linetable *l; - - /* First the line table. */ - l = SYMTAB_LINETABLE (s); - if (l) + for (struct compunit_symtab *cust : objfile_compunits (objfile)) + for (struct symtab *s : compunit_filetabs (cust)) { - for (int i = 0; i < l->nitems; ++i) - l->item[i].pc += ANOFFSET (delta, - COMPUNIT_BLOCK_LINE_SECTION - (cust)); + struct linetable *l; + + /* First the line table. */ + l = SYMTAB_LINETABLE (s); + if (l) + { + for (int i = 0; i < l->nitems; ++i) + l->item[i].pc += ANOFFSET (delta, + COMPUNIT_BLOCK_LINE_SECTION + (cust)); + } } - } for (struct compunit_symtab *cust : objfile_compunits (objfile)) { diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 4bbe7ea613..94394e79ae 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -612,12 +612,6 @@ public: (obj) != NULL; \ (obj) = (obj)->next) -/* Traverse all symtabs in one objfile. */ - -#define ALL_OBJFILE_FILETABS(objfile, cu, s) \ - for (struct compunit_symtab *cu : objfile_compunits (objfile)) \ - for (struct symtab *s : compunit_filetabs (cu)) - /* A range adapter that makes it possible to iterate over all compunits in one objfile. */ @@ -714,9 +708,10 @@ private: /* Traverse all symtabs in all objfiles in the current symbol space. */ -#define ALL_FILETABS(objfile, ps, s) \ - ALL_OBJFILES (objfile) \ - ALL_OBJFILE_FILETABS (objfile, ps, s) +#define ALL_FILETABS(objfile, ps, s) \ + ALL_OBJFILES (objfile) \ + for (struct compunit_symtab *ps : objfile_compunits (objfile)) \ + for (struct symtab *s : compunit_filetabs (cu)) #define ALL_OBJFILE_OSECTIONS(objfile, osect) \ for (osect = objfile->sections; osect < objfile->sections_end; osect++) \ diff --git a/gdb/source.c b/gdb/source.c index 65b9bf554d..6111453eb0 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -355,19 +355,20 @@ show_directories_command (struct ui_file *file, int from_tty, void forget_cached_source_info_for_objfile (struct objfile *objfile) { - ALL_OBJFILE_FILETABS (objfile, cu, s) - { - if (s->line_charpos != NULL) - { - xfree (s->line_charpos); - s->line_charpos = NULL; - } - if (s->fullname != NULL) - { - xfree (s->fullname); - s->fullname = NULL; - } - } + for (struct compunit_symtab *cu : objfile_compunits (objfile)) + for (struct symtab *s : compunit_filetabs (cu)) + { + if (s->line_charpos != NULL) + { + xfree (s->line_charpos); + s->line_charpos = NULL; + } + if (s->fullname != NULL) + { + xfree (s->fullname); + s->fullname = NULL; + } + } if (objfile->sf) objfile->sf->qf->forget_cached_source_info (objfile); diff --git a/gdb/symmisc.c b/gdb/symmisc.c index e9ab1c95b8..148e839599 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -107,12 +107,13 @@ print_objfile_statistics (void) if (objfile->sf) objfile->sf->qf->print_stats (objfile); i = linetables = 0; - ALL_OBJFILE_FILETABS (objfile, cu, s) - { - i++; - if (SYMTAB_LINETABLE (s) != NULL) - linetables++; - } + for (struct compunit_symtab *cu : objfile_compunits (objfile)) + for (struct symtab *s : compunit_filetabs (cu)) + { + i++; + if (SYMTAB_LINETABLE (s) != NULL) + linetables++; + } blockvectors = std::distance (objfile_compunits (objfile).begin (), objfile_compunits (objfile).end ()); printf_filtered (_(" Number of symbol tables: %d\n"), i); @@ -157,17 +158,18 @@ dump_objfile (struct objfile *objfile) if (objfile->compunit_symtabs != NULL) { printf_filtered ("Symtabs:\n"); - ALL_OBJFILE_FILETABS (objfile, cust, symtab) - { - printf_filtered ("%s at ", symtab_to_filename_for_display (symtab)); - gdb_print_host_address (symtab, gdb_stdout); - printf_filtered (", "); - if (SYMTAB_OBJFILE (symtab) != objfile) - { - printf_filtered ("NOT ON CHAIN! "); - } - wrap_here (" "); - } + for (struct compunit_symtab *cu : objfile_compunits (objfile)) + for (struct symtab *symtab : compunit_filetabs (cu)) + { + printf_filtered ("%s at ", symtab_to_filename_for_display (symtab)); + gdb_print_host_address (symtab, gdb_stdout); + printf_filtered (", "); + if (SYMTAB_OBJFILE (symtab) != objfile) + { + printf_filtered ("NOT ON CHAIN! "); + } + wrap_here (" "); + } printf_filtered ("\n\n"); } } @@ -477,22 +479,23 @@ maintenance_print_symbols (const char *args, int from_tty) if (!print_for_objfile) continue; - ALL_OBJFILE_FILETABS (objfile, cu, s) - { - int print_for_source = 0; + for (struct compunit_symtab *cu : objfile_compunits (objfile)) + for (struct symtab *s : compunit_filetabs (cu)) + { + int print_for_source = 0; - QUIT; - if (source_arg != NULL) - { - print_for_source - = compare_filenames_for_search - (symtab_to_filename_for_display (s), source_arg); - found = 1; - } - if (source_arg == NULL - || print_for_source) - dump_symtab (s, outfile); - } + QUIT; + if (source_arg != NULL) + { + print_for_source + = compare_filenames_for_search + (symtab_to_filename_for_display (s), source_arg); + found = 1; + } + if (source_arg == NULL + || print_for_source) + dump_symtab (s, outfile); + } } if (source_arg != NULL && !found)