diff options
author | David Carlton <carlton@bactrian.org> | 2003-04-15 23:07:11 +0000 |
---|---|---|
committer | David Carlton <carlton@bactrian.org> | 2003-04-15 23:07:11 +0000 |
commit | 72ce4edf8dba53bccdae1c88a56b8fcebdd50153 (patch) | |
tree | 0b5b02e08fdf06c78a872979fc0cbd6c3f676d6c /gdb/block.c | |
parent | 2bd4afdef7635ea1361f972b1d00df78cf688258 (diff) | |
download | gdb-72ce4edf8dba53bccdae1c88a56b8fcebdd50153.tar.gz |
2003-04-15 David Carlton <carlton@math.stanford.edu>
* Makefile.in (SFILES): Add cp-namespace.c.
(COMMON_OBS): Add cp-namespace.o.
(block.o): Depend on gdb_obstack_h and cp_support_h.
(buildsym.o): Depend on cp_support_h.
(cp-namespace.o): New.
(cp-support.o): Depend on gdb_string_h, demangle_h, gdb_assert_h,
gdb_obstack_h, symtab_h, symfile_h, and gdbcmd_h.
(dwarf2read.o): Depend on cp_support_h.
* jv-lang.c (get_java_class_symtab): Set BLOCK_NAMESPACE.
* dwarf2read.c (process_die): Set processing_has_namespace_info,
processing_current_namespace.
(read_namespace): Update processing_current_namespace; check for
anonymous namespaces.
(dwarf2_name): New function.
(dwarf2_extension): Ditto.
* cp-support.h: Update copyright, contributors.
Add inclusion guards.
Add opaque declaration for structs obstack, block, symbol.
(struct using_direct): New struct.
Add declarations for cp_find_first_component,
cp_entire_prefix_len, processing_has_namespace_info,
processing_current_namespace, cp_is_anonymous,
cp_add_using_directive, cp_initialize_namespace,
cp_finalize_namespace, cp_set_block_scope,
cp_scan_for_anonymous_namespaces.
* cp-namespace.c: New file.
* cp-support.c: Update copyright.
Include ctype.h, gdb_assert.h, gdbcmd.h.
New variable maint_cplus_cmd_list.
(cp_find_first_component): New function.
(cp_entire_prefix_len, maint_cplus_command)
(first_component_command, _initialize_cp_support): Ditto.
* buildsym.c: Include cp-support.h.
New variable using_list.
(add_symbol_to_list): Check for anonymous namespaces.
(finish_block): Set block's scope.
(start_symtab): Initialize C++ namespace support.
(end_symtab): Finalize C++ namespace support.
* block.h: Add opaque declarations for structs
block_namespace_info, using_direct, and obstack.
Add declarations for block_set_scope and block_set_using.
(struct block): Add 'language_specific' member.
(BLOCK_NAMESPACE): New macro.
* block.c: Include gdb_obstack.h and cp-support.h.
(struct block_namespace_info): New struct.
(block_set_scope): New function.
(block_set_using, block_initialize_namespace): Ditto.
2003-04-15 David Carlton <carlton@math.stanford.edu>
* gdb.c++/maint.exp: New file.
Diffstat (limited to 'gdb/block.c')
-rw-r--r-- | gdb/block.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/gdb/block.c b/gdb/block.c index 8aa08fb175d..7bfd8663848 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -23,6 +23,21 @@ #include "block.h" #include "symtab.h" #include "symfile.h" +#include "gdb_obstack.h" +#include "cp-support.h" + +/* This is used by struct block to store namespace-related info for + C++ files, namely using declarations and the current namespace in + scope. */ + +struct block_namespace_info +{ + const char *scope; + struct using_direct *using; +}; + +static void block_initialize_namespace (struct block *block, + struct obstack *obstack); /* Return Nonzero if block a is lexically nested within block b, or if a and b have the same pc range. @@ -139,3 +154,48 @@ block_for_pc (register CORE_ADDR pc) { return block_for_pc_sect (pc, find_pc_mapped_section (pc)); } + +/* Now come some functions designed to deal with C++ namespace + issues. */ + +/* Set BLOCK's scope member to SCOPE; if needed, allocate memory via + OBSTACK. (It won't make a copy of SCOPE, however, so that already + has to be allocated correctly.) */ + +void +block_set_scope (struct block *block, const char *scope, + struct obstack *obstack) +{ + block_initialize_namespace (block, obstack); + + BLOCK_NAMESPACE (block)->scope = scope; +} + +/* Set BLOCK's using member to USING; if needed, allocate memory via + OBSTACK. (It won't make a copy of USING, however, so that already + has to be allocated correctly.) */ + +void +block_set_using (struct block *block, + struct using_direct *using, + struct obstack *obstack) +{ + block_initialize_namespace (block, obstack); + + BLOCK_NAMESPACE (block)->using = using; +} + +/* If BLOCK_NAMESPACE (block) is NULL, allocate it via OBSTACK and + ititialize its members to zero. */ + +static void +block_initialize_namespace (struct block *block, struct obstack *obstack) +{ + if (BLOCK_NAMESPACE (block) == NULL) + { + BLOCK_NAMESPACE (block) + = obstack_alloc (obstack, sizeof (struct block_namespace_info)); + BLOCK_NAMESPACE (block)->scope = NULL; + BLOCK_NAMESPACE (block)->using = NULL; + } +} |