22 #include "splay-tree.h" 23 #include "filenames.h" 121 memcpy (copy, addr, len);
133 return (
const char *)
macro_bcache (t, s, strlen (s) + 1);
252 while (depth1 > depth2)
259 while (depth2 > depth1)
269 while (file1 != file2)
306 return line1 - line2;
323 int names = strcmp (key->
name,
name);
337 splay_tree_key untyped_key2)
357 memset (k, 0,
sizeof (*k));
391 memset (f, 0,
sizeof (*f));
407 for (child = src->
includes; child; child = next_child)
452 const char *included)
469 char *link_fullname, *source_fullname;
482 _(
"both `%s' and `%s' allegedly #included at %s:%d"),
483 included, link_fullname, source_fullname, line);
484 xfree (source_fullname);
485 xfree (link_fullname);
532 if (! best || result_depth < best_depth)
535 best_depth = result_depth;
560 memset (d, 0,
sizeof (*d));
569 const char **cached_argv;
570 int cached_argv_size =
argc *
sizeof (*cached_argv);
573 cached_argv = (
const char **) alloca (cached_argv_size);
574 for (i = 0; i <
argc; i++)
578 d->
argv = ((
const char *
const *)
614 for (i = 0; i < d->
argc; i++)
626 static splay_tree_node
638 query.start_file = file;
639 query.start_line = line;
640 query.end_file = NULL;
651 splay_tree_node pred = splay_tree_predecessor (t->
definitions,
652 (splay_tree_key) &
query);
690 int argc,
const char **
argv,
691 const char *replacement)
709 if (kind != found_def->kind)
711 else if (strcmp (replacement, found_def->replacement))
715 if (argc != found_def->argc)
721 for (i = 0; i < argc; i++)
722 if (strcmp (
argv[i], found_def->argv[i]))
729 char *source_fullname, *found_key_fullname;
734 _(
"macro `%s' redefined at %s:%d; " 735 "original definition at %s:%d"),
736 name, source_fullname, line, found_key_fullname,
738 xfree (found_key_fullname);
739 xfree (source_fullname);
752 const char *
name,
const char *replacement,
780 splay_tree_insert (t->
definitions, (splay_tree_key) k, (splay_tree_value) d);
826 splay_tree_insert (t->
definitions, (splay_tree_key) k, (splay_tree_value) d);
858 char *source_fullname, *key_fullname;
863 _(
"macro '%s' is #undefined twice," 864 " at %s:%d and %s:%d"),
865 name, source_fullname, line, key_fullname,
867 xfree (key_fullname);
868 xfree (source_fullname);
884 _(
"no definition for macro `%s' in scope to #undef at %s:%d"),
896 static char *saved_expansion;
900 xfree (saved_expansion);
901 saved_expansion = NULL;
923 int line,
const char *
name)
930 char *source_fullname;
935 xfree (source_fullname);
947 int *definition_line)
985 xfree (key_fullname);
1010 char *datum_fullname;
1015 xfree (datum_fullname);
1059 memset (t, 0,
sizeof (*t));
1092 const char *comp_dir = NULL;
1097 if (comp_dir == NULL || IS_ABSOLUTE_PATH (file->
filename))
void macro_define_function(struct macro_source_file *source, int line, const char *name, int argc, const char **argv, const char *replacement)
struct macro_source_file * next_included
static void macro_define_object_internal(struct macro_source_file *source, int line, const char *name, const char *replacement, enum macro_special_kind kind)
static struct macro_key * check_for_redefinition(struct macro_source_file *source, int line, const char *name, enum macro_kind kind, int argc, const char **argv, const char *replacement)
const void * bcache(const void *addr, int length, struct bcache *cache)
struct macro_table * table
__extension__ enum macro_kind kind
struct macro_table * table
struct macro_table * table
struct macro_source_file * includes
int query(const char *ctlstr,...)
struct macro_source_file * included_by
struct compunit_symtab * compunit_symtab
struct macro_source_file * macro_lookup_inclusion(struct macro_source_file *source, const char *name)
void * memset(T *s, int c, size_t n)=delete
static int macro_tree_compare(splay_tree_key untyped_key1, splay_tree_key untyped_key2)
static const char * macro_bcache_str(struct macro_table *t, const char *s)
gdb::function_view< macro_callback_fn > fn
static const void * macro_bcache(struct macro_table *t, const void *addr, int len)
static int inclusion_depth(struct macro_source_file *file)
#define COMPUNIT_DIRNAME(cust)
void macro_define_object(struct macro_source_file *source, int line, const char *name, const char *replacement)
static void * macro_alloc(int size, struct macro_table *t)
static struct macro_definition * fixup_definition(const char *filename, int line, struct macro_definition *def)
void macro_for_each(struct macro_table *table, gdb::function_view< macro_callback_fn > fn)
struct macro_source_file * file
static int compare_locations(struct macro_source_file *file1, int line1, struct macro_source_file *file2, int line2)
struct macro_definition * macro_lookup_definition(struct macro_source_file *source, int line, const char *name)
static void macro_tree_delete_key(void *untyped_key)
static int foreach_macro(splay_tree_node node, void *arg)
struct macro_source_file * macro_include(struct macro_source_file *source, int line, const char *included)
#define complaint(COMPLAINTS, FMT,...)
void macro_define_special(struct macro_table *table)
char * xstrprintf(const char *format,...)
static struct macro_source_file * new_source_file(struct macro_table *t, const char *filename)
char * macro_source_fullname(struct macro_source_file *file)
char * macro_stringify(const char *str)
struct macro_source_file * macro_definition_location(struct macro_source_file *source, int line, const char *name, int *definition_line)
static struct macro_definition * new_macro_definition(struct macro_table *t, enum macro_kind kind, int argc, const char **argv, const char *replacement)
static struct macro_key * new_macro_key(struct macro_table *t, const char *name, struct macro_source_file *file, int line)
static splay_tree_node find_definition(const char *name, struct macro_source_file *file, int line)
static int key_compare(struct macro_key *key, const char *name, struct macro_source_file *file, int line)
struct macro_source_file * end_file
struct complaints * symfile_complaints
struct macro_source_file * main_source
static void macro_tree_delete_value(void *untyped_definition)
void free_macro_table(struct macro_table *table)
static void free_macro_source_file(struct macro_source_file *src)
struct macro_source_file * start_file
static void macro_free(void *object, struct macro_table *t)
void macro_for_each_in_scope(struct macro_source_file *file, int line, gdb::function_view< macro_callback_fn > fn)
struct macro_source_file * macro_set_main(struct macro_table *t, const char *filename)
void macro_allow_redefinitions(struct macro_table *t)
struct macro_source_file * macro_main(struct macro_table *t)
static void macro_bcache_free(struct macro_table *t, void *obj)
static int foreach_macro_in_scope(splay_tree_node node, void *info)
void macro_undef(struct macro_source_file *source, int line, const char *name)
struct macro_table * new_macro_table(struct obstack *obstack, struct bcache *b, struct compunit_symtab *cust)