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.
2003-04-16 01:07:11 +02:00
|
|
|
/* Helper routines for C++ support in GDB.
|
2015-01-01 10:32:14 +01:00
|
|
|
Copyright (C) 2003-2015 Free Software Foundation, Inc.
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
|
2003-05-20 05:56:29 +02:00
|
|
|
Contributed by David Carlton and by Kealia, Inc.
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-23 20:08:50 +02:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 20:08:50 +02:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "cp-support.h"
|
|
|
|
#include "gdb_obstack.h"
|
|
|
|
#include "symtab.h"
|
|
|
|
#include "symfile.h"
|
|
|
|
#include "block.h"
|
2003-09-11 David Carlton <carlton@kealia.com>
* gdbtypes.h: Add TYPE_CODE_NAMESPACE.
* gdbtypes.c (init_type): Handle TYPE_CODE_NAMESPACE.
(recursive_dump_type): Ditto.
* printcmd.c (print_formatted): Ditto.
* typeprint.c (print_type_scalar): Ditto.
* c-typeprint.c (c_type_print_varspec_prefix): Ditto.
(c_type_print_varspec_suffix, c_type_print_base): Ditto.
* cp-support.h: Declare cp_check_possible_namespace_symbols,
maint_cplus_cmd_list.
* cp-support.c: Make maint_cplus_cmd_list extern.
* cp-namespace.c: Include objfiles.h, gdbtypes.h, dictionary.h,
command.h.
(lookup_symbol_file): Look in possible namespace blocks when
appropriate.
(initialize_namespace_symtab): New.
(get_possible_namespace_block, free_namespace_block)
(check_possible_namespace_symbols)
(check_possible_namespace_symbols_loop)
(check_one_possible_namespace_symbol)
(lookup_possible_namespace_symbol, maintenance_cplus_namespace)
(_initialize_cp_namespace): Ditto.
* block.h: Declare allocate_block.
* block.c (allocate_block): New.
* jv-lang.c (get_java_class_symtab): Allocate blocks via
allocate_block.
* symfile.h: Update declaration of add_psymbol_to_list.
* symfile.c (add_psymbol_to_list): Return the partial symbol in
question.
* dwarf2read.c (dwarf2_build_psymtabs_hard): Add argument to
scan_partial_symbols_call.
(scan_partial_symbols): Add NAMESPACE argument; update calls to
helper functions.
(add_partial_symbol): If necessary, scan mangled names for names
of namespaces.
(add_partial_namespace): Add NAMESPACE argument; generate partial
symbols associated to namespaces.
(add_partial_enumeration): Add NAMESPACE argument.
(new_symbol): Allow namespace syms.
(read_namespace): Generate namespace syms.
* objfiles.h: Add opaque declaration of struct symtab.
(struct objfile): Add cp_namespace_symtab member.
* objfiles.c (allocate_objfile): Set
objfile->cp_namespace_symtab.
* Makefile.in (cp-namespace.o): Depend on objfiles_h, gdbtypes_h,
dictionary_h, command_h.
2003-09-11 David Carlton <carlton@kealia.com>
* gdb.c++/namespace.exp: Add tests for namespace types.
* gdb.c++/maint.exp (test_help): Test 'help maint cp namespace'.
(test_namespace): New.
2003-09-11 21:49:20 +02:00
|
|
|
#include "objfiles.h"
|
|
|
|
#include "gdbtypes.h"
|
|
|
|
#include "dictionary.h"
|
|
|
|
#include "command.h"
|
2004-01-24 00:03:31 +01:00
|
|
|
#include "frame.h"
|
2009-06-23 19:46:52 +02:00
|
|
|
#include "buildsym.h"
|
2010-07-28 18:23:59 +02:00
|
|
|
#include "language.h"
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
|
2014-12-22 18:11:44 +01:00
|
|
|
static struct symbol *
|
|
|
|
cp_lookup_nested_symbol_1 (struct type *container_type,
|
|
|
|
const char *nested_name,
|
|
|
|
const char *concatenated_name,
|
|
|
|
const struct block *block,
|
2015-05-27 21:17:37 +02:00
|
|
|
const domain_enum domain,
|
2015-02-22 06:58:31 +01:00
|
|
|
int basic_lookup, int is_in_anonymous);
|
2014-12-22 18:11:44 +01:00
|
|
|
|
2004-01-24 00:03:31 +01:00
|
|
|
static struct type *cp_lookup_transparent_type_loop (const char *name,
|
|
|
|
const char *scope,
|
|
|
|
int scope_len);
|
|
|
|
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
/* Check to see if SYMBOL refers to an object contained within an
|
|
|
|
anonymous namespace; if so, add an appropriate using directive. */
|
|
|
|
|
|
|
|
void
|
2011-10-20 22:06:14 +02:00
|
|
|
cp_scan_for_anonymous_namespaces (const struct symbol *const symbol,
|
|
|
|
struct objfile *const objfile)
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
{
|
2008-08-21 20:40:34 +02:00
|
|
|
if (SYMBOL_DEMANGLED_NAME (symbol) != NULL)
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
{
|
2008-08-21 20:40:34 +02:00
|
|
|
const char *name = SYMBOL_DEMANGLED_NAME (symbol);
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
unsigned int previous_component;
|
|
|
|
unsigned int next_component;
|
|
|
|
|
|
|
|
/* Start with a quick-and-dirty check for mention of "(anonymous
|
|
|
|
namespace)". */
|
|
|
|
|
2014-12-13 07:33:26 +01:00
|
|
|
if (!cp_is_in_anonymous (name))
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
previous_component = 0;
|
|
|
|
next_component = cp_find_first_component (name + previous_component);
|
|
|
|
|
|
|
|
while (name[next_component] == ':')
|
|
|
|
{
|
2011-05-31 23:54:07 +02:00
|
|
|
if (((next_component - previous_component)
|
|
|
|
== CP_ANONYMOUS_NAMESPACE_LEN)
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
&& strncmp (name + previous_component,
|
2011-05-31 23:54:07 +02:00
|
|
|
CP_ANONYMOUS_NAMESPACE_STR,
|
|
|
|
CP_ANONYMOUS_NAMESPACE_LEN) == 0)
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
{
|
2010-12-31 23:59:52 +01:00
|
|
|
int dest_len = (previous_component == 0
|
|
|
|
? 0 : previous_component - 2);
|
2009-07-07 19:25:11 +02:00
|
|
|
int src_len = next_component;
|
2009-06-29 17:18:07 +02:00
|
|
|
|
2009-07-07 19:25:11 +02:00
|
|
|
char *dest = alloca (dest_len + 1);
|
|
|
|
char *src = alloca (src_len + 1);
|
2009-06-29 17:18:07 +02:00
|
|
|
|
2009-07-07 19:25:11 +02:00
|
|
|
memcpy (dest, name, dest_len);
|
|
|
|
memcpy (src, name, src_len);
|
2009-06-29 17:18:07 +02:00
|
|
|
|
2009-07-07 19:25:11 +02:00
|
|
|
dest[dest_len] = '\0';
|
|
|
|
src[src_len] = '\0';
|
2009-06-29 17:18:07 +02:00
|
|
|
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
/* We've found a component of the name that's an
|
|
|
|
anonymous namespace. So add symbols in it to the
|
|
|
|
namespace given by the previous component if there is
|
|
|
|
one, or to the global namespace if there isn't. */
|
2013-01-25 18:36:01 +01:00
|
|
|
cp_add_using_directive (dest, src, NULL, NULL, NULL, 1,
|
2011-10-20 22:06:14 +02:00
|
|
|
&objfile->objfile_obstack);
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
}
|
|
|
|
/* The "+ 2" is for the "::". */
|
|
|
|
previous_component = next_component + 2;
|
|
|
|
next_component = (previous_component
|
|
|
|
+ cp_find_first_component (name
|
|
|
|
+ previous_component));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
/* Add a using directive to using_directives. If the using directive
|
|
|
|
in question has already been added, don't add it twice.
|
|
|
|
|
|
|
|
Create a new struct using_direct which imports the namespace SRC
|
|
|
|
into the scope DEST. ALIAS is the name of the imported namespace
|
|
|
|
in the current scope. If ALIAS is NULL then the namespace is known
|
|
|
|
by its original name. DECLARATION is the name if the imported
|
|
|
|
varable if this is a declaration import (Eg. using A::x), otherwise
|
2013-01-25 18:36:01 +01:00
|
|
|
it is NULL. EXCLUDES is a list of names not to import from an
|
|
|
|
imported module or NULL. If COPY_NAMES is non-zero, then the
|
|
|
|
arguments are copied into newly allocated memory so they can be
|
|
|
|
temporaries. For EXCLUDES the VEC pointers are copied but the
|
gdb/
Fix non-only rename list for Fortran modules import.
* cp-namespace.c (cp_scan_for_anonymous_namespaces): Adjust the
cp_add_using_directive caller.
(cp_add_using_directive): New parameter excludes, describe it. New
variables ix and param. Compare if also excludes match. Allocate NEW
with variable size, initialize EXCLUDES there.
(cp_lookup_symbol_imports): New variable excludep, test
current->EXCLUDES with it.
* cp-support.h: Include vec.h.
(struct using_direct): New field excludes, describe it.
(DEF_VEC_P (const_char_ptr)): New.
(cp_add_using_directive): New parameter excludes.
* defs.h (const_char_ptr): New typedef.
* dwarf2read.c (read_import_statement): New variables child_die,
excludes and cleanups, read in excludes.
(read_namespace): Adjust the cp_add_using_directive caller.
gdb/testsuite/
Fix non-only rename list for Fortran modules import.
* gdb.fortran/module.exp (print var_x, print var_y, print var_z): New
tests.
* gdb.fortran/module.f90 (module moduse): New.
(program module): use moduse, test var_x, var_y and var_z.
2011-06-30 00:05:16 +02:00
|
|
|
pointed to characters are not copied. */
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
|
|
|
|
void
|
2010-03-15 18:29:36 +01:00
|
|
|
cp_add_using_directive (const char *dest,
|
|
|
|
const char *src,
|
|
|
|
const char *alias,
|
|
|
|
const char *declaration,
|
gdb/
Fix non-only rename list for Fortran modules import.
* cp-namespace.c (cp_scan_for_anonymous_namespaces): Adjust the
cp_add_using_directive caller.
(cp_add_using_directive): New parameter excludes, describe it. New
variables ix and param. Compare if also excludes match. Allocate NEW
with variable size, initialize EXCLUDES there.
(cp_lookup_symbol_imports): New variable excludep, test
current->EXCLUDES with it.
* cp-support.h: Include vec.h.
(struct using_direct): New field excludes, describe it.
(DEF_VEC_P (const_char_ptr)): New.
(cp_add_using_directive): New parameter excludes.
* defs.h (const_char_ptr): New typedef.
* dwarf2read.c (read_import_statement): New variables child_die,
excludes and cleanups, read in excludes.
(read_namespace): Adjust the cp_add_using_directive caller.
gdb/testsuite/
Fix non-only rename list for Fortran modules import.
* gdb.fortran/module.exp (print var_x, print var_y, print var_z): New
tests.
* gdb.fortran/module.f90 (module moduse): New.
(program module): use moduse, test var_x, var_y and var_z.
2011-06-30 00:05:16 +02:00
|
|
|
VEC (const_char_ptr) *excludes,
|
2013-01-25 18:36:01 +01:00
|
|
|
int copy_names,
|
2010-03-10 17:22:29 +01:00
|
|
|
struct obstack *obstack)
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
{
|
|
|
|
struct using_direct *current;
|
2015-02-27 17:33:07 +01:00
|
|
|
struct using_direct *newobj;
|
2014-12-22 17:42:02 +01:00
|
|
|
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
/* Has it already been added? */
|
|
|
|
|
2009-06-23 19:46:52 +02:00
|
|
|
for (current = using_directives; current != NULL; current = current->next)
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
{
|
gdb/
Fix non-only rename list for Fortran modules import.
* cp-namespace.c (cp_scan_for_anonymous_namespaces): Adjust the
cp_add_using_directive caller.
(cp_add_using_directive): New parameter excludes, describe it. New
variables ix and param. Compare if also excludes match. Allocate NEW
with variable size, initialize EXCLUDES there.
(cp_lookup_symbol_imports): New variable excludep, test
current->EXCLUDES with it.
* cp-support.h: Include vec.h.
(struct using_direct): New field excludes, describe it.
(DEF_VEC_P (const_char_ptr)): New.
(cp_add_using_directive): New parameter excludes.
* defs.h (const_char_ptr): New typedef.
* dwarf2read.c (read_import_statement): New variables child_die,
excludes and cleanups, read in excludes.
(read_namespace): Adjust the cp_add_using_directive caller.
gdb/testsuite/
Fix non-only rename list for Fortran modules import.
* gdb.fortran/module.exp (print var_x, print var_y, print var_z): New
tests.
* gdb.fortran/module.f90 (module moduse): New.
(program module): use moduse, test var_x, var_y and var_z.
2011-06-30 00:05:16 +02:00
|
|
|
int ix;
|
|
|
|
const char *param;
|
|
|
|
|
2011-06-30 00:02:58 +02:00
|
|
|
if (strcmp (current->import_src, src) != 0)
|
|
|
|
continue;
|
|
|
|
if (strcmp (current->import_dest, dest) != 0)
|
|
|
|
continue;
|
|
|
|
if ((alias == NULL && current->alias != NULL)
|
|
|
|
|| (alias != NULL && current->alias == NULL)
|
|
|
|
|| (alias != NULL && current->alias != NULL
|
|
|
|
&& strcmp (alias, current->alias) != 0))
|
|
|
|
continue;
|
|
|
|
if ((declaration == NULL && current->declaration != NULL)
|
|
|
|
|| (declaration != NULL && current->declaration == NULL)
|
|
|
|
|| (declaration != NULL && current->declaration != NULL
|
|
|
|
&& strcmp (declaration, current->declaration) != 0))
|
|
|
|
continue;
|
|
|
|
|
gdb/
Fix non-only rename list for Fortran modules import.
* cp-namespace.c (cp_scan_for_anonymous_namespaces): Adjust the
cp_add_using_directive caller.
(cp_add_using_directive): New parameter excludes, describe it. New
variables ix and param. Compare if also excludes match. Allocate NEW
with variable size, initialize EXCLUDES there.
(cp_lookup_symbol_imports): New variable excludep, test
current->EXCLUDES with it.
* cp-support.h: Include vec.h.
(struct using_direct): New field excludes, describe it.
(DEF_VEC_P (const_char_ptr)): New.
(cp_add_using_directive): New parameter excludes.
* defs.h (const_char_ptr): New typedef.
* dwarf2read.c (read_import_statement): New variables child_die,
excludes and cleanups, read in excludes.
(read_namespace): Adjust the cp_add_using_directive caller.
gdb/testsuite/
Fix non-only rename list for Fortran modules import.
* gdb.fortran/module.exp (print var_x, print var_y, print var_z): New
tests.
* gdb.fortran/module.f90 (module moduse): New.
(program module): use moduse, test var_x, var_y and var_z.
2011-06-30 00:05:16 +02:00
|
|
|
/* Compare the contents of EXCLUDES. */
|
|
|
|
for (ix = 0; VEC_iterate (const_char_ptr, excludes, ix, param); ix++)
|
|
|
|
if (current->excludes[ix] == NULL
|
|
|
|
|| strcmp (param, current->excludes[ix]) != 0)
|
|
|
|
break;
|
|
|
|
if (ix < VEC_length (const_char_ptr, excludes)
|
|
|
|
|| current->excludes[ix] != NULL)
|
|
|
|
continue;
|
|
|
|
|
2011-06-30 00:02:58 +02:00
|
|
|
/* Parameters exactly match CURRENT. */
|
|
|
|
return;
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
}
|
|
|
|
|
2015-02-27 17:33:07 +01:00
|
|
|
newobj = obstack_alloc (obstack, (sizeof (*newobj)
|
gdb/
Fix non-only rename list for Fortran modules import.
* cp-namespace.c (cp_scan_for_anonymous_namespaces): Adjust the
cp_add_using_directive caller.
(cp_add_using_directive): New parameter excludes, describe it. New
variables ix and param. Compare if also excludes match. Allocate NEW
with variable size, initialize EXCLUDES there.
(cp_lookup_symbol_imports): New variable excludep, test
current->EXCLUDES with it.
* cp-support.h: Include vec.h.
(struct using_direct): New field excludes, describe it.
(DEF_VEC_P (const_char_ptr)): New.
(cp_add_using_directive): New parameter excludes.
* defs.h (const_char_ptr): New typedef.
* dwarf2read.c (read_import_statement): New variables child_die,
excludes and cleanups, read in excludes.
(read_namespace): Adjust the cp_add_using_directive caller.
gdb/testsuite/
Fix non-only rename list for Fortran modules import.
* gdb.fortran/module.exp (print var_x, print var_y, print var_z): New
tests.
* gdb.fortran/module.f90 (module moduse): New.
(program module): use moduse, test var_x, var_y and var_z.
2011-06-30 00:05:16 +02:00
|
|
|
+ (VEC_length (const_char_ptr, excludes)
|
2015-02-27 17:33:07 +01:00
|
|
|
* sizeof (*newobj->excludes))));
|
|
|
|
memset (newobj, 0, sizeof (*newobj));
|
2010-03-10 17:22:29 +01:00
|
|
|
|
2013-01-25 18:36:01 +01:00
|
|
|
if (copy_names)
|
|
|
|
{
|
2015-02-27 17:33:07 +01:00
|
|
|
newobj->import_src = obstack_copy0 (obstack, src, strlen (src));
|
|
|
|
newobj->import_dest = obstack_copy0 (obstack, dest, strlen (dest));
|
2013-01-25 18:36:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-27 17:33:07 +01:00
|
|
|
newobj->import_src = src;
|
|
|
|
newobj->import_dest = dest;
|
2013-01-25 18:36:01 +01:00
|
|
|
}
|
2009-06-29 17:18:07 +02:00
|
|
|
|
2013-01-25 18:36:01 +01:00
|
|
|
if (alias != NULL && copy_names)
|
2015-02-27 17:33:07 +01:00
|
|
|
newobj->alias = obstack_copy0 (obstack, alias, strlen (alias));
|
2013-01-25 18:36:01 +01:00
|
|
|
else
|
2015-02-27 17:33:07 +01:00
|
|
|
newobj->alias = alias;
|
2010-03-10 17:22:29 +01:00
|
|
|
|
2013-01-25 18:36:01 +01:00
|
|
|
if (declaration != NULL && copy_names)
|
2015-02-27 17:33:07 +01:00
|
|
|
newobj->declaration = obstack_copy0 (obstack,
|
* symfile.h (obsavestring): Don't declare.
* symfile.c (obsavestring): Remove.
* ada-exp.y: Use obstack_copy0, not obsavestring.
* ada-lang.c: Use obstack_copy0, not obsavestring.
* coffread.c: Use obstack_copy0, not obsavestring.
* cp-namespace.c: Use obstack_copy0, not obsavestring.
* dbxread.c: Use obstack_copy0, not obsavestring.
* dwarf2read.c: Use obstack_copy0, not obsavestring.
* jit.c: Use obstack_copy0, not obsavestring.
* mdebugread.c: Use obstack_copy0, not obsavestring.
* psymtab.c: Use obstack_copy0, not obsavestring.
* stabsread.c: Use obstack_copy0, not obsavestring.
* xcoffread.c: Use obstack_copy0, not obsavestring.
2013-01-21 19:13:14 +01:00
|
|
|
declaration, strlen (declaration));
|
2013-01-25 18:36:01 +01:00
|
|
|
else
|
2015-02-27 17:33:07 +01:00
|
|
|
newobj->declaration = declaration;
|
2010-03-15 18:29:36 +01:00
|
|
|
|
2015-02-27 17:33:07 +01:00
|
|
|
memcpy (newobj->excludes, VEC_address (const_char_ptr, excludes),
|
|
|
|
VEC_length (const_char_ptr, excludes) * sizeof (*newobj->excludes));
|
|
|
|
newobj->excludes[VEC_length (const_char_ptr, excludes)] = NULL;
|
gdb/
Fix non-only rename list for Fortran modules import.
* cp-namespace.c (cp_scan_for_anonymous_namespaces): Adjust the
cp_add_using_directive caller.
(cp_add_using_directive): New parameter excludes, describe it. New
variables ix and param. Compare if also excludes match. Allocate NEW
with variable size, initialize EXCLUDES there.
(cp_lookup_symbol_imports): New variable excludep, test
current->EXCLUDES with it.
* cp-support.h: Include vec.h.
(struct using_direct): New field excludes, describe it.
(DEF_VEC_P (const_char_ptr)): New.
(cp_add_using_directive): New parameter excludes.
* defs.h (const_char_ptr): New typedef.
* dwarf2read.c (read_import_statement): New variables child_die,
excludes and cleanups, read in excludes.
(read_namespace): Adjust the cp_add_using_directive caller.
gdb/testsuite/
Fix non-only rename list for Fortran modules import.
* gdb.fortran/module.exp (print var_x, print var_y, print var_z): New
tests.
* gdb.fortran/module.f90 (module moduse): New.
(program module): use moduse, test var_x, var_y and var_z.
2011-06-30 00:05:16 +02:00
|
|
|
|
2015-02-27 17:33:07 +01:00
|
|
|
newobj->next = using_directives;
|
|
|
|
using_directives = newobj;
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Test whether or not NAMESPACE looks like it mentions an anonymous
|
|
|
|
namespace; return nonzero if so. */
|
|
|
|
|
|
|
|
int
|
2014-12-13 07:33:26 +01:00
|
|
|
cp_is_in_anonymous (const char *symbol_name)
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
{
|
2014-12-13 07:33:26 +01:00
|
|
|
return (strstr (symbol_name, CP_ANONYMOUS_NAMESPACE_STR)
|
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.
2003-04-16 01:07:11 +02:00
|
|
|
!= NULL);
|
|
|
|
}
|
|
|
|
|
2014-12-22 18:11:44 +01:00
|
|
|
/* Look up NAME in DOMAIN in BLOCK's static block and in global blocks.
|
2015-02-13 21:03:50 +01:00
|
|
|
If IS_IN_ANONYMOUS is nonzero, the symbol in question is located
|
2014-12-22 18:11:44 +01:00
|
|
|
within an anonymous namespace. */
|
2014-12-10 19:21:31 +01:00
|
|
|
|
|
|
|
static struct symbol *
|
2014-12-22 18:11:44 +01:00
|
|
|
cp_basic_lookup_symbol (const char *name, const struct block *block,
|
2015-02-13 21:03:50 +01:00
|
|
|
const domain_enum domain, int is_in_anonymous)
|
2014-12-10 19:21:31 +01:00
|
|
|
{
|
2014-12-22 18:11:44 +01:00
|
|
|
struct symbol *sym;
|
2014-12-10 19:21:31 +01:00
|
|
|
|
|
|
|
sym = lookup_symbol_in_static_block (name, block, domain);
|
|
|
|
if (sym != NULL)
|
|
|
|
return sym;
|
|
|
|
|
2015-02-13 21:03:50 +01:00
|
|
|
if (is_in_anonymous)
|
2014-12-10 19:21:31 +01:00
|
|
|
{
|
|
|
|
/* Symbols defined in anonymous namespaces have external linkage
|
|
|
|
but should be treated as local to a single file nonetheless.
|
|
|
|
So we only search the current file's global block. */
|
|
|
|
|
|
|
|
const struct block *global_block = block_global_block (block);
|
2014-12-22 17:42:02 +01:00
|
|
|
|
2014-12-10 19:21:31 +01:00
|
|
|
if (global_block != NULL)
|
|
|
|
sym = lookup_symbol_in_block (name, global_block, domain);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sym = lookup_global_symbol (name, block, domain);
|
|
|
|
}
|
|
|
|
|
2014-12-22 18:11:44 +01:00
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Search bare symbol NAME in DOMAIN in BLOCK.
|
2014-12-23 16:55:39 +01:00
|
|
|
NAME is guaranteed to not have any scope (no "::") in its name, though
|
|
|
|
if for example NAME is a template spec then "::" may appear in the
|
|
|
|
argument list.
|
|
|
|
If LANGDEF is non-NULL then try to lookup NAME as a primitive type in
|
|
|
|
that language. Normally we wouldn't need LANGDEF but fortran also uses
|
|
|
|
this code.
|
2014-12-22 18:11:44 +01:00
|
|
|
If SEARCH is non-zero then see if we can determine "this" from BLOCK, and
|
|
|
|
if so then also search for NAME in that class. */
|
|
|
|
|
|
|
|
static struct symbol *
|
2014-12-23 16:55:39 +01:00
|
|
|
cp_lookup_bare_symbol (const struct language_defn *langdef,
|
|
|
|
const char *name, const struct block *block,
|
2014-12-22 18:11:44 +01:00
|
|
|
const domain_enum domain, int search)
|
|
|
|
{
|
|
|
|
struct symbol *sym;
|
|
|
|
|
|
|
|
/* Note: We can't do a simple assert for ':' not being in NAME because
|
|
|
|
':' may be in the args of a template spec. This isn't intended to be
|
|
|
|
a complete test, just cheap and documentary. */
|
|
|
|
if (strchr (name, '<') == NULL && strchr (name, '(') == NULL)
|
|
|
|
gdb_assert (strchr (name, ':') == NULL);
|
|
|
|
|
|
|
|
sym = lookup_symbol_in_static_block (name, block, domain);
|
|
|
|
if (sym != NULL)
|
|
|
|
return sym;
|
|
|
|
|
2014-12-23 16:55:39 +01:00
|
|
|
/* If we didn't find a definition for a builtin type in the static block,
|
|
|
|
search for it now. This is actually the right thing to do and can be
|
|
|
|
a massive performance win. E.g., when debugging a program with lots of
|
|
|
|
shared libraries we could search all of them only to find out the
|
|
|
|
builtin type isn't defined in any of them. This is common for types
|
|
|
|
like "void". */
|
|
|
|
if (langdef != NULL && domain == VAR_DOMAIN)
|
|
|
|
{
|
|
|
|
struct gdbarch *gdbarch;
|
|
|
|
|
|
|
|
if (block == NULL)
|
|
|
|
gdbarch = target_gdbarch ();
|
|
|
|
else
|
|
|
|
gdbarch = block_gdbarch (block);
|
|
|
|
sym = language_lookup_primitive_type_as_symbol (langdef, gdbarch, name);
|
|
|
|
if (sym != NULL)
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
2014-12-22 18:11:44 +01:00
|
|
|
sym = lookup_global_symbol (name, block, domain);
|
2014-12-10 19:21:31 +01:00
|
|
|
if (sym != NULL)
|
|
|
|
return sym;
|
|
|
|
|
|
|
|
if (search)
|
|
|
|
{
|
2015-02-27 17:33:07 +01:00
|
|
|
struct symbol *lang_this;
|
2014-12-22 18:11:44 +01:00
|
|
|
struct type *type;
|
2014-12-10 19:21:31 +01:00
|
|
|
|
2015-02-27 17:33:07 +01:00
|
|
|
lang_this = lookup_language_this (language_def (language_cplus), block);
|
|
|
|
if (lang_this == NULL)
|
2014-12-22 18:11:44 +01:00
|
|
|
return NULL;
|
2014-12-10 19:21:31 +01:00
|
|
|
|
2015-02-27 17:33:07 +01:00
|
|
|
type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (lang_this)));
|
2014-12-22 18:11:44 +01:00
|
|
|
/* If TYPE_NAME is NULL, abandon trying to find this symbol.
|
|
|
|
This can happen for lambda functions compiled with clang++,
|
|
|
|
which outputs no name for the container class. */
|
|
|
|
if (TYPE_NAME (type) == NULL)
|
|
|
|
return NULL;
|
2014-12-10 19:21:31 +01:00
|
|
|
|
2015-02-13 21:03:50 +01:00
|
|
|
/* Look for symbol NAME in this class. */
|
2015-05-27 21:17:37 +02:00
|
|
|
sym = cp_lookup_nested_symbol (type, name, block, domain);
|
2014-12-22 18:11:44 +01:00
|
|
|
}
|
2014-12-10 19:21:31 +01:00
|
|
|
|
2014-12-22 18:11:44 +01:00
|
|
|
return sym;
|
|
|
|
}
|
2014-12-10 19:21:31 +01:00
|
|
|
|
2014-12-22 18:11:44 +01:00
|
|
|
/* Search NAME in DOMAIN in all static blocks, and then in all baseclasses.
|
|
|
|
BLOCK specifies the context in which to perform the search.
|
|
|
|
NAME is guaranteed to have scope (contain "::") and PREFIX_LEN specifies
|
2015-02-13 21:03:50 +01:00
|
|
|
the length of the entire scope of NAME (up to, but not including, the last
|
2014-12-22 18:11:44 +01:00
|
|
|
"::".
|
2014-12-10 19:21:31 +01:00
|
|
|
|
2014-12-22 18:11:44 +01:00
|
|
|
Note: At least in the case of Fortran, which also uses this code, there
|
|
|
|
may be no text after the last "::". */
|
2014-12-10 19:21:31 +01:00
|
|
|
|
2014-12-22 18:11:44 +01:00
|
|
|
static struct symbol *
|
|
|
|
cp_search_static_and_baseclasses (const char *name,
|
|
|
|
const struct block *block,
|
|
|
|
const domain_enum domain,
|
2015-02-22 06:58:31 +01:00
|
|
|
unsigned int prefix_len,
|
|
|
|
int is_in_anonymous)
|
2014-12-22 18:11:44 +01:00
|
|
|
{
|
|
|
|
struct symbol *sym;
|
|
|
|
char *klass, *nested;
|
|
|
|
struct cleanup *cleanup;
|
|
|
|
struct symbol *klass_sym;
|
|
|
|
struct type *klass_type;
|
2014-12-10 19:21:31 +01:00
|
|
|
|
2014-12-22 18:11:44 +01:00
|
|
|
/* The test here uses <= instead of < because Fortran also uses this,
|
|
|
|
and the module.exp testcase will pass "modmany::" for NAME here. */
|
|
|
|
gdb_assert (prefix_len + 2 <= strlen (name));
|
|
|
|
gdb_assert (name[prefix_len + 1] == ':');
|
2014-12-10 19:21:31 +01:00
|
|
|
|
2014-12-22 18:11:44 +01:00
|
|
|
/* Find the name of the class and the name of the method, variable, etc. */
|
2014-12-10 19:21:31 +01:00
|
|
|
|
2014-12-22 18:11:44 +01:00
|
|
|
/* The class name is everything up to and including PREFIX_LEN. */
|
|
|
|
klass = savestring (name, prefix_len);
|
|
|
|
|
|
|
|
/* The rest of the name is everything else past the initial scope
|
|
|
|
operator. */
|
|
|
|
nested = xstrdup (name + prefix_len + 2);
|
|
|
|
|
|
|
|
/* Add cleanups to free memory for these strings. */
|
|
|
|
cleanup = make_cleanup (xfree, klass);
|
|
|
|
make_cleanup (xfree, nested);
|
|
|
|
|
|
|
|
/* Lookup a class named KLASS. If none is found, there is nothing
|
2015-03-31 01:41:05 +02:00
|
|
|
more that can be done. KLASS could be a namespace, so always look
|
|
|
|
in VAR_DOMAIN. This works for classes too because of
|
|
|
|
symbol_matches_domain (which should be replaced with something else,
|
|
|
|
but it's what we have today). */
|
|
|
|
klass_sym = lookup_global_symbol (klass, block, VAR_DOMAIN);
|
2014-12-22 18:11:44 +01:00
|
|
|
if (klass_sym == NULL)
|
|
|
|
{
|
2014-12-10 19:21:31 +01:00
|
|
|
do_cleanups (cleanup);
|
2014-12-22 18:11:44 +01:00
|
|
|
return NULL;
|
2014-12-10 19:21:31 +01:00
|
|
|
}
|
2014-12-22 18:11:44 +01:00
|
|
|
klass_type = SYMBOL_TYPE (klass_sym);
|
|
|
|
|
|
|
|
/* Look for a symbol named NESTED in this class.
|
|
|
|
The caller is assumed to have already have done a basic lookup of NAME.
|
|
|
|
So we pass zero for BASIC_LOOKUP to cp_lookup_nested_symbol_1 here. */
|
2015-05-27 21:17:37 +02:00
|
|
|
sym = cp_lookup_nested_symbol_1 (klass_type, nested, name, block, domain,
|
|
|
|
0, is_in_anonymous);
|
2014-12-10 19:21:31 +01:00
|
|
|
|
2014-12-22 18:11:44 +01:00
|
|
|
do_cleanups (cleanup);
|
2014-12-10 19:21:31 +01:00
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
/* Look up NAME in the C++ namespace NAMESPACE. Other arguments are
|
2012-11-16 21:54:30 +01:00
|
|
|
as in cp_lookup_symbol_nonlocal. If SEARCH is non-zero, search
|
2014-12-22 18:11:44 +01:00
|
|
|
through base classes for a matching symbol.
|
|
|
|
|
|
|
|
Note: Part of the complexity is because NAME may itself specify scope.
|
|
|
|
Part of the complexity is also because this handles the case where
|
|
|
|
there is no scoping in which case we also try looking in the class of
|
|
|
|
"this" if we can compute it. */
|
2010-01-26 16:48:25 +01:00
|
|
|
|
|
|
|
static struct symbol *
|
2015-02-27 17:33:07 +01:00
|
|
|
cp_lookup_symbol_in_namespace (const char *the_namespace, const char *name,
|
2014-12-22 18:11:44 +01:00
|
|
|
const struct block *block,
|
|
|
|
const domain_enum domain, int search)
|
2010-01-26 16:48:25 +01:00
|
|
|
{
|
2014-12-22 17:44:50 +01:00
|
|
|
char *concatenated_name = NULL;
|
2014-12-22 18:11:44 +01:00
|
|
|
int is_in_anonymous;
|
|
|
|
unsigned int prefix_len;
|
|
|
|
struct symbol *sym;
|
2010-05-14 01:53:32 +02:00
|
|
|
|
2015-02-27 17:33:07 +01:00
|
|
|
if (the_namespace[0] != '\0')
|
2014-12-22 17:44:50 +01:00
|
|
|
{
|
2015-02-27 17:33:07 +01:00
|
|
|
concatenated_name = alloca (strlen (the_namespace) + 2
|
2014-12-22 17:44:50 +01:00
|
|
|
+ strlen (name) + 1);
|
2015-02-27 17:33:07 +01:00
|
|
|
strcpy (concatenated_name, the_namespace);
|
2010-01-26 16:48:25 +01:00
|
|
|
strcat (concatenated_name, "::");
|
|
|
|
strcat (concatenated_name, name);
|
2014-12-22 17:44:50 +01:00
|
|
|
name = concatenated_name;
|
2010-01-26 16:48:25 +01:00
|
|
|
}
|
2014-12-22 17:44:50 +01:00
|
|
|
|
2014-12-22 18:11:44 +01:00
|
|
|
prefix_len = cp_entire_prefix_len (name);
|
|
|
|
if (prefix_len == 0)
|
2014-12-23 16:55:39 +01:00
|
|
|
return cp_lookup_bare_symbol (NULL, name, block, domain, search);
|
2014-12-22 18:11:44 +01:00
|
|
|
|
|
|
|
/* This would be simpler if we just called cp_lookup_nested_symbol
|
|
|
|
at this point. But that would require first looking up the containing
|
|
|
|
class/namespace. Since we're only searching static and global blocks
|
|
|
|
there's often no need to first do that lookup. */
|
|
|
|
|
2015-02-27 17:33:07 +01:00
|
|
|
is_in_anonymous
|
|
|
|
= the_namespace[0] != '\0' && cp_is_in_anonymous (the_namespace);
|
2014-12-22 18:11:44 +01:00
|
|
|
sym = cp_basic_lookup_symbol (name, block, domain, is_in_anonymous);
|
|
|
|
if (sym != NULL)
|
|
|
|
return sym;
|
|
|
|
|
|
|
|
if (search)
|
2015-02-22 06:58:31 +01:00
|
|
|
sym = cp_search_static_and_baseclasses (name, block, domain, prefix_len,
|
|
|
|
is_in_anonymous);
|
2014-12-22 18:11:44 +01:00
|
|
|
|
|
|
|
return sym;
|
2010-01-26 16:48:25 +01:00
|
|
|
}
|
|
|
|
|
2015-02-13 21:03:50 +01:00
|
|
|
/* Used for cleanups to reset the "searched" flag in case of an error. */
|
2010-01-26 17:47:35 +01:00
|
|
|
|
|
|
|
static void
|
|
|
|
reset_directive_searched (void *data)
|
|
|
|
{
|
|
|
|
struct using_direct *direct = data;
|
|
|
|
direct->searched = 0;
|
|
|
|
}
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
/* Search for NAME by applying all import statements belonging to
|
|
|
|
BLOCK which are applicable in SCOPE. If DECLARATION_ONLY the
|
|
|
|
search is restricted to using declarations.
|
2010-03-15 18:29:36 +01:00
|
|
|
Example:
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
namespace A {
|
2010-03-15 18:29:36 +01:00
|
|
|
int x;
|
|
|
|
}
|
|
|
|
using A::x;
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
If SEARCH_PARENTS the search will include imports which are
|
|
|
|
applicable in parents of SCOPE.
|
2010-01-26 17:47:35 +01:00
|
|
|
Example:
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
namespace A {
|
2010-01-26 17:47:35 +01:00
|
|
|
using namespace X;
|
2010-12-31 23:59:52 +01:00
|
|
|
namespace B {
|
2010-01-26 17:47:35 +01:00
|
|
|
using namespace Y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
If SCOPE is "A::B" and SEARCH_PARENTS is true the imports of
|
|
|
|
namespaces X and Y will be considered. If SEARCH_PARENTS is false
|
2014-12-22 18:20:50 +01:00
|
|
|
only the import of Y is considered.
|
|
|
|
|
|
|
|
SEARCH_SCOPE_FIRST is an internal implementation detail: Callers must
|
|
|
|
pass 0 for it. Internally we pass 1 when recursing. */
|
2010-01-26 16:48:25 +01:00
|
|
|
|
2014-12-10 19:04:00 +01:00
|
|
|
static struct symbol *
|
2014-12-17 07:19:15 +01:00
|
|
|
cp_lookup_symbol_via_imports (const char *scope,
|
|
|
|
const char *name,
|
|
|
|
const struct block *block,
|
|
|
|
const domain_enum domain,
|
2014-12-22 18:20:50 +01:00
|
|
|
const int search_scope_first,
|
2014-12-17 07:19:15 +01:00
|
|
|
const int declaration_only,
|
|
|
|
const int search_parents)
|
2010-01-26 16:48:25 +01:00
|
|
|
{
|
2010-01-26 17:47:35 +01:00
|
|
|
struct using_direct *current;
|
2010-03-15 18:29:36 +01:00
|
|
|
struct symbol *sym = NULL;
|
2010-01-26 16:48:25 +01:00
|
|
|
int len;
|
2010-01-26 17:47:35 +01:00
|
|
|
int directive_match;
|
|
|
|
struct cleanup *searched_cleanup;
|
2010-01-26 16:48:25 +01:00
|
|
|
|
2014-12-22 18:20:50 +01:00
|
|
|
/* First, try to find the symbol in the given namespace if requested. */
|
|
|
|
if (search_scope_first)
|
2010-12-31 23:59:52 +01:00
|
|
|
sym = cp_lookup_symbol_in_namespace (scope, name,
|
2012-11-16 21:54:30 +01:00
|
|
|
block, domain, 1);
|
2014-12-22 17:42:02 +01:00
|
|
|
|
2010-01-26 16:48:25 +01:00
|
|
|
if (sym != NULL)
|
|
|
|
return sym;
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
/* Go through the using directives. If any of them add new names to
|
|
|
|
the namespace we're searching in, see if we can find a match by
|
|
|
|
applying them. */
|
2010-01-26 16:48:25 +01:00
|
|
|
|
|
|
|
for (current = block_using (block);
|
|
|
|
current != NULL;
|
|
|
|
current = current->next)
|
|
|
|
{
|
gdb/
Fix non-only rename list for Fortran modules import.
* cp-namespace.c (cp_scan_for_anonymous_namespaces): Adjust the
cp_add_using_directive caller.
(cp_add_using_directive): New parameter excludes, describe it. New
variables ix and param. Compare if also excludes match. Allocate NEW
with variable size, initialize EXCLUDES there.
(cp_lookup_symbol_imports): New variable excludep, test
current->EXCLUDES with it.
* cp-support.h: Include vec.h.
(struct using_direct): New field excludes, describe it.
(DEF_VEC_P (const_char_ptr)): New.
(cp_add_using_directive): New parameter excludes.
* defs.h (const_char_ptr): New typedef.
* dwarf2read.c (read_import_statement): New variables child_die,
excludes and cleanups, read in excludes.
(read_namespace): Adjust the cp_add_using_directive caller.
gdb/testsuite/
Fix non-only rename list for Fortran modules import.
* gdb.fortran/module.exp (print var_x, print var_y, print var_z): New
tests.
* gdb.fortran/module.f90 (module moduse): New.
(program module): use moduse, test var_x, var_y and var_z.
2011-06-30 00:05:16 +02:00
|
|
|
const char **excludep;
|
|
|
|
|
2010-01-26 17:47:35 +01:00
|
|
|
len = strlen (current->import_dest);
|
|
|
|
directive_match = (search_parents
|
2015-03-06 10:42:06 +01:00
|
|
|
? (startswith (scope, current->import_dest)
|
2010-01-26 17:47:35 +01:00
|
|
|
&& (len == 0
|
2010-12-31 23:59:52 +01:00
|
|
|
|| scope[len] == ':'
|
|
|
|
|| scope[len] == '\0'))
|
2010-01-26 17:47:35 +01:00
|
|
|
: strcmp (scope, current->import_dest) == 0);
|
2010-01-26 16:48:25 +01:00
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
/* If the import destination is the current scope or one of its
|
|
|
|
ancestors then it is applicable. */
|
2010-01-26 17:47:35 +01:00
|
|
|
if (directive_match && !current->searched)
|
2010-01-26 16:48:25 +01:00
|
|
|
{
|
2011-11-04 17:37:17 +01:00
|
|
|
/* Mark this import as searched so that the recursive call
|
|
|
|
does not search it again. */
|
|
|
|
current->searched = 1;
|
|
|
|
searched_cleanup = make_cleanup (reset_directive_searched,
|
|
|
|
current);
|
|
|
|
|
|
|
|
/* If there is an import of a single declaration, compare the
|
|
|
|
imported declaration (after optional renaming by its alias)
|
|
|
|
with the sought out name. If there is a match pass
|
|
|
|
current->import_src as NAMESPACE to direct the search
|
|
|
|
towards the imported namespace. */
|
|
|
|
if (current->declaration
|
|
|
|
&& strcmp (name, current->alias
|
|
|
|
? current->alias : current->declaration) == 0)
|
|
|
|
sym = cp_lookup_symbol_in_namespace (current->import_src,
|
|
|
|
current->declaration,
|
2012-11-16 21:54:30 +01:00
|
|
|
block, domain, 1);
|
2011-11-04 17:37:17 +01:00
|
|
|
|
|
|
|
/* If this is a DECLARATION_ONLY search or a symbol was found
|
|
|
|
or this import statement was an import declaration, the
|
|
|
|
search of this import is complete. */
|
|
|
|
if (declaration_only || sym != NULL || current->declaration)
|
|
|
|
{
|
|
|
|
current->searched = 0;
|
|
|
|
discard_cleanups (searched_cleanup);
|
|
|
|
|
|
|
|
if (sym != NULL)
|
|
|
|
return sym;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do not follow CURRENT if NAME matches its EXCLUDES. */
|
|
|
|
for (excludep = current->excludes; *excludep; excludep++)
|
|
|
|
if (strcmp (name, *excludep) == 0)
|
|
|
|
break;
|
|
|
|
if (*excludep)
|
|
|
|
{
|
|
|
|
discard_cleanups (searched_cleanup);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (current->alias != NULL
|
|
|
|
&& strcmp (name, current->alias) == 0)
|
|
|
|
/* If the import is creating an alias and the alias matches
|
|
|
|
the sought name. Pass current->import_src as the NAME to
|
|
|
|
direct the search towards the aliased namespace. */
|
|
|
|
{
|
|
|
|
sym = cp_lookup_symbol_in_namespace (scope,
|
|
|
|
current->import_src,
|
2012-11-16 21:54:30 +01:00
|
|
|
block, domain, 1);
|
2011-11-04 17:37:17 +01:00
|
|
|
}
|
|
|
|
else if (current->alias == NULL)
|
|
|
|
{
|
|
|
|
/* If this import statement creates no alias, pass
|
|
|
|
current->inner as NAMESPACE to direct the search
|
|
|
|
towards the imported namespace. */
|
2014-12-17 07:19:15 +01:00
|
|
|
sym = cp_lookup_symbol_via_imports (current->import_src,
|
|
|
|
name, block,
|
2014-12-22 18:20:50 +01:00
|
|
|
domain, 1, 0, 0);
|
2011-11-04 17:37:17 +01:00
|
|
|
}
|
|
|
|
current->searched = 0;
|
|
|
|
discard_cleanups (searched_cleanup);
|
|
|
|
|
|
|
|
if (sym != NULL)
|
|
|
|
return sym;
|
2010-01-26 16:48:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-02-13 21:03:50 +01:00
|
|
|
/* Helper function that searches an array of symbols for one named NAME. */
|
2010-07-28 18:23:59 +02:00
|
|
|
|
|
|
|
static struct symbol *
|
2010-12-31 23:59:52 +01:00
|
|
|
search_symbol_list (const char *name, int num,
|
|
|
|
struct symbol **syms)
|
2010-07-28 18:23:59 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Maybe we should store a dictionary in here instead. */
|
|
|
|
for (i = 0; i < num; ++i)
|
|
|
|
{
|
|
|
|
if (strcmp (name, SYMBOL_NATURAL_NAME (syms[i])) == 0)
|
|
|
|
return syms[i];
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-12-17 07:19:15 +01:00
|
|
|
/* Like cp_lookup_symbol_via_imports, but if BLOCK is a function, it
|
2010-07-28 18:23:59 +02:00
|
|
|
searches through the template parameters of the function and the
|
|
|
|
function's type. */
|
|
|
|
|
|
|
|
struct symbol *
|
|
|
|
cp_lookup_symbol_imports_or_template (const char *scope,
|
|
|
|
const char *name,
|
|
|
|
const struct block *block,
|
|
|
|
const domain_enum domain)
|
|
|
|
{
|
|
|
|
struct symbol *function = BLOCK_FUNCTION (block);
|
2014-12-17 09:17:27 +01:00
|
|
|
struct symbol *result;
|
|
|
|
|
|
|
|
if (symbol_lookup_debug)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
"cp_lookup_symbol_imports_or_template"
|
|
|
|
" (%s, %s, %s, %s)\n",
|
|
|
|
scope, name, host_address_to_string (block),
|
|
|
|
domain_name (domain));
|
|
|
|
}
|
2010-07-28 18:23:59 +02:00
|
|
|
|
|
|
|
if (function != NULL && SYMBOL_LANGUAGE (function) == language_cplus)
|
|
|
|
{
|
|
|
|
/* Search the function's template parameters. */
|
|
|
|
if (SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION (function))
|
|
|
|
{
|
2014-12-22 17:42:02 +01:00
|
|
|
struct template_symbol *templ
|
2010-12-31 23:59:52 +01:00
|
|
|
= (struct template_symbol *) function;
|
2010-07-28 18:23:59 +02:00
|
|
|
|
|
|
|
result = search_symbol_list (name,
|
|
|
|
templ->n_template_arguments,
|
|
|
|
templ->template_arguments);
|
|
|
|
if (result != NULL)
|
2014-12-17 09:17:27 +01:00
|
|
|
{
|
|
|
|
if (symbol_lookup_debug)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
"cp_lookup_symbol_imports_or_template"
|
|
|
|
" (...) = %s\n",
|
|
|
|
host_address_to_string (result));
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2010-07-28 18:23:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Search the template parameters of the function's defining
|
|
|
|
context. */
|
|
|
|
if (SYMBOL_NATURAL_NAME (function))
|
|
|
|
{
|
|
|
|
struct type *context;
|
|
|
|
char *name_copy = xstrdup (SYMBOL_NATURAL_NAME (function));
|
|
|
|
struct cleanup *cleanups = make_cleanup (xfree, name_copy);
|
|
|
|
const struct language_defn *lang = language_def (language_cplus);
|
2014-12-23 16:21:10 +01:00
|
|
|
struct gdbarch *arch = symbol_arch (function);
|
2010-07-28 18:23:59 +02:00
|
|
|
const struct block *parent = BLOCK_SUPERBLOCK (block);
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
unsigned int prefix_len = cp_entire_prefix_len (name_copy);
|
|
|
|
|
|
|
|
if (prefix_len == 0)
|
|
|
|
context = NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
name_copy[prefix_len] = '\0';
|
2010-12-31 23:59:52 +01:00
|
|
|
context = lookup_typename (lang, arch,
|
|
|
|
name_copy,
|
|
|
|
parent, 1);
|
2010-07-28 18:23:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (context == NULL)
|
|
|
|
break;
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
result
|
|
|
|
= search_symbol_list (name,
|
|
|
|
TYPE_N_TEMPLATE_ARGUMENTS (context),
|
|
|
|
TYPE_TEMPLATE_ARGUMENTS (context));
|
2010-07-28 18:23:59 +02:00
|
|
|
if (result != NULL)
|
2013-05-30 19:29:06 +02:00
|
|
|
{
|
|
|
|
do_cleanups (cleanups);
|
2014-12-17 09:17:27 +01:00
|
|
|
if (symbol_lookup_debug)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
"cp_lookup_symbol_imports_or_template"
|
|
|
|
" (...) = %s\n",
|
|
|
|
host_address_to_string (result));
|
|
|
|
}
|
2013-05-30 19:29:06 +02:00
|
|
|
return result;
|
|
|
|
}
|
2010-07-28 18:23:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
do_cleanups (cleanups);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-22 18:20:50 +01:00
|
|
|
result = cp_lookup_symbol_via_imports (scope, name, block, domain, 0, 1, 1);
|
2014-12-17 09:17:27 +01:00
|
|
|
if (symbol_lookup_debug)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
"cp_lookup_symbol_imports_or_template (...) = %s\n",
|
|
|
|
result != NULL
|
|
|
|
? host_address_to_string (result) : "NULL");
|
|
|
|
}
|
|
|
|
return result;
|
2010-07-28 18:23:59 +02:00
|
|
|
}
|
|
|
|
|
2014-12-22 18:29:25 +01:00
|
|
|
/* Search for NAME by applying relevant import statements belonging to BLOCK
|
|
|
|
and its parents. SCOPE is the namespace scope of the context in which the
|
|
|
|
search is being evaluated. */
|
|
|
|
|
|
|
|
static struct symbol *
|
|
|
|
cp_lookup_symbol_via_all_imports (const char *scope, const char *name,
|
|
|
|
const struct block *block,
|
|
|
|
const domain_enum domain)
|
|
|
|
{
|
|
|
|
struct symbol *sym;
|
|
|
|
|
|
|
|
while (block != NULL)
|
|
|
|
{
|
|
|
|
sym = cp_lookup_symbol_via_imports (scope, name, block, domain, 0, 0, 1);
|
|
|
|
if (sym)
|
|
|
|
return sym;
|
|
|
|
|
|
|
|
block = BLOCK_SUPERBLOCK (block);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-12-22 17:42:02 +01:00
|
|
|
/* Searches for NAME in the current namespace, and by applying
|
|
|
|
relevant import statements belonging to BLOCK and its parents.
|
|
|
|
SCOPE is the namespace scope of the context in which the search is
|
|
|
|
being evaluated. */
|
2010-01-26 16:48:25 +01:00
|
|
|
|
2014-12-22 18:29:25 +01:00
|
|
|
struct symbol *
|
2010-01-26 16:48:25 +01:00
|
|
|
cp_lookup_symbol_namespace (const char *scope,
|
|
|
|
const char *name,
|
|
|
|
const struct block *block,
|
2010-03-15 18:29:36 +01:00
|
|
|
const domain_enum domain)
|
2010-01-26 16:48:25 +01:00
|
|
|
{
|
|
|
|
struct symbol *sym;
|
2014-12-17 09:17:27 +01:00
|
|
|
|
|
|
|
if (symbol_lookup_debug)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
"cp_lookup_symbol_namespace (%s, %s, %s, %s)\n",
|
|
|
|
scope, name, host_address_to_string (block),
|
|
|
|
domain_name (domain));
|
|
|
|
}
|
|
|
|
|
2010-03-15 18:29:36 +01:00
|
|
|
/* First, try to find the symbol in the given namespace. */
|
2014-12-22 18:29:25 +01:00
|
|
|
sym = cp_lookup_symbol_in_namespace (scope, name, block, domain, 1);
|
2010-01-26 16:48:25 +01:00
|
|
|
|
2014-12-22 18:29:25 +01:00
|
|
|
/* Search for name in namespaces imported to this and parent blocks. */
|
|
|
|
if (sym == NULL)
|
|
|
|
sym = cp_lookup_symbol_via_all_imports (scope, name, block, domain);
|
2010-01-26 16:48:25 +01:00
|
|
|
|
2014-12-17 09:17:27 +01:00
|
|
|
if (symbol_lookup_debug)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
2014-12-22 18:29:25 +01:00
|
|
|
"cp_lookup_symbol_namespace (...) = %s\n",
|
|
|
|
sym != NULL ? host_address_to_string (sym) : "NULL");
|
2014-12-17 09:17:27 +01:00
|
|
|
}
|
2014-12-22 18:29:25 +01:00
|
|
|
return sym;
|
2003-05-20 05:56:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Lookup NAME at namespace scope (or, in C terms, in static and
|
|
|
|
global variables). SCOPE is the namespace that the current
|
|
|
|
function is defined within; only consider namespaces whose length
|
|
|
|
is at least SCOPE_LEN. Other arguments are as in
|
|
|
|
cp_lookup_symbol_nonlocal.
|
|
|
|
|
|
|
|
For example, if we're within a function A::B::f and looking for a
|
2003-11-13 20:34:02 +01:00
|
|
|
symbol x, this will get called with NAME = "x", SCOPE = "A::B", and
|
2003-05-20 05:56:29 +02:00
|
|
|
SCOPE_LEN = 0. It then calls itself with NAME and SCOPE the same,
|
|
|
|
but with SCOPE_LEN = 1. And then it calls itself with NAME and
|
|
|
|
SCOPE the same, but with SCOPE_LEN = 4. This third call looks for
|
|
|
|
"A::B::x"; if it doesn't find it, then the second call looks for
|
|
|
|
"A::x", and if that call fails, then the first call looks for
|
|
|
|
"x". */
|
|
|
|
|
|
|
|
static struct symbol *
|
2014-12-23 16:55:39 +01:00
|
|
|
lookup_namespace_scope (const struct language_defn *langdef,
|
|
|
|
const char *name,
|
2003-05-20 05:56:29 +02:00
|
|
|
const struct block *block,
|
|
|
|
const domain_enum domain,
|
|
|
|
const char *scope,
|
|
|
|
int scope_len)
|
|
|
|
{
|
2015-02-27 17:33:07 +01:00
|
|
|
char *the_namespace;
|
2003-05-20 05:56:29 +02:00
|
|
|
|
|
|
|
if (scope[scope_len] != '\0')
|
|
|
|
{
|
|
|
|
/* Recursively search for names in child namespaces first. */
|
|
|
|
|
|
|
|
struct symbol *sym;
|
|
|
|
int new_scope_len = scope_len;
|
|
|
|
|
|
|
|
/* If the current scope is followed by "::", skip past that. */
|
|
|
|
if (new_scope_len != 0)
|
|
|
|
{
|
|
|
|
gdb_assert (scope[new_scope_len] == ':');
|
|
|
|
new_scope_len += 2;
|
|
|
|
}
|
|
|
|
new_scope_len += cp_find_first_component (scope + new_scope_len);
|
2014-12-23 16:55:39 +01:00
|
|
|
sym = lookup_namespace_scope (langdef, name, block, domain,
|
2010-12-31 23:59:52 +01:00
|
|
|
scope, new_scope_len);
|
2003-05-20 05:56:29 +02:00
|
|
|
if (sym != NULL)
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Okay, we didn't find a match in our children, so look for the
|
2014-12-23 16:55:39 +01:00
|
|
|
name in the current namespace.
|
|
|
|
|
|
|
|
If we there is no scope and we know we have a bare symbol, then short
|
|
|
|
circuit everything and call cp_lookup_bare_symbol directly.
|
|
|
|
This isn't an optimization, rather it allows us to pass LANGDEF which
|
|
|
|
is needed for primitive type lookup. The test doesn't have to be
|
|
|
|
perfect: if NAME is a bare symbol that our test doesn't catch (e.g., a
|
|
|
|
template symbol with "::" in the argument list) then
|
|
|
|
cp_lookup_symbol_in_namespace will catch it. */
|
|
|
|
|
|
|
|
if (scope_len == 0 && strchr (name, ':') == NULL)
|
|
|
|
return cp_lookup_bare_symbol (langdef, name, block, domain, 1);
|
2003-05-20 05:56:29 +02:00
|
|
|
|
2015-02-27 17:33:07 +01:00
|
|
|
the_namespace = alloca (scope_len + 1);
|
|
|
|
strncpy (the_namespace, scope, scope_len);
|
|
|
|
the_namespace[scope_len] = '\0';
|
|
|
|
return cp_lookup_symbol_in_namespace (the_namespace, name,
|
2012-11-16 21:54:30 +01:00
|
|
|
block, domain, 1);
|
2003-05-20 05:56:29 +02:00
|
|
|
}
|
|
|
|
|
2014-12-10 19:42:22 +01:00
|
|
|
/* The C++-specific version of name lookup for static and global
|
|
|
|
names. This makes sure that names get looked for in all namespaces
|
|
|
|
that are in scope. NAME is the natural name of the symbol that
|
|
|
|
we're looking for, BLOCK is the block that we're searching within,
|
|
|
|
DOMAIN says what kind of symbols we're looking for. */
|
|
|
|
|
|
|
|
struct symbol *
|
2014-12-23 16:24:48 +01:00
|
|
|
cp_lookup_symbol_nonlocal (const struct language_defn *langdef,
|
|
|
|
const char *name,
|
2014-12-10 19:42:22 +01:00
|
|
|
const struct block *block,
|
|
|
|
const domain_enum domain)
|
|
|
|
{
|
|
|
|
struct symbol *sym;
|
|
|
|
const char *scope = block_scope (block);
|
|
|
|
|
2014-12-17 09:17:27 +01:00
|
|
|
if (symbol_lookup_debug)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
"cp_lookup_symbol_non_local"
|
|
|
|
" (%s, %s (scope %s), %s)\n",
|
|
|
|
name, host_address_to_string (block), scope,
|
|
|
|
domain_name (domain));
|
|
|
|
}
|
|
|
|
|
2014-12-22 18:29:25 +01:00
|
|
|
/* First, try to find the symbol in the given namespace, and all
|
|
|
|
containing namespaces. */
|
2014-12-23 16:55:39 +01:00
|
|
|
sym = lookup_namespace_scope (langdef, name, block, domain, scope, 0);
|
2014-12-10 19:42:22 +01:00
|
|
|
|
2014-12-22 18:29:25 +01:00
|
|
|
/* Search for name in namespaces imported to this and parent blocks. */
|
|
|
|
if (sym == NULL)
|
|
|
|
sym = cp_lookup_symbol_via_all_imports (scope, name, block, domain);
|
|
|
|
|
2014-12-17 09:17:27 +01:00
|
|
|
if (symbol_lookup_debug)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
"cp_lookup_symbol_nonlocal (...) = %s\n",
|
|
|
|
sym != NULL ? host_address_to_string (sym) : "NULL");
|
|
|
|
}
|
|
|
|
return sym;
|
2014-12-10 19:42:22 +01:00
|
|
|
}
|
|
|
|
|
2013-11-25 22:37:08 +01:00
|
|
|
/* Search through the base classes of PARENT_TYPE for a base class
|
|
|
|
named NAME and return its type. If not found, return NULL. */
|
|
|
|
|
|
|
|
struct type *
|
2014-12-17 07:13:57 +01:00
|
|
|
cp_find_type_baseclass_by_name (struct type *parent_type, const char *name)
|
2013-11-25 22:37:08 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
CHECK_TYPEDEF (parent_type);
|
|
|
|
for (i = 0; i < TYPE_N_BASECLASSES (parent_type); ++i)
|
|
|
|
{
|
|
|
|
struct type *type = check_typedef (TYPE_BASECLASS (parent_type, i));
|
|
|
|
const char *base_name = TYPE_BASECLASS_NAME (parent_type, i);
|
|
|
|
|
|
|
|
if (base_name == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (streq (base_name, name))
|
|
|
|
return type;
|
|
|
|
|
2014-12-17 07:13:57 +01:00
|
|
|
type = cp_find_type_baseclass_by_name (type, name);
|
2013-11-25 22:37:08 +01:00
|
|
|
if (type != NULL)
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-11-16 21:54:30 +01:00
|
|
|
/* Search through the base classes of PARENT_TYPE for a symbol named
|
|
|
|
NAME in block BLOCK. */
|
|
|
|
|
|
|
|
static struct symbol *
|
|
|
|
find_symbol_in_baseclass (struct type *parent_type, const char *name,
|
2015-05-27 21:17:37 +02:00
|
|
|
const struct block *block, const domain_enum domain,
|
|
|
|
int is_in_anonymous)
|
2012-11-16 21:54:30 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct symbol *sym;
|
|
|
|
struct cleanup *cleanup;
|
|
|
|
char *concatenated_name;
|
|
|
|
|
|
|
|
sym = NULL;
|
|
|
|
concatenated_name = NULL;
|
|
|
|
cleanup = make_cleanup (free_current_contents, &concatenated_name);
|
2014-12-22 17:42:02 +01:00
|
|
|
|
2012-11-16 21:54:30 +01:00
|
|
|
for (i = 0; i < TYPE_N_BASECLASSES (parent_type); ++i)
|
|
|
|
{
|
|
|
|
size_t len;
|
2013-06-06 00:28:51 +02:00
|
|
|
struct type *base_type = TYPE_BASECLASS (parent_type, i);
|
2012-11-16 21:54:30 +01:00
|
|
|
const char *base_name = TYPE_BASECLASS_NAME (parent_type, i);
|
|
|
|
|
|
|
|
if (base_name == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
len = strlen (base_name) + 2 + strlen (name) + 1;
|
|
|
|
concatenated_name = xrealloc (concatenated_name, len);
|
|
|
|
xsnprintf (concatenated_name, len, "%s::%s", base_name, name);
|
|
|
|
|
2014-12-22 18:11:44 +01:00
|
|
|
sym = cp_lookup_nested_symbol_1 (base_type, name, concatenated_name,
|
2015-05-27 21:17:37 +02:00
|
|
|
block, domain, 1, is_in_anonymous);
|
2013-06-06 00:28:51 +02:00
|
|
|
if (sym != NULL)
|
|
|
|
break;
|
2012-11-16 21:54:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
do_cleanups (cleanup);
|
2011-04-04 16:37:17 +02:00
|
|
|
return sym;
|
2003-09-11 David Carlton <carlton@kealia.com>
* gdbtypes.h: Add TYPE_CODE_NAMESPACE.
* gdbtypes.c (init_type): Handle TYPE_CODE_NAMESPACE.
(recursive_dump_type): Ditto.
* printcmd.c (print_formatted): Ditto.
* typeprint.c (print_type_scalar): Ditto.
* c-typeprint.c (c_type_print_varspec_prefix): Ditto.
(c_type_print_varspec_suffix, c_type_print_base): Ditto.
* cp-support.h: Declare cp_check_possible_namespace_symbols,
maint_cplus_cmd_list.
* cp-support.c: Make maint_cplus_cmd_list extern.
* cp-namespace.c: Include objfiles.h, gdbtypes.h, dictionary.h,
command.h.
(lookup_symbol_file): Look in possible namespace blocks when
appropriate.
(initialize_namespace_symtab): New.
(get_possible_namespace_block, free_namespace_block)
(check_possible_namespace_symbols)
(check_possible_namespace_symbols_loop)
(check_one_possible_namespace_symbol)
(lookup_possible_namespace_symbol, maintenance_cplus_namespace)
(_initialize_cp_namespace): Ditto.
* block.h: Declare allocate_block.
* block.c (allocate_block): New.
* jv-lang.c (get_java_class_symtab): Allocate blocks via
allocate_block.
* symfile.h: Update declaration of add_psymbol_to_list.
* symfile.c (add_psymbol_to_list): Return the partial symbol in
question.
* dwarf2read.c (dwarf2_build_psymtabs_hard): Add argument to
scan_partial_symbols_call.
(scan_partial_symbols): Add NAMESPACE argument; update calls to
helper functions.
(add_partial_symbol): If necessary, scan mangled names for names
of namespaces.
(add_partial_namespace): Add NAMESPACE argument; generate partial
symbols associated to namespaces.
(add_partial_enumeration): Add NAMESPACE argument.
(new_symbol): Allow namespace syms.
(read_namespace): Generate namespace syms.
* objfiles.h: Add opaque declaration of struct symtab.
(struct objfile): Add cp_namespace_symtab member.
* objfiles.c (allocate_objfile): Set
objfile->cp_namespace_symtab.
* Makefile.in (cp-namespace.o): Depend on objfiles_h, gdbtypes_h,
dictionary_h, command_h.
2003-09-11 David Carlton <carlton@kealia.com>
* gdb.c++/namespace.exp: Add tests for namespace types.
* gdb.c++/maint.exp (test_help): Test 'help maint cp namespace'.
(test_namespace): New.
2003-09-11 21:49:20 +02:00
|
|
|
}
|
|
|
|
|
2015-05-27 21:17:37 +02:00
|
|
|
/* Helper function to look up NESTED_NAME in CONTAINER_TYPE and in DOMAIN
|
|
|
|
and within the context of BLOCK.
|
2015-02-13 21:03:50 +01:00
|
|
|
NESTED_NAME may have scope ("::").
|
2014-12-22 18:11:44 +01:00
|
|
|
CONTAINER_TYPE needn't have been "check_typedef'd" yet.
|
|
|
|
CONCATENATED_NAME is the fully scoped spelling of NESTED_NAME, it is
|
|
|
|
passed as an argument so that callers can control how space for it is
|
|
|
|
allocated.
|
|
|
|
If BASIC_LOOKUP is non-zero then perform a basic lookup of
|
2015-02-22 06:58:31 +01:00
|
|
|
CONCATENATED_NAME. See cp_basic_lookup_symbol for details.
|
|
|
|
If IS_IN_ANONYMOUS is non-zero then CONCATENATED_NAME is in an anonymous
|
|
|
|
namespace. */
|
2014-12-22 18:11:44 +01:00
|
|
|
|
|
|
|
static struct symbol *
|
|
|
|
cp_lookup_nested_symbol_1 (struct type *container_type,
|
|
|
|
const char *nested_name,
|
|
|
|
const char *concatenated_name,
|
|
|
|
const struct block *block,
|
2015-05-27 21:17:37 +02:00
|
|
|
const domain_enum domain,
|
2015-02-22 06:58:31 +01:00
|
|
|
int basic_lookup, int is_in_anonymous)
|
2014-12-22 18:11:44 +01:00
|
|
|
{
|
|
|
|
struct symbol *sym;
|
|
|
|
|
|
|
|
/* NOTE: carlton/2003-11-10: We don't treat C++ class members
|
|
|
|
of classes like, say, data or function members. Instead,
|
|
|
|
they're just represented by symbols whose names are
|
|
|
|
qualified by the name of the surrounding class. This is
|
|
|
|
just like members of namespaces; in particular,
|
|
|
|
cp_basic_lookup_symbol works when looking them up. */
|
|
|
|
|
|
|
|
if (basic_lookup)
|
|
|
|
{
|
2015-05-27 21:17:37 +02:00
|
|
|
sym = cp_basic_lookup_symbol (concatenated_name, block, domain,
|
2014-12-22 18:11:44 +01:00
|
|
|
is_in_anonymous);
|
|
|
|
if (sym != NULL)
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now search all static file-level symbols. We have to do this for things
|
|
|
|
like typedefs in the class. We do not try to guess any imported
|
|
|
|
namespace as even the fully specified namespace search is already not
|
|
|
|
C++ compliant and more assumptions could make it too magic. */
|
|
|
|
|
|
|
|
/* First search in this symtab, what we want is possibly there. */
|
2015-05-27 21:17:37 +02:00
|
|
|
sym = lookup_symbol_in_static_block (concatenated_name, block, domain);
|
2014-12-22 18:11:44 +01:00
|
|
|
if (sym != NULL)
|
|
|
|
return sym;
|
|
|
|
|
|
|
|
/* Nope. We now have to search all static blocks in all objfiles,
|
|
|
|
even if block != NULL, because there's no guarantees as to which
|
2015-02-22 06:58:31 +01:00
|
|
|
symtab the symbol we want is in. Except for symbols defined in
|
|
|
|
anonymous namespaces should be treated as local to a single file,
|
|
|
|
which we just searched. */
|
|
|
|
if (!is_in_anonymous)
|
|
|
|
{
|
2015-05-27 21:17:37 +02:00
|
|
|
sym = lookup_static_symbol (concatenated_name, domain);
|
2015-02-22 06:58:31 +01:00
|
|
|
if (sym != NULL)
|
|
|
|
return sym;
|
|
|
|
}
|
2014-12-22 18:11:44 +01:00
|
|
|
|
|
|
|
/* If this is a class with baseclasses, search them next. */
|
|
|
|
CHECK_TYPEDEF (container_type);
|
|
|
|
if (TYPE_N_BASECLASSES (container_type) > 0)
|
|
|
|
{
|
2015-02-22 06:58:31 +01:00
|
|
|
sym = find_symbol_in_baseclass (container_type, nested_name, block,
|
2015-05-27 21:17:37 +02:00
|
|
|
domain, is_in_anonymous);
|
2014-12-22 18:11:44 +01:00
|
|
|
if (sym != NULL)
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
gdb/
PR c++/14177 - Fix parsing TYPENAME:: in parentheses.
* c-exp.y (classify_inner_name): Remove caller assumptions in the
function comment. Return ERROR for unresolved cases. Implement
returning proper NAME.
(yylex): Accept also NAME from classify_inner_name.
* cp-namespace.c (cp_lookup_nested_type): Rename to ...
(cp_lookup_nested_symbol): ... here. Return any found symbol, not just
LOC_TYPEDEF type.
* cp-support.h (cp_lookup_nested_type): Update its declaration.
gdb/testsuite/
PR c++/14177 - Fix parsing TYPENAME:: in parentheses.
* gdb.cp/cpexprs.cc (class CV, CV::i, ATTRIBUTE_USED, CV_f): New.
(test_function): Call CV_f.
* gdb.cp/cpexprs.exp (p 'CV::m(int)', p CV::m(int))
(p 'CV::m(int) const', p CV::m(int) const, p 'CV::m(int) volatile')
(p CV::m(int) volatile, p 'CV::m(int) const volatile')
(p CV::m(int) const volatile, p CV_f(int), p CV_f(CV::t))
(p CV_f(CV::i)): New tests.
2012-06-13 18:10:10 +02:00
|
|
|
/* Look up a symbol named NESTED_NAME that is nested inside the C++
|
2003-09-25 18:39:39 +02:00
|
|
|
class or namespace given by PARENT_TYPE, from within the context
|
2015-05-27 21:17:37 +02:00
|
|
|
given by BLOCK, and in DOMAIN.
|
|
|
|
Return NULL if there is no such nested symbol. */
|
2003-09-25 18:39:39 +02:00
|
|
|
|
gdb/
PR c++/14177 - Fix parsing TYPENAME:: in parentheses.
* c-exp.y (classify_inner_name): Remove caller assumptions in the
function comment. Return ERROR for unresolved cases. Implement
returning proper NAME.
(yylex): Accept also NAME from classify_inner_name.
* cp-namespace.c (cp_lookup_nested_type): Rename to ...
(cp_lookup_nested_symbol): ... here. Return any found symbol, not just
LOC_TYPEDEF type.
* cp-support.h (cp_lookup_nested_type): Update its declaration.
gdb/testsuite/
PR c++/14177 - Fix parsing TYPENAME:: in parentheses.
* gdb.cp/cpexprs.cc (class CV, CV::i, ATTRIBUTE_USED, CV_f): New.
(test_function): Call CV_f.
* gdb.cp/cpexprs.exp (p 'CV::m(int)', p CV::m(int))
(p 'CV::m(int) const', p CV::m(int) const, p 'CV::m(int) volatile')
(p CV::m(int) volatile, p 'CV::m(int) const volatile')
(p CV::m(int) const volatile, p CV_f(int), p CV_f(CV::t))
(p CV_f(CV::i)): New tests.
2012-06-13 18:10:10 +02:00
|
|
|
struct symbol *
|
|
|
|
cp_lookup_nested_symbol (struct type *parent_type,
|
|
|
|
const char *nested_name,
|
2015-05-27 21:17:37 +02:00
|
|
|
const struct block *block,
|
|
|
|
const domain_enum domain)
|
2003-09-25 18:39:39 +02:00
|
|
|
{
|
2014-12-11 21:05:25 +01:00
|
|
|
/* type_name_no_tag_or_error provides better error reporting using the
|
2011-05-06 16:12:18 +02:00
|
|
|
original type. */
|
|
|
|
struct type *saved_parent_type = parent_type;
|
|
|
|
|
|
|
|
CHECK_TYPEDEF (parent_type);
|
|
|
|
|
2014-12-17 09:17:27 +01:00
|
|
|
if (symbol_lookup_debug)
|
|
|
|
{
|
|
|
|
const char *type_name = type_name_no_tag (saved_parent_type);
|
|
|
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
2015-05-27 21:17:37 +02:00
|
|
|
"cp_lookup_nested_symbol (%s, %s, %s, %s)\n",
|
2014-12-17 09:17:27 +01:00
|
|
|
type_name != NULL ? type_name : "unnamed",
|
2015-05-27 21:17:37 +02:00
|
|
|
nested_name, host_address_to_string (block),
|
|
|
|
domain_name (domain));
|
2014-12-17 09:17:27 +01:00
|
|
|
}
|
|
|
|
|
2003-09-25 18:39:39 +02:00
|
|
|
switch (TYPE_CODE (parent_type))
|
|
|
|
{
|
2004-01-14 David Carlton <carlton@kealia.com>
Change symbols for C++ nested types to contain the fully qualified
name, if possible. (At least in the DWARF-2 case.) Partial fix
for PR's c++/57, c++/488, c++/539, c++/573, c++/609, c++/832,
c++/895.
* c-exp.y: Update copyright:
(qualified_type): Handle types nested within classes.
* cp-namespace.c: Update comments.
(cp_set_block_scope): Delete #if 0.
(cp_lookup_nested_type): Handle types nested within classes.
* dwarf2read.c: (scan_partial_symbols): Call add_partial_structure
when appropriate.
(add_partial_symbol): Add the name of the enclosing namespace to
types.
(pdi_needs_namespace): New.
(add_partial_namespace): Tweak comment.
(add_partial_structure): New.
(psymtab_to_symtab_1): Initialize processing_current_prefix
here...
(process_die): instead of here.
(read_structure_scope): Try to figure out the name of the class or
namespace that the structure might be defined within.
(read_enumeration): Generate fully-qualified names, if possible.
(read_namespace): Don't set name to NULL.
(die_specification): New.
(new_symbol): Generate fully-qualified names for types.
(read_type_die): Determine appropriate prefix.
(determine_prefix): New.
(typename_concat): New.
(class_name): New.
* valops.c: Update copyright.
(value_aggregate_elt): Pass NOSIDE to
value_struct_elt_for_reference.
(value_struct_elt_for_reference): Make static, add NOSIDE
parameter, call value_maybe_namespace_elt as a last resort.
(value_namespace_elt): Break out code into
value_maybe_namespace_elt.
(value_maybe_namespace_elt): New.
2004-01-14 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Add tests involving classes defined within
namespaces.
* gdb.cp/namespace.cc (C::CClass): New.
* gdb.cp/namespace1.cc: Update copyright.
(C::OtherFileClass): New.
2004-01-14 17:54:43 +01:00
|
|
|
case TYPE_CODE_STRUCT:
|
2003-09-25 18:39:39 +02:00
|
|
|
case TYPE_CODE_NAMESPACE:
|
2010-02-19 21:22:03 +01:00
|
|
|
case TYPE_CODE_UNION:
|
2014-03-27 19:24:27 +01:00
|
|
|
case TYPE_CODE_ENUM:
|
2013-11-15 11:32:01 +01:00
|
|
|
/* NOTE: Handle modules here as well, because Fortran is re-using the C++
|
|
|
|
specific code to lookup nested symbols in modules, by calling the
|
|
|
|
function pointer la_lookup_symbol_nonlocal, which ends up here. */
|
|
|
|
case TYPE_CODE_MODULE:
|
2003-09-25 18:39:39 +02:00
|
|
|
{
|
2012-11-13 10:46:11 +01:00
|
|
|
int size;
|
2011-05-06 16:12:18 +02:00
|
|
|
const char *parent_name = type_name_no_tag_or_error (saved_parent_type);
|
2014-12-22 18:11:44 +01:00
|
|
|
struct symbol *sym;
|
2010-06-28 22:35:52 +02:00
|
|
|
char *concatenated_name;
|
2015-02-22 06:58:31 +01:00
|
|
|
int is_in_anonymous;
|
2010-05-14 01:53:32 +02:00
|
|
|
|
2012-11-13 10:46:11 +01:00
|
|
|
size = strlen (parent_name) + 2 + strlen (nested_name) + 1;
|
|
|
|
concatenated_name = alloca (size);
|
|
|
|
xsnprintf (concatenated_name, size, "%s::%s",
|
2014-12-22 18:11:44 +01:00
|
|
|
parent_name, nested_name);
|
2015-02-22 06:58:31 +01:00
|
|
|
is_in_anonymous = cp_is_in_anonymous (concatenated_name);
|
2014-12-22 18:11:44 +01:00
|
|
|
|
|
|
|
sym = cp_lookup_nested_symbol_1 (parent_type, nested_name,
|
2015-05-27 21:17:37 +02:00
|
|
|
concatenated_name, block, domain,
|
|
|
|
1, is_in_anonymous);
|
2010-06-28 22:35:52 +02:00
|
|
|
|
2014-12-17 09:17:27 +01:00
|
|
|
if (symbol_lookup_debug)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
"cp_lookup_nested_symbol (...) = %s\n",
|
|
|
|
sym != NULL
|
|
|
|
? host_address_to_string (sym) : "NULL");
|
|
|
|
}
|
|
|
|
return sym;
|
2003-09-25 18:39:39 +02:00
|
|
|
}
|
From: Sergio Durigan Junior <sergiodj@redhat.com>
Subject: [PATCH] Fix for PR c++/15203 and PR c++/15210
Date: Sat, 09 Mar 2013 02:50:49 -0300 (5 days, 4 hours, 57 minutes ago)
Message-ID: <m3a9qdnmti.fsf@redhat.com>
Hi,
This bug was reported internally at our Bugzilla, along with a proposed
fix. After talking to Keith about it, he investigated and came up with
another patch needed to really fix the issue on CVS HEAD.
The first part of the fix is the patch to cp-namespace.c. It handles
the case when we are accessing a static variable inside a function
(inside a class) by the full linespec (is it right, Keith?). E.g.:
class foo
{
public:
int bar()
{
static int var = 0;
}
};
And then, printing the value of `var':
(gdb) print 'foo::bar()::var'
GDB would fall in an internal_error:
gdb/cp-namespace.c:816: internal-error: cp_lookup_nested_symbol called on a non-aggregate type.
This is because `cp_lookup_nested_symbol' is not handling the case when
TYPE_CODE is either _FUNC or _METHOD. This patch fixes it by returning
NULL in this case.
The second part of the fix is the patch to elfread.c. It is needed
because the BSF_GNU_UNIQUE flag was added to some symbols in
<http://sourceware.org/ml/binutils/2009-06/msg00016.html>. Because of
that, (still) the command:
(gdb) print 'foo::bar()::var'
where `var' is a static variable returns:
"No symbol "foo::bar()::var" in current context."
So with the second patch applied the command finally DTRT:
(gdb) print 'foo::bar()::var'
$1 = 0
This may not be the ideal solution, according to Keith it would be good
to implement productions on c-exp.y in order to recognize
CLASS::FUNCTION::VARIABLE, but it is a solution which works with what we
have today.
I regtested it in Fedora 17 x86_64 with -m64 and -m32, including
gdbserver, without regressions.
gdb/:
2013-03-14 Keith Seitz <keiths@redhat.com>
Alan Matsuoka <alanm@redhat.com>
PR c++/15203
PR c++/15210
* cp-namespace.c (cp_lookup_nested_symbol): Handle TYPE_CODE_FUNC and
TYPE_CODE_METHOD.
* elfread.c (elf_symtab_read): Handle BSF_GNU_UNIQUE for certain
symbols.
gdb/testsuite/:
2013-03-14 Sergio Durigan Junior <sergiodj@redhat.com>
PR c++/15203
PR c++/15210
* gdb.cp/m-static.cc (keepalive_int): New function.
(gnu_obj_1::method): New variable `sintvar', call `keepalive_int'.
* gdb.cp/m-static.exp: New test for `sintvar'.
2013-03-14 12:13:36 +01:00
|
|
|
|
|
|
|
case TYPE_CODE_FUNC:
|
|
|
|
case TYPE_CODE_METHOD:
|
2014-12-17 09:17:27 +01:00
|
|
|
if (symbol_lookup_debug)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stdlog,
|
|
|
|
"cp_lookup_nested_symbol (...) = NULL"
|
|
|
|
" (func/method)\n");
|
|
|
|
}
|
From: Sergio Durigan Junior <sergiodj@redhat.com>
Subject: [PATCH] Fix for PR c++/15203 and PR c++/15210
Date: Sat, 09 Mar 2013 02:50:49 -0300 (5 days, 4 hours, 57 minutes ago)
Message-ID: <m3a9qdnmti.fsf@redhat.com>
Hi,
This bug was reported internally at our Bugzilla, along with a proposed
fix. After talking to Keith about it, he investigated and came up with
another patch needed to really fix the issue on CVS HEAD.
The first part of the fix is the patch to cp-namespace.c. It handles
the case when we are accessing a static variable inside a function
(inside a class) by the full linespec (is it right, Keith?). E.g.:
class foo
{
public:
int bar()
{
static int var = 0;
}
};
And then, printing the value of `var':
(gdb) print 'foo::bar()::var'
GDB would fall in an internal_error:
gdb/cp-namespace.c:816: internal-error: cp_lookup_nested_symbol called on a non-aggregate type.
This is because `cp_lookup_nested_symbol' is not handling the case when
TYPE_CODE is either _FUNC or _METHOD. This patch fixes it by returning
NULL in this case.
The second part of the fix is the patch to elfread.c. It is needed
because the BSF_GNU_UNIQUE flag was added to some symbols in
<http://sourceware.org/ml/binutils/2009-06/msg00016.html>. Because of
that, (still) the command:
(gdb) print 'foo::bar()::var'
where `var' is a static variable returns:
"No symbol "foo::bar()::var" in current context."
So with the second patch applied the command finally DTRT:
(gdb) print 'foo::bar()::var'
$1 = 0
This may not be the ideal solution, according to Keith it would be good
to implement productions on c-exp.y in order to recognize
CLASS::FUNCTION::VARIABLE, but it is a solution which works with what we
have today.
I regtested it in Fedora 17 x86_64 with -m64 and -m32, including
gdbserver, without regressions.
gdb/:
2013-03-14 Keith Seitz <keiths@redhat.com>
Alan Matsuoka <alanm@redhat.com>
PR c++/15203
PR c++/15210
* cp-namespace.c (cp_lookup_nested_symbol): Handle TYPE_CODE_FUNC and
TYPE_CODE_METHOD.
* elfread.c (elf_symtab_read): Handle BSF_GNU_UNIQUE for certain
symbols.
gdb/testsuite/:
2013-03-14 Sergio Durigan Junior <sergiodj@redhat.com>
PR c++/15203
PR c++/15210
* gdb.cp/m-static.cc (keepalive_int): New function.
(gnu_obj_1::method): New variable `sintvar', call `keepalive_int'.
* gdb.cp/m-static.exp: New test for `sintvar'.
2013-03-14 12:13:36 +01:00
|
|
|
return NULL;
|
|
|
|
|
2003-09-25 18:39:39 +02:00
|
|
|
default:
|
|
|
|
internal_error (__FILE__, __LINE__,
|
gdb/
PR c++/14177 - Fix parsing TYPENAME:: in parentheses.
* c-exp.y (classify_inner_name): Remove caller assumptions in the
function comment. Return ERROR for unresolved cases. Implement
returning proper NAME.
(yylex): Accept also NAME from classify_inner_name.
* cp-namespace.c (cp_lookup_nested_type): Rename to ...
(cp_lookup_nested_symbol): ... here. Return any found symbol, not just
LOC_TYPEDEF type.
* cp-support.h (cp_lookup_nested_type): Update its declaration.
gdb/testsuite/
PR c++/14177 - Fix parsing TYPENAME:: in parentheses.
* gdb.cp/cpexprs.cc (class CV, CV::i, ATTRIBUTE_USED, CV_f): New.
(test_function): Call CV_f.
* gdb.cp/cpexprs.exp (p 'CV::m(int)', p CV::m(int))
(p 'CV::m(int) const', p CV::m(int) const, p 'CV::m(int) volatile')
(p CV::m(int) volatile, p 'CV::m(int) const volatile')
(p CV::m(int) const volatile, p CV_f(int), p CV_f(CV::t))
(p CV_f(CV::i)): New tests.
2012-06-13 18:10:10 +02:00
|
|
|
_("cp_lookup_nested_symbol called "
|
2011-01-05 23:22:53 +01:00
|
|
|
"on a non-aggregate type."));
|
2003-09-25 18:39:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-24 00:03:31 +01:00
|
|
|
/* The C++-version of lookup_transparent_type. */
|
|
|
|
|
|
|
|
/* FIXME: carlton/2004-01-16: The problem that this is trying to
|
|
|
|
address is that, unfortunately, sometimes NAME is wrong: it may not
|
|
|
|
include the name of namespaces enclosing the type in question.
|
2011-02-26 03:07:10 +01:00
|
|
|
lookup_transparent_type gets called when the type in question
|
2004-01-24 00:03:31 +01:00
|
|
|
is a declaration, and we're trying to find its definition; but, for
|
|
|
|
declarations, our type name deduction mechanism doesn't work.
|
|
|
|
There's nothing we can do to fix this in general, I think, in the
|
|
|
|
absence of debug information about namespaces (I've filed PR
|
|
|
|
gdb/1511 about this); until such debug information becomes more
|
|
|
|
prevalent, one heuristic which sometimes looks is to search for the
|
|
|
|
definition in namespaces containing the current namespace.
|
|
|
|
|
|
|
|
We should delete this functions once the appropriate debug
|
|
|
|
information becomes more widespread. (GCC 3.4 will be the first
|
|
|
|
released version of GCC with such information.) */
|
|
|
|
|
|
|
|
struct type *
|
|
|
|
cp_lookup_transparent_type (const char *name)
|
|
|
|
{
|
|
|
|
/* First, try the honest way of looking up the definition. */
|
|
|
|
struct type *t = basic_lookup_transparent_type (name);
|
|
|
|
const char *scope;
|
|
|
|
|
|
|
|
if (t != NULL)
|
|
|
|
return t;
|
|
|
|
|
|
|
|
/* If that doesn't work and we're within a namespace, look there
|
|
|
|
instead. */
|
|
|
|
scope = block_scope (get_selected_block (0));
|
|
|
|
|
|
|
|
if (scope[0] == '\0')
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return cp_lookup_transparent_type_loop (name, scope, 0);
|
|
|
|
}
|
|
|
|
|
2011-02-26 03:07:10 +01:00
|
|
|
/* Lookup the type definition associated to NAME in namespaces/classes
|
|
|
|
containing SCOPE whose name is strictly longer than LENGTH. LENGTH
|
|
|
|
must be the index of the start of a component of SCOPE. */
|
2004-01-24 00:03:31 +01:00
|
|
|
|
|
|
|
static struct type *
|
2010-12-31 23:59:52 +01:00
|
|
|
cp_lookup_transparent_type_loop (const char *name,
|
|
|
|
const char *scope,
|
2004-01-24 00:03:31 +01:00
|
|
|
int length)
|
|
|
|
{
|
2004-03-05 18:32:25 +01:00
|
|
|
int scope_length = length + cp_find_first_component (scope + length);
|
2004-01-24 00:03:31 +01:00
|
|
|
char *full_name;
|
|
|
|
|
|
|
|
/* If the current scope is followed by "::", look in the next
|
|
|
|
component. */
|
|
|
|
if (scope[scope_length] == ':')
|
|
|
|
{
|
|
|
|
struct type *retval
|
2010-12-31 23:59:52 +01:00
|
|
|
= cp_lookup_transparent_type_loop (name, scope,
|
|
|
|
scope_length + 2);
|
2010-05-14 01:53:32 +02:00
|
|
|
|
2004-01-24 00:03:31 +01:00
|
|
|
if (retval != NULL)
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
full_name = alloca (scope_length + 2 + strlen (name) + 1);
|
|
|
|
strncpy (full_name, scope, scope_length);
|
|
|
|
strncpy (full_name + scope_length, "::", 2);
|
|
|
|
strcpy (full_name + scope_length + 2, name);
|
|
|
|
|
|
|
|
return basic_lookup_transparent_type (full_name);
|
|
|
|
}
|
|
|
|
|
2011-04-04 16:37:17 +02:00
|
|
|
/* This used to do something but was removed when it became
|
|
|
|
obsolete. */
|
2003-09-11 David Carlton <carlton@kealia.com>
* gdbtypes.h: Add TYPE_CODE_NAMESPACE.
* gdbtypes.c (init_type): Handle TYPE_CODE_NAMESPACE.
(recursive_dump_type): Ditto.
* printcmd.c (print_formatted): Ditto.
* typeprint.c (print_type_scalar): Ditto.
* c-typeprint.c (c_type_print_varspec_prefix): Ditto.
(c_type_print_varspec_suffix, c_type_print_base): Ditto.
* cp-support.h: Declare cp_check_possible_namespace_symbols,
maint_cplus_cmd_list.
* cp-support.c: Make maint_cplus_cmd_list extern.
* cp-namespace.c: Include objfiles.h, gdbtypes.h, dictionary.h,
command.h.
(lookup_symbol_file): Look in possible namespace blocks when
appropriate.
(initialize_namespace_symtab): New.
(get_possible_namespace_block, free_namespace_block)
(check_possible_namespace_symbols)
(check_possible_namespace_symbols_loop)
(check_one_possible_namespace_symbol)
(lookup_possible_namespace_symbol, maintenance_cplus_namespace)
(_initialize_cp_namespace): Ditto.
* block.h: Declare allocate_block.
* block.c (allocate_block): New.
* jv-lang.c (get_java_class_symtab): Allocate blocks via
allocate_block.
* symfile.h: Update declaration of add_psymbol_to_list.
* symfile.c (add_psymbol_to_list): Return the partial symbol in
question.
* dwarf2read.c (dwarf2_build_psymtabs_hard): Add argument to
scan_partial_symbols_call.
(scan_partial_symbols): Add NAMESPACE argument; update calls to
helper functions.
(add_partial_symbol): If necessary, scan mangled names for names
of namespaces.
(add_partial_namespace): Add NAMESPACE argument; generate partial
symbols associated to namespaces.
(add_partial_enumeration): Add NAMESPACE argument.
(new_symbol): Allow namespace syms.
(read_namespace): Generate namespace syms.
* objfiles.h: Add opaque declaration of struct symtab.
(struct objfile): Add cp_namespace_symtab member.
* objfiles.c (allocate_objfile): Set
objfile->cp_namespace_symtab.
* Makefile.in (cp-namespace.o): Depend on objfiles_h, gdbtypes_h,
dictionary_h, command_h.
2003-09-11 David Carlton <carlton@kealia.com>
* gdb.c++/namespace.exp: Add tests for namespace types.
* gdb.c++/maint.exp (test_help): Test 'help maint cp namespace'.
(test_namespace): New.
2003-09-11 21:49:20 +02:00
|
|
|
|
|
|
|
static void
|
|
|
|
maintenance_cplus_namespace (char *args, int from_tty)
|
|
|
|
{
|
2011-04-04 16:37:17 +02:00
|
|
|
printf_unfiltered (_("The `maint namespace' command was removed.\n"));
|
2003-09-11 David Carlton <carlton@kealia.com>
* gdbtypes.h: Add TYPE_CODE_NAMESPACE.
* gdbtypes.c (init_type): Handle TYPE_CODE_NAMESPACE.
(recursive_dump_type): Ditto.
* printcmd.c (print_formatted): Ditto.
* typeprint.c (print_type_scalar): Ditto.
* c-typeprint.c (c_type_print_varspec_prefix): Ditto.
(c_type_print_varspec_suffix, c_type_print_base): Ditto.
* cp-support.h: Declare cp_check_possible_namespace_symbols,
maint_cplus_cmd_list.
* cp-support.c: Make maint_cplus_cmd_list extern.
* cp-namespace.c: Include objfiles.h, gdbtypes.h, dictionary.h,
command.h.
(lookup_symbol_file): Look in possible namespace blocks when
appropriate.
(initialize_namespace_symtab): New.
(get_possible_namespace_block, free_namespace_block)
(check_possible_namespace_symbols)
(check_possible_namespace_symbols_loop)
(check_one_possible_namespace_symbol)
(lookup_possible_namespace_symbol, maintenance_cplus_namespace)
(_initialize_cp_namespace): Ditto.
* block.h: Declare allocate_block.
* block.c (allocate_block): New.
* jv-lang.c (get_java_class_symtab): Allocate blocks via
allocate_block.
* symfile.h: Update declaration of add_psymbol_to_list.
* symfile.c (add_psymbol_to_list): Return the partial symbol in
question.
* dwarf2read.c (dwarf2_build_psymtabs_hard): Add argument to
scan_partial_symbols_call.
(scan_partial_symbols): Add NAMESPACE argument; update calls to
helper functions.
(add_partial_symbol): If necessary, scan mangled names for names
of namespaces.
(add_partial_namespace): Add NAMESPACE argument; generate partial
symbols associated to namespaces.
(add_partial_enumeration): Add NAMESPACE argument.
(new_symbol): Allow namespace syms.
(read_namespace): Generate namespace syms.
* objfiles.h: Add opaque declaration of struct symtab.
(struct objfile): Add cp_namespace_symtab member.
* objfiles.c (allocate_objfile): Set
objfile->cp_namespace_symtab.
* Makefile.in (cp-namespace.o): Depend on objfiles_h, gdbtypes_h,
dictionary_h, command_h.
2003-09-11 David Carlton <carlton@kealia.com>
* gdb.c++/namespace.exp: Add tests for namespace types.
* gdb.c++/maint.exp (test_help): Test 'help maint cp namespace'.
(test_namespace): New.
2003-09-11 21:49:20 +02:00
|
|
|
}
|
|
|
|
|
2008-02-21 Pedro Alves <pedro@codesorcery.com>
Silence a few -Wmissing-prototypes warnings.
PR build/9877:
* amd64-nat.c: Include "amd64-nat.h".
* fork-child.c (_initialize_fork_child): Ditto.
* gcore.c (_initialize_gcore): Ditto.
* inf-ptrace.c: Include "inf-ptrace.h".
(inf_ptrace_store_registers): Make it static.
* linux-nat.c (linux_nat_terminal_ours): Make it static.
(_initialize_linux_nat): Declare before definition.
* linux-tdep.c: Include "linux-tdep.h".
* linux-thread-db.c (_initialize_thread_db): Declare before
definition.
* proc-service.c (_initialize_proc_service): Ditto.
* remote.c (remote_send_printf): Make it static.
* solib.c: Include "solib.h".
* symfile-mem.c (_initialize_symfile_mem): Declare before
definition.
* ada-lang.c (ada_la_decode, ada_match_name)
(ada_suppress_symbol_printing, ada_is_array_type)
(ada_value_ptr_subscript, ada_array_length)
(ada_to_static_fixed_value): Make them static.
(_initialize_ada_language): Declare before definition.
* ada-tasks.c (ada_get_task_number, ada_get_environment_task)
(ada_task_list_changed, ada_new_objfile_observer): Make them
static.
(_initialize_tasks): Declare before definition.
* addrmap.c (_initialize_addrmap): Declare before definition.
* auxv.c (default_auxv_parse): Make it static.
* bfd-target.c (target_bfd_xfer_partial, target_bfd_xclose): Make
them static.
* breakpoint.c (remove_sal): Add line break.
(expand_line_sal_maybe): Make it static.
* cp-name-parser.y: Include "cp-support.h".
* cp-valprint.c (cp_find_class_member): Make it static.
* eval.c (value_f90_subarray): Ditto.
* exceptions.c (print_any_exception): Ditto.
* findcmd.c (_initialize_mem_search): Declare before definition.
* frame.c (frame_observer_target_changed): Make it static.
* gnu-v3-abi.c (gnuv3_find_method_in): Make it static.
* inf-child.c: Include "inf-child.h".
* inferior.h (valid_inferior_id): Rename to ...
(valid_gdb_inferior_id): ... this.
* infrun.c (infrun_thread_stop_requested, siginfo_make_value):
Make them static.
* jv-lang.c (java_language_arch_info): Make it static.
* m2-typeprint.c (m2_get_discrete_bounds): Ditto.
* osdata.c (info_osdata_command): Make it static.
* regcache.c (regcache_observer_target_changed): Make it static.
* reverse.c (_initialize_reverse): Declare before definition.
* stabsread.c (cleanup_undefined_types_noname)
(cleanup_undefined_types_1): Make them static.
* symfile.c (place_section): Make it static.
* symtab.c (find_pc_sect_psymtab_closer): Make it static.
* target-descriptions.c (_initialize_target_descriptions): Declare
before definition.
* target.c (default_get_ada_task_ptid, find_default_can_async_p)
(find_default_is_async_p, find_default_supports_non_stop): Make
them static.
(target_supports_non_stop): Add prototype.
(dummy_pid_to_str): Make it static.
* utils.c (_initialize_utils): Declare before definition.
* ada-exp.y (_initialize_ada_exp): Declare before definition.
* solib-svr4.c (HAS_LM_DYNAMIC_FROM_LINK_MAP): Add a prototype.
* target.h (struct target_ops): Add a prototype to the
to_can_execute_reverse callback.
* macroscope.c (_initialize_macroscope): Declare before definition.
* cp-namespace.c (_initialize_cp_namespace): Declare before definition.
* python/python.c (_initialize_python): Declare before definition.
* tui/tui-command.c: Include "tui/tui-command.h".
* tui/tui-data.c (init_content_element, init_win_info): Make them
static.
* tui/tui-disasm.c: Include "tui/tui-disasm.h".
* tui/tui-interp.c (_initialize_tui_interp): Declare before
definition.
* tui/tui-layout.c: Include "tui/tui-layout.h".
(_initialize_tui_layout): Declare before definition.
* tui/tui-regs.c: Include "tui/tui-regs.h".
(tui_display_reg_element_at_line): Make it static.
(_initialize_tui_regs): Declare before definition.
* tui/tui-stack.c (_initialize_tui_stack): Declare before
definition.
* tui/tui-win.c: Include "tui/tui-win.h".
(_initialize_tui_win): Declare before definition.
(tui_sigwinch_handler): Make it static. Wrap in ifdef SIGWINCH.
* tui/tui-win.h (tui_sigwinch_handler): Delete declaration.
(tui_get_cmd_list): Add a prototype.
* tui/tui-windata.c: Include tui-windata.h.
* tui/tui-wingeneral.c (box_win): Make it static.
* cli/cli-logging.c (show_logging_command): Make it static.
(_initialize_cli_logging): Declare before definition.
* mi/mi-common.c (_initialize_gdb_mi_common): Declare before
definition.
2009-02-21 17:14:50 +01:00
|
|
|
/* Provide a prototype to silence -Wmissing-prototypes. */
|
|
|
|
extern initialize_file_ftype _initialize_cp_namespace;
|
|
|
|
|
2003-09-11 David Carlton <carlton@kealia.com>
* gdbtypes.h: Add TYPE_CODE_NAMESPACE.
* gdbtypes.c (init_type): Handle TYPE_CODE_NAMESPACE.
(recursive_dump_type): Ditto.
* printcmd.c (print_formatted): Ditto.
* typeprint.c (print_type_scalar): Ditto.
* c-typeprint.c (c_type_print_varspec_prefix): Ditto.
(c_type_print_varspec_suffix, c_type_print_base): Ditto.
* cp-support.h: Declare cp_check_possible_namespace_symbols,
maint_cplus_cmd_list.
* cp-support.c: Make maint_cplus_cmd_list extern.
* cp-namespace.c: Include objfiles.h, gdbtypes.h, dictionary.h,
command.h.
(lookup_symbol_file): Look in possible namespace blocks when
appropriate.
(initialize_namespace_symtab): New.
(get_possible_namespace_block, free_namespace_block)
(check_possible_namespace_symbols)
(check_possible_namespace_symbols_loop)
(check_one_possible_namespace_symbol)
(lookup_possible_namespace_symbol, maintenance_cplus_namespace)
(_initialize_cp_namespace): Ditto.
* block.h: Declare allocate_block.
* block.c (allocate_block): New.
* jv-lang.c (get_java_class_symtab): Allocate blocks via
allocate_block.
* symfile.h: Update declaration of add_psymbol_to_list.
* symfile.c (add_psymbol_to_list): Return the partial symbol in
question.
* dwarf2read.c (dwarf2_build_psymtabs_hard): Add argument to
scan_partial_symbols_call.
(scan_partial_symbols): Add NAMESPACE argument; update calls to
helper functions.
(add_partial_symbol): If necessary, scan mangled names for names
of namespaces.
(add_partial_namespace): Add NAMESPACE argument; generate partial
symbols associated to namespaces.
(add_partial_enumeration): Add NAMESPACE argument.
(new_symbol): Allow namespace syms.
(read_namespace): Generate namespace syms.
* objfiles.h: Add opaque declaration of struct symtab.
(struct objfile): Add cp_namespace_symtab member.
* objfiles.c (allocate_objfile): Set
objfile->cp_namespace_symtab.
* Makefile.in (cp-namespace.o): Depend on objfiles_h, gdbtypes_h,
dictionary_h, command_h.
2003-09-11 David Carlton <carlton@kealia.com>
* gdb.c++/namespace.exp: Add tests for namespace types.
* gdb.c++/maint.exp (test_help): Test 'help maint cp namespace'.
(test_namespace): New.
2003-09-11 21:49:20 +02:00
|
|
|
void
|
|
|
|
_initialize_cp_namespace (void)
|
|
|
|
{
|
2011-04-04 16:37:17 +02:00
|
|
|
struct cmd_list_element *cmd;
|
|
|
|
|
|
|
|
cmd = add_cmd ("namespace", class_maintenance,
|
|
|
|
maintenance_cplus_namespace,
|
|
|
|
_("Deprecated placeholder for removed functionality."),
|
|
|
|
&maint_cplus_cmd_list);
|
|
|
|
deprecate_cmd (cmd, NULL);
|
2003-05-20 05:56:29 +02:00
|
|
|
}
|