From patchwork Thu Nov 13 12:54:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 3698 Received: (qmail 10001 invoked by alias); 13 Nov 2014 12:55:27 -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 9964 invoked by uid 89); 13 Nov 2014 12:55:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f170.google.com Received: from mail-pd0-f170.google.com (HELO mail-pd0-f170.google.com) (209.85.192.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 13 Nov 2014 12:55:24 +0000 Received: by mail-pd0-f170.google.com with SMTP id z10so14483219pdj.15 for ; Thu, 13 Nov 2014 04:55:23 -0800 (PST) X-Received: by 10.68.243.3 with SMTP id wu3mr2280781pbc.133.1415883323062; Thu, 13 Nov 2014 04:55:23 -0800 (PST) Received: from sspiff.org (173-13-178-53-sfba.hfc.comcastbusiness.net. [173.13.178.53]) by mx.google.com with ESMTPSA id w5sm24898665pds.25.2014.11.13.04.55.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Nov 2014 04:55:22 -0800 (PST) Message-ID: <5464aa3a.6541460a.3afc.ffff8ff3@mx.google.com> Received: by sspiff.org (sSMTP sendmail emulation); Thu, 13 Nov 2014 04:54:30 -0800 Date: Thu, 13 Nov 2014 04:54:30 -0800 From: Doug Evans To: gdb-patches@sourceware.org Subject: [PATCH 14/21] struct symtab split part 2: macroscope.c macrotab.c macrotab.h X-IsSubscribed: yes This patch contains the changes to macroscope.c, macrotab.c, macrotab.h. Full ChangeLog: https://sourceware.org/ml/gdb-patches/2014-11/msg00233.html 2014-11-12 Doug Evans * macroscope.c (sal_macro_scope): Fetch macro table from compunit. * macrotab.c (struct macro_table) : Renamed from comp_dir. Change type to "struct compunit_symtab *". All uses updated. (new_macro_table): Change comp_dir argument to cust, "struct compunit_symtab *". All callers updated. diff --git a/gdb/macroscope.c b/gdb/macroscope.c index c025eb7..6df86ea 100644 --- a/gdb/macroscope.c +++ b/gdb/macroscope.c @@ -40,14 +40,17 @@ sal_macro_scope (struct symtab_and_line sal) { struct macro_source_file *main_file, *inclusion; struct macro_scope *ms; + struct compunit_symtab *cust; - if (! sal.symtab - || ! sal.symtab->macro_table) - return 0; + if (sal.symtab == NULL) + return NULL; + cust = SYMTAB_COMPUNIT (sal.symtab); + if (COMPUNIT_MACRO_TABLE (cust) == NULL) + return NULL; ms = (struct macro_scope *) xmalloc (sizeof (*ms)); - main_file = macro_main (sal.symtab->macro_table); + main_file = macro_main (COMPUNIT_MACRO_TABLE (cust)); inclusion = macro_lookup_inclusion (main_file, sal.symtab->filename); if (inclusion) diff --git a/gdb/macrotab.c b/gdb/macrotab.c index 1e02b0a..1e21f50 100644 --- a/gdb/macrotab.c +++ b/gdb/macrotab.c @@ -47,9 +47,8 @@ struct macro_table #inclusion tree; everything else is #included from here. */ struct macro_source_file *main_source; - /* Compilation directory for all files of this macro table. It is allocated - on objfile's obstack. */ - const char *comp_dir; + /* Backlink to containing compilation unit, or NULL if there isn't one. */ + struct compunit_symtab *compunit_symtab; /* True if macros in this table can be redefined without issuing an error. */ @@ -1049,7 +1048,7 @@ macro_for_each_in_scope (struct macro_source_file *file, int line, struct macro_table * new_macro_table (struct obstack *obstack, struct bcache *b, - const char *comp_dir) + struct compunit_symtab *cust) { struct macro_table *t; @@ -1063,7 +1062,7 @@ new_macro_table (struct obstack *obstack, struct bcache *b, t->obstack = obstack; t->bcache = b; t->main_source = NULL; - t->comp_dir = comp_dir; + t->compunit_symtab = cust; t->redef_ok = 0; t->definitions = (splay_tree_new_with_allocator (macro_tree_compare, @@ -1092,8 +1091,13 @@ free_macro_table (struct macro_table *table) char * macro_source_fullname (struct macro_source_file *file) { - if (file->table->comp_dir == NULL || IS_ABSOLUTE_PATH (file->filename)) + const char *comp_dir = NULL; + + if (file->table->compunit_symtab != NULL) + comp_dir = COMPUNIT_DIRNAME (file->table->compunit_symtab); + + if (comp_dir == NULL || IS_ABSOLUTE_PATH (file->filename)) return xstrdup (file->filename); - return concat (file->table->comp_dir, SLASH_STRING, file->filename, NULL); + return concat (comp_dir, SLASH_STRING, file->filename, NULL); } diff --git a/gdb/macrotab.h b/gdb/macrotab.h index aca7fd4..202b4e8 100644 --- a/gdb/macrotab.h +++ b/gdb/macrotab.h @@ -22,6 +22,7 @@ struct obstack; struct bcache; +struct compunit_symtab; /* How do we represent a source location? I mean, how should we represent them within GDB; the user wants to use all sorts of @@ -154,8 +155,8 @@ struct macro_source_file xmalloc if OBSTACK is zero. Use BCACHE to store all macro names, arguments, definitions, and anything else that might be the same amongst compilation units in an executable file; if BCACHE is zero, - don't cache these things. COMP_DIR optionally contains the compilation - directory of all files for this macro table. + don't cache these things. CUST is a pointer to the containing + compilation unit, or NULL if there isn't one. Note that, if either OBSTACK or BCACHE are non-zero, then removing information from the table may leak memory. Neither obstacks nor @@ -168,7 +169,7 @@ struct macro_source_file do that in GCC 4.1.2.). */ struct macro_table *new_macro_table (struct obstack *obstack, struct bcache *bcache, - const char *comp_dir); + struct compunit_symtab *cust); /* Free TABLE, and any macro definitions, source file structures,