* [RFA] dwarf2_physname FINAL
@ 2010-03-04 22:52 Keith Seitz
2010-03-05 21:54 ` Tom Tromey
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Keith Seitz @ 2010-03-04 22:52 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1531 bytes --]
Hi,
Okay, now that 7.1 has branch, it is time to give the go/no-go on this
patch. I'm attaching the "final" version (in full this time, in case
anyone wants to apply it to their own sandbox).
The only "new" stuff in this patch is a fixlet to py-symbol.exp, in
which a test prints out the linkage name (which has obviously changed).
There is an apparent regression in jprint.exp. Printing static class
variables (java only) is "broken." This is a gcc bug (gcc/43260): we
don't get any location info from gcc about where the static variable
lives, so we report it as "optimized out." NOTE: This "works" on CVS
HEAD because we fallback to using the linkage name (from
DW_AT_MIPS_linkage_name) to search the minimal symbol table, using that
to grab the address of the variable. Obviously we won't be able to do
that any more.
One other issue that I uncovered: DW_AT_MIPS_linkage_name appears to be
necessary for Ada. I have a patch that I used to address this (for one
of our internal releases), but it is probably not complete. [In other
words: it's now just as broken as it was before.] I can submit this as a
follow-up, if so desired.
I have tested the attached patch against i686-linux-gnu (Fedora 11) and
Jan has kindly tested it in his usual array of configurations
({x86_64,x86_64-m32,i686}-fedora{11,12,13}-linux-gnu) with no
regressions (other than the aforementioned jprint.exp static variable
failure).
Final comments/questions/concerns?
Keith
[I'm omitting the ChangeLog -- you've seen it before]
[-- Attachment #2: dwarf2_physname-full-3.patch --]
[-- Type: text/plain, Size: 144787 bytes --]
Index: ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.248
diff -u -p -r1.248 ada-lang.c
--- ada-lang.c 9 Feb 2010 13:15:09 -0000 1.248
+++ ada-lang.c 4 Mar 2010 21:52:42 -0000
@@ -4781,14 +4781,10 @@ ada_lookup_symbol (const char *name, con
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);
}
Index: ax-gdb.c
===================================================================
RCS file: /cvs/src/src/gdb/ax-gdb.c,v
retrieving revision 1.64
diff -u -p -r1.64 ax-gdb.c
--- ax-gdb.c 11 Feb 2010 23:03:22 -0000 1.64
+++ ax-gdb.c 4 Mar 2010 21:52:42 -0000
@@ -1812,7 +1812,7 @@ gen_expr (struct expression *exp, union
/* 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);
Index: c-typeprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-typeprint.c,v
retrieving revision 1.53
diff -u -p -r1.53 c-typeprint.c
--- c-typeprint.c 19 Feb 2010 22:22:48 -0000 1.53
+++ c-typeprint.c 4 Mar 2010 21:52:43 -0000
@@ -32,6 +32,7 @@
#include "c-lang.h"
#include "typeprint.h"
#include "cp-abi.h"
+#include "jv-lang.h"
#include "gdb_string.h"
#include <errno.h>
@@ -40,8 +41,6 @@ static void cp_type_print_method_args (s
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,
@@ -197,6 +196,23 @@ cp_type_print_method_args (struct type *
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");
+ }
}
@@ -352,10 +368,14 @@ c_type_print_modifier (struct type *type
/* 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;
@@ -367,13 +387,19 @@ c_type_print_args (struct type *type, st
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;
}
@@ -590,7 +616,7 @@ c_type_print_varspec_suffix (struct type
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;
Index: cp-namespace.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-namespace.c,v
retrieving revision 1.35
diff -u -p -r1.35 cp-namespace.c
--- cp-namespace.c 19 Feb 2010 20:22:03 -0000 1.35
+++ cp-namespace.c 4 Mar 2010 21:52:43 -0000
@@ -34,14 +34,12 @@
#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);
@@ -231,26 +229,23 @@ cp_add_using (const char *dest,
/* 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
@@ -259,14 +254,12 @@ cp_lookup_symbol_nonlocal (const char *n
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
{
@@ -275,8 +268,8 @@ cp_lookup_symbol_in_namespace (const cha
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));
}
}
@@ -310,7 +303,6 @@ reset_directive_searched (void *data)
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)
@@ -322,8 +314,7 @@ cp_lookup_symbol_imports (const char *sc
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;
@@ -359,7 +350,6 @@ cp_lookup_symbol_imports (const char *sc
{
sym = cp_lookup_symbol_in_namespace (scope,
current->import_src,
- linkage_name,
block,
domain);
}
@@ -369,7 +359,6 @@ cp_lookup_symbol_imports (const char *sc
NAMESPACE to direct the search towards the imported namespace. */
sym = cp_lookup_symbol_imports (current->import_src,
name,
- linkage_name,
block,
domain,
0);
@@ -392,7 +381,6 @@ cp_lookup_symbol_imports (const char *sc
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)
@@ -402,7 +390,7 @@ cp_lookup_symbol_namespace (const char *
/* 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)
@@ -431,7 +419,6 @@ cp_lookup_symbol_namespace (const char *
static struct symbol *
lookup_namespace_scope (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain,
const char *scope,
@@ -453,8 +440,7 @@ lookup_namespace_scope (const char *name
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;
}
@@ -465,8 +451,7 @@ lookup_namespace_scope (const char *name
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
@@ -476,14 +461,13 @@ lookup_namespace_scope (const char *name
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;
@@ -496,12 +480,11 @@ lookup_symbol_file (const char *name,
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)
@@ -552,7 +535,6 @@ cp_lookup_nested_type (struct type *pare
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)
@@ -798,7 +780,7 @@ check_one_possible_namespace_symbol (con
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)
{
@@ -839,7 +821,7 @@ lookup_possible_namespace_symbol (const
struct symbol *sym;
sym = lookup_block_symbol (get_possible_namespace_block (objfile),
- name, NULL, VAR_DOMAIN);
+ name, VAR_DOMAIN);
if (sym != NULL)
return sym;
Index: cp-support.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-support.c,v
retrieving revision 1.35
diff -u -p -r1.35 cp-support.c
--- cp-support.c 1 Jan 2010 07:31:30 -0000 1.35
+++ cp-support.c 4 Mar 2010 21:52:43 -0000
@@ -840,9 +840,9 @@ read_in_psymtabs (const char *func_name)
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);
}
Index: cp-support.h
===================================================================
RCS file: /cvs/src/src/gdb/cp-support.h,v
retrieving revision 1.33
diff -u -p -r1.33 cp-support.h
--- cp-support.h 5 Feb 2010 19:03:40 -0000 1.33
+++ cp-support.h 4 Mar 2010 21:52:43 -0000
@@ -111,13 +111,11 @@ extern void cp_set_block_scope (const st
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);
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.357
diff -u -p -r1.357 dwarf2read.c
--- dwarf2read.c 2 Mar 2010 17:19:58 -0000 1.357
+++ dwarf2read.c 4 Mar 2010 21:52:45 -0000
@@ -48,6 +48,8 @@
#include "gdbcmd.h"
#include "block.h"
#include "addrmap.h"
+#include "typeprint.h"
+#include "jv-lang.h"
#include <fcntl.h>
#include "gdb_string.h"
@@ -487,8 +489,7 @@ struct partial_die_info
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
@@ -788,8 +789,6 @@ static void scan_partial_symbols (struct
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);
@@ -984,9 +983,6 @@ static void dwarf2_attach_fn_fields_to_t
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 *);
@@ -1028,8 +1024,6 @@ static gdb_byte *read_full_die (const st
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 *);
@@ -2441,12 +2435,9 @@ add_partial_symbol (struct partial_die_i
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;
@@ -2586,49 +2577,10 @@ add_partial_symbol (struct partial_die_i
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. */
@@ -2740,7 +2692,6 @@ guess_structure_name (struct partial_die
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
@@ -2753,27 +2704,6 @@ guess_structure_name (struct partial_die
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;
- }
}
}
@@ -3338,42 +3268,156 @@ process_die (struct die_info *die, struc
}
}
+/* 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;
-
- name = dwarf2_name (die, cu);
- if (!name)
- return NULL;
+ return dwarf2_compute_name (name, die, cu, 0);
+}
- /* These are the only languages we know how to qualify names in. */
- if (cu->language != language_cplus
- && cu->language != language_java)
- return name;
+/* 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 teh objfile_objstack or NULL if the DIE does not have a
+ 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. */
@@ -3851,7 +3895,7 @@ read_func_scope (struct die_info *die, s
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. */
@@ -4525,7 +4569,7 @@ dwarf2_add_field (struct field_info *fip
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. */
@@ -4687,7 +4731,7 @@ dwarf2_add_member_fn (struct field_info
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++)
@@ -4994,14 +5038,18 @@ read_structure_type (struct die_info *di
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);
}
}
@@ -5220,7 +5268,7 @@ read_enumeration_type (struct die_info *
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;
@@ -5245,51 +5293,6 @@ read_enumeration_type (struct die_info *
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.
@@ -5945,7 +5948,7 @@ read_typedef (struct die_info *die, stru
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;
@@ -6773,7 +6776,8 @@ read_partial_die (struct partial_die_inf
}
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;
@@ -8338,13 +8342,11 @@ new_symbol (struct die_info *die, struct
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++);
@@ -8352,7 +8354,8 @@ new_symbol (struct die_info *die, struct
/* 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. */
@@ -8577,7 +8580,8 @@ new_symbol (struct die_info *die, struct
}
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);
@@ -8589,7 +8593,8 @@ new_symbol (struct die_info *die, struct
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)
{
@@ -8626,8 +8631,7 @@ new_symbol (struct die_info *die, struct
/* 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);
@@ -9079,19 +9083,6 @@ sibling_die (struct die_info *die)
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 *
Index: eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.127
diff -u -p -r1.127 eval.c
--- eval.c 8 Feb 2010 20:55:42 -0000 1.127
+++ eval.c 4 Mar 2010 21:52:46 -0000
@@ -1433,7 +1433,7 @@ evaluate_subexp_standard (struct type *e
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)
Index: gnu-v3-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-v3-abi.c,v
retrieving revision 1.58
diff -u -p -r1.58 gnu-v3-abi.c
--- gnu-v3-abi.c 1 Jan 2010 07:31:32 -0000 1.58
+++ gnu-v3-abi.c 4 Mar 2010 21:52:46 -0000
@@ -26,6 +26,7 @@
#include "demangle.h"
#include "objfiles.h"
#include "valprint.h"
+#include "c-lang.h"
#include "gdb_assert.h"
#include "gdb_string.h"
@@ -456,10 +457,8 @@ gnuv3_find_method_in (struct type *domai
LONGEST adjustment)
{
int i;
- const char *physname;
/* Search this class first. */
- physname = NULL;
if (adjustment == 0)
{
int len;
@@ -587,15 +586,24 @@ gnuv3_print_method_ptr (const gdb_byte *
{
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)
Index: language.h
===================================================================
RCS file: /cvs/src/src/gdb/language.h,v
retrieving revision 1.63
diff -u -p -r1.63 language.h
--- language.h 2 Feb 2010 16:45:16 -0000 1.63
+++ language.h 4 Mar 2010 21:52:46 -0000
@@ -258,7 +258,6 @@ struct language_defn
variables. */
struct symbol *(*la_lookup_symbol_nonlocal) (const char *,
- const char *,
const struct block *,
const domain_enum);
Index: linespec.c
===================================================================
RCS file: /cvs/src/src/gdb/linespec.c,v
retrieving revision 1.97
diff -u -p -r1.97 linespec.c
--- linespec.c 4 Mar 2010 18:38:35 -0000 1.97
+++ linespec.c 4 Mar 2010 21:52:47 -0000
@@ -40,6 +40,7 @@
#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. */
@@ -50,8 +51,6 @@ extern char *operator_chars (char *, cha
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);
@@ -628,6 +627,37 @@ See set/show multiple-symbol."));
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. */
@@ -688,9 +718,6 @@ decode_line_1 (char **argptr, int funfir
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;
@@ -715,12 +742,9 @@ decode_line_1 (char **argptr, int funfir
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);
@@ -738,10 +762,7 @@ decode_line_1 (char **argptr, int funfir
/* 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. */
@@ -766,63 +787,33 @@ decode_line_1 (char **argptr, int funfir
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);
+ /* No, the first part is a filename; set file_symtab to be that file's
+ symtab. Also, move argptr past the filename. */
- /* 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 */
-
- /* 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. */
@@ -868,10 +859,6 @@ decode_line_1 (char **argptr, int funfir
/* 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);
@@ -881,6 +868,14 @@ decode_line_1 (char **argptr, int funfir
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';
@@ -928,10 +923,9 @@ decode_line_1 (char **argptr, int funfir
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
@@ -958,44 +952,6 @@ initialize_defaults (struct symtab **def
}
}
-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. */
@@ -1102,8 +1058,9 @@ locate_first_half (char **argptr, int *i
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;
@@ -1255,6 +1212,7 @@ decode_compound (char **argptr, int funf
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
@@ -1303,7 +1261,8 @@ decode_compound (char **argptr, int funf
/* 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);
@@ -1381,8 +1340,10 @@ decode_compound (char **argptr, int funf
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
@@ -1394,6 +1355,42 @@ decode_compound (char **argptr, int funf
/* 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
@@ -1422,9 +1419,26 @@ decode_compound (char **argptr, int funf
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 */
@@ -1548,8 +1562,39 @@ find_method (int funfirstline, char ***c
}
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
@@ -1855,7 +1900,7 @@ symbol_found (int funfirstline, char ***
{
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;
Index: scm-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/scm-valprint.c,v
retrieving revision 1.29
diff -u -p -r1.29 scm-valprint.c
--- scm-valprint.c 1 Jan 2010 07:31:41 -0000 1.29
+++ scm-valprint.c 4 Mar 2010 21:52:47 -0000
@@ -62,9 +62,9 @@ scm_inferior_print (struct type *type, L
{
/* 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;
Index: solib-darwin.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-darwin.c,v
retrieving revision 1.12
diff -u -p -r1.12 solib-darwin.c
--- solib-darwin.c 24 Feb 2010 00:29:02 -0000 1.12
+++ solib-darwin.c 4 Mar 2010 21:52:47 -0000
@@ -404,7 +404,6 @@ darwin_relocate_section_addresses (struc
static struct symbol *
darwin_lookup_lib_symbol (const struct objfile *objfile,
const char *name,
- const char *linkage_name,
const domain_enum domain)
{
return NULL;
Index: solib-spu.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-spu.c,v
retrieving revision 1.6
diff -u -p -r1.6 solib-spu.c
--- solib-spu.c 24 Feb 2010 00:29:02 -0000 1.6
+++ solib-spu.c 4 Mar 2010 21:52:47 -0000
@@ -326,16 +326,13 @@ spu_bfd_open (char *pathname)
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;
}
Index: solib-svr4.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-svr4.c,v
retrieving revision 1.125
diff -u -p -r1.125 solib-svr4.c
--- solib-svr4.c 24 Feb 2010 00:29:02 -0000 1.125
+++ solib-svr4.c 4 Mar 2010 21:52:47 -0000
@@ -2034,7 +2034,6 @@ struct target_so_ops svr4_so_ops;
static struct symbol *
elf_lookup_lib_symbol (const struct objfile *objfile,
const char *name,
- const char *linkage_name,
const domain_enum domain)
{
bfd *abfd;
@@ -2052,8 +2051,7 @@ elf_lookup_lib_symbol (const struct objf
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 */
Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.133
diff -u -p -r1.133 solib.c
--- solib.c 20 Jan 2010 14:23:07 -0000 1.133
+++ solib.c 4 Mar 2010 21:52:48 -0000
@@ -1154,13 +1154,12 @@ show_auto_solib_add (struct ui_file *fil
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;
}
Index: solist.h
===================================================================
RCS file: /cvs/src/src/gdb/solist.h,v
retrieving revision 1.29
diff -u -p -r1.29 solist.h
--- solist.h 8 Jan 2010 22:52:04 -0000 1.29
+++ solist.h 4 Mar 2010 21:52:48 -0000
@@ -117,7 +117,6 @@ struct target_so_ops
/* 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
@@ -157,7 +156,6 @@ extern struct target_so_ops *current_tar
/* 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
Index: spu-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/spu-tdep.c,v
retrieving revision 1.56
diff -u -p -r1.56 spu-tdep.c
--- spu-tdep.c 2 Mar 2010 20:21:08 -0000 1.56
+++ spu-tdep.c 4 Mar 2010 21:52:48 -0000
@@ -1851,7 +1851,7 @@ spu_catch_start (struct objfile *objfile
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);
Index: symmisc.c
===================================================================
RCS file: /cvs/src/src/gdb/symmisc.c,v
retrieving revision 1.67
diff -u -p -r1.67 symmisc.c
--- symmisc.c 1 Jan 2010 07:31:42 -0000 1.67
+++ symmisc.c 4 Mar 2010 21:52:48 -0000
@@ -1143,7 +1143,7 @@ maintenance_check_symtabs (char *ignore,
while (length--)
{
sym = lookup_block_symbol (b, SYMBOL_LINKAGE_NAME (*psym),
- NULL, SYMBOL_DOMAIN (*psym));
+ SYMBOL_DOMAIN (*psym));
if (!sym)
{
printf_filtered ("Static symbol `");
@@ -1160,7 +1160,7 @@ maintenance_check_symtabs (char *ignore,
while (length--)
{
sym = lookup_block_symbol (b, SYMBOL_LINKAGE_NAME (*psym),
- NULL, SYMBOL_DOMAIN (*psym));
+ SYMBOL_DOMAIN (*psym));
if (!sym)
{
printf_filtered ("Global symbol `");
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.224
diff -u -p -r1.224 symtab.c
--- symtab.c 26 Jan 2010 15:48:25 -0000 1.224
+++ symtab.c 4 Mar 2010 21:52:49 -0000
@@ -85,7 +85,6 @@ static int find_line_common (struct line
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,
@@ -93,20 +92,17 @@ static struct symbol *lookup_symbol_aux
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);
@@ -498,7 +494,7 @@ symbol_find_demangled_name (struct gener
|| 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;
@@ -1257,7 +1253,6 @@ lookup_symbol_in_language (const char *n
{
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);
@@ -1270,7 +1265,6 @@ lookup_symbol_in_language (const char *n
demangled_name = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS);
if (demangled_name)
{
- mangled_name = name;
modified_name = demangled_name;
make_cleanup (xfree, demangled_name);
}
@@ -1292,7 +1286,6 @@ lookup_symbol_in_language (const char *n
DMGL_ANSI | DMGL_PARAMS | DMGL_JAVA);
if (demangled_name)
{
- mangled_name = name;
modified_name = demangled_name;
make_cleanup (xfree, demangled_name);
}
@@ -1311,8 +1304,8 @@ lookup_symbol_in_language (const char *n
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;
@@ -1336,9 +1329,9 @@ lookup_symbol (const char *name, const s
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;
@@ -1354,7 +1347,7 @@ lookup_symbol_aux (const char *name, con
/* 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;
@@ -1375,7 +1368,7 @@ lookup_symbol_aux (const char *name, con
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;
@@ -1403,7 +1396,7 @@ lookup_symbol_aux (const char *name, con
/* 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;
@@ -1413,11 +1406,11 @@ lookup_symbol_aux (const char *name, con
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;
@@ -1428,8 +1421,7 @@ lookup_symbol_aux (const char *name, con
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;
@@ -1442,7 +1434,7 @@ lookup_symbol_aux_local (const char *nam
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;
@@ -1485,13 +1477,12 @@ lookup_objfile_from_block (const struct
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;
@@ -1507,7 +1498,6 @@ lookup_symbol_aux_block (const char *nam
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;
@@ -1526,7 +1516,7 @@ lookup_global_symbol_from_objfile (const
{
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;
@@ -1538,13 +1528,12 @@ lookup_global_symbol_from_objfile (const
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);
}
}
@@ -1559,8 +1548,7 @@ lookup_global_symbol_from_objfile (const
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;
@@ -1573,7 +1561,7 @@ lookup_symbol_aux_symtabs (int block_ind
{
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;
@@ -1591,7 +1579,6 @@ lookup_symbol_aux_symtabs (int block_ind
static struct symbol *
lookup_symbol_aux_psymtabs (int block_index, const char *name,
- const char *linkage_name,
const domain_enum domain)
{
struct symbol *sym;
@@ -1605,13 +1592,12 @@ lookup_symbol_aux_psymtabs (int block_in
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
@@ -1628,7 +1614,7 @@ lookup_symbol_aux_psymtabs (int block_in
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",
@@ -1647,7 +1633,6 @@ lookup_symbol_aux_psymtabs (int block_in
struct symbol *
basic_lookup_symbol_nonlocal (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain)
{
@@ -1681,11 +1666,11 @@ basic_lookup_symbol_nonlocal (const char
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
@@ -1693,14 +1678,13 @@ basic_lookup_symbol_nonlocal (const char
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;
}
@@ -1710,7 +1694,6 @@ lookup_symbol_static (const char *name,
struct symbol *
lookup_symbol_global (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain)
{
@@ -1720,15 +1703,15 @@ lookup_symbol_global (const char *name,
/* 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
@@ -1752,14 +1735,11 @@ symbol_matches_domain (enum language sym
}
/* 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;
@@ -1811,9 +1791,7 @@ lookup_partial_symbol (struct partial_sy
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))
@@ -1830,15 +1808,9 @@ lookup_partial_symbol (struct partial_sy
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);
}
}
@@ -1880,7 +1852,7 @@ basic_lookup_transparent_type (const cha
{
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);
@@ -1889,13 +1861,12 @@ basic_lookup_transparent_type (const cha
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
@@ -1904,7 +1875,7 @@ basic_lookup_transparent_type (const cha
* 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\
@@ -1928,7 +1899,7 @@ basic_lookup_transparent_type (const cha
{
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);
@@ -1937,12 +1908,12 @@ basic_lookup_transparent_type (const cha
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
@@ -1951,7 +1922,7 @@ basic_lookup_transparent_type (const cha
* 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\
@@ -1978,7 +1949,7 @@ find_main_psymtab (void)
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);
}
@@ -1996,14 +1967,10 @@ find_main_psymtab (void)
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;
@@ -2016,9 +1983,7 @@ lookup_block_symbol (const struct block
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;
@@ -2038,9 +2003,7 @@ lookup_block_symbol (const struct block
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))
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.146
diff -u -p -r1.146 symtab.h
--- symtab.h 27 Jan 2010 00:15:59 -0000 1.146
+++ symtab.h 4 Mar 2010 21:52:50 -0000
@@ -172,9 +172,6 @@ extern CORE_ADDR symbol_overlayed_addres
#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) \
@@ -994,7 +991,6 @@ extern struct symbol *lookup_symbol (con
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);
@@ -1005,7 +1001,6 @@ extern struct symbol *basic_lookup_symbo
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);
@@ -1013,7 +1008,6 @@ extern struct symbol *lookup_symbol_stat
necessary). */
extern struct symbol *lookup_symbol_global (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain);
@@ -1022,21 +1016,18 @@ extern struct symbol *lookup_symbol_glob
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 */
@@ -1372,7 +1363,6 @@ extern /*const */ char *main_name (void)
/* 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
Index: typeprint.h
===================================================================
RCS file: /cvs/src/src/gdb/typeprint.h,v
retrieving revision 1.9
diff -u -p -r1.9 typeprint.h
--- typeprint.h 1 Jan 2010 07:31:43 -0000 1.9
+++ typeprint.h 4 Mar 2010 21:52:50 -0000
@@ -20,10 +20,13 @@
#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
Index: ui-file.c
===================================================================
RCS file: /cvs/src/src/gdb/ui-file.c,v
retrieving revision 1.20
diff -u -p -r1.20 ui-file.c
--- ui-file.c 1 Jan 2010 07:31:43 -0000 1.20
+++ ui-file.c 4 Mar 2010 21:52:50 -0000
@@ -22,6 +22,7 @@
#include "defs.h"
#include "ui-file.h"
+#include "gdb_obstack.h"
#include "gdb_string.h"
#include "gdb_select.h"
@@ -264,7 +265,7 @@ set_ui_file_data (struct ui_file *file,
}
/* ui_file utility function for converting a ``struct ui_file'' into
- a memory buffer''. */
+ a memory buffer. */
struct accumulated_ui_file
{
@@ -298,6 +299,23 @@ ui_file_xstrdup (struct ui_file *file, l
*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
Index: ui-file.h
===================================================================
RCS file: /cvs/src/src/gdb/ui-file.h,v
retrieving revision 1.11
diff -u -p -r1.11 ui-file.h
--- ui-file.h 1 Jan 2010 07:31:43 -0000 1.11
+++ ui-file.h 4 Mar 2010 21:52:50 -0000
@@ -20,6 +20,7 @@
#ifndef UI_FILE_H
#define UI_FILE_H
+struct obstack;
struct ui_file;
/* Create a generic ui_file object with null methods. */
@@ -78,7 +79,10 @@ extern void ui_file_put (struct ui_file
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);
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.237
diff -u -p -r1.237 valops.c
--- valops.c 8 Feb 2010 20:55:43 -0000 1.237
+++ valops.c 4 Mar 2010 21:52:51 -0000
@@ -2346,12 +2346,25 @@ find_overload_match (struct type **arg_t
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,
@@ -2371,16 +2384,29 @@ find_overload_match (struct type **arg_t
}
else
{
- const char *qualified_name = SYMBOL_CPLUS_DEMANGLED_NAME (fsym);
+ const char *qualified_name = SYMBOL_NATURAL_NAME (fsym);
+
+ /* 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 we have a C++ name, try to extract just the function
- part. */
- if (qualified_name)
- func_name = cp_func_name (qualified_name);
-
- /* 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;
@@ -3117,7 +3143,7 @@ value_maybe_namespace_elt (const struct
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);
@@ -3261,7 +3287,7 @@ value_of_local (const char *name, int co
/* 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)
Index: value.c
===================================================================
RCS file: /cvs/src/src/gdb/value.c,v
retrieving revision 1.99
diff -u -p -r1.99 value.c
--- value.c 3 Jan 2010 18:55:31 -0000 1.99
+++ value.c 4 Mar 2010 21:52:51 -0000
@@ -1819,7 +1819,9 @@ value_static_field (struct type *type, i
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
Index: testsuite/gdb.cp/cp-relocate.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/cp-relocate.exp,v
retrieving revision 1.7
diff -u -p -r1.7 cp-relocate.exp
--- testsuite/gdb.cp/cp-relocate.exp 1 Jan 2010 07:32:01 -0000 1.7
+++ testsuite/gdb.cp/cp-relocate.exp 4 Mar 2010 21:52:51 -0000
@@ -30,7 +30,7 @@ proc get_func_address { func } {
global gdb_prompt hex
set rfunc [string_to_regexp $func]
- gdb_test_multiple "print '${func}'" "get address of ${func}" {
+ gdb_test_multiple "print ${func}" "get address of ${func}" {
-re "\\\$\[0-9\]+ = \\{.*\\} (0|($hex) <${rfunc}>)\[\r\n\]+${gdb_prompt} $" {
# $1 = {int ()} 0x24 <function_bar>
# But if the function is at zero, the name may be omitted.
@@ -130,7 +130,7 @@ gdb_test "add-symbol-file ${binfile} 0 -
"y"
# Make sure the function addresses were updated.
-gdb_test "break *'$func1_name'" \
+gdb_test "break *$func1_name" \
"Breakpoint $decimal at 0x1....: file .*"
-gdb_test "break *'$func2_name'" \
+gdb_test "break *$func2_name" \
"Breakpoint $decimal at 0x2....: file .*"
Index: testsuite/gdb.cp/cpexprs.cc
===================================================================
RCS file: testsuite/gdb.cp/cpexprs.cc
diff -N testsuite/gdb.cp/cpexprs.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.cp/cpexprs.cc 4 Mar 2010 21:52:51 -0000
@@ -0,0 +1,431 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
+
+ Contributed by Red Hat, originally written by Keith Seitz.
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (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
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Please email any bugs, comments, and/or additions to this file to:
+ bug-gdb@gnu.org */
+
+#include <stdlib.h>
+#include <iostream>
+
+// Forward decls
+class base;
+class derived;
+
+// A simple template with specializations
+template <typename T>
+class tclass
+{
+public:
+ void do_something () { } // tclass<T>::do_something
+};
+
+template <>
+void tclass<char>::do_something () { } // tclass<char>::do_something
+
+template <>
+void tclass<int>::do_something () { } // tclass<int>::do_something
+
+template<>
+void tclass<long>::do_something () { } // tclass<long>::do_something
+
+template<>
+void tclass<short>::do_something () { } // tclass<short>::do_something
+
+// A simple template with multiple template parameters
+template <class A, class B, class C, class D, class E>
+void flubber (void) // flubber
+{
+ A a;
+ B b;
+ C c;
+ D d;
+ E e;
+
+ ++a;
+ ++b;
+ ++c;
+ ++d;
+ ++e;
+}
+
+// Some contrived policies
+template <class T>
+struct operation_1
+{
+ static void function (void) { } // operation_1<T>::function
+};
+
+template <class T>
+struct operation_2
+{
+ static void function (void) { } // operation_2<T>::function
+};
+
+template <class T>
+struct operation_3
+{
+ static void function (void) { } // operation_3<T>::function
+};
+
+template <class T>
+struct operation_4
+{
+ static void function (void) { } // operation_4<T>::function
+};
+
+// A policy-based class w/ and w/o default policy
+template <class T, class Policy>
+class policy : public Policy
+{
+public:
+ policy (T obj) : obj_ (obj) { } // policy<T, Policy>::policy
+
+private:
+ T obj_;
+};
+
+template <class T, class Policy = operation_1<T> >
+class policyd : public Policy
+{
+public:
+ policyd (T obj) : obj_ (obj) { } // policyd<T, Policy>::policyd
+ ~policyd (void) { } // policyd<T, Policy>::~policyd
+
+private:
+ T obj_;
+};
+
+typedef policy<int, operation_1<void*> > policy1;
+typedef policy<int, operation_2<void*> > policy2;
+typedef policy<int, operation_3<void*> > policy3;
+typedef policy<int, operation_4<void*> > policy4;
+
+typedef policyd<int> policyd1;
+typedef policyd<long> policyd2;
+typedef policyd<char> policyd3;
+typedef policyd<base> policyd4;
+typedef policyd<tclass<int> > policyd5;
+
+class fluff { };
+static fluff *g_fluff = new fluff ();
+
+class base
+{
+protected:
+ int foo_;
+
+public:
+ base (void) : foo_ (42) { } // base::base(void)
+ base (int foo) : foo_ (foo) { } // base::base(int)
+ ~base (void) { } // base::~base
+
+ // Some overloaded methods
+ int overload (void) const { return 0; } // base::overload(void) const
+ int overload (int i) const { return 1; } // base::overload(int) const
+ int overload (short s) const { return 2; } // base::overload(short) const
+ int overload (long l) const { return 3; } // base::overload(long) const
+ int overload (char* a) const { return 4; } // base::overload(char*) const
+ int overload (base& b) const { return 5; } // base::overload(base&) const
+
+ // Operators
+ int operator+ (base const& o) const // base::operator+
+ { return foo_ + o.foo_; }
+
+ base operator++ (void) // base::operator++
+ { ++foo_; return *this; }
+
+ base operator+=(base const& o) // base::operator+=
+ { foo_ += o.foo_; return *this; }
+
+ int operator- (base const& o) const // base::operator-
+ { return foo_ - o.foo_; }
+
+ base operator-- (void) // base::operator--
+ { --foo_; return *this; }
+
+ base operator-= (base const& o) // base::operator-=
+ { foo_ -= o.foo_; return *this; }
+
+ int operator* (base const& o) const // base::operator*
+ { return foo_ * o.foo_; }
+
+ base operator*= (base const& o) // base::operator*=
+ { foo_ *= o.foo_; return *this; }
+
+ int operator/ (base const& o) const // base::operator/
+ { return foo_ / o.foo_; }
+
+ base operator/= (base const& o) // base::operator/=
+ { foo_ /= o.foo_; return *this; }
+
+ int operator% (base const& o) const // base::operator%
+ { return foo_ % o.foo_; }
+
+ base operator%= (base const& o) // base::operator%=
+ { foo_ %= o.foo_; return *this; }
+
+ bool operator< (base const& o) const // base::operator<
+ { return foo_ < o.foo_; }
+
+ bool operator<= (base const& o) const // base::operator<=
+ { return foo_ <= o.foo_; }
+
+ bool operator> (base const& o) const // base::operator>
+ { return foo_ > o.foo_; }
+
+ bool operator>= (base const& o) const // base::operator>=
+ { return foo_ >= o.foo_; }
+
+ bool operator!= (base const& o) const // base::operator!=
+ { return foo_ != o.foo_; }
+
+ bool operator== (base const& o) const // base::operator==
+ { return foo_ == o.foo_; }
+
+ bool operator! (void) const // base::operator!
+ { return !foo_; }
+
+ bool operator&& (base const& o) const // base::operator&&
+ { return foo_ && o.foo_; }
+
+ bool operator|| (base const& o) const // base::operator||
+ { return foo_ || o.foo_; }
+
+ int operator<< (int value) const // base::operator<<
+ { return foo_ << value; }
+
+ base operator<<= (int value) // base::operator<<=
+ { foo_ <<= value; return *this; }
+
+ int operator>> (int value) const // base::operator>>
+ { return foo_ >> value; }
+
+ base operator>>= (int value) // base::operator>>=
+ { foo_ >>= value; return *this; }
+
+ int operator~ (void) const // base::operator~
+ { return ~foo_; }
+
+ int operator& (base const& o) const // base::operator&
+ { return foo_ & o.foo_; }
+
+ base operator&= (base const& o) // base::operator&=
+ { foo_ &= o.foo_; return *this; }
+
+ int operator| (base const& o) const // base::operator|
+ { return foo_ | o.foo_; }
+
+ base operator|= (base const& o) // base::operator|=
+ { foo_ |= o.foo_; return *this; }
+
+ int operator^ (base const& o) const // base::operator^
+ { return foo_ ^ o.foo_; }
+
+ base operator^= (base const& o) // base::operator^=
+ { foo_ ^= o.foo_; return *this; }
+
+ base operator= (base const& o) // base::operator=
+ { foo_ = o.foo_; return *this; }
+
+ void operator() (void) const // base::operator()
+ { return; }
+
+ int operator[] (int idx) const // base::operator[]
+ { return idx; }
+
+ void* operator new (size_t size) throw () // base::operator new
+ { return malloc (size); }
+
+ void operator delete (void* ptr) // base::operator delete
+ { free (ptr); }
+
+ void* operator new[] (size_t size) throw () // base::operator new[]
+ { return malloc (size); }
+
+ void operator delete[] (void* ptr) // base::operator delete[]
+ { free (ptr); }
+
+ base const* operator-> (void) const // base::opeartor->
+ { return this; }
+
+ int operator->* (base const& b) const // base::operator->*
+ { return foo_ * b.foo_; }
+
+ operator char* () const { return const_cast<char*> ("hello"); } // base::operator char*
+ operator int () const { return 21; } // base::operator int
+ operator fluff* () const { return new fluff (); } // base::operator fluff*
+ operator fluff** () const { return &g_fluff; } // base::operator fluff**
+};
+
+class base1 : public virtual base
+{
+public:
+ base1 (void) : foo_ (21) { } // base1::base1(void)
+ base1 (int a) : foo_(a) { } // base1::base1(int)
+ void a_function (void) const { } // base1::a_function
+
+protected:
+ int foo_;
+};
+
+class base2 : public virtual base
+{
+public:
+ base2 () : foo_ (3) { } // base2::base2
+
+protected:
+ void a_function (void) const { } // base2::a_function
+ int foo_;
+};
+
+class derived : public base1, public base2
+{
+ public:
+ derived(void) : foo_ (4) { } // derived::derived
+ void a_function (void) const // derived::a_function
+ {
+ this->base1::a_function ();
+ this->base2::a_function ();
+ }
+
+ protected:
+ int foo_;
+};
+
+int
+main (int argc, char* argv[]) // main
+{ // main
+ derived d;
+ void (derived::*pfunc) (void) const = &derived::a_function;
+ (d.*pfunc) ();
+
+ base a (1), b (3), c (8);
+ (void) a.overload ();
+ (void) a.overload (static_cast<int> (0));
+ (void) a.overload (static_cast<short> (0));
+ (void) a.overload (static_cast<long> (0));
+ (void) a.overload (static_cast<char*> (0));
+ (void) a.overload (a);
+
+ int r;
+ r = b + c;
+ ++a;
+ a += b;
+ r = b - c;
+ --a;
+ a -= b;
+ r = b * c;
+ a *= b;
+ r = b / c;
+ a /= b;
+ r = b % c;
+ a %= b;
+ bool x = (b < c);
+ x = (b <= c);
+ x = (b > c);
+ x = (b >= c);
+ x = (b != c);
+ x = (b == c);
+ x = (!b);
+ x = (b && c);
+ x = (b || c);
+ r = b << 2;
+ a <<= 1;
+ r = b >> 2;
+ a >>= 1;
+ r = ~b;
+ r = b & c;
+ a &= c;
+ r = b | c;
+ a |= c;
+ r = b ^ c;
+ a ^= c;
+ a = c;
+ a ();
+ int i = a[3];
+ derived* f = new derived ();
+ derived* g = new derived[3];
+ delete f;
+ delete[] g;
+ a->overload ();
+ r = a->*b;
+
+ tclass<char> char_tclass;
+ tclass<int> int_tclass;
+ tclass<short> short_tclass;
+ tclass<long> long_tclass;
+ tclass<base> base_tclass;
+ char_tclass.do_something ();
+ int_tclass.do_something ();
+ short_tclass.do_something ();
+ long_tclass.do_something ();
+ base_tclass.do_something ();
+
+ flubber<int, int, int, int, int> ();
+ flubber<int, int, int, int, short> ();
+ flubber<int, int, int, int, long> ();
+ flubber<int, int, int, int, char> ();
+ flubber<int, int, int, short, int> ();
+ flubber<int, int, int, short, short> ();
+ flubber<int, int, int, short, long> ();
+ flubber<int, int, int, short, char> ();
+ flubber<int, int, int, long, int> ();
+ flubber<int, int, int, long, short> ();
+ flubber<int, int, int, long, long> ();
+ flubber<int, int, int, long, char> ();
+ flubber<int, int, int, char, int> ();
+ flubber<int, int, int, char, short> ();
+ flubber<int, int, int, char, long> ();
+ flubber<int, int, int, char, char> ();
+ flubber<int, int, short, int, int> ();
+ flubber<int, int, short, int, short> ();
+ flubber<int, int, short, int, long> ();
+ flubber<int, int, short, int, char> ();
+ flubber<int, int, short, short, int> ();
+ flubber<short, int, short, int, short> ();
+ flubber<long, short, long, short, long> ();
+
+ policy1 p1 (1);
+ p1.function ();
+ policy2 p2 (2);
+ p2.function ();
+ policy3 p3 (3);
+ p3.function ();
+ policy4 p4 (4);
+ p4.function ();
+
+ policyd1 pd1 (5);
+ pd1.function ();
+ policyd2 pd2 (6);
+ pd2.function ();
+ policyd3 pd3 (7);
+ pd3.function ();
+ policyd4 pd4 (d);
+ pd4.function ();
+ policyd5 pd5 (int_tclass);
+ pd5.function ();
+
+ base1 b1 (3);
+
+ r = a;
+ char* str = a;
+ fluff* flp = a;
+ fluff** flpp = a;
+}
+
Index: testsuite/gdb.cp/cpexprs.exp
===================================================================
RCS file: testsuite/gdb.cp/cpexprs.exp
diff -N testsuite/gdb.cp/cpexprs.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.cp/cpexprs.exp 4 Mar 2010 21:52:51 -0000
@@ -0,0 +1,724 @@
+# cpexprs.exp - C++ expressions tests
+#
+# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
+#
+# Contributed by Red Hat, originally written by Keith Seitz.
+#
+# 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
+# the Free Software Foundation; either version 3 of the License, or
+# (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
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the gdb testsuite.
+
+# A helper proc which sets a breakpoint at FUNC and attempts to
+# run to the breakpoint.
+proc test_breakpoint {func} {
+ global DEC
+
+ # Restart every time
+ if {![runto_main]} {
+ perror "could not run to main when attempting to break at $func"
+ } else {
+ gdb_breakpoint "$func"
+ set i [expr {[string last : $func] + 1}]
+ set efunc [string_to_regexp [string range $func $i end]]
+ gdb_test "continue" \
+ "Continuing.\r\n\r\nBreakpoint $DEC+,.*$efunc.*" \
+ "continue to $func"
+ }
+}
+
+# Add a function to the list of tested functions
+# FUNC is the name of the function (which will be passed to gdb commands)
+# TYPE is the type of the function, as expected from the "print" command
+# PRINT is the name of the function, as expected result of the print command
+# *OR* "-", indicating that FUNC should be used (needed for virtual/inherited
+# funcs)
+# LST is either the expected result of the list command (the comment from
+# the source code) *OR* "-", in which case FUNC will be used
+#
+# Usage:
+# add NAME TYPE PRINT LST
+# add NAME TYPE PRINT -
+proc add {func type print lst} {
+ global all_functions CONVAR ADDR
+
+ set all_functions($func,type) $type
+ if {$print == "-"} {
+ set print $func
+ }
+
+ # An exception: since gdb canonicalizes C++ output,
+ # "(void)" must be mutated to "()".
+ regsub {\(void\)} $print {()} print
+
+ set all_functions($func,print) \
+ "$CONVAR = {[string_to_regexp $type]} $ADDR <[string_to_regexp $print].*>"
+ if {$lst == "-"} {
+ set lst "$func"
+ }
+ set all_functions($func,list) ".*// [string_to_regexp $lst]"
+}
+
+proc get {func cmd} {
+ global all_functions
+ return $all_functions($func,$cmd)
+}
+
+# Returns a list of function names for a given command
+proc get_functions {cmd} {
+ global all_functions
+ set result {}
+ foreach i [array names all_functions *,$cmd] {
+ if {$all_functions($i) != ""} {
+ set idx [string last , $i]
+ if {$idx != -1} {
+ lappend result [string range $i 0 [expr {$idx - 1}]]
+ }
+ }
+ }
+
+ return [lsort $result]
+}
+
+# Some convenience variables for this test
+set DEC {[0-9]}; # a decimal number
+set HEX {[0-9a-fA-F]}; # a hexidecimal number
+set CONVAR "\\\$$DEC+"; # convenience variable regexp
+set ADDR "0x$HEX+"; # address
+
+# An array of functions/methods that we are testing...
+# Each element consists is indexed by NAME,COMMAND, where
+# NAME is the function name and COMMAND is the gdb command that
+# we are testing. The value of the array for any index pair is
+# the expected result of running COMMAND with the NAME as argument.
+
+# The array holding all functions/methods to test. Valid subindexes
+# are (none need character escaping -- "add" will take care of that):
+
+# add name type print_name list
+# NAME,type: value is type of function
+# NAME,print: value is print name of function (careful w/inherited/virtual!)
+# NAME,list: value is comment in source code on first line of function
+# (without the leading "//")
+array set all_functions {}
+
+# "Normal" functions/methods
+add {main} \
+ {int (int, char **)} \
+ - \
+ -
+add {derived::a_function} \
+ {void (const derived * const)} \
+ - \
+ -
+add {base1::a_function} \
+ {void (const base1 * const)} \
+ - \
+ -
+add {base2::a_function} \
+ {void (const base2 * const)} \
+ - \
+ -
+
+# Constructors
+
+# On targets using the ARM EABI, the constructor is expected to return
+# "this".
+proc ctor { type arglist } {
+ if { [istarget arm*-*eabi*] } {
+ set ret "$type *"
+ } else {
+ set ret "void "
+ }
+ if { $arglist != "" } {
+ set arglist ", $arglist"
+ }
+ return "${ret}($type * const$arglist)"
+}
+
+add {derived::derived} \
+ [ctor derived ""] \
+ - \
+ -
+add {base1::base1(void)} \
+ [ctor base1 "const void ** const"] \
+ - \
+ -
+add {base1::base1(int)} \
+ [ctor base1 "int"] \
+ - \
+ -
+add {base2::base2} \
+ [ctor base2 "const void ** const"] \
+ - \
+ -
+add {base::base(void)} \
+ [ctor base ""] \
+ - \
+ -
+add {base::base(int)} \
+ [ctor base "int"] \
+ - \
+ -
+
+# Destructors
+
+# On targets using the ARM EABI, some destructors are expected
+# to return "this". Others are void. For internal reasons,
+# GCC returns void * instead of $type *; RealView appears to do
+# the same.
+proc dtor { type } {
+ if { [istarget arm*-*eabi*] } {
+ set ret "void *"
+ } else {
+ set ret "void "
+ }
+ return "${ret}($type * const)"
+}
+
+add {base::~base} \
+ [dtor base] \
+ - \
+ -
+
+# Overloaded methods (all are const -- we try to use the void
+# method with and without specifying "const")
+add {base::overload(void)} \
+ {int (const base * const)} \
+ - \
+ {base::overload(void) const}
+add {base::overload(void) const} \
+ {int (const base * const)} \
+ - \
+ {base::overload(void) const}
+add {base::overload(int) const} \
+ {int (const base * const, int)} \
+ - \
+ -
+add {base::overload(short) const} \
+ {int (const base * const, short)} \
+ - \
+ -
+add {base::overload(long) const} \
+ {int (const base * const, long)} \
+ - \
+ -
+add {base::overload(char*) const} \
+ {int (const base * const, char *)} \
+ - \
+ -
+add {base::overload(base&) const} \
+ {int (const base * const, base &)} \
+ - \
+ -
+
+# Operators
+add {base::operator+} \
+ {int (const base * const, const base &)} \
+ - \
+ -
+add {base::operator++} \
+ {base (base * const)} \
+ - \
+ -
+add {base::operator+=} \
+ {base (base * const, const base &)} \
+ - \
+ -
+add {base::operator-} \
+ {int (const base * const, const base &)} \
+ - \
+ -
+add {base::operator--} \
+ {base (base * const)} \
+ - \
+ -
+add {base::operator-=} \
+ {base (base * const, const base &)} \
+ - \
+ -
+add {base::operator*} \
+ {int (const base * const, const base &)} \
+ - \
+ -
+add {base::operator*=} \
+ {base (base * const, const base &)} \
+ - \
+ -
+add {base::operator/} \
+ {int (const base * const, const base &)} \
+ - \
+ -
+add {base::operator/=} \
+ {base (base * const, const base &)} \
+ - \
+ -
+add {base::operator%} \
+ {int (const base * const, const base &)} \
+ - \
+ -
+add {base::operator%=} \
+ {base (base * const, const base &)} \
+ - \
+ -
+add {base::operator<} \
+ {bool (const base * const, const base &)} \
+ - \
+ -
+add {base::operator<=} \
+ {bool (const base * const, const base &)} \
+ - \
+ -
+add {base::operator>} \
+ {bool (const base * const, const base &)} \
+ - \
+ -
+add {base::operator>=} \
+ {bool (const base * const, const base &)} \
+ - \
+ -
+add {base::operator!=} \
+ {bool (const base * const, const base &)} \
+ - \
+ -
+add {base::operator==} \
+ {bool (const base * const, const base &)} \
+ - \
+ -
+add {base::operator!} \
+ {bool (const base * const)} \
+ - \
+ -
+add {base::operator&&} \
+ {bool (const base * const, const base &)} \
+ - \
+ -
+add {base::operator||} \
+ {bool (const base * const, const base &)} \
+ - \
+ -
+add {base::operator<<} \
+ {int (const base * const, int)} \
+ - \
+ -
+add {base::operator<<=} \
+ {base (base * const, int)} \
+ - \
+ -
+add {base::operator>>} \
+ {int (const base * const, int)} \
+ - \
+ -
+add {base::operator>>=} \
+ {base (base * const, int)} \
+ - \
+ -
+add {base::operator~} \
+ {int (const base * const)} \
+ - \
+ -
+add {base::operator&} \
+ {int (const base * const, const base &)} \
+ - \
+ -
+add {base::operator&=} \
+ {base (base * const, const base &)} \
+ - \
+ -
+add {base::operator|} \
+ {int (const base * const, const base &)} \
+ - \
+ -
+add {base::operator|=} \
+ {base (base * const, const base &)} \
+ - \
+ -
+add {base::operator^} \
+ {int (const base * const, const base &)} \
+ - \
+ -
+add {base::operator^=} \
+ {base (base * const, const base &)} \
+ - \
+ -
+add {base::operator=} \
+ {base (base * const, const base &)} \
+ - \
+ -
+add {base::operator()} \
+ {void (const base * const)} \
+ - \
+ -
+add {base::operator[]} \
+ {int (const base * const, int)} \
+ - \
+ -
+add {base::operator new} \
+ {void *(size_t)} \
+ - \
+ -
+add {base::operator delete} \
+ {void (void *)} \
+ - \
+ -
+add {base::operator new[]} \
+ {void *(size_t)} \
+ - \
+ -
+add {base::operator delete[]} \
+ {void (void *)} \
+ - \
+ -
+add {base::operator char*} \
+ {char *(const base * const)} \
+ - \
+ -
+add {base::operator fluff*} \
+ {fluff *(const base * const)} \
+ - \
+ -
+add {base::operator fluff**} \
+ {fluff **(const base * const)} \
+ - \
+ -
+add {base::operator int} \
+ {int (const base * const)} \
+ - \
+ -
+
+# Templates
+add {tclass<char>::do_something} \
+ {void (tclass<char> * const)} \
+ - \
+ -
+add {tclass<int>::do_something} \
+ {void (tclass<int> * const)} \
+ - \
+ -
+add {tclass<long>::do_something} \
+ {void (tclass<long> * const)} \
+ - \
+ -
+add {tclass<short>::do_something} \
+ {void (tclass<short> * const)} \
+ - \
+ -
+add {tclass<base>::do_something} \
+ {void (tclass<base> * const)} \
+ - \
+ -
+add {flubber<int, int, int, int, int>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, int, int, short>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, int, int, long>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, int, int, char>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, int, short, int>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, int, short, short>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, int, short, long>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, int, short, char>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, int, long, int>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, int, long, short>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, int, long, long>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, int, long, char>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, int, char, int>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, int, char, short>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, int, char, long>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, int, char, char>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, short, int, int>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, short, int, short>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, short, int, long>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, short, int, char>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<int, int, short, short, int>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<short, int, short, int, short>} \
+ {void (void)} \
+ - \
+ flubber
+add {flubber<long, short, long, short, long>} \
+ {void (void)} \
+ - \
+ flubber
+add {tclass<base>::do_something} \
+ {void (tclass<base> * const)} \
+ - \
+ {tclass<T>::do_something}
+add {policy1::policy} \
+ [ctor "policy<int, operation_1<void*> >" "int"] \
+ {policy<int, operation_1<void*> >::policy} \
+ {policy<T, Policy>::policy}
+add {policy2::policy} \
+ [ctor "policy<int, operation_2<void*> >" int] \
+ {policy<int, operation_2<void*> >::policy} \
+ {policy<T, Policy>::policy}
+add {policy3::policy} \
+ [ctor "policy<int, operation_3<void*> >" "int"] \
+ {policy<int, operation_3<void*> >::policy} \
+ {policy<T, Policy>::policy}
+add {policy4::policy} \
+ [ctor "policy<int, operation_4<void*> >" "int"] \
+ {policy<int, operation_4<void*> >::policy} \
+ {policy<T, Policy>::policy}
+add {policy1::function} \
+ {void (void)} \
+ {operation_1<void*>::function} \
+ {operation_1<T>::function}
+add {policy2::function} \
+ {void (void)} \
+ {operation_2<void*>::function} \
+ {operation_2<T>::function}
+add {policy3::function} \
+ {void (void)} \
+ {operation_3<void*>::function} \
+ {operation_3<T>::function}
+add {policy4::function} \
+ {void (void)} \
+ {operation_4<void*>::function} \
+ {operation_4<T>::function}
+add {policyd<int, operation_1<int> >::policyd} \
+ [ctor "policyd<int, operation_1<int> >" "int"] \
+ - \
+ {policyd<T, Policy>::policyd}
+add {policyd1::policyd} \
+ [ctor "policyd<int, operation_1<int> >" "int"] \
+ {policyd<int, operation_1<int> >::policyd} \
+ {policyd<T, Policy>::policyd}
+add {policyd<int, operation_1<int> >::~policyd} \
+ [dtor "policyd<int, operation_1<int> >"] \
+ - \
+ {policyd<T, Policy>::~policyd}
+add {policyd1::~policyd} \
+ [dtor "policyd<int, operation_1<int> >"] \
+ {policyd<int, operation_1<int> >::~policyd} \
+ {policyd<T, Policy>::~policyd}
+add {policyd<long, operation_1<long> >::policyd} \
+ [ctor "policyd<long, operation_1<long> >" "long"] \
+ - \
+ {policyd<T, Policy>::policyd}
+add {policyd2::policyd} \
+ [ctor "policyd<long, operation_1<long> >" "long"] \
+ {policyd<long, operation_1<long> >::policyd} \
+ {policyd<T, Policy>::policyd}
+add {policyd<long, operation_1<long> >::~policyd} \
+ [dtor "policyd<long, operation_1<long> >"] \
+ - \
+ {policyd<T, Policy>::~policyd}
+add {policyd2::~policyd} \
+ [dtor "policyd<long, operation_1<long> >"] \
+ {policyd<long, operation_1<long> >::~policyd} \
+ {policyd<T, Policy>::~policyd}
+add {policyd<char, operation_1<char> >::policyd} \
+ [ctor "policyd<char, operation_1<char> >" "char"] \
+ - \
+ {policyd<T, Policy>::policyd}
+add {policyd3::policyd} \
+ [ctor "policyd<char, operation_1<char> >" "char"] \
+ {policyd<char, operation_1<char> >::policyd} \
+ {policyd<T, Policy>::policyd}
+add {policyd<char, operation_1<char> >::~policyd} \
+ [dtor "policyd<char, operation_1<char> >"] \
+ - \
+ {policyd<T, Policy>::~policyd}
+add {policyd3::~policyd} \
+ [dtor "policyd<char, operation_1<char> >"] \
+ {policyd<char, operation_1<char> >::~policyd} \
+ {policyd<T, Policy>::~policyd}
+add {policyd<base, operation_1<base> >::policyd} \
+ [ctor "policyd<base, operation_1<base> >" "base"] \
+ - \
+ {policyd<T, Policy>::policyd}
+add {policyd4::policyd} \
+ [ctor "policyd<base, operation_1<base> >" "base"] \
+ {policyd<base, operation_1<base> >::policyd} \
+ {policyd<T, Policy>::policyd}
+add {policyd<base, operation_1<base> >::~policyd} \
+ [dtor "policyd<base, operation_1<base> >"] \
+ - \
+ {policyd<T, Policy>::~policyd}
+add {policyd4::~policyd} \
+ [dtor "policyd<base, operation_1<base> >"] \
+ {policyd<base, operation_1<base> >::~policyd} \
+ {policyd<T, Policy>::~policyd}
+add {policyd<tclass<int>, operation_1<tclass<int> > >::policyd} \
+ [ctor "policyd<tclass<int>, operation_1<tclass<int> > >" "tclass<int>"] \
+ - \
+ {policyd<T, Policy>::policyd}
+add {policyd5::policyd} \
+ [ctor "policyd<tclass<int>, operation_1<tclass<int> > >" "tclass<int>"] \
+ {policyd<tclass<int>, operation_1<tclass<int> > >::policyd} \
+ {policyd<T, Policy>::policyd}
+add {policyd<tclass<int>, operation_1<tclass<int> > >::~policyd} \
+ [dtor "policyd<tclass<int>, operation_1<tclass<int> > >"] \
+ - \
+ {policyd<T, Policy>::~policyd}
+add {policyd5::~policyd} \
+ [dtor "policyd<tclass<int>, operation_1<tclass<int> > >"] \
+ {policyd<tclass<int>, operation_1<tclass<int> > >::~policyd} \
+ {policyd<T, Policy>::~policyd}
+add {policyd<int, operation_1<int> >::function} \
+ {void (void)} \
+ {operation_1<int>::function}\
+ {operation_1<T>::function}
+add {policyd1::function} \
+ {void (void)} \
+ {operation_1<int>::function} \
+ {operation_1<T>::function}
+add {policyd2::function} \
+ {void (void)} \
+ {operation_1<long>::function} \
+ {operation_1<T>::function}
+add {policyd<char, operation_1<char> >::function} \
+ {void (void)} \
+ {operation_1<char>::function} \
+ {operation_1<T>::function}
+add {policyd3::function} \
+ {void (void)} \
+ {operation_1<char>::function} \
+ {operation_1<T>::function}
+add {policyd<base, operation_1<base> >::function} \
+ {void (void)} \
+ {operation_1<base>::function} \
+ {operation_1<T>::function}
+add {policyd4::function} \
+ {void (void)} \
+ {operation_1<base>::function} \
+ {operation_1<T>::function}
+add {policyd<tclass<int>, operation_1<tclass<int> > >::function} \
+ {void (void)} \
+ {operation_1<tclass<int> >::function} \
+ {operation_1<T>::function}
+add {policyd5::function} \
+ {void (void)} \
+ {operation_1<tclass<int> >::function} \
+ {operation_1<T>::function}
+
+# Start the test
+if {$tracelevel} {
+ strace $tracelevel
+}
+
+if {[skip_cplus_tests]} { continue }
+
+#
+# test running programs
+#
+set prms_id 0
+set bug_id 0
+
+set testfile "cpexprs"
+set srcfile "${testfile}.cc"
+set binfile [file join $objdir $subdir $testfile]
+
+if {[gdb_compile [file join $srcdir $subdir $srcfile] $binfile \
+ executable {debug c++}] != "" } {
+ untested "$testfile.exp"
+ return -1
+}
+
+if {[get_compiler_info $binfile "c++"]} {
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir [file join $srcdir $subdir]
+gdb_load $binfile
+
+if {![runto_main]} {
+ perror "couldn't run to breakpoint"
+ continue
+}
+
+# Set the listsize to one. This will help with testing "list".
+gdb_test "set listsize 1"
+
+# "print METHOD"
+foreach name [get_functions print] {
+ gdb_test "print $name" [get $name print] "print $name"
+}
+
+# "list METHOD"
+foreach name [get_functions list] {
+ gdb_test "list $name" [get $name list] "list $name"
+}
+
+# Running to breakpoint -- use any function we can "list"
+foreach name [get_functions list] {
+ # Skip "main", since test_breakpoint uses it
+ if {[string compare $name "main"] != 0} {
+ test_breakpoint $name
+ }
+}
+
+gdb_exit
+return 0
Index: testsuite/gdb.cp/cplusfuncs.cc
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/cplusfuncs.cc,v
retrieving revision 1.2
diff -u -p -r1.2 cplusfuncs.cc
--- testsuite/gdb.cp/cplusfuncs.cc 11 Nov 2009 16:45:16 -0000 1.2
+++ testsuite/gdb.cp/cplusfuncs.cc 4 Mar 2010 21:52:51 -0000
@@ -195,6 +195,12 @@ char * dm_type_char_star (char * p) { r
int dm_type_foo_ref (foo & foo) { return foo.ifoo; }
int * dm_type_int_star (int * p) { return p; }
long * dm_type_long_star (long * p) { return p; }
+int dm_type_short (short i) { return i; }
+int dm_type_long (long i) { return i; }
int dm_type_unsigned_int (unsigned int i) { return i; }
+int dm_type_unsigned_short (unsigned short i) { return i; }
+int dm_type_unsigned_long (unsigned long i) { return i; }
int dm_type_void (void) { return 0; }
void * dm_type_void_star (void * p) { return p; }
+typedef int myint;
+int dm_type_typedef (myint i) { return i; }
Index: testsuite/gdb.cp/cplusfuncs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/cplusfuncs.exp,v
retrieving revision 1.11
diff -u -p -r1.11 cplusfuncs.exp
--- testsuite/gdb.cp/cplusfuncs.exp 1 Jan 2010 07:32:01 -0000 1.11
+++ testsuite/gdb.cp/cplusfuncs.exp 4 Mar 2010 21:52:52 -0000
@@ -66,9 +66,25 @@ set dm_type_unsigned_int "unsigned"
set dm_type_void "void"
set dm_type_void_star "void*"
+# Some other vagaries of GDB's type printing machinery. The integer types
+# may have unsigned before or after their length, and may have "int"
+# appended. The char* conversion operator may have name "char*" even if
+# the type is "char *", because the name comes from the debug information
+# and the type from GDB. Function types may not see through typedefs.
+
+set dm_type_short "short"
+set dm_type_long "long"
+set dm_type_unsigned_short "unsigned short"
+set dm_type_unsigned_long "unsigned long"
+set dm_operator_char_star "char*"
+set dm_operator_char_star_quoted "char\\*"
+set dm_type_typedef 0
+
proc probe_demangler { } {
global gdb_prompt
global dm_operator_comma
+ global dm_operator_char_star
+ global dm_operator_char_star_quoted
global dm_type_char_star
global dm_type_char_star_quoted
global dm_type_foo_ref
@@ -77,6 +93,11 @@ proc probe_demangler { } {
global dm_type_unsigned_int
global dm_type_void
global dm_type_void_star
+ global dm_type_short
+ global dm_type_unsigned_short
+ global dm_type_long
+ global dm_type_unsigned_long
+ global dm_type_typedef
send_gdb "print &foo::operator,(foo&)\n"
gdb_expect {
@@ -97,6 +118,26 @@ proc probe_demangler { } {
}
}
+ send_gdb "print &foo::operator char*($dm_type_void)\n"
+ gdb_expect {
+ -re ".*foo::operator char \\*\\(void\\).*\r\n$gdb_prompt $" {
+ # v2 demangler or GDB type printer
+ set dm_operator_char_star "char *"
+ set dm_operator_char_star_quoted "char \\*"
+ pass "detect dm_operator_char_star"
+ }
+ -re ".*foo::operator char\\*\\(\\).*\r\n$gdb_prompt $" {
+ # v3 demangler
+ pass "detect dm_operator_char_star"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "detect dm_operator_char_star"
+ }
+ timeout {
+ fail "detect dm_operator_char_star"
+ }
+ }
+
send_gdb "print &dm_type_char_star\n"
gdb_expect {
-re ".*dm_type_char_star\\(char \\*\\).*\r\n$gdb_prompt $" {
@@ -166,6 +207,11 @@ proc probe_demangler { } {
# v3 demangler
pass "detect dm_type_long_star"
}
+ -re ".*dm_type_long_star\\(long int \\*\\).*\r\n$gdb_prompt $" {
+ # GCC v3 and GDB's type printer
+ set dm_type_long_star "long int *"
+ pass "detect dm_type_long_star"
+ }
-re ".*$gdb_prompt $" {
fail "detect dm_type_long_star"
}
@@ -230,6 +276,101 @@ proc probe_demangler { } {
fail "detect dm_type_void_star (timeout)"
}
}
+
+ send_gdb "print &dm_type_short\n"
+ gdb_expect {
+ -re ".*dm_type_short\\(short\\).*\r\n$gdb_prompt $" {
+ # v2 and v3 demanglers
+ pass "detect dm_type_short"
+ }
+ -re ".*dm_type_short\\(short int\\).*\r\n$gdb_prompt $" {
+ # GDB type printer
+ set dm_type_short "short int"
+ pass "detect dm_type_short"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "detect dm_type_short"
+ }
+ timeout {
+ fail "detect dm_type_short (timeout)"
+ }
+ }
+
+ send_gdb "print &dm_type_unsigned_short\n"
+ gdb_expect {
+ -re ".*dm_type_unsigned_short\\(unsigned short\\).*\r\n$gdb_prompt $" {
+ # v2 and v3 demanglers
+ pass "detect dm_type_unsigned_short"
+ }
+ -re ".*dm_type_unsigned_short\\(short unsigned int\\).*\r\n$gdb_prompt $" {
+ # GDB type printer
+ set dm_type_unsigned_short "short unsigned int"
+ pass "detect dm_type_unsigned_short"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "detect dm_type_unsigned_short"
+ }
+ timeout {
+ fail "detect dm_type_unsigned_short (timeout)"
+ }
+ }
+
+ send_gdb "print &dm_type_long\n"
+ gdb_expect {
+ -re ".*dm_type_long\\(long\\).*\r\n$gdb_prompt $" {
+ # v2 and v3 demanglers
+ pass "detect dm_type_long"
+ }
+ -re ".*dm_type_long\\(long int\\).*\r\n$gdb_prompt $" {
+ # GDB type printer
+ set dm_type_long "long int"
+ pass "detect dm_type_long"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "detect dm_type_long"
+ }
+ timeout {
+ fail "detect dm_type_long (timeout)"
+ }
+ }
+
+ send_gdb "print &dm_type_unsigned_long\n"
+ gdb_expect {
+ -re ".*dm_type_unsigned_long\\(unsigned long\\).*\r\n$gdb_prompt $" {
+ # v2 and v3 demanglers
+ pass "detect dm_type_unsigned_long"
+ }
+ -re ".*dm_type_unsigned_long\\(long unsigned int\\).*\r\n$gdb_prompt $" {
+ # GDB type printer
+ set dm_type_unsigned_long "long unsigned int"
+ pass "detect dm_type_unsigned_long"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "detect dm_type_unsigned_long"
+ }
+ timeout {
+ fail "detect dm_type_unsigned_long (timeout)"
+ }
+ }
+
+ send_gdb "print &dm_type_typedef\n"
+ gdb_expect {
+ -re ".*dm_type_typedef\\(int\\).*\r\n$gdb_prompt $" {
+ # v2 and v3 demanglers
+ pass "detect dm_type_typedef"
+ }
+ -re ".*dm_type_typedef\\(myint\\).*\r\n$gdb_prompt $" {
+ # GDB type printer
+ set dm_type_typedef 1
+ pass "detect dm_type_typedef"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "detect dm_type_typedef"
+ }
+ timeout {
+ fail "detect dm_type_typedef (timeout)"
+ }
+ }
}
#
@@ -351,8 +492,9 @@ proc print_addr { name } {
proc test_lookup_operator_functions {} {
global dm_operator_comma
+ global dm_operator_char_star
global dm_type_char_star
- global dm_type_char_star_quoted
+ global dm_operator_char_star_quoted
global dm_type_foo_ref
global dm_type_void
global dm_type_void_star
@@ -410,8 +552,8 @@ proc test_lookup_operator_functions {} {
info_func "operator int(" "int foo::operator int($dm_type_void);"
info_func "operator()(" "void foo::operator()($dm_type_foo_ref);"
- info_func "operator $dm_type_char_star_quoted\(" \
- "char *foo::operator $dm_type_char_star\($dm_type_void);"
+ info_func "operator $dm_operator_char_star_quoted\(" \
+ "char *foo::operator $dm_operator_char_star\($dm_type_void);"
}
@@ -426,6 +568,7 @@ proc test_paddr_operator_functions {} {
global dm_type_unsigned_int
global dm_type_void
global dm_type_void_star
+ global dm_operator_char_star
print_addr "foo::operator*($dm_type_foo_ref)"
print_addr "foo::operator%($dm_type_foo_ref)"
@@ -479,7 +622,7 @@ proc test_paddr_operator_functions {} {
}
print_addr "foo::operator int($dm_type_void)"
- print_addr "foo::operator $dm_type_char_star\($dm_type_void)"
+ print_addr "foo::operator $dm_operator_char_star\($dm_type_void)"
}
#
@@ -489,17 +632,21 @@ proc test_paddr_operator_functions {} {
proc test_paddr_overloaded_functions {} {
global dm_type_unsigned_int
global dm_type_void
+ global dm_type_short
+ global dm_type_unsigned_short
+ global dm_type_long
+ global dm_type_unsigned_long
print_addr "overload1arg($dm_type_void)"
print_addr "overload1arg(char)"
print_addr "overload1arg(signed char)"
print_addr "overload1arg(unsigned char)"
- print_addr "overload1arg(short)"
- print_addr "overload1arg(unsigned short)"
+ print_addr "overload1arg($dm_type_short)"
+ print_addr "overload1arg($dm_type_unsigned_short)"
print_addr "overload1arg(int)"
print_addr "overload1arg($dm_type_unsigned_int)"
- print_addr "overload1arg(long)"
- print_addr "overload1arg(unsigned long)"
+ print_addr "overload1arg($dm_type_long)"
+ print_addr "overload1arg($dm_type_unsigned_long)"
print_addr "overload1arg(float)"
print_addr "overload1arg(double)"
@@ -522,17 +669,31 @@ proc test_paddr_hairy_functions {} {
global dm_type_char_star
global dm_type_int_star
global dm_type_long_star
+ global dm_type_typedef
print_addr_2 "hairyfunc1" "hairyfunc1(int)"
- print_addr_2 "hairyfunc2" "hairyfunc2(int (*)($dm_type_char_star))"
- print_addr_2 "hairyfunc3" "hairyfunc3(int (*)(short (*)($dm_type_long_star)))"
- print_addr_2 "hairyfunc4" "hairyfunc4(int (*)(short (*)($dm_type_char_star)))"
-
- # gdb-gnats bug gdb/19:
- # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7"
- print_addr_2_kfail "hairyfunc5" "hairyfunc5(int (*(*)($dm_type_char_star))(long))" "hairyfunc5(int (*)(long) (*)(char*))" "gdb/19"
- print_addr_2_kfail "hairyfunc6" "hairyfunc6(int (*(*)($dm_type_int_star))(long))" "hairyfunc6(int (*)(long) (*)(int*))" "gdb/19"
- print_addr_2_kfail "hairyfunc7" "hairyfunc7(int (*(*)(int (*)($dm_type_char_star)))(long))" "hairyfunc7(int (*)(long) (*)(int (*)(char*)))" "gdb/19"
+
+ if {$dm_type_typedef == 0} {
+ print_addr_2 "hairyfunc2" "hairyfunc2(int (*)($dm_type_char_star))"
+ print_addr_2 "hairyfunc3" "hairyfunc3(int (*)(short (*)($dm_type_long_star)))"
+ print_addr_2 "hairyfunc4" "hairyfunc4(int (*)(short (*)($dm_type_char_star)))"
+
+ # gdb-gnats bug gdb/19:
+ # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7"
+ print_addr_2_kfail "hairyfunc5" "hairyfunc5(int (*(*)($dm_type_char_star))(long))" "hairyfunc5(int (*)(long) (*)(char*))" "gdb/19"
+ print_addr_2_kfail "hairyfunc6" "hairyfunc6(int (*(*)($dm_type_int_star))(long))" "hairyfunc6(int (*)(long) (*)(int*))" "gdb/19"
+ print_addr_2_kfail "hairyfunc7" "hairyfunc7(int (*(*)(int (*)($dm_type_char_star)))(long))" "hairyfunc7(int (*)(long) (*)(int (*)(char*)))" "gdb/19"
+ } else {
+ print_addr_2 "hairyfunc2" "hairyfunc2(PFPc_i)"
+ print_addr_2 "hairyfunc3" "hairyfunc3(PFPFPl_s_i)"
+ print_addr_2 "hairyfunc4" "hairyfunc4(PFPFPc_s_i)"
+
+ # gdb-gnats bug gdb/19:
+ # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7"
+ print_addr_2 "hairyfunc5" "hairyfunc5(PFPc_PFl_i)"
+ print_addr_2 "hairyfunc6" "hairyfunc6(PFPi_PFl_i)"
+ print_addr_2 "hairyfunc7" "hairyfunc7(PFPFPc_i_PFl_i)"
+ }
}
proc do_tests {} {
Index: testsuite/gdb.cp/exception.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/exception.exp,v
retrieving revision 1.16
diff -u -p -r1.16 exception.exp
--- testsuite/gdb.cp/exception.exp 1 Jan 2010 07:32:01 -0000 1.16
+++ testsuite/gdb.cp/exception.exp 4 Mar 2010 21:52:52 -0000
@@ -146,7 +146,9 @@ gdb_test_multiple "continue" $name {
set name "backtrace after first throw"
gdb_test_multiple "backtrace" $name {
- -re ".*#\[0-9\]+${ws}($hex in |)__cxa_throw.*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" {
+ -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_throw\[\[:>:\]\].*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" {
+ # Either __cxxabiv1::__cxa_throw or __cxa_throw can be printed
+ # depending on debug info presence.
pass $name
}
}
@@ -168,7 +170,7 @@ gdb_test_multiple "continue" $name {
set name "backtrace after first catch"
gdb_test_multiple "backtrace" $name {
- -re ".*#\[0-9\]+${ws}($hex in |)__cxa_begin_catch.*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" {
+ -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_begin_catch\[\[:>:\]\].*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" {
pass $name
}
}
@@ -190,7 +192,7 @@ gdb_test_multiple "continue" $name {
set name "backtrace after second throw"
gdb_test_multiple "backtrace" $name {
- -re ".*#\[0-9\]+${ws}($hex in |)__cxa_throw.*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" {
+ -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_throw\[\[:>:\]\].*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" {
pass $name
}
}
@@ -212,7 +214,7 @@ gdb_test_multiple "continue" $name {
set name "backtrace after second catch"
gdb_test_multiple "backtrace" $name {
- -re ".*#\[0-9\]+${ws}($hex in |)__cxa_begin_catch.*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" {
+ -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_begin_catch\[\[:>:\]\].*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" {
pass $name
}
}
Index: testsuite/gdb.cp/expand-sals.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/expand-sals.exp,v
retrieving revision 1.3
diff -u -p -r1.3 expand-sals.exp
--- testsuite/gdb.cp/expand-sals.exp 1 Jan 2010 07:32:01 -0000 1.3
+++ testsuite/gdb.cp/expand-sals.exp 4 Mar 2010 21:52:52 -0000
@@ -46,7 +46,7 @@ gdb_continue_to_breakpoint "caller" ".*c
# Test GDB caught this return call and not the next one through B::B()
gdb_test "bt" \
- "#0 \[^\r\n\]* A \[^\r\n\]*\r\n#1 \[^\r\n\]* main \[^\r\n\]*" \
+ "#0 \[^\r\n\]* (A::)?A \[^\r\n\]*\r\n#1 \[^\r\n\]* main \[^\r\n\]*" \
"bt from A"
gdb_continue_to_breakpoint "next caller func" ".*func-line.*"
Index: testsuite/gdb.cp/member-ptr.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/member-ptr.exp,v
retrieving revision 1.11
diff -u -p -r1.11 member-ptr.exp
--- testsuite/gdb.cp/member-ptr.exp 1 Jan 2010 07:32:01 -0000 1.11
+++ testsuite/gdb.cp/member-ptr.exp 4 Mar 2010 21:52:52 -0000
@@ -420,7 +420,7 @@ gdb_test_multiple "ptype pmf" $name {
set name "print pmf"
gdb_test_multiple "print pmf" $name {
- -re "$vhn = $hex <A::bar\\(int\\)>\r\n$gdb_prompt $" {
+ -re "$vhn = \\(int \\(A::\\*\\)\\(A \\*, int\\)\\) $hex <A::bar\\(int\\)>\r\n$gdb_prompt $" {
pass $name
}
-re "$vhn = .*not supported with HP aCC.*\r\n$gdb_prompt $" {
@@ -608,6 +608,8 @@ gdb_test_multiple "print (a.*pmf)(3)" $n
}
}
+gdb_test "ptype a.*pmf" "type = int \\(A \\*, int\\)"
+
# Print out a pointer to data member which requires looking into
# a base class.
gdb_test "print diamond_pmi" "$vhn = &Base::x"
@@ -658,5 +660,5 @@ gdb_test "print null_pmi = &A::j" "$vhn
gdb_test "print null_pmi = 0" "$vhn = NULL"
gdb_test "print null_pmf" "$vhn = NULL"
-gdb_test "print null_pmf = &A::foo" "$vhn = $hex <A::foo ?\\(int\\)>"
+gdb_test "print null_pmf = &A::foo" "$vhn = \\(int \\(A::\\*\\)\\(A \\*, int\\)\\) $hex <A::foo ?\\(int\\)>"
gdb_test "print null_pmf = 0" "$vhn = NULL"
Index: testsuite/gdb.cp/overload.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/overload.exp,v
retrieving revision 1.17
diff -u -p -r1.17 overload.exp
--- testsuite/gdb.cp/overload.exp 4 Mar 2010 18:38:17 -0000 1.17
+++ testsuite/gdb.cp/overload.exp 4 Mar 2010 21:52:52 -0000
@@ -74,12 +74,12 @@ set re_methods "${re_methods}${ws}int ov
set re_methods "${re_methods}${ws}int overload1arg\\(char\\);"
set re_methods "${re_methods}${ws}int overload1arg\\(signed char\\);"
set re_methods "${re_methods}${ws}int overload1arg\\(unsigned char\\);"
-set re_methods "${re_methods}${ws}int overload1arg\\(short\\);"
-set re_methods "${re_methods}${ws}int overload1arg\\(unsigned short\\);"
+set re_methods "${re_methods}${ws}int overload1arg\\(short( int)?\\);"
+set re_methods "${re_methods}${ws}int overload1arg\\((unsigned short|short unsigned)( int)?\\);"
set re_methods "${re_methods}${ws}int overload1arg\\(int\\);"
set re_methods "${re_methods}${ws}int overload1arg\\(unsigned int\\);"
-set re_methods "${re_methods}${ws}int overload1arg\\(long\\);"
-set re_methods "${re_methods}${ws}int overload1arg\\(unsigned long\\);"
+set re_methods "${re_methods}${ws}int overload1arg\\(long( int)?\\);"
+set re_methods "${re_methods}${ws}int overload1arg\\((unsigned long|long unsigned)( int)?\\);"
set re_methods "${re_methods}${ws}int overload1arg\\(float\\);"
set re_methods "${re_methods}${ws}int overload1arg\\(double\\);"
set re_methods "${re_methods}${ws}int overloadfnarg\\((void|)\\);"
Index: testsuite/gdb.cp/ovldbreak.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/ovldbreak.exp,v
retrieving revision 1.12
diff -u -p -r1.12 ovldbreak.exp
--- testsuite/gdb.cp/ovldbreak.exp 1 Jan 2010 07:32:01 -0000 1.12
+++ testsuite/gdb.cp/ovldbreak.exp 4 Mar 2010 21:52:52 -0000
@@ -23,7 +23,8 @@
# overloaded member functions
#
-
+global timeout
+set timeout 15
if $tracelevel then {
strace $tracelevel
}
@@ -127,10 +128,24 @@ proc set_bp_overloaded {name expectedmen
}
# This is the expected menu for overload1arg.
-# Note the arg type variations on lines 6 and 13.
+# Note the arg type variations for void and integer types.
# This accommodates different versions of g++.
-set menu_overload1arg "\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\] foo::overload1arg\\(double\\) at.*$srcfile:121\r\n\\\[3\\\] foo::overload1arg\\(float\\) at.*$srcfile:120\r\n\\\[4\\\] foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r\n\\\[5\\\] foo::overload1arg\\(long\\) at.*$srcfile:118\r\n\\\[6\\\] foo::overload1arg\\((unsigned int|unsigned)\\) at.*$srcfile:117\r\n\\\[7\\\] foo::overload1arg\\(int\\) at.*$srcfile:116\r\n\\\[8\\\] foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r\n\\\[9\\\] foo::overload1arg\\(short\\) at.*$srcfile:114\r\n\\\[10\\\] foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r\n\\\[11\\\] foo::overload1arg\\(signed char\\) at.*$srcfile:112\r\n\\\[12\\\] foo::overload1arg\\(char\\) at.*$srcfile:111\r\n\\\[13\\\] foo::overload1arg\\((void|)\\) at.*$srcfile:110\r\n> $"
+set menu_overload1arg "\\\[0\\\] cancel\r\n"
+append menu_overload1arg "\\\[1\\\] all\r\n"
+append menu_overload1arg "\\\[2\\\] foo::overload1arg\\(double\\) at.*$srcfile:121\r\n"
+append menu_overload1arg "\\\[3\\\] foo::overload1arg\\(float\\) at.*$srcfile:120\r\n"
+append menu_overload1arg "\\\[4\\\] foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r\n"
+append menu_overload1arg "\\\[5\\\] foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r\n"
+append menu_overload1arg "\\\[6\\\] foo::overload1arg\\((unsigned int|unsigned)\\) at.*$srcfile:117\r\n"
+append menu_overload1arg "\\\[7\\\] foo::overload1arg\\(int\\) at.*$srcfile:116\r\n"
+append menu_overload1arg "\\\[8\\\] foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r\n"
+append menu_overload1arg "\\\[9\\\] foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r\n"
+append menu_overload1arg "\\\[10\\\] foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r\n"
+append menu_overload1arg "\\\[11\\\] foo::overload1arg\\(signed char\\) at.*$srcfile:112\r\n"
+append menu_overload1arg "\\\[12\\\] foo::overload1arg\\(char\\) at.*$srcfile:111\r\n"
+append menu_overload1arg "\\\[13\\\] foo::overload1arg\\((void|)\\) at.*$srcfile:110\r\n"
+append menu_overload1arg "> $"
# Set multiple-symbols to "ask", to allow us to test the use
# of the multiple-choice menu when breaking on an overloaded method.
@@ -157,17 +172,17 @@ set_bp_overloaded "foo::overload1arg" "$
gdb_test "info break" \
"Num Type\[\t \]+Disp Enb Address\[\t \]+What.*
-\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main at.*$srcfile:49\r
+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main(\\((|void)\\))? at.*$srcfile:49\r
\[\t \]+breakpoint already hit 1 time\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r
-\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r
-\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r
+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r
+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r
-\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r
-\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r
+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r
+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \
@@ -215,17 +230,17 @@ gdb_expect {
gdb_test "info break" \
"Num Type\[\t \]+Disp Enb Address\[\t \]+What.*
-\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main at.*$srcfile:49\r
+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main(\\((|void)\\))? at.*$srcfile:49\r
\[\t \]+breakpoint already hit 1 time\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r
-\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r
-\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r
+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r
+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r
-\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r
-\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r
+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r
+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \
@@ -296,12 +311,12 @@ gdb_test "info break" \
"Num Type\[\t \]+Disp Enb Address\[\t \]+What.*
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r
-\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r
-\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r
+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r
+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r
-\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r
-\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r
+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r
+\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r
\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r
Index: testsuite/gdb.java/jmain.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.java/jmain.exp,v
retrieving revision 1.11
diff -u -p -r1.11 jmain.exp
--- testsuite/gdb.java/jmain.exp 1 Jan 2010 07:32:03 -0000 1.11
+++ testsuite/gdb.java/jmain.exp 4 Mar 2010 21:52:52 -0000
@@ -65,7 +65,7 @@ gdb_test "break jmain.main" "${bpmain}"
# Check that a fully qualified "main" works.
gdb_load "${binfile}"
-set cmd "break \'${testfile}.main(java.lang.String\[\])\'"
+set cmd "break ${testfile}.main(java.lang.String\[\])"
set msg $cmd
gdb_test_multiple $cmd $msg {
-re "${bpmain}\r\n$gdb_prompt $" {
@@ -79,7 +79,7 @@ gdb_test_multiple $cmd $msg {
gdb_test "n" "" ""
# Check again with a method signature at the end.
- set cmd "break \'${testfile}.main(java.lang.String\[\])void\'"
+ set cmd "break ${testfile}.main(java.lang.String\[\])void"
set msg $cmd
gdb_test_multiple $cmd $msg {
-re "${bpmain}\r\n$gdb_prompt $" {
Index: testsuite/gdb.java/jmisc.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.java/jmisc.exp,v
retrieving revision 1.14
diff -u -p -r1.14 jmisc.exp
--- testsuite/gdb.java/jmisc.exp 1 Jan 2010 07:32:03 -0000 1.14
+++ testsuite/gdb.java/jmisc.exp 4 Mar 2010 21:52:52 -0000
@@ -71,8 +71,8 @@ if ![set_lang_java] then {
# signature.
runto_main
set function "${testfile}.main(java.lang.String\[\])"
- gdb_breakpoint "\'$function\'" { allow-pending }
- gdb_breakpoint "\'${function}void\'" { allow-pending }
+ gdb_breakpoint "$function" { allow-pending }
+ gdb_breakpoint "${function}void" { allow-pending }
gdb_continue_to_breakpoint $function
send_gdb "ptype jmisc\n"
Index: testsuite/gdb.java/jprint.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.java/jprint.exp,v
retrieving revision 1.11
diff -u -p -r1.11 jprint.exp
--- testsuite/gdb.java/jprint.exp 17 Feb 2010 22:25:05 -0000 1.11
+++ testsuite/gdb.java/jprint.exp 4 Mar 2010 21:52:52 -0000
@@ -70,8 +70,8 @@ if ![set_lang_java] then {
# signature.
runto_main
set function "${testfile}.main(java.lang.String\[\])"
- gdb_breakpoint "\'$function\'" { allow-pending }
- gdb_breakpoint "\'${function}void\'" { allow-pending }
+ gdb_breakpoint "$function" { allow-pending }
+ gdb_breakpoint "${function}void" { allow-pending }
gdb_continue_to_breakpoint $function
gdb_test "p jvclass.addprint(4,5,6)" "sum is 15\r\n.*" "unambiguous static call"
Index: testsuite/gdb.python/py-symbol.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-symbol.exp,v
retrieving revision 1.1
diff -u -p -r1.1 py-symbol.exp
--- testsuite/gdb.python/py-symbol.exp 24 Feb 2010 21:18:28 -0000 1.1
+++ testsuite/gdb.python/py-symbol.exp 4 Mar 2010 21:52:52 -0000
@@ -128,5 +128,5 @@ gdb_test "python print cplusfunc.is_argu
gdb_test "python print cplusfunc.is_function" "True" "Test func.is_function"
gdb_test "python print cplusfunc.name" "SimpleClass::valueofi().*" "Test func.name"
gdb_test "python print cplusfunc.print_name" "SimpleClass::valueofi().*" "Test func.print_name"
-gdb_test "python print cplusfunc.linkage_name" "_ZN11SimpleClass8valueofiEv" "Test func.linkage_name"
+gdb_test "python print cplusfunc.linkage_name" "SimpleClass::valueofi().*" "Test func.linkage_name"
gdb_test "python print cplusfunc.addr_class == gdb.SYMBOL_LOC_BLOCK" "True" "Test func.addr_class"
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [RFA] dwarf2_physname FINAL
2010-03-04 22:52 [RFA] dwarf2_physname FINAL Keith Seitz
@ 2010-03-05 21:54 ` Tom Tromey
2010-03-05 22:12 ` Keith Seitz
2010-03-08 6:18 ` Joel Brobecker
2010-03-23 20:25 ` [RFA] dwarf2_physname FINAL Ulrich Weigand
2 siblings, 1 reply; 14+ messages in thread
From: Tom Tromey @ 2010-03-05 21:54 UTC (permalink / raw)
To: Keith Seitz; +Cc: gdb-patches
>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
Keith> Okay, now that 7.1 has branch, it is time to give the go/no-go on this
Keith> patch. I'm attaching the "final" version (in full this time, in case
Keith> anyone wants to apply it to their own sandbox).
Keith> The only "new" stuff in this patch is a fixlet to py-symbol.exp, in
Keith> which a test prints out the linkage name (which has obviously
Keith> changed).
Given the earlier approvals, I think this is ok. Please check it in.
If there are lingering problems, we can fix them.
Keith> One other issue that I uncovered: DW_AT_MIPS_linkage_name appears to
Keith> be necessary for Ada. I have a patch that I used to address this (for
Keith> one of our internal releases), but it is probably not complete. [In
Keith> other words: it's now just as broken as it was before.] I can submit
Keith> this as a follow-up, if so desired.
By this, I assume you mean that after your patch, Ada continues to work,
but still uses DW_AT_MIPS_linkage_name; and that you have a follow-on
patch that is incomplete but which attempts to remove the reliance on
DW_AT_MIPS_linkage_name?
thanks,
Tom
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFA] dwarf2_physname FINAL
2010-03-05 21:54 ` Tom Tromey
@ 2010-03-05 22:12 ` Keith Seitz
0 siblings, 0 replies; 14+ messages in thread
From: Keith Seitz @ 2010-03-05 22:12 UTC (permalink / raw)
To: tromey; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1275 bytes --]
On 03/05/2010 01:53 PM, Tom Tromey wrote:
> Keith> One other issue that I uncovered: DW_AT_MIPS_linkage_name appears to
> Keith> be necessary for Ada. I have a patch that I used to address this (for
> Keith> one of our internal releases), but it is probably not complete. [In
> Keith> other words: it's now just as broken as it was before.] I can submit
> Keith> this as a follow-up, if so desired.
>
> By this, I assume you mean that after your patch, Ada continues to work,
> but still uses DW_AT_MIPS_linkage_name; and that you have a follow-on
> patch that is incomplete but which attempts to remove the reliance on
> DW_AT_MIPS_linkage_name?
The patch simply keeps/uses MIPS_linkage_name for Ada. Almost nothing
else is changed. I've attached it. With this patch, Ada tests now fail
as much as they did before. I'm guessing there is a lot more to do, though.
It is incomplete in the fact that I did not spend much time with it, and
this patch is quite hacky. If we want to incorporate something like
this, I'll need to play with it a bit first. Probably want to try to
move this from dwarf2_name to dwarf2_physname, if that's even possible.
[DW_AT_name and DW_AT_MIPS_linkage_name don't appear to be related in
any way in the test cases I've seen.]
Keith
[-- Attachment #2: ada-linkage-name.patch --]
[-- Type: text/plain, Size: 1137 bytes --]
*** a/gdb/dwarf2read.c.orig 2010-02-19 17:36:48.000000000 -0500
--- b/gdb/dwarf2read.c 2010-02-19 17:37:37.000000000 -0500
*************** read_partial_die (struct partial_die_inf
*** 7366,7371 ****
--- 7366,7375 ----
break;
}
break;
+ case DW_AT_MIPS_linkage_name:
+ if (cu->language == language_ada)
+ part_die->name = DW_STRING (&attr);
+ break;
case DW_AT_comp_dir:
if (part_die->dirname == NULL)
part_die->dirname = DW_STRING (&attr);
*************** dwarf2_canonicalize_name (char *name, st
*** 9928,9936 ****
static char *
dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
{
! struct attribute *attr;
! attr = dwarf2_attr (die, DW_AT_name, cu);
if (!attr || !DW_STRING (attr))
return NULL;
--- 9932,9944 ----
static char *
dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
{
! struct attribute *attr = NULL;
!
! if (cu->language == language_ada)
! attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu);
! if (!attr)
! attr = dwarf2_attr (die, DW_AT_name, cu);
if (!attr || !DW_STRING (attr))
return NULL;
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFA] dwarf2_physname FINAL
2010-03-04 22:52 [RFA] dwarf2_physname FINAL Keith Seitz
2010-03-05 21:54 ` Tom Tromey
@ 2010-03-08 6:18 ` Joel Brobecker
2010-03-09 18:10 ` Keith Seitz
2010-03-23 20:25 ` [RFA] dwarf2_physname FINAL Ulrich Weigand
2 siblings, 1 reply; 14+ messages in thread
From: Joel Brobecker @ 2010-03-08 6:18 UTC (permalink / raw)
To: Keith Seitz; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1802 bytes --]
> One other issue that I uncovered: DW_AT_MIPS_linkage_name appears to
> be necessary for Ada.
That's correct. In the cases where the DW_AT_MIPS_linkage_name is used,
it provides the exported name of our entity, whereas the DW_AT_name
contains the name of the entity as it would have been encoded had
the entity not been given a specific exported name. For instance,
consider the following declaration:
package Pck is
procedure Do_Nothing;
pragma Export (C, Do_Nothing, "__foo_bar");
end Pck;
The associated DWARF looks like this:
.uleb128 0x2 # (DIE (0x2d) DW_TAG_subprogram)
.byte 0x1 # DW_AT_external
.long .LASF3 # DW_AT_name: "pck__do_nothing"
.long .LASF4 # DW_AT_MIPS_linkage_name: "__foo_bar"
> I have a patch that I used to address this (for one of our internal
> releases), but it is probably not complete. [In other words: it's now
> just as broken as it was before.] I can submit this as a follow-up, if
> so desired.
Just to clarify a little bit, it's the compiler that is probably broken,
generating incorrect debugging info. I keep pushing internally for us
to improve the situation so that others can test Ada too, but we only
have few engineers working on this area, and it's hard to get their
attention on this :-(.
Attached is a patch that fixes all regressions for Ada. Basically,
it updates dwarf2_compute_name to handle Ada entities... The function
comment will probably need to be updated - something like this:
/* Compute the fully qualified name of DIE in CU:
. For Ada, this is the DIE exported name;
. For C++ and Java, [...]; <mention canonicalization here?>
. For other languages, this is just the DIE name.
The result is allocated on the objfile_obstack. */
--
Joel
[-- Attachment #2: physname-ada.diff --]
[-- Type: text/x-diff, Size: 1016 bytes --]
commit 0a992b13eb758bf26c172a67240022a9d1e1226f
Author: Joel Brobecker <brobecker@adacore.com>
Date: Mon Mar 8 09:56:21 2010 +0400
Compute the name of Ada entities using the MIPS_linkage_name first.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index d8629e4..9e4334a 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3399,6 +3399,19 @@ dwarf2_compute_name (char *name, struct die_info *die, struct dwarf2_cu *cu,
}
}
}
+ else if (cu->language == language_ada)
+ {
+ /* For Ada unit, we prefer the linkage name over the name, as
+ the former contains the exported name, which the user expects
+ to be able to reference. Ideally, we want the user to be able
+ to reference this entity using either natural or linkage name,
+ but we haven't started looking at this enhancement yet. */
+ struct attribute *attr;
+
+ attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu);
+ if (attr && DW_STRING (attr))
+ name = DW_STRING (attr);
+ }
return name;
}
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [RFA] dwarf2_physname FINAL
2010-03-08 6:18 ` Joel Brobecker
@ 2010-03-09 18:10 ` Keith Seitz
2010-03-10 8:11 ` [commit/dwarf2/Ada] Adjust handling of Ada DIEs after dwarf2_physname patch Joel Brobecker
0 siblings, 1 reply; 14+ messages in thread
From: Keith Seitz @ 2010-03-09 18:10 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
I have now committed this patchset. At long, long last. My thanks to
everyone who reviewed it.
On 03/07/2010 10:17 PM, Joel Brobecker wrote:
> Attached is a patch that fixes all regressions for Ada.
I like your patch a whole lot better than mine, you should probably
commit it. O:-)
Keith
^ permalink raw reply [flat|nested] 14+ messages in thread
* [commit/dwarf2/Ada] Adjust handling of Ada DIEs after dwarf2_physname patch.
2010-03-09 18:10 ` Keith Seitz
@ 2010-03-10 8:11 ` Joel Brobecker
0 siblings, 0 replies; 14+ messages in thread
From: Joel Brobecker @ 2010-03-10 8:11 UTC (permalink / raw)
To: gdb-patches
Hello,
This patch fixes some regressions introduced by the dwarf2_physname
patch. For Ada, we prefer the DW_AT_MIPS_linkage_name if available
for the name attribute. Eventually, we will want to be able to use
both, so that users can reference an entity using either linkage name
or natural name. But that's for another time...
gdb/ChangeLog:
Adjust handling of Ada DIEs after dwarf2_physname patch.
* dwarf2read.c (dwarf2_compute_name): Add handling of Ada DIEs.
Tested on x86_64-linux. No regression. Checked in.
---
gdb/dwarf2read.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 1f25a45..fd75c74 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3324,6 +3324,9 @@ die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu)
compute the physname for the object, which include a method's
formal parameters (C++/Java) and return type (Java).
+ For Ada, return the DIE's linkage name rather than the fully qualified
+ name. PHYSNAME is ignored..
+
The result is allocated on the objfile_obstack and canonicalized. */
static const char *
@@ -3396,6 +3399,19 @@ dwarf2_compute_name (char *name, struct die_info *die, struct dwarf2_cu *cu,
}
}
}
+ else if (cu->language == language_ada)
+ {
+ /* For Ada unit, we prefer the linkage name over the name, as
+ the former contains the exported name, which the user expects
+ to be able to reference. Ideally, we want the user to be able
+ to reference this entity using either natural or linkage name,
+ but we haven't started looking at this enhancement yet. */
+ struct attribute *attr;
+
+ attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu);
+ if (attr && DW_STRING (attr))
+ name = DW_STRING (attr);
+ }
return name;
}
--
1.6.3.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFA] dwarf2_physname FINAL
2010-03-04 22:52 [RFA] dwarf2_physname FINAL Keith Seitz
2010-03-05 21:54 ` Tom Tromey
2010-03-08 6:18 ` Joel Brobecker
@ 2010-03-23 20:25 ` Ulrich Weigand
2010-03-24 20:24 ` Keith Seitz
2 siblings, 1 reply; 14+ messages in thread
From: Ulrich Weigand @ 2010-03-23 20:25 UTC (permalink / raw)
To: Keith Seitz; +Cc: gdb-patches
Keith Seitz wrote:
> There is an apparent regression in jprint.exp. Printing static class
> variables (java only) is "broken." This is a gcc bug (gcc/43260): we
> don't get any location info from gcc about where the static variable
> lives, so we report it as "optimized out." NOTE: This "works" on CVS
> HEAD because we fallback to using the linkage name (from
> DW_AT_MIPS_linkage_name) to search the minimal symbol table, using that
> to grab the address of the variable. Obviously we won't be able to do
> that any more.
Would it be possible to KFAIL that?
I'm also seeing a second Java-related regression:
FAIL: gdb.java/jmisc.exp: ptype jmisc
This is because "ptype jmisc" now shows:
type = class jmisc extends java.lang.Object {
void main(java.lang.String[])void;
void <init>(void)void;
}
instead of
type = class jmisc extends java.lang.Object {
void main(java.lang.String[])void;
jmisc();
}
This is apparently caused by Java using DW_AT_MIPS_linkage_name to hide
the <init> magic name for the constructor:
<2><223>: Abbrev Number: 6 (DW_TAG_subprogram)
DW_AT_external : 1
DW_AT_name : <init>
DW_AT_MIPS_linkage_name: _ZN5jmiscC1Ev
DW_AT_artificial : 1
DW_AT_declaration : 1
Is this to be expected? Or should this be handled by the new code
somewhere?
Also, I'm now seeing three failures in the new cpexprs.exp:
FAIL: gdb.cp/cpexprs.exp: list base::overload(void)
FAIL: gdb.cp/cpexprs.exp: setting breakpoint at base::overload(void)
FAIL: gdb.cp/cpexprs.exp: continue to base::overload(void)
apparently related to whether "const" needs to be specified when
identifying an overloaded method. I seem to recall some reference
to this problem in one of the dwarf2_physname threads -- is this
still an expected problem with the final patch?
This is all on a RHEL5.4 with the system GCC 4.1.
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [RFA] dwarf2_physname FINAL
2010-03-23 20:25 ` [RFA] dwarf2_physname FINAL Ulrich Weigand
@ 2010-03-24 20:24 ` Keith Seitz
2010-03-25 10:21 ` Ulrich Weigand
0 siblings, 1 reply; 14+ messages in thread
From: Keith Seitz @ 2010-03-24 20:24 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
On 03/23/2010 01:24 PM, Ulrich Weigand wrote:
> Would it be possible to KFAIL that?
I should think so... :-) If maintainers wish it so, it will be done.
> <2><223>: Abbrev Number: 6 (DW_TAG_subprogram)
> DW_AT_external : 1
> DW_AT_name :<init>
> DW_AT_MIPS_linkage_name: _ZN5jmiscC1Ev
> DW_AT_artificial : 1
> DW_AT_declaration : 1
>
> Is this to be expected? Or should this be handled by the new code
> somewhere?
No, it's not. I have a patch for this, but I've noticed some other
little java regressions (which are not tested by the test suite), so I
am going to delay submitting my patch until I can get the problems all
worked out.
> Also, I'm now seeing three failures in the new cpexprs.exp:
> FAIL: gdb.cp/cpexprs.exp: list base::overload(void)
> FAIL: gdb.cp/cpexprs.exp: setting breakpoint at base::overload(void)
> FAIL: gdb.cp/cpexprs.exp: continue to base::overload(void)
> apparently related to whether "const" needs to be specified when
> identifying an overloaded method. I seem to recall some reference
> to this problem in one of the dwarf2_physname threads -- is this
> still an expected problem with the final patch?
Yeah, I meant to return to this, but got caught up in one thing or
another. I will attempt to fix this (or XFAIL it) when I get the above
Java issues sorted out.
Keith
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFA] dwarf2_physname FINAL
2010-03-24 20:24 ` Keith Seitz
@ 2010-03-25 10:21 ` Ulrich Weigand
2010-03-25 18:31 ` [RFA] Java DWARF fixes (was Re: [RFA] dwarf2_physname FINAL) Keith Seitz
0 siblings, 1 reply; 14+ messages in thread
From: Ulrich Weigand @ 2010-03-25 10:21 UTC (permalink / raw)
To: Keith Seitz; +Cc: gdb-patches
Keith Seitz wrote:
> On 03/23/2010 01:24 PM, Ulrich Weigand wrote:
>
> > Would it be possible to KFAIL that?
(I guess this should have been XFAIL ...)
> I should think so... :-) If maintainers wish it so, it will be done.
I'd appreciate that, thanks!
> > <2><223>: Abbrev Number: 6 (DW_TAG_subprogram)
> > DW_AT_external : 1
> > DW_AT_name :<init>
> > DW_AT_MIPS_linkage_name: _ZN5jmiscC1Ev
> > DW_AT_artificial : 1
> > DW_AT_declaration : 1
> >
> > Is this to be expected? Or should this be handled by the new code
> > somewhere?
>
> No, it's not. I have a patch for this, but I've noticed some other
> little java regressions (which are not tested by the test suite), so I
> am going to delay submitting my patch until I can get the problems all
> worked out.
>
> > Also, I'm now seeing three failures in the new cpexprs.exp:
> > FAIL: gdb.cp/cpexprs.exp: list base::overload(void)
> > FAIL: gdb.cp/cpexprs.exp: setting breakpoint at base::overload(void)
> > FAIL: gdb.cp/cpexprs.exp: continue to base::overload(void)
> > apparently related to whether "const" needs to be specified when
> > identifying an overloaded method. I seem to recall some reference
> > to this problem in one of the dwarf2_physname threads -- is this
> > still an expected problem with the final patch?
>
> Yeah, I meant to return to this, but got caught up in one thing or
> another. I will attempt to fix this (or XFAIL it) when I get the above
> Java issues sorted out.
OK, thanks for looking into these!
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 14+ messages in thread
* [RFA] Java DWARF fixes (was Re: [RFA] dwarf2_physname FINAL)
2010-03-25 10:21 ` Ulrich Weigand
@ 2010-03-25 18:31 ` Keith Seitz
2010-03-25 20:05 ` [RFA] Java DWARF fixes Tom Tromey
0 siblings, 1 reply; 14+ messages in thread
From: Keith Seitz @ 2010-03-25 18:31 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1259 bytes --]
On 03/25/2010 03:20 AM, Ulrich Weigand wrote:
>> I should think so... :-) If maintainers wish it so, it will be done.
>
> I'd appreciate that, thanks!
I've appended this to the attached patch.
>> No, it's not. I have a patch for this, but I've noticed some other
>> little java regressions (which are not tested by the test suite), so I
>> am going to delay submitting my patch until I can get the problems all
>> worked out.
My problems turned out to stem from another GCC debuginfo problem,
described in gcc/43521 (out-of-line debuginfo for class methods does not
mark "this" ptr with DW_AT_artificial).
I've worked around the issue in the attached patch, which should fix all
the problems with Java that the dwarf2_physname patch introduced (or at
least all the problems that anyone has yet noticed :-).
Ok?
Keith
ChangeLog
2010-03-25 Keith Seitz <keiths@redhat.com>
* dwarf2read.c (read_subroutine_type): If the compilation unit
language is Java, mark any formal parameter named "this" as
artificial (GCC/43521).
(dwarf2_name): Add special handling for Java constructors.
testsuite/ChangeLog
2010-03-25 Keith Seitz <keiths@redhat.com>
* gdb.java/jprint.exp: XFAIL printing of static class members
because of GCC debuginfo problem.
[-- Attachment #2: java-dwarf.patch --]
[-- Type: text/plain, Size: 2913 bytes --]
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.372
diff -u -p -r1.372 dwarf2read.c
--- dwarf2read.c 22 Mar 2010 13:21:39 -0000 1.372
+++ dwarf2read.c 25 Mar 2010 18:25:53 -0000
@@ -5932,7 +5932,18 @@ read_subroutine_type (struct die_info *d
if (attr)
TYPE_FIELD_ARTIFICIAL (ftype, iparams) = DW_UNSND (attr);
else
- TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0;
+ {
+ TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0;
+
+ /* GCC/43521: In java, the formal parameter
+ "this" is sometimes not marked with DW_AT_artificial. */
+ if (cu->language == language_java)
+ {
+ const char *name = dwarf2_name (child_die, cu);
+ if (name && !strcmp (name, "this"))
+ TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 1;
+ }
+ }
TYPE_FIELD_TYPE (ftype, iparams) = die_type (child_die, cu);
iparams++;
}
@@ -9159,6 +9170,34 @@ dwarf2_name (struct die_info *die, struc
/* These tags always have simple identifiers already; no need
to canonicalize them. */
return DW_STRING (attr);
+ case DW_TAG_subprogram:
+ /* Java constructors will all be named "<init>", so return
+ the class name when we see this special case. */
+ if (cu->language == language_java
+ && DW_STRING (attr) != NULL
+ && strcmp (DW_STRING (attr), "<init>") == 0)
+ {
+ struct dwarf2_cu *spec_cu = cu;
+ struct die_info *spec_die;
+
+ /* GCJ will output '<init>' for Java constructor names.
+ For this special case, return the name of the parent class. */
+
+ /* GCJ may output suprogram DIEs with AT_specification set.
+ If so, use the name of the specified DIE. */
+ spec_die = die_specification (die, &spec_cu);
+ if (spec_die != NULL)
+ return dwarf2_name (spec_die, spec_cu);
+
+ do
+ {
+ die = die->parent;
+ if (die->tag == DW_TAG_class_type)
+ return dwarf2_name (die, cu);
+ }
+ while (die->tag != DW_TAG_compile_unit);
+ }
+ /* fall through */
default:
if (!DW_STRING_IS_CANONICAL (attr))
{
Index: testsuite/gdb.java/jprint.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.java/jprint.exp,v
retrieving revision 1.12
diff -u -p -r1.12 jprint.exp
--- testsuite/gdb.java/jprint.exp 9 Mar 2010 18:08:05 -0000 1.12
+++ testsuite/gdb.java/jprint.exp 25 Mar 2010 18:25:53 -0000
@@ -86,5 +86,8 @@ if ![set_lang_java] then {
gdb_test "call x.addk(44)" "adding k gives 121\r\n.*= 121.*" "inherited virtual fn call"
# Regression test for a crasher.
+ # GCC does not output location information for static class members,
+ # so GDB will report these as "optimized out". See gcc/43260.
+ setup_xfail *-*-* gcc/43260
gdb_test "print *jprint.props" " = .*" "print a java.util.Properties"
}
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [RFA] Java DWARF fixes
2010-03-25 18:31 ` [RFA] Java DWARF fixes (was Re: [RFA] dwarf2_physname FINAL) Keith Seitz
@ 2010-03-25 20:05 ` Tom Tromey
2010-03-25 22:14 ` Keith Seitz
0 siblings, 1 reply; 14+ messages in thread
From: Tom Tromey @ 2010-03-25 20:05 UTC (permalink / raw)
To: Keith Seitz; +Cc: Ulrich Weigand, gdb-patches
>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
Keith> 2010-03-25 Keith Seitz <keiths@redhat.com>
Keith> * dwarf2read.c (read_subroutine_type): If the compilation unit
Keith> language is Java, mark any formal parameter named "this" as
Keith> artificial (GCC/43521).
Keith> (dwarf2_name): Add special handling for Java constructors.
Keith> 2010-03-25 Keith Seitz <keiths@redhat.com>
Keith> * gdb.java/jprint.exp: XFAIL printing of static class members
Keith> because of GCC debuginfo problem.
This all seems pretty reasonable to me. It is ok.
Thanks.
Tom
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFA] Java DWARF fixes
2010-03-25 20:05 ` [RFA] Java DWARF fixes Tom Tromey
@ 2010-03-25 22:14 ` Keith Seitz
2010-03-26 16:48 ` Ulrich Weigand
0 siblings, 1 reply; 14+ messages in thread
From: Keith Seitz @ 2010-03-25 22:14 UTC (permalink / raw)
To: gdb-patches
On 03/25/2010 01:05 PM, Tom Tromey wrote:
> This all seems pretty reasonable to me. It is ok.
I have committed the patches. Thank you for reviewing them.
Keith
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFA] Java DWARF fixes
2010-03-25 22:14 ` Keith Seitz
@ 2010-03-26 16:48 ` Ulrich Weigand
2010-03-26 16:54 ` Keith Seitz
0 siblings, 1 reply; 14+ messages in thread
From: Ulrich Weigand @ 2010-03-26 16:48 UTC (permalink / raw)
To: Keith Seitz; +Cc: gdb-patches
Keith Seitz wrote:
> On 03/25/2010 01:05 PM, Tom Tromey wrote:
> > This all seems pretty reasonable to me. It is ok.
>
> I have committed the patches. Thank you for reviewing them.
Thanks! Unfortunately, the test case still fails for me:
FAIL: gdb.java/jmisc.exp: ptype jmisc
This time the problem seems to be that the constructor
is shown with a "void" argument list:
type = class jmisc extends java.lang.Object {
void main(java.lang.String[])void;
jmisc(void)void;
}
while the test expects this to be just "jmisc()":
send_gdb "ptype jmisc\n"
gdb_expect {
-re "type = class jmisc extends java.lang.Object \{\[\r\n\ \t]+void main\\(java\.lang\.String\\\[]\\);\[\r\n\ \t]+jmisc\\(\\);\[\r\n\ \t]+\}\[\r\n\ \t]+$gdb_prompt $"
{ pass "ptype jmisc" }
-re "type = class jmisc extends java.lang.Object \{\[\r\n\ \t]+void main\\(java\.lang\.String\\\[]\\)void;\[\r\n\ \t]+jmisc\\(\\);\[\r\n\ \t]+\}\[\r\n\ \t]+$gdb_prompt $" {
# Just because GCC includes the signature doesn't mean we
# should print it here. We already show the return type.
kfail "ptype jmisc" gdb/2215
}
-re ".*$gdb_prompt $" { fail "ptype jmisc" }
timeout { fail "ptype jmisc (timeout)" ; return }
}
Is this a testcase problem or still something wrong in
the symbol reader?
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [RFA] Java DWARF fixes
2010-03-26 16:48 ` Ulrich Weigand
@ 2010-03-26 16:54 ` Keith Seitz
0 siblings, 0 replies; 14+ messages in thread
From: Keith Seitz @ 2010-03-26 16:54 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
On 03/26/2010 09:48 AM, Ulrich Weigand wrote:
> Thanks! Unfortunately, the test case still fails for me:
> FAIL: gdb.java/jmisc.exp: ptype jmisc
>
> This time the problem seems to be that the constructor
> is shown with a "void" argument list:
>
> type = class jmisc extends java.lang.Object {
>
> void main(java.lang.String[])void;
> jmisc(void)void;
> }
For reference, this is what the test log shows for this test before
dwarf2_physname:
ptype jmisc
type = class jmisc extends java.lang.Object {
jmisc();
void main(java.lang.String[])void;
}
(gdb) FAIL: gdb.java/jmisc.exp: ptype jmisc
> Is this a testcase problem or still something wrong in
> the symbol reader?
This is more a problem with the type printer, I should think. I've been
trying to fix this "for good," but I've run into a few roadblock
thinko's that need working around.
Stay tuned...
Keith
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2010-03-26 16:54 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-04 22:52 [RFA] dwarf2_physname FINAL Keith Seitz
2010-03-05 21:54 ` Tom Tromey
2010-03-05 22:12 ` Keith Seitz
2010-03-08 6:18 ` Joel Brobecker
2010-03-09 18:10 ` Keith Seitz
2010-03-10 8:11 ` [commit/dwarf2/Ada] Adjust handling of Ada DIEs after dwarf2_physname patch Joel Brobecker
2010-03-23 20:25 ` [RFA] dwarf2_physname FINAL Ulrich Weigand
2010-03-24 20:24 ` Keith Seitz
2010-03-25 10:21 ` Ulrich Weigand
2010-03-25 18:31 ` [RFA] Java DWARF fixes (was Re: [RFA] dwarf2_physname FINAL) Keith Seitz
2010-03-25 20:05 ` [RFA] Java DWARF fixes Tom Tromey
2010-03-25 22:14 ` Keith Seitz
2010-03-26 16:48 ` Ulrich Weigand
2010-03-26 16:54 ` Keith Seitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox