aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2015-02-09 14:59:05 +0000
committerPedro Alves <palves@redhat.com>2015-02-27 17:19:15 +0000
commit52059ffd6935427d02ee418be3eceeff6fd5c066 (patch)
tree5ea61d24cc0cc0bebe9493ba00afe8877a330955 /gdb/symtab.c
parentfe978cb071b460b2d4aed2f9a71d895f84efce0e (diff)
downloadgdb-52059ffd6935427d02ee418be3eceeff6fd5c066.zip
gdb-52059ffd6935427d02ee418be3eceeff6fd5c066.tar.gz
gdb-52059ffd6935427d02ee418be3eceeff6fd5c066.tar.bz2
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global scope just like it had been defined outside the struct in the first place. However, in C++, such a nested structure is given a name that is nested inside the structure. This patch moves such affected structures/enums out to global scope, so that code using them works the same in C++ as it works today in C. gdb/ChangeLog: 2015-02-27 Tom Tromey <tromey@redhat.com> Pedro Alves <palves@redhat.com> * dwarf2-frame.c (enum cfa_how_kind, struct dwarf2_frame_state_reg_info): Move out of struct dwarf2_frame_state. * dwarf2read.c (struct tu_stats): Move out of struct dwarf2_per_objfile. (struct file_entry): Move out of struct line_header. (struct nextfield, struct nextfnfield, struct fnfieldlist, struct typedef_field_list): Move out of struct field_info. * gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data): Move out of struct dynamic_prop. (union type_owner, union field_location, struct field, struct range_bounds, union type_specific): Move out of struct main_type. (struct fn_fieldlist, struct fn_field, struct typedef_field) (VOFFSET_STATIC): Move out of struct cplus_struct_type. (struct call_site_target, union call_site_parameter_u, struct call_site_parameter): Move out of struct call_site. * m32c-tdep.c (enum m32c_prologue_kind): Move out of struct m32c_prologue. (enum srcdest_kind): Move out of struct srcdest. * main.c (enum cmdarg_kind): Move out of struct cmdarg. * prologue-value.h (enum prologue_value_kind): Move out of struct prologue_value. * s390-linux-tdep.c (enum s390_abi_kind): Move out of struct gdbarch_tdep. * stabsread.c (struct nextfield, struct next_fnfieldlist): Move out of struct field_info. * symfile.h (struct other_sections): Move out of struct section_addr_info. * symtab.c (struct symbol_cache_slot): Move out struct block_symbol_cache. * target-descriptions.c (enum tdesc_type_kind): Move out of typedef struct tdesc_type. * tui/tui-data.h (enum tui_line_or_address_kind): Move out of struct tui_line_or_address. * value.c (enum internalvar_kind, union internalvar_data): Move out of struct internalvar. * xtensa-tdep.h (struct ctype_cache): Move out of struct gdbarch_tdep.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c66
1 files changed, 34 insertions, 32 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 81fdddf..12168cb 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -133,6 +133,39 @@ enum symbol_cache_slot_state
SYMBOL_SLOT_FOUND
};
+struct symbol_cache_slot
+{
+ enum symbol_cache_slot_state state;
+
+ /* The objfile that was current when the symbol was looked up.
+ This is only needed for global blocks, but for simplicity's sake
+ we allocate the space for both. If data shows the extra space used
+ for static blocks is a problem, we can split things up then.
+
+ Global blocks need cache lookup to include the objfile context because
+ we need to account for gdbarch_iterate_over_objfiles_in_search_order
+ which can traverse objfiles in, effectively, any order, depending on
+ the current objfile, thus affecting which symbol is found. Normally,
+ only the current objfile is searched first, and then the rest are
+ searched in recorded order; but putting cache lookup inside
+ gdbarch_iterate_over_objfiles_in_search_order would be awkward.
+ Instead we just make the current objfile part of the context of
+ cache lookup. This means we can record the same symbol multiple times,
+ each with a different "current objfile" that was in effect when the
+ lookup was saved in the cache, but cache space is pretty cheap. */
+ const struct objfile *objfile_context;
+
+ union
+ {
+ struct symbol *found;
+ struct
+ {
+ char *name;
+ domain_enum domain;
+ } not_found;
+ } value;
+};
+
/* Symbols don't specify global vs static block.
So keep them in separate caches. */
@@ -148,38 +181,7 @@ struct block_symbol_cache
on which to decide. */
unsigned int size;
- struct symbol_cache_slot
- {
- enum symbol_cache_slot_state state;
-
- /* The objfile that was current when the symbol was looked up.
- This is only needed for global blocks, but for simplicity's sake
- we allocate the space for both. If data shows the extra space used
- for static blocks is a problem, we can split things up then.
-
- Global blocks need cache lookup to include the objfile context because
- we need to account for gdbarch_iterate_over_objfiles_in_search_order
- which can traverse objfiles in, effectively, any order, depending on
- the current objfile, thus affecting which symbol is found. Normally,
- only the current objfile is searched first, and then the rest are
- searched in recorded order; but putting cache lookup inside
- gdbarch_iterate_over_objfiles_in_search_order would be awkward.
- Instead we just make the current objfile part of the context of
- cache lookup. This means we can record the same symbol multiple times,
- each with a different "current objfile" that was in effect when the
- lookup was saved in the cache, but cache space is pretty cheap. */
- const struct objfile *objfile_context;
-
- union
- {
- struct symbol *found;
- struct
- {
- char *name;
- domain_enum domain;
- } not_found;
- } value;
- } symbols[1];
+ struct symbol_cache_slot symbols[1];
};
/* The symbol cache.