/* 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.
#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. */
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
/* 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;
}
struct macro_table *
new_macro_table (struct obstack *obstack, struct bcache *b,
- const char *comp_dir)
+ struct compunit_symtab *cust)
{
struct macro_table *t;
/* First, get storage for the `struct macro_table' itself. */
if (obstack)
- t = obstack_alloc (obstack, sizeof (*t));
+ t = XOBNEW (obstack, struct macro_table);
else
- t = xmalloc (sizeof (*t));
+ t = XNEW (struct macro_table);
memset (t, 0, sizeof (*t));
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,
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);
}