+2010-03-09 Keith Seitz <keiths@redhat.com>
+
+ Based on work from Daniel Jacobowitz <dan@codesourcery.com>
+ * c-typeprint.c (cp_type_print_method_args): For non-static methods,
+ print out const or volatile qualifiers, too.
+ (c_type_print_args): Add parameters show_artificial and language.
+ Skip artificial parameters when requested.
+ Use the appropriate language printer.
+ (c_type_print_varspec): Tell c_type_print_args to skip artificial
+ parameters and pass language_c.
+ * dwarf2read.c (die_list): New file global.
+ (struct partial_die_info): Update comments for name field.
+ (pdi_needs_namespace): Renamed to ...
+ (die_needs_namespace): ... this. Rewrite.
+ (dwarf2_linkage_name): Remove.
+ (add_partial_symbol): Do not predicate the call to
+ partial_die_full_name based on pdi_needs_namespace.
+ Remove call to cp_check_possible_namespace_symbols and associated
+ outdated comments.
+ (guess_structure_name): Do not inspect child subprogram DIEs.
+ (dwarf2_fullname): Update comments.
+ Use die_needs_namespace to assist in computing the name.
+ (read_func_scope): Use dwarf2_name to get the DIE's name.
+ Use dwarf2_physname to get the "linkage name" of the DIE.
+ (dwarf2_add_member_field): Use dwarf2_physname instead of
+ dwarf2_linkage_name.
+ (read_structure_type): For structs and classes, set TYPE_NAME, too.
+ (determine_class): Remove.
+ (read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages
+ except Ada.
+ (new_symbol): Unconditionally call dwarf2_name.
+ Compute the "linkage name" using dwarf2_physname.
+ Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs.
+ When determining to scan for anonymous C++ namespaces, ignore
+ the linkage name.
+ (dwarf2_physname): New function.
+ (dwarf2_full_name): Move content to new function and call
+ that.
+ (dwarf2_compute_name): "New" function.
+ (_initialize_dwarf2_read): Initialize die_list.
+ * gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable
+ physname.
+ (gnu_v3_print_method_ptr): Use the physname for virtual methods
+ without a demangled name.
+ Print out type information for non-virtual methods.
+ * linespec.c (decode_line_1): Force ANY string using "::" (or
+ "." for java) to use decode_compound, and clean up any stray quoting.
+ If we found a file symtab, re-evaluate whether the remainder is_quoted.
+ (decode_compound): Stop consuming at an open parenthesis.
+ Keep template parameters.
+ Keep any overload information.
+ Keep keywords like "const".
+ Remove paren_pointer.
+ Move is_quoted check from set_flags to here.
+ Remove #if 0 code from 2000. Ten years is long enough.
+ (find_method): Before comparing symbol names, canonicalize the string
+ from the user.
+ If a specific overload is requested, find it. Otherwise throw an error.
+ (find_method_overload_end): New function.
+ (set_flags): Remove.
+ (decode_compound): Assume that parentheses are matched.
+ It's a lot easier.
+ * symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag
+ to cplus_demangle.
+ * linespec.c (decode_line_1): Keep important keywords like
+ "const" and "volatile".
+ * symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove.
+ * typeprint.h (c_type_print_args): Add declaration.
+ * ui-file.c (do_ui_file_obsavestring): New function.
+ (ui_file_obsavestring): New function.
+ * ui-file.h (ui_file_obsavestring): Add declaration.
+ * valops.c (find_overload_match): Resolve the object to
+ a non-pointer type.
+ If the object is a data member, search the object for the member
+ and return with staticp set.
+ Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME.
+ Do not attempt to extract a function name from non-function types.
+ If the extracted function name and the original name are the same,
+ we don't have a C++ method.
+
+ From Jan Kratochvil <jan.kratochvil@redhat.com>:
+ * dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name.
+
+ * ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters
+ and arguments from symbol lookups.
+ * ax-gdb.c (gen_expr): Likewise.
+ * cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope,
+ cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type,
+ lookup_possible_namespace_symbol): Likewise.
+ * cp-support.c (read_in_psymtabs): Likewise.
+ * cp-support.h (cp_lookup_symbol_nonlocal): Likewise.
+ * language.h (la_lookup_symbol_nonlocal): Likewise.
+ * scm-valprint.c (scm_inferior_print): Likewise.
+ * solib-darwin.c (darwin_relocate_section_addresses): Likewise.
+ * solib-svr.c (elf_lookup_lib): Likewise.
+ * solib.c (show_auto_solib_add): Likewise.
+ * solist.h (lookup_lib_global, solib_global_lookup): Likewise.
+ * symmisc.c (maintenance_check_symtabs): Likewise.
+ * symtab.c (lookup_symbol_in_language, lookup_symbol_aux,
+ lookup_symbol_aux_local, lookup_symbol_aux_block,
+ lookup_symbol_from_objfile, lookup_symbol_aux_symtabs,
+ lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal,
+ lookup_symbol_static, lookup_symbol_global, symbol_matches_domain,
+ basic_lookup_transparent_type, find_main_psymtab,
+ lookup_block_symbol): Likewise.
+ * symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static,
+ lookup_symbol_global, lookup_symbol_aux_block,
+ lookup_symbol_partial_symbol, lookup_block_symbol,
+ lookup_global_symbol, value_maybe_namespace_elt): Likewise.
+
2010-03-09 Pierre Muller <muller@ics.u-strasbg.fr>
* python/python-internal.h: Include symtab.h.
static struct symbol *
ada_lookup_symbol_nonlocal (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain)
{
- if (linkage_name == NULL)
- linkage_name = name;
- return ada_lookup_symbol (linkage_name, block_static_block (block), domain,
- NULL);
+ return ada_lookup_symbol (name, block_static_block (block), domain, NULL);
}
/* Calling lookup_block_symbol is necessary to get the LOC_REGISTER
symbol instead of the LOC_ARG one (if both exist). */
- sym = lookup_block_symbol (b, this_name, NULL, VAR_DOMAIN);
+ sym = lookup_block_symbol (b, this_name, VAR_DOMAIN);
if (!sym)
error (_("no `%s' found"), this_name);
#include "c-lang.h"
#include "typeprint.h"
#include "cp-abi.h"
+#include "jv-lang.h"
#include "gdb_string.h"
#include <errno.h>
char *varstring, int staticp,
struct ui_file *stream);
-static void c_type_print_args (struct type *, struct ui_file *);
-
static void cp_type_print_derivation_info (struct ui_file *, struct type *);
static void c_type_print_varspec_prefix (struct type *, struct ui_file *, int,
fprintf_filtered (stream, "void");
fprintf_filtered (stream, ")");
+
+ /* For non-static methods, read qualifiers from the type of
+ THIS. */
+ if (!staticp)
+ {
+ struct type *domain;
+
+ gdb_assert (nargs > 0);
+ gdb_assert (TYPE_CODE (args[0].type) == TYPE_CODE_PTR);
+ domain = TYPE_TARGET_TYPE (args[0].type);
+
+ if (TYPE_CONST (domain))
+ fprintf_filtered (stream, " const");
+
+ if (TYPE_VOLATILE (domain))
+ fprintf_filtered (stream, " volatile");
+ }
}
/* Print out the arguments of TYPE, which should have TYPE_CODE_METHOD
or TYPE_CODE_FUNC, to STREAM. Artificial arguments, such as "this"
- in non-static methods, are displayed. */
+ in non-static methods, are displayed if SHOW_ARTIFICIAL is
+ non-zero. LANGUAGE is the language in which TYPE was defined. This is
+ a necessary evil since this code is used by the C, C++, and Java
+ backends. */
-static void
-c_type_print_args (struct type *type, struct ui_file *stream)
+void
+c_type_print_args (struct type *type, struct ui_file *stream,
+ int show_artificial, enum language language)
{
int i, len;
struct field *args;
for (i = 0; i < TYPE_NFIELDS (type); i++)
{
+ if (TYPE_FIELD_ARTIFICIAL (type, i) && !show_artificial)
+ continue;
+
if (printed_any)
{
fprintf_filtered (stream, ", ");
wrap_here (" ");
}
- c_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0);
+ if (language == language_java)
+ java_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0);
+ else
+ c_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0);
printed_any = 1;
}
if (passed_a_ptr)
fprintf_filtered (stream, ")");
if (!demangled_args)
- c_type_print_args (type, stream);
+ c_type_print_args (type, stream, 1, language_c);
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
passed_a_ptr, 0);
break;
#include "buildsym.h"
static struct symbol *lookup_namespace_scope (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain,
const char *scope,
int scope_len);
static struct symbol *lookup_symbol_file (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain,
int anonymous_namespace);
/* 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, LINKAGE_NAME (which is optional) is its linkage
- name, BLOCK is the block that we're searching within, DOMAIN says
- what kind of symbols we're looking for, and if SYMTAB is non-NULL,
- we should store the symtab where we found the symbol in it. */
+ we're looking for, BLOCK is the block that we're searching within,
+ DOMAIN says what kind of symbols we're looking for, and if SYMTAB is
+ non-NULL, we should store the symtab where we found the symbol in it. */
struct symbol *
cp_lookup_symbol_nonlocal (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain)
{
struct symbol *sym;
const char *scope = block_scope (block);
- sym = lookup_namespace_scope (name, linkage_name, block, domain, scope, 0);
+ sym = lookup_namespace_scope (name, block, domain, scope, 0);
if (sym != NULL)
return sym;
- return cp_lookup_symbol_namespace (scope, name, linkage_name, block, domain,
- 1);
+ return cp_lookup_symbol_namespace (scope, name, block, domain, 1);
}
/* Look up NAME in the C++ namespace NAMESPACE. Other arguments are as in
static struct symbol *
cp_lookup_symbol_in_namespace (const char *namespace,
const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain)
{
if (namespace[0] == '\0')
{
- return lookup_symbol_file (name, linkage_name, block,
- domain, 0);
+ return lookup_symbol_file (name, block, domain, 0);
}
else
{
strcpy (concatenated_name, namespace);
strcat (concatenated_name, "::");
strcat (concatenated_name, name);
- return lookup_symbol_file (concatenated_name, linkage_name,
- block, domain,cp_is_anonymous (namespace));
+ return lookup_symbol_file (concatenated_name, block,
+ domain,cp_is_anonymous (namespace));
}
}
static struct symbol *
cp_lookup_symbol_imports (const char *scope,
const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain,
const int search_parents)
struct cleanup *searched_cleanup;
/* First, try to find the symbol in the given namespace. */
- sym = cp_lookup_symbol_in_namespace (scope, name, linkage_name, block,
- domain);
+ sym = cp_lookup_symbol_in_namespace (scope, name, block, domain);
if (sym != NULL)
return sym;
{
sym = cp_lookup_symbol_in_namespace (scope,
current->import_src,
- linkage_name,
block,
domain);
}
NAMESPACE to direct the search towards the imported namespace. */
sym = cp_lookup_symbol_imports (current->import_src,
name,
- linkage_name,
block,
domain,
0);
struct symbol*
cp_lookup_symbol_namespace (const char *scope,
const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain,
const int search_parents)
/* Search for name in namespaces imported to this and parent blocks. */
while (block != NULL)
{
- sym = cp_lookup_symbol_imports (scope, name, linkage_name, block, domain,
+ sym = cp_lookup_symbol_imports (scope, name, block, domain,
search_parents);
if (sym)
static struct symbol *
lookup_namespace_scope (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain,
const char *scope,
new_scope_len += 2;
}
new_scope_len += cp_find_first_component (scope + new_scope_len);
- sym = lookup_namespace_scope (name, linkage_name, block,
- domain, scope, new_scope_len);
+ sym = lookup_namespace_scope (name, block, domain, scope, new_scope_len);
if (sym != NULL)
return sym;
}
namespace = alloca (scope_len + 1);
strncpy (namespace, scope, scope_len);
namespace[scope_len] = '\0';
- return cp_lookup_symbol_in_namespace (namespace, name, linkage_name,
- block, domain);
+ return cp_lookup_symbol_in_namespace (namespace, name, block, domain);
}
/* Look up NAME in BLOCK's static block and in global blocks. If
static struct symbol *
lookup_symbol_file (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain,
int anonymous_namespace)
{
struct symbol *sym = NULL;
- sym = lookup_symbol_static (name, linkage_name, block, domain);
+ sym = lookup_symbol_static (name, block, domain);
if (sym != NULL)
return sym;
const struct block *global_block = block_global_block (block);
if (global_block != NULL)
- sym = lookup_symbol_aux_block (name, linkage_name, global_block,
- domain);
+ sym = lookup_symbol_aux_block (name, global_block, domain);
}
else
{
- sym = lookup_symbol_global (name, linkage_name, block, domain);
+ sym = lookup_symbol_global (name, block, domain);
}
if (sym != NULL)
const char *parent_name = TYPE_TAG_NAME (parent_type);
struct symbol *sym = cp_lookup_symbol_in_namespace (parent_name,
nested_name,
- NULL,
block,
VAR_DOMAIN);
if (sym == NULL || SYMBOL_CLASS (sym) != LOC_TYPEDEF)
memcpy (name_copy, name, len);
name_copy[len] = '\0';
- sym = lookup_block_symbol (block, name_copy, NULL, VAR_DOMAIN);
+ sym = lookup_block_symbol (block, name_copy, VAR_DOMAIN);
if (sym == NULL)
{
struct symbol *sym;
sym = lookup_block_symbol (get_possible_namespace_block (objfile),
- name, NULL, VAR_DOMAIN);
+ name, VAR_DOMAIN);
if (sym != NULL)
return sym;
if (ps->readin)
continue;
- if ((lookup_partial_symbol (ps, func_name, NULL, 1, VAR_DOMAIN)
+ if ((lookup_partial_symbol (ps, func_name, 1, VAR_DOMAIN)
!= NULL)
- || (lookup_partial_symbol (ps, func_name, NULL, 0, VAR_DOMAIN)
+ || (lookup_partial_symbol (ps, func_name, 0, VAR_DOMAIN)
!= NULL))
psymtab_to_symtab (ps);
}
extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol);
extern struct symbol *cp_lookup_symbol_nonlocal (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain);
extern struct symbol *cp_lookup_symbol_namespace (const char *namespace,
const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain,
const int search_parents);
#include "gdbcmd.h"
#include "block.h"
#include "addrmap.h"
+#include "typeprint.h"
+#include "jv-lang.h"
#include <fcntl.h>
#include "gdb_string.h"
unsigned int has_byte_size : 1;
/* The name of this DIE. Normally the value of DW_AT_name, but
- sometimes DW_TAG_MIPS_linkage_name or a string computed in some
- other fashion. */
+ sometimes a default name for unnamed DIEs. */
char *name;
/* The scope to prepend to our children. This is generally
static void add_partial_symbol (struct partial_die_info *,
struct dwarf2_cu *);
-static int pdi_needs_namespace (enum dwarf_tag tag);
-
static void add_partial_namespace (struct partial_die_info *pdi,
CORE_ADDR *lowpc, CORE_ADDR *highpc,
int need_pc, struct dwarf2_cu *cu);
static void process_structure_scope (struct die_info *, struct dwarf2_cu *);
-static const char *determine_class_name (struct die_info *die,
- struct dwarf2_cu *cu);
-
static void read_common_block (struct die_info *, struct dwarf2_cu *);
static void read_namespace (struct die_info *die, struct dwarf2_cu *);
static void process_die (struct die_info *, struct dwarf2_cu *);
-static char *dwarf2_linkage_name (struct die_info *, struct dwarf2_cu *);
-
static char *dwarf2_canonicalize_name (char *, struct dwarf2_cu *,
struct obstack *);
baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
- if (pdi_needs_namespace (pdi->tag))
- {
- actual_name = partial_die_full_name (pdi, cu);
- if (actual_name)
- built_actual_name = 1;
- }
+ actual_name = partial_die_full_name (pdi, cu);
+ if (actual_name)
+ built_actual_name = 1;
if (actual_name == NULL)
actual_name = pdi->name;
break;
}
- /* Check to see if we should scan the name for possible namespace
- info. Only do this if this is C++, if we don't have namespace
- debugging info in the file, if the psym is of an appropriate type
- (otherwise we'll have psym == NULL), and if we actually had a
- mangled name to begin with. */
-
- /* FIXME drow/2004-02-22: Why don't we do this for classes, i.e. the
- cases which do not set PSYM above? */
-
- if (cu->language == language_cplus
- && cu->has_namespace_info == 0
- && psym != NULL
- && SYMBOL_CPLUS_DEMANGLED_NAME (psym) != NULL)
- cp_check_possible_namespace_symbols (SYMBOL_CPLUS_DEMANGLED_NAME (psym),
- objfile);
-
if (built_actual_name)
xfree (actual_name);
}
-/* Determine whether a die of type TAG living in a C++ class or
- namespace needs to have the name of the scope prepended to the
- name listed in the die. */
-
-static int
-pdi_needs_namespace (enum dwarf_tag tag)
-{
- switch (tag)
- {
- case DW_TAG_namespace:
- case DW_TAG_typedef:
- case DW_TAG_class_type:
- case DW_TAG_interface_type:
- case DW_TAG_structure_type:
- case DW_TAG_union_type:
- case DW_TAG_enumeration_type:
- case DW_TAG_enumerator:
- return 1;
- default:
- return 0;
- }
-}
-
/* Read a partial die corresponding to a namespace; also, add a symbol
corresponding to that namespace to the symbol table. NAMESPACE is
the name of the enclosing namespace. */
could fix this by only using the demangled name to get the
prefix (but see comment in read_structure_type). */
- struct partial_die_info *child_pdi = struct_pdi->die_child;
struct partial_die_info *real_pdi;
/* If this DIE (this DIE's specification, if any) has a parent, then
if (real_pdi->die_parent != NULL)
return;
-
- while (child_pdi != NULL)
- {
- if (child_pdi->tag == DW_TAG_subprogram)
- {
- char *actual_class_name
- = language_class_name_from_physname (cu->language_defn,
- child_pdi->name);
- if (actual_class_name != NULL)
- {
- struct_pdi->name
- = obsavestring (actual_class_name,
- strlen (actual_class_name),
- &cu->objfile->objfile_obstack);
- xfree (actual_class_name);
- }
- break;
- }
-
- child_pdi = child_pdi->die_sibling;
- }
}
}
}
}
+/* A helper function for dwarf2_compute_name which determines whether DIE
+ needs to have the name of the scope prepended to the name listed in the
+ die. */
+
+static int
+die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu)
+{
+ switch (die->tag)
+ {
+ case DW_TAG_namespace:
+ case DW_TAG_typedef:
+ case DW_TAG_class_type:
+ case DW_TAG_interface_type:
+ case DW_TAG_structure_type:
+ case DW_TAG_union_type:
+ case DW_TAG_enumeration_type:
+ case DW_TAG_enumerator:
+ case DW_TAG_subprogram:
+ case DW_TAG_member:
+ return 1;
+
+ case DW_TAG_variable:
+ /* We only need to prefix "globally" visible variables. These include
+ any variable marked with DW_AT_external or any variable that
+ lives in a namespace. [Variables in anonymous namespaces
+ require prefixing, but they are not DW_AT_external.] */
+
+ if (dwarf2_attr (die, DW_AT_specification, cu))
+ {
+ struct dwarf2_cu *spec_cu = cu;
+ return die_needs_namespace (die_specification (die, &spec_cu),
+ spec_cu);
+ }
+
+ if (dwarf2_attr (die, DW_AT_external, cu)
+ || die->parent->tag == DW_TAG_namespace)
+ return 1;
+
+ return 0;
+
+ default:
+ return 0;
+ }
+}
+
+/* Compute the fully qualified name of DIE in CU. If PHYSNAME is nonzero,
+ compute the physname for the object, which include a method's
+ formal parameters (C++/Java) and return type (Java).
+
+ The result is allocated on the objfile_obstack and canonicalized. */
+
+static const char *
+dwarf2_compute_name (char *name, struct die_info *die, struct dwarf2_cu *cu,
+ int physname)
+{
+ if (name == NULL)
+ name = dwarf2_name (die, cu);
+
+ /* These are the only languages we know how to qualify names in. */
+ if (name != NULL
+ && (cu->language == language_cplus || cu->language == language_java))
+ {
+ if (die_needs_namespace (die, cu))
+ {
+ long length;
+ char *prefix;
+ struct ui_file *buf;
+
+ prefix = determine_prefix (die, cu);
+ buf = mem_fileopen ();
+ if (*prefix != '\0')
+ {
+ char *prefixed_name = typename_concat (NULL, prefix, name, cu);
+ fputs_unfiltered (prefixed_name, buf);
+ xfree (prefixed_name);
+ }
+ else
+ fputs_unfiltered (name ? name : "", buf);
+
+ /* For Java and C++ methods, append formal parameter type
+ information, if PHYSNAME. */
+
+ if (physname && die->tag == DW_TAG_subprogram
+ && (cu->language == language_cplus
+ || cu->language == language_java))
+ {
+ struct type *type = read_type_die (die, cu);
+
+ c_type_print_args (type, buf, 0, cu->language);
+
+ if (cu->language == language_java)
+ {
+ /* For java, we must append the return type to method
+ names. */
+ if (die->tag == DW_TAG_subprogram)
+ java_print_type (TYPE_TARGET_TYPE (type), "", buf,
+ 0, 0);
+ }
+ else if (cu->language == language_cplus)
+ {
+ if (TYPE_NFIELDS (type) > 0
+ && TYPE_FIELD_ARTIFICIAL (type, 0)
+ && TYPE_CONST (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0))))
+ fputs_unfiltered (" const", buf);
+ }
+ }
+
+ name = ui_file_obsavestring (buf, &cu->objfile->objfile_obstack,
+ &length);
+ ui_file_delete (buf);
+
+ if (cu->language == language_cplus)
+ {
+ char *cname
+ = dwarf2_canonicalize_name (name, cu,
+ &cu->objfile->objfile_obstack);
+ if (cname != NULL)
+ name = cname;
+ }
+ }
+ }
+
+ return name;
+}
+
/* Return the fully qualified name of DIE, based on its DW_AT_name.
If scope qualifiers are appropriate they will be added. The result
will be allocated on the objfile_obstack, or NULL if the DIE does
- not have a name. */
+ not have a name. NAME may either be from a previous call to
+ dwarf2_name or NULL.
+
+ The output string will be canonicalized (if C++/Java). */
static const char *
-dwarf2_full_name (struct die_info *die, struct dwarf2_cu *cu)
+dwarf2_full_name (char *name, struct die_info *die, struct dwarf2_cu *cu)
{
- struct attribute *attr;
- char *prefix, *name;
- struct ui_file *buf = NULL;
+ return dwarf2_compute_name (name, die, cu, 0);
+}
- name = dwarf2_name (die, cu);
- if (!name)
- return NULL;
+/* Construct a physname for the given DIE in CU. NAME may either be
+ from a previous call to dwarf2_name or NULL. The result will be
+ allocated on the objfile_objstack or NULL if the DIE does not have a
+ name.
- /* These are the only languages we know how to qualify names in. */
- if (cu->language != language_cplus
- && cu->language != language_java)
- return name;
-
- /* If no prefix is necessary for this type of DIE, return the
- unqualified name. The other three tags listed could be handled
- in pdi_needs_namespace, but that requires broader changes. */
- if (!pdi_needs_namespace (die->tag)
- && die->tag != DW_TAG_subprogram
- && die->tag != DW_TAG_variable
- && die->tag != DW_TAG_member)
- return name;
-
- prefix = determine_prefix (die, cu);
- if (*prefix != '\0')
- name = typename_concat (&cu->objfile->objfile_obstack, prefix,
- name, cu);
+ The output string will be canonicalized (if C++/Java). */
- return name;
+static const char *
+dwarf2_physname (char *name, struct die_info *die, struct dwarf2_cu *cu)
+{
+ return dwarf2_compute_name (name, die, cu, 1);
}
/* Read the import statement specified by the given die and record it. */
baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
- name = dwarf2_linkage_name (die, cu);
+ name = dwarf2_name (die, cu);
/* Ignore functions with missing or empty names and functions with
missing or invalid low and high pc attributes. */
return;
/* Get physical name. */
- physname = dwarf2_linkage_name (die, cu);
+ physname = (char *) dwarf2_physname (fieldname, die, cu);
/* The name is already allocated along with this objfile, so we don't
need to duplicate it for the type. */
return;
/* Get the mangled name. */
- physname = dwarf2_linkage_name (die, cu);
+ physname = (char *) dwarf2_physname (fieldname, die, cu);
/* Look up member function name in fieldlist. */
for (i = 0; i < fip->nfnfields; i++)
if (cu->language == language_cplus
|| cu->language == language_java)
{
- const char *new_prefix = determine_class_name (die, cu);
- TYPE_TAG_NAME (type) = (char *) new_prefix;
+ TYPE_TAG_NAME (type) = (char *) dwarf2_full_name (name, die, cu);
+ if (die->tag == DW_TAG_structure_type
+ || die->tag == DW_TAG_class_type)
+ TYPE_NAME (type) = TYPE_TAG_NAME (type);
}
else
{
/* The name is already allocated along with this objfile, so
we don't need to duplicate it for the type. */
- TYPE_TAG_NAME (type) = name;
+ TYPE_TAG_NAME (type) = (char *) name;
+ if (die->tag == DW_TAG_class_type)
+ TYPE_NAME (type) = TYPE_TAG_NAME (type);
}
}
type = alloc_type (objfile);
TYPE_CODE (type) = TYPE_CODE_ENUM;
- name = dwarf2_full_name (die, cu);
+ name = dwarf2_full_name (NULL, die, cu);
if (name != NULL)
TYPE_TAG_NAME (type) = (char *) name;
return set_die_type (die, type, cu);
}
-/* Determine the name of the type represented by DIE, which should be
- a named C++ or Java compound type. Return the name in question,
- allocated on the objfile obstack. */
-
-static const char *
-determine_class_name (struct die_info *die, struct dwarf2_cu *cu)
-{
- const char *new_prefix = NULL;
-
- /* If we don't have namespace debug info, guess the name by trying
- to demangle the names of members, just like we did in
- guess_structure_name. */
- if (!processing_has_namespace_info)
- {
- struct die_info *child;
-
- for (child = die->child;
- child != NULL && child->tag != 0;
- child = sibling_die (child))
- {
- if (child->tag == DW_TAG_subprogram)
- {
- char *phys_prefix
- = language_class_name_from_physname (cu->language_defn,
- dwarf2_linkage_name
- (child, cu));
-
- if (phys_prefix != NULL)
- {
- new_prefix
- = obsavestring (phys_prefix, strlen (phys_prefix),
- &cu->objfile->objfile_obstack);
- xfree (phys_prefix);
- break;
- }
- }
- }
- }
-
- if (new_prefix == NULL)
- new_prefix = dwarf2_full_name (die, cu);
-
- return new_prefix;
-}
-
/* Given a pointer to a die which begins an enumeration, process all
the dies that define the members of the enumeration, and create the
symbol for the enumeration type.
const char *name = NULL;
struct type *this_type;
- name = dwarf2_full_name (die, cu);
+ name = dwarf2_full_name (NULL, die, cu);
this_type = init_type (TYPE_CODE_TYPEDEF, 0,
TYPE_FLAG_TARGET_STUB, NULL, objfile);
TYPE_NAME (this_type) = (char *) name;
}
break;
case DW_AT_MIPS_linkage_name:
- part_die->name = DW_STRING (&attr);
+ if (cu->language == language_ada)
+ part_die->name = DW_STRING (&attr);
break;
case DW_AT_low_pc:
has_low_pc_attr = 1;
baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
- if (die->tag != DW_TAG_namespace)
- name = dwarf2_linkage_name (die, cu);
- else
- name = TYPE_NAME (type);
-
+ name = dwarf2_name (die, cu);
if (name)
{
+ const char *linkagename;
+
sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
sizeof (struct symbol));
OBJSTAT (objfile, n_syms++);
/* Cache this symbol's name and the name's demangled form (if any). */
SYMBOL_LANGUAGE (sym) = cu->language;
- SYMBOL_SET_NAMES (sym, name, strlen (name), 0, objfile);
+ linkagename = dwarf2_physname (name, die, cu);
+ SYMBOL_SET_NAMES (sym, linkagename, strlen (linkagename), 0, objfile);
/* Default assumptions.
Use the passed type or decode it from the die. */
}
break;
case DW_TAG_typedef:
- SYMBOL_LINKAGE_NAME (sym) = (char *) dwarf2_full_name (die, cu);
+ SYMBOL_LINKAGE_NAME (sym)
+ = (char *) dwarf2_full_name (name, die, cu);
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
add_symbol_to_list (sym, cu->list_in_scope);
add_symbol_to_list (sym, cu->list_in_scope);
break;
case DW_TAG_enumerator:
- SYMBOL_LINKAGE_NAME (sym) = (char *) dwarf2_full_name (die, cu);
+ SYMBOL_LINKAGE_NAME (sym)
+ = (char *) dwarf2_full_name (name, die, cu);
attr = dwarf2_attr (die, DW_AT_const_value, cu);
if (attr)
{
/* For the benefit of old versions of GCC, check for anonymous
namespaces based on the demangled name. */
if (!processing_has_namespace_info
- && cu->language == language_cplus
- && dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu) != NULL)
+ && cu->language == language_cplus)
cp_scan_for_anonymous_namespaces (sym);
}
return (sym);
return die->sibling;
}
-/* Get linkage name of a die, return NULL if not found. */
-
-static char *
-dwarf2_linkage_name (struct die_info *die, struct dwarf2_cu *cu)
-{
- struct attribute *attr;
-
- attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu);
- if (attr && DW_STRING (attr))
- return DW_STRING (attr);
- return dwarf2_name (die, cu);
-}
-
/* Get name of a die, return NULL if not found. */
static char *
if (TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
{
function = cp_lookup_symbol_namespace (TYPE_TAG_NAME (type),
- name, NULL,
+ name,
get_selected_block (0),
VAR_DOMAIN, 1);
if (function == NULL)
#include "demangle.h"
#include "objfiles.h"
#include "valprint.h"
+#include "c-lang.h"
#include "gdb_assert.h"
#include "gdb_string.h"
LONGEST adjustment)
{
int i;
- const char *physname;
/* Search this class first. */
- physname = NULL;
if (adjustment == 0)
{
int len;
{
char *demangled_name = cplus_demangle (physname,
DMGL_ANSI | DMGL_PARAMS);
- if (demangled_name != NULL)
+ fprintf_filtered (stream, "&virtual ");
+ if (demangled_name == NULL)
+ fputs_filtered (physname, stream);
+ else
{
- fprintf_filtered (stream, "&virtual ");
fputs_filtered (demangled_name, stream);
xfree (demangled_name);
- return;
}
+ return;
}
}
+ else if (ptr_value != 0)
+ {
+ /* Found a non-virtual function: print out the type. */
+ fputs_filtered ("(", stream);
+ c_print_type (type, "", stream, -1, 0);
+ fputs_filtered (") ", stream);
+ }
/* We didn't find it; print the raw data. */
if (vbit)
variables. */
struct symbol *(*la_lookup_symbol_nonlocal) (const char *,
- const char *,
const struct block *,
const domain_enum);
#include "interps.h"
#include "mi/mi-cmds.h"
#include "target.h"
+#include "arch-utils.h"
/* We share this one with symtab.c, but it is not exported widely. */
static void initialize_defaults (struct symtab **default_symtab,
int *default_line);
-static void set_flags (char *arg, int *is_quoted, char **paren_pointer);
-
static struct symtabs_and_lines decode_indirect (char **argptr);
static char *locate_first_half (char **argptr, int *is_quote_enclosed);
discard_cleanups (old_chain);
return return_values;
}
+
+/* A helper function for decode_line_1 and friends which skips P
+ past any method overload information at the beginning of P, e.g.,
+ "(const struct foo *)".
+
+ This function assumes that P has already been validated to contain
+ overload information, and it will assert if *P != '('. */
+static char *
+find_method_overload_end (char *p)
+{
+ int depth = 0;
+
+ gdb_assert (*p == '(');
+
+ while (*p)
+ {
+ if (*p == '(')
+ ++depth;
+ else if (*p == ')')
+ {
+ if (--depth == 0)
+ {
+ ++p;
+ break;
+ }
+ }
+ ++p;
+ }
+
+ return p;
+}
\f
/* The parser of linespec itself. */
struct symtab *file_symtab = NULL;
char *copy;
- /* This is NULL if there are no parens in *ARGPTR, or a pointer to
- the closing parenthesis if there are parens. */
- char *paren_pointer;
/* This says whether or not something in *ARGPTR is quoted with
completer_quotes (i.e. with single quotes). */
int is_quoted;
if (**argptr == '*')
return decode_indirect (argptr);
- /* Set various flags. 'paren_pointer' is important for overload
- checking, where we allow things like:
- (gdb) break c::f(int)
- */
-
- set_flags (*argptr, &is_quoted, &paren_pointer);
+ is_quoted = (*argptr
+ && strchr (get_gdb_completer_quote_characters (),
+ **argptr) != NULL);
if (is_quoted)
end_quote = skip_quoted (*argptr);
/* Check if this is an Objective-C method (anything that starts with
a '+' or '-' and a '['). */
if (is_objc_method_format (p))
- {
- is_objc_method = 1;
- paren_pointer = NULL; /* Just a category name. Ignore it. */
- }
+ is_objc_method = 1;
/* Check if the symbol could be an Objective-C selector. */
if (p[0] == '.' || p[1] == ':')
{
- if (paren_pointer == NULL)
- return decode_compound (argptr, funfirstline, canonical,
+ struct symtabs_and_lines values;
+
+ if (is_quote_enclosed)
+ ++saved_arg;
+ values = decode_compound (argptr, funfirstline, canonical,
saved_arg, p, not_found_ptr);
- /* Otherwise, fall through to decode_variable below. */
+ if (is_quoted && **argptr == '\'')
+ *argptr = *argptr + 1;
+ return values;
}
- else
- {
- /* No, the first part is a filename; set file_symtab to be that file's
- symtab. Also, move argptr past the filename. */
-
- file_symtab = symtab_from_filename (argptr, p, is_quote_enclosed,
- not_found_ptr);
- /* Check for single quotes on the non-filename part. */
- if (!is_quoted)
- {
- is_quoted = (**argptr
- && strchr (get_gdb_completer_quote_characters (),
- **argptr) != NULL);
- if (is_quoted)
- end_quote = skip_quoted (*argptr);
- }
- }
- }
-#if 0
- /* No one really seems to know why this was added. It certainly
- breaks the command line, though, whenever the passed
- name is of the form ClassName::Method. This bit of code
- singles out the class name, and if funfirstline is set (for
- example, you are setting a breakpoint at this function),
- you get an error. This did not occur with earlier
- verions, so I am ifdef'ing this out. 3/29/99 */
- else
- {
- /* Check if what we have till now is a symbol name */
+ /* No, the first part is a filename; set file_symtab to be that file's
+ symtab. Also, move argptr past the filename. */
- /* We may be looking at a template instantiation such
- as "foo<int>". Check here whether we know about it,
- instead of falling through to the code below which
- handles ordinary function names, because that code
- doesn't like seeing '<' and '>' in a name -- the
- skip_quoted call doesn't go past them. So see if we
- can figure it out right now. */
+ file_symtab = symtab_from_filename (argptr, p, is_quote_enclosed,
+ not_found_ptr);
- copy = (char *) alloca (p - *argptr + 1);
- memcpy (copy, *argptr, p - *argptr);
- copy[p - *argptr] = '\000';
- sym = lookup_symbol (copy, 0, VAR_DOMAIN, 0);
- if (sym)
+ /* Check for single quotes on the non-filename part. */
+ if (!is_quoted)
{
- *argptr = (*p == '\'') ? p + 1 : p;
- return symbol_found (funfirstline, canonical, copy, sym, NULL);
+ is_quoted = (**argptr
+ && strchr (get_gdb_completer_quote_characters (),
+ **argptr) != NULL);
+ if (is_quoted)
+ end_quote = skip_quoted (*argptr);
}
- /* Otherwise fall out from here and go to file/line spec
- processing, etc. */
}
-#endif
/* file_symtab is specified file's symtab, or 0 if no file specified.
arg no longer contains the file name. */
/* allow word separators in method names for Obj-C */
p = skip_quoted_chars (*argptr, NULL, "");
}
- else if (paren_pointer != NULL)
- {
- p = paren_pointer + 1;
- }
else
{
p = skip_quoted (*argptr);
if (*p == '<')
p = find_template_name_end (p);
+ /* Keep method overload information. */
+ if (*p == '(')
+ p = find_method_overload_end (p);
+
+ /* Make sure we keep important kewords like "const" */
+ if (strncmp (p, " const", 6) == 0)
+ p += 6;
+
copy = (char *) alloca (p - *argptr + 1);
memcpy (copy, *argptr, p - *argptr);
copy[p - *argptr] = '\0';
function is passed ARGPTR as an argument, it modifies what ARGPTR
points to; typically, it advances *ARGPTR past whatever substring
it has just looked at. (If it doesn't modify *ARGPTR, then the
- function gets passed *ARGPTR instead, which is then called ARG: see
- set_flags, for example.) Also, functions that return a struct
- symtabs_and_lines may modify CANONICAL, as in the description of
- decode_line_1.
+ function gets passed *ARGPTR instead, which is then called ARG.)
+ Also, functions that return a struct symtabs_and_lines may modify
+ CANONICAL, as in the description of decode_line_1.
If a function returns a struct symtabs_and_lines, then that struct
will immediately make its way up the call chain to be returned by
}
}
-static void
-set_flags (char *arg, int *is_quoted, char **paren_pointer)
-{
- char *ii;
- int has_if = 0;
-
- /* 'has_if' is for the syntax:
- (gdb) break foo if (a==b)
- */
- if ((ii = strstr (arg, " if ")) != NULL ||
- (ii = strstr (arg, "\tif ")) != NULL ||
- (ii = strstr (arg, " if\t")) != NULL ||
- (ii = strstr (arg, "\tif\t")) != NULL ||
- (ii = strstr (arg, " if(")) != NULL ||
- (ii = strstr (arg, "\tif( ")) != NULL)
- has_if = 1;
- /* Temporarily zap out "if (condition)" to not confuse the
- parenthesis-checking code below. This is undone below. Do not
- change ii!! */
- if (has_if)
- {
- *ii = '\0';
- }
-
- *is_quoted = (*arg
- && strchr (get_gdb_completer_quote_characters (),
- *arg) != NULL);
-
- *paren_pointer = strchr (arg, '(');
- if (*paren_pointer != NULL)
- *paren_pointer = strrchr (*paren_pointer, ')');
-
- /* Now that we're safely past the paren_pointer check, put back " if
- (condition)" so outer layers can see it. */
- if (has_if)
- *ii = ' ';
-}
-
\f
/* Decode arg of the form *PC. */
if (p[0] == '.' && strchr (p, ':') == NULL)
{
/* Java qualified method. Find the *last* '.', since the
- others are package qualifiers. */
- for (p1 = p; *p1; p1++)
+ others are package qualifiers. Stop at any open parenthesis
+ which might provide overload information. */
+ for (p1 = p; *p1 && *p1 != '('; p1++)
{
if (*p1 == '.')
p = p1;
struct symbol *sym_class;
struct symbol **sym_arr;
struct type *t;
+ char *saved_java_argptr = NULL;
/* First check for "global" namespace specification, of the form
"::foo". If found, skip over the colons and jump to normal
/* PASS2: p2->"::fun", p->":fun" */
/* Move pointer ahead to next double-colon. */
- while (*p && (p[0] != ' ') && (p[0] != '\t') && (p[0] != '\''))
+ while (*p && (p[0] != ' ') && (p[0] != '\t') && (p[0] != '\'')
+ && (*p != '('))
{
if (current_language->la_language == language_cplus)
p += cp_validate_operator (p);
else
{
/* At this point argptr->"fun". */
+ char *a;
p = *argptr;
- while (*p && *p != ' ' && *p != '\t' && *p != ',' && *p != ':')
+ while (*p && *p != ' ' && *p != '\t' && *p != ',' && *p != ':'
+ && *p != '(')
p++;
/* At this point p->"". String ended. */
/* Nope, C++ operators could have spaces in them
/* The above loop has already swallowed "operator". */
p += cp_validate_operator (p - 8) - 8;
}
+
+ /* Keep any template parameters */
+ if (*p == '<')
+ p = find_template_name_end (p);
+
+ /* Keep method overload information. */
+ a = strchr (p, '(');
+ if (a != NULL)
+ p = find_method_overload_end (a);
+
+ /* Make sure we keep important kewords like "const" */
+ if (strncmp (p, " const", 6) == 0)
+ p += 6;
+
+ /* Java may append typenames, so assume that if there is
+ anything else left in *argptr, it must be a typename. */
+ if (*p && current_language->la_language == language_java)
+ {
+ struct type *type;
+ p2 = p;
+ while (*p2)
+ ++p2;
+ copy = (char *) alloca (p2 - p + 1);
+ memcpy (copy, p, p2 - p);
+ copy[p2 - p] = '\0';
+ type = lookup_typename (current_language, get_current_arch (),
+ copy, NULL, 1);
+ if (type != NULL)
+ {
+ /* Save the location of this just in case this
+ method/type combination isn't actually defined.
+ It will be checked later. */
+ saved_java_argptr = p;
+ p = p2;
+ }
+ }
}
/* Allocate our own copy of the substring between argptr and
here, we return. If not, and we are at the and of the string,
we'll lookup the whole string in the symbol tables. */
- return find_method (funfirstline, canonical, saved_arg,
- copy, t, sym_class, not_found_ptr);
-
+ values = find_method (funfirstline, canonical, saved_arg,
+ copy, t, sym_class, not_found_ptr);
+ if (saved_java_argptr != NULL && values.nelts == 1)
+ {
+ /* The user specified a specific return type for a java method.
+ Double-check that it really is the one the user specified.
+ [This is a necessary evil because strcmp_iw_ordered stops
+ comparisons too prematurely.] */
+ sym = find_pc_sect_function (values.sals[0].pc,
+ values.sals[0].section);
+ /* We just found a SAL, we had better be able to go backwards! */
+ gdb_assert (sym != NULL);
+ if (strcmp_iw (SYMBOL_LINKAGE_NAME (sym), saved_arg) != 0)
+ {
+ xfree (values.sals);
+ error (_("the class `%s' does not have any method instance named %s\n"),
+ SYMBOL_PRINT_NAME (sym_class), copy);
+ }
+ }
+ return values;
} /* End if symbol found */
}
if (i1 > 0)
{
- /* There is more than one field with that name
- (overloaded). Ask the user which one to use. */
+ /* If we were given a specific overload instance, use that
+ (or error if no matches were found). Otherwise ask the user
+ which one to use. */
+ if (strchr (saved_arg, '(') != NULL)
+ {
+ int i;
+ for (i = 0; i < i1; ++i)
+ {
+ char *name = saved_arg;
+ char *canon = cp_canonicalize_string (name);
+ if (canon != NULL)
+ name = canon;
+
+ if (strcmp_iw (name, SYMBOL_LINKAGE_NAME (sym_arr[i])) == 0)
+ {
+ values.sals = (struct symtab_and_line *)
+ xmalloc (sizeof (struct symtab_and_line));
+ values.nelts = 1;
+ values.sals[0] = find_function_start_sal (sym_arr[i],
+ funfirstline);
+ if (canon)
+ xfree (canon);
+ return values;
+ }
+
+ if (canon)
+ xfree (canon);
+ }
+
+ error (_("the class `%s' does not have any method instance named %s\n"),
+ SYMBOL_PRINT_NAME (sym_class), copy);
+ }
+
return decode_line_2 (sym_arr, i1, funfirstline, canonical);
}
else
{
struct blockvector *bv = BLOCKVECTOR (SYMBOL_SYMTAB (sym));
struct block *b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- if (lookup_block_symbol (b, copy, NULL, VAR_DOMAIN) != NULL)
+ if (lookup_block_symbol (b, copy, VAR_DOMAIN) != NULL)
build_canonical_line_spec (values.sals, copy, canonical);
}
return values;
{
/* XXX: Should we cache these symbols? */
gdb_output_sym =
- lookup_symbol_global ("gdb_output", NULL, NULL, VAR_DOMAIN);
+ lookup_symbol_global ("gdb_output", NULL, VAR_DOMAIN);
gdb_output_len_sym =
- lookup_symbol_global ("gdb_output_length", NULL, NULL, VAR_DOMAIN);
+ lookup_symbol_global ("gdb_output_length", NULL, VAR_DOMAIN);
if ((gdb_output_sym == NULL) || (gdb_output_len_sym == NULL))
ret = -1;
static struct symbol *
darwin_lookup_lib_symbol (const struct objfile *objfile,
const char *name,
- const char *linkage_name,
const domain_enum domain)
{
return NULL;
static struct symbol *
spu_lookup_lib_symbol (const struct objfile *objfile,
const char *name,
- const char *linkage_name,
const domain_enum domain)
{
if (bfd_get_arch (objfile->obfd) == bfd_arch_spu)
- return lookup_global_symbol_from_objfile (objfile, name, linkage_name,
- domain);
+ return lookup_global_symbol_from_objfile (objfile, name, domain);
if (svr4_so_ops.lookup_lib_global_symbol != NULL)
- return svr4_so_ops.lookup_lib_global_symbol (objfile, name, linkage_name,
- domain);
+ return svr4_so_ops.lookup_lib_global_symbol (objfile, name, domain);
return NULL;
}
static struct symbol *
elf_lookup_lib_symbol (const struct objfile *objfile,
const char *name,
- const char *linkage_name,
const domain_enum domain)
{
bfd *abfd;
if (abfd == NULL || scan_dyntag (DT_SYMBOLIC, abfd, NULL) != 1)
return NULL;
- return lookup_global_symbol_from_objfile
- (objfile, name, linkage_name, domain);
+ return lookup_global_symbol_from_objfile (objfile, name, domain);
}
extern initialize_file_ftype _initialize_svr4_solib; /* -Wmissing-prototypes */
struct symbol *
solib_global_lookup (const struct objfile *objfile,
const char *name,
- const char *linkage_name,
const domain_enum domain)
{
struct target_so_ops *ops = solib_ops (target_gdbarch);
if (ops->lookup_lib_global_symbol != NULL)
- return ops->lookup_lib_global_symbol (objfile, name, linkage_name, domain);
+ return ops->lookup_lib_global_symbol (objfile, name, domain);
return NULL;
}
/* Hook for looking up global symbols in a library-specific way. */
struct symbol * (*lookup_lib_global_symbol) (const struct objfile *objfile,
const char *name,
- const char *linkage_name,
const domain_enum domain);
/* Given two so_list objects, one from the GDB thread list
/* Handler for library-specific global symbol lookup in solib.c. */
struct symbol *solib_global_lookup (const struct objfile *objfile,
const char *name,
- const char *linkage_name,
const domain_enum domain);
#endif
struct symbol *sym;
struct symtab_and_line sal;
- sym = lookup_block_symbol (block, "main", NULL, VAR_DOMAIN);
+ sym = lookup_block_symbol (block, "main", VAR_DOMAIN);
if (sym)
{
fixup_symbol_section (sym, objfile);
while (length--)
{
sym = lookup_block_symbol (b, SYMBOL_LINKAGE_NAME (*psym),
- NULL, SYMBOL_DOMAIN (*psym));
+ SYMBOL_DOMAIN (*psym));
if (!sym)
{
printf_filtered ("Static symbol `");
while (length--)
{
sym = lookup_block_symbol (b, SYMBOL_LINKAGE_NAME (*psym),
- NULL, SYMBOL_DOMAIN (*psym));
+ SYMBOL_DOMAIN (*psym));
if (!sym)
{
printf_filtered ("Global symbol `");
char *operator_chars (char *p, char **end);
static struct symbol *lookup_symbol_aux (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain,
enum language language,
static
struct symbol *lookup_symbol_aux_local (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain);
static
struct symbol *lookup_symbol_aux_symtabs (int block_index,
const char *name,
- const char *linkage_name,
const domain_enum domain);
static
struct symbol *lookup_symbol_aux_psymtabs (int block_index,
const char *name,
- const char *linkage_name,
const domain_enum domain);
static int file_matches (char *, char **, int);
|| gsymbol->language == language_auto)
{
demangled =
- cplus_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
+ cplus_demangle (mangled, DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE);
if (demangled != NULL)
{
gsymbol->language = language_cplus;
{
char *demangled_name = NULL;
const char *modified_name = NULL;
- const char *mangled_name = NULL;
struct symbol *returnval;
struct cleanup *cleanup = make_cleanup (null_cleanup, 0);
demangled_name = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS);
if (demangled_name)
{
- mangled_name = name;
modified_name = demangled_name;
make_cleanup (xfree, demangled_name);
}
DMGL_ANSI | DMGL_PARAMS | DMGL_JAVA);
if (demangled_name)
{
- mangled_name = name;
modified_name = demangled_name;
make_cleanup (xfree, demangled_name);
}
modified_name = copy;
}
- returnval = lookup_symbol_aux (modified_name, mangled_name, block,
- domain, lang, is_a_field_of_this);
+ returnval = lookup_symbol_aux (modified_name, block, domain, lang,
+ is_a_field_of_this);
do_cleanups (cleanup);
return returnval;
well. */
static struct symbol *
-lookup_symbol_aux (const char *name, const char *linkage_name,
- const struct block *block, const domain_enum domain,
- enum language language, int *is_a_field_of_this)
+lookup_symbol_aux (const char *name, const struct block *block,
+ const domain_enum domain, enum language language,
+ int *is_a_field_of_this)
{
struct symbol *sym;
const struct language_defn *langdef;
/* Search specified block and its superiors. Don't search
STATIC_BLOCK or GLOBAL_BLOCK. */
- sym = lookup_symbol_aux_local (name, linkage_name, block, domain);
+ sym = lookup_symbol_aux_local (name, block, domain);
if (sym != NULL)
return sym;
if (function_block && !dict_empty (BLOCK_DICT (function_block)))
sym = lookup_block_symbol (function_block, langdef->la_name_of_this,
- NULL, VAR_DOMAIN);
+ VAR_DOMAIN);
if (sym)
{
struct type *t = sym->type;
/* Now do whatever is appropriate for LANGUAGE to look
up static and global variables. */
- sym = langdef->la_lookup_symbol_nonlocal (name, linkage_name, block, domain);
+ sym = langdef->la_lookup_symbol_nonlocal (name, block, domain);
if (sym != NULL)
return sym;
desired name as a file-level static, then do psymtab-to-symtab
conversion on the fly and return the found symbol. */
- sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, linkage_name, domain);
+ sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain);
if (sym != NULL)
return sym;
- sym = lookup_symbol_aux_psymtabs (STATIC_BLOCK, name, linkage_name, domain);
+ sym = lookup_symbol_aux_psymtabs (STATIC_BLOCK, name, domain);
if (sym != NULL)
return sym;
Don't search STATIC_BLOCK or GLOBAL_BLOCK. */
static struct symbol *
-lookup_symbol_aux_local (const char *name, const char *linkage_name,
- const struct block *block,
+lookup_symbol_aux_local (const char *name, const struct block *block,
const domain_enum domain)
{
struct symbol *sym;
while (block != static_block)
{
- sym = lookup_symbol_aux_block (name, linkage_name, block, domain);
+ sym = lookup_symbol_aux_block (name, block, domain);
if (sym != NULL)
return sym;
block_found appropriately. */
struct symbol *
-lookup_symbol_aux_block (const char *name, const char *linkage_name,
- const struct block *block,
+lookup_symbol_aux_block (const char *name, const struct block *block,
const domain_enum domain)
{
struct symbol *sym;
- sym = lookup_block_symbol (block, name, linkage_name, domain);
+ sym = lookup_block_symbol (block, name, domain);
if (sym)
{
block_found = block;
struct symbol *
lookup_global_symbol_from_objfile (const struct objfile *main_objfile,
const char *name,
- const char *linkage_name,
const domain_enum domain)
{
const struct objfile *objfile;
{
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, linkage_name, domain);
+ sym = lookup_block_symbol (block, name, domain);
if (sym)
{
block_found = block;
ALL_OBJFILE_PSYMTABS (objfile, ps)
{
if (!ps->readin
- && lookup_partial_symbol (ps, name, linkage_name,
- 1, domain))
+ && lookup_partial_symbol (ps, name, 1, domain))
{
s = PSYMTAB_TO_SYMTAB (ps);
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, linkage_name, domain);
+ sym = lookup_block_symbol (block, name, domain);
return fixup_symbol_section (sym, (struct objfile *)objfile);
}
}
static symbols. */
static struct symbol *
-lookup_symbol_aux_symtabs (int block_index,
- const char *name, const char *linkage_name,
+lookup_symbol_aux_symtabs (int block_index, const char *name,
const domain_enum domain)
{
struct symbol *sym;
{
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, block_index);
- sym = lookup_block_symbol (block, name, linkage_name, domain);
+ sym = lookup_block_symbol (block, name, domain);
if (sym)
{
block_found = block;
static struct symbol *
lookup_symbol_aux_psymtabs (int block_index, const char *name,
- const char *linkage_name,
const domain_enum domain)
{
struct symbol *sym;
ALL_PSYMTABS (objfile, ps)
{
if (!ps->readin
- && lookup_partial_symbol (ps, name, linkage_name,
- psymtab_index, domain))
+ && lookup_partial_symbol (ps, name, psymtab_index, domain))
{
s = PSYMTAB_TO_SYMTAB (ps);
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, block_index);
- sym = lookup_block_symbol (block, name, linkage_name, domain);
+ sym = lookup_block_symbol (block, name, domain);
if (!sym)
{
/* This shouldn't be necessary, but as a last resort try
block = BLOCKVECTOR_BLOCK (bv,
block_index == GLOBAL_BLOCK ?
STATIC_BLOCK : GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, linkage_name, domain);
+ sym = lookup_block_symbol (block, name, domain);
if (!sym)
error (_("Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n%s may be an inlined function, or may be a template function\n(if a template, try specifying an instantiation: %s<type>)."),
block_index == GLOBAL_BLOCK ? "global" : "static",
struct symbol *
basic_lookup_symbol_nonlocal (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain)
{
than that one, so I don't think we should worry about that for
now. */
- sym = lookup_symbol_static (name, linkage_name, block, domain);
+ sym = lookup_symbol_static (name, block, domain);
if (sym != NULL)
return sym;
- return lookup_symbol_global (name, linkage_name, block, domain);
+ return lookup_symbol_global (name, block, domain);
}
/* Lookup a symbol in the static block associated to BLOCK, if there
struct symbol *
lookup_symbol_static (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain)
{
const struct block *static_block = block_static_block (block);
if (static_block != NULL)
- return lookup_symbol_aux_block (name, linkage_name, static_block, domain);
+ return lookup_symbol_aux_block (name, static_block, domain);
else
return NULL;
}
struct symbol *
lookup_symbol_global (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain)
{
/* Call library-specific lookup procedure. */
objfile = lookup_objfile_from_block (block);
if (objfile != NULL)
- sym = solib_global_lookup (objfile, name, linkage_name, domain);
+ sym = solib_global_lookup (objfile, name, domain);
if (sym != NULL)
return sym;
- sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, linkage_name, domain);
+ sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, domain);
if (sym != NULL)
return sym;
- return lookup_symbol_aux_psymtabs (GLOBAL_BLOCK, name, linkage_name, domain);
+ return lookup_symbol_aux_psymtabs (GLOBAL_BLOCK, name, domain);
}
int
}
/* Look, in partial_symtab PST, for symbol whose natural name is NAME.
- If LINKAGE_NAME is non-NULL, check in addition that the symbol's
- linkage name matches it. Check the global symbols if GLOBAL, the
- static symbols if not */
+ Check the global symbols if GLOBAL, the static symbols if not. */
struct partial_symbol *
lookup_partial_symbol (struct partial_symtab *pst, const char *name,
- const char *linkage_name, int global,
- domain_enum domain)
+ int global, domain_enum domain)
{
struct partial_symbol *temp;
struct partial_symbol **start, **psym;
internal_error (__FILE__, __LINE__, _("failed internal consistency check"));
while (top <= real_top
- && (linkage_name != NULL
- ? strcmp (SYMBOL_LINKAGE_NAME (*top), linkage_name) == 0
- : SYMBOL_MATCHES_SEARCH_NAME (*top,name)))
+ && SYMBOL_MATCHES_SEARCH_NAME (*top, name))
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (*top),
SYMBOL_DOMAIN (*top), domain))
for (psym = start; psym < start + length; psym++)
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym),
- SYMBOL_DOMAIN (*psym), domain))
- {
- if (linkage_name != NULL
- ? strcmp (SYMBOL_LINKAGE_NAME (*psym), linkage_name) == 0
- : SYMBOL_MATCHES_SEARCH_NAME (*psym, name))
- {
- return (*psym);
- }
- }
+ SYMBOL_DOMAIN (*psym), domain)
+ && SYMBOL_MATCHES_SEARCH_NAME (*psym, name))
+ return (*psym);
}
}
{
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
{
return SYMBOL_TYPE (sym);
ALL_PSYMTABS (objfile, ps)
{
- if (!ps->readin && lookup_partial_symbol (ps, name, NULL,
- 1, STRUCT_DOMAIN))
+ if (!ps->readin && lookup_partial_symbol (ps, name, 1, STRUCT_DOMAIN))
{
s = PSYMTAB_TO_SYMTAB (ps);
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
if (!sym)
{
/* This shouldn't be necessary, but as a last resort
* the psymtab gets it wrong in some cases.
*/
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
if (!sym)
error (_("Internal: global symbol `%s' found in %s psymtab but not in symtab.\n\
%s may be an inlined function, or may be a template function\n\
{
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
{
return SYMBOL_TYPE (sym);
ALL_PSYMTABS (objfile, ps)
{
- if (!ps->readin && lookup_partial_symbol (ps, name, NULL, 0, STRUCT_DOMAIN))
+ if (!ps->readin && lookup_partial_symbol (ps, name, 0, STRUCT_DOMAIN))
{
s = PSYMTAB_TO_SYMTAB (ps);
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
if (!sym)
{
/* This shouldn't be necessary, but as a last resort
* the psymtab gets it wrong in some cases.
*/
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
if (!sym)
error (_("Internal: static symbol `%s' found in %s psymtab but not in symtab.\n\
%s may be an inlined function, or may be a template function\n\
ALL_PSYMTABS (objfile, pst)
{
- if (lookup_partial_symbol (pst, main_name (), NULL, 1, VAR_DOMAIN))
+ if (lookup_partial_symbol (pst, main_name (), 1, VAR_DOMAIN))
{
return (pst);
}
search on the symbols. Each symbol which is marked as being a ObjC/C++
symbol (language_cplus or language_objc set) has both the encoded and
non-encoded names tested for a match.
-
- If LINKAGE_NAME is non-NULL, verify that any symbol we find has this
- particular mangled name.
*/
struct symbol *
lookup_block_symbol (const struct block *block, const char *name,
- const char *linkage_name,
const domain_enum domain)
{
struct dict_iterator iter;
sym = dict_iter_name_next (name, &iter))
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
- SYMBOL_DOMAIN (sym), domain)
- && (linkage_name != NULL
- ? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1))
+ SYMBOL_DOMAIN (sym), domain))
return sym;
}
return NULL;
sym = dict_iter_name_next (name, &iter))
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
- SYMBOL_DOMAIN (sym), domain)
- && (linkage_name != NULL
- ? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1))
+ SYMBOL_DOMAIN (sym), domain))
{
sym_found = sym;
if (!SYMBOL_IS_ARGUMENT (sym))
#define SYMBOL_SECTION(symbol) (symbol)->ginfo.section
#define SYMBOL_OBJ_SECTION(symbol) (symbol)->ginfo.obj_section
-#define SYMBOL_CPLUS_DEMANGLED_NAME(symbol) \
- (symbol)->ginfo.language_specific.cplus_specific.demangled_name
-
/* Initializes the language dependent portion of a symbol
depending upon the language for the symbol. */
#define SYMBOL_INIT_LANGUAGE_SPECIFIC(symbol,language) \
that can't think of anything better to do. */
extern struct symbol *basic_lookup_symbol_nonlocal (const char *,
- const char *,
const struct block *,
const domain_enum);
is one; do nothing if BLOCK is NULL or a global block. */
extern struct symbol *lookup_symbol_static (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain);
necessary). */
extern struct symbol *lookup_symbol_global (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain);
will fix up the symbol if necessary. */
extern struct symbol *lookup_symbol_aux_block (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain);
/* Lookup a partial symbol. */
extern struct partial_symbol *lookup_partial_symbol (struct partial_symtab *,
- const char *,
const char *, int,
domain_enum);
/* lookup a symbol by name, within a specified block */
extern struct symbol *lookup_block_symbol (const struct block *, const char *,
- const char *,
const domain_enum);
/* lookup a [struct, union, enum] by name, within a specified block */
/* Check global symbols in objfile. */
struct symbol *lookup_global_symbol_from_objfile (const struct objfile *objfile,
const char *name,
- const char *linkage_name,
const domain_enum domain);
extern struct symtabs_and_lines
#ifndef TYPEPRINT_H
#define TYPEPRINT_H
+enum language;
struct ui_file;
void print_type_scalar (struct type * type, LONGEST, struct ui_file *);
void c_type_print_varspec_suffix (struct type *, struct ui_file *, int,
int, int);
+
+void c_type_print_args (struct type *, struct ui_file *, int, enum language);
#endif
#include "defs.h"
#include "ui-file.h"
+#include "gdb_obstack.h"
#include "gdb_string.h"
#include "gdb_select.h"
}
/* ui_file utility function for converting a ``struct ui_file'' into
- a memory buffer''. */
+ a memory buffer. */
struct accumulated_ui_file
{
*length = acc.length;
return acc.buffer;
}
+
+static void
+do_ui_file_obsavestring (void *context, const char *buffer, long length)
+{
+ struct obstack *obstack = (struct obstack *) context;
+ obstack_grow (obstack, buffer, length);
+}
+
+char *
+ui_file_obsavestring (struct ui_file *file, struct obstack *obstack,
+ long *length)
+{
+ ui_file_put (file, do_ui_file_obsavestring, obstack);
+ *length = obstack_object_size (obstack);
+ obstack_1grow (obstack, '\0');
+ return obstack_finish (obstack);
+}
\f
/* A pure memory based ``struct ui_file'' that can be used an output
buffer. The buffers accumulated contents are available via
#ifndef UI_FILE_H
#define UI_FILE_H
+struct obstack;
struct ui_file;
/* Create a generic ui_file object with null methods. */
minus that appended NUL. */
extern char *ui_file_xstrdup (struct ui_file *file, long *length);
-
+/* Similar to ui_file_xstrdup, but return a new string allocated on
+ OBSTACK. */
+extern char *ui_file_obsavestring (struct ui_file *file,
+ struct obstack *obstack, long *length);
extern long ui_file_read (struct ui_file *file, char *buf, long length_buf);
if (method)
{
gdb_assert (obj);
+
+ /* OBJ may be a pointer value rather than the object itself. */
+ obj = coerce_ref (obj);
+ while (TYPE_CODE (check_typedef (value_type (obj))) == TYPE_CODE_PTR)
+ obj = coerce_ref (value_ind (obj));
obj_type_name = TYPE_NAME (value_type (obj));
- /* Hack: evaluate_subexp_standard often passes in a pointer
- value rather than the object itself, so try again. */
- if ((!obj_type_name || !*obj_type_name)
- && (TYPE_CODE (value_type (obj)) == TYPE_CODE_PTR))
- obj_type_name = TYPE_NAME (TYPE_TARGET_TYPE (value_type (obj)));
+
+ /* First check whether this is a data member, e.g. a pointer to
+ a function. */
+ if (TYPE_CODE (check_typedef (value_type (obj))) == TYPE_CODE_STRUCT)
+ {
+ *valp = search_struct_field (name, obj, 0,
+ check_typedef (value_type (obj)), 0);
+ if (*valp)
+ {
+ *staticp = 1;
+ return 0;
+ }
+ }
fns_ptr = value_find_oload_method_list (&temp, name,
0, &num_fns,
}
else
{
- const char *qualified_name = SYMBOL_CPLUS_DEMANGLED_NAME (fsym);
+ const char *qualified_name = SYMBOL_NATURAL_NAME (fsym);
- /* If we have a C++ name, try to extract just the function
- part. */
- if (qualified_name)
- func_name = cp_func_name (qualified_name);
+ /* If we have a function with a C++ name, try to extract just
+ the function part. Do not try this for non-functions (e.g.
+ function pointers). */
+ if (qualified_name
+ && TYPE_CODE (check_typedef (SYMBOL_TYPE (fsym))) == TYPE_CODE_FUNC)
+ {
+ func_name = cp_func_name (qualified_name);
+
+ /* If cp_func_name did not remove anything, the name of the
+ symbol did not include scope or argument types - it was
+ probably a C-style function. */
+ if (func_name && strcmp (func_name, qualified_name) == 0)
+ {
+ xfree (func_name);
+ func_name = NULL;
+ }
+ }
- /* If there was no C++ name, this must be a C-style function.
- Just return the same symbol. Do the same if cp_func_name
- fails for some reason. */
+ /* If there was no C++ name, this must be a C-style function or
+ not a function at all. Just return the same symbol. Do the
+ same if cp_func_name fails for some reason. */
if (func_name == NULL)
{
*symp = fsym;
struct symbol *sym;
struct value *result;
- sym = cp_lookup_symbol_namespace (namespace_name, name, NULL,
+ sym = cp_lookup_symbol_namespace(namespace_name, name,
get_selected_block (0),
VAR_DOMAIN, 1);
/* Calling lookup_block_symbol is necessary to get the LOC_REGISTER
symbol instead of the LOC_ARG one (if both exist). */
- sym = lookup_block_symbol (b, name, NULL, VAR_DOMAIN);
+ sym = lookup_block_symbol (b, name, VAR_DOMAIN);
if (sym == NULL)
{
if (complain)
else
{
char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno);
+ /*TYPE_FIELD_NAME (type, fieldno);*/
struct symbol *sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0);
+
if (sym == NULL)
{
/* With some compilers, e.g. HP aCC, static data members are reported