Make sure terminal settings are restored before exiting
[deliverable/binutils-gdb.git] / gdb / macrotab.c
index 49f00b6c772865be158806ae5954b1f8fb12fe10..4c5341ea98ca9b78b2c8784717e2272f408c9bc5 100644 (file)
@@ -1,5 +1,5 @@
 /* C preprocessor macro tables for GDB.
-   Copyright (C) 2002-2014 Free Software Foundation, Inc.
+   Copyright (C) 2002-2015 Free Software Foundation, Inc.
    Contributed by Red Hat, Inc.
 
    This file is part of GDB.
@@ -25,7 +25,6 @@
 #include "symfile.h"
 #include "objfiles.h"
 #include "macrotab.h"
-#include "gdb_assert.h"
 #include "bcache.h"
 #include "complaints.h"
 #include "macroexp.h"
@@ -48,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.  */
@@ -452,7 +450,7 @@ macro_include (struct macro_source_file *source,
                int line,
                const char *included)
 {
-  struct macro_source_file *new;
+  struct macro_source_file *newobj;
   struct macro_source_file **link;
 
   /* Find the right position in SOURCE's `includes' list for the new
@@ -498,13 +496,13 @@ macro_include (struct macro_source_file *source,
   /* At this point, we know that LINE is an unused line number, and
      *LINK points to the entry an #inclusion at that line should
      precede.  */
-  new = new_source_file (source->table, included);
-  new->included_by = source;
-  new->included_at_line = line;
-  new->next_included = *link;
-  *link = new;
+  newobj = new_source_file (source->table, included);
+  newobj->included_by = source;
+  newobj->included_at_line = line;
+  newobj->next_included = *link;
+  *link = newobj;
 
-  return new;
+  return newobj;
 }
 
 
@@ -1050,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;
 
@@ -1064,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,
@@ -1093,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);
 }
This page took 0.025094 seconds and 4 git commands to generate.