mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-17 07:53:51 +08:00
gdb/
* cp-namespace.c (cp_lookup_nested_type): New variable concatenated_name. Turn the current return condition into a reverse one. Call also lookup_static_symbol_aux on the constructed qualified name. * symtab.c (lookup_symbol_aux): Move variable objfile and searching in other files into a called ... (lookup_static_symbol_aux): ... new function here. * symtab.h (lookup_static_symbol_aux): New prototype. * valops.c (value_maybe_namespace_elt): Call also lookup_static_symbol_aux if we failed otherwise. gdb/testsuite/ * gdb.cp/namespace.exp (whatis C::cOtherFileType) (whatis ::C::cOtherFileType, whatis C::cOtherFileVar) (whatis ::C::cOtherFileVar, print C::cOtherFileVar) (print ::C::cOtherFileVar) (whatis C::OtherFileClass::cOtherFileClassType) (whatis ::C::OtherFileClass::cOtherFileClassType) (print C::OtherFileClass::cOtherFileClassVar) (print ::cOtherFileClassVar) (print ::C::OtherFileClass::cOtherFileClassVar): New tests. (ptype OtherFileClass, ptype ::C::OtherFileClass): Permit arbitrary trailing content. * gdb.cp/namespace1.cc (C::OtherFileClass::cOtherFileClassType) (C::OtherFileClass::cOtherFileClassVar) (C::OtherFileClass::cOtherFileClassVar_use, C::cOtherFileType) (C::cOtherFileVar, C::cOtherFileVar_use): New.
This commit is contained in:
@ -1,3 +1,16 @@
|
|||||||
|
2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
|
* cp-namespace.c (cp_lookup_nested_type): New variable
|
||||||
|
concatenated_name. Turn the current return condition into a reverse
|
||||||
|
one. Call also lookup_static_symbol_aux on the constructed qualified
|
||||||
|
name.
|
||||||
|
* symtab.c (lookup_symbol_aux): Move variable objfile and searching in
|
||||||
|
other files into a called ...
|
||||||
|
(lookup_static_symbol_aux): ... new function here.
|
||||||
|
* symtab.h (lookup_static_symbol_aux): New prototype.
|
||||||
|
* valops.c (value_maybe_namespace_elt): Call also
|
||||||
|
lookup_static_symbol_aux if we failed otherwise.
|
||||||
|
|
||||||
2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com>
|
2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
Fix PR c++/11703 and PR gdb/1448.
|
Fix PR c++/11703 and PR gdb/1448.
|
||||||
|
@ -578,11 +578,24 @@ cp_lookup_nested_type (struct type *parent_type,
|
|||||||
nested_name,
|
nested_name,
|
||||||
block,
|
block,
|
||||||
VAR_DOMAIN);
|
VAR_DOMAIN);
|
||||||
|
char *concatenated_name;
|
||||||
|
|
||||||
if (sym == NULL || SYMBOL_CLASS (sym) != LOC_TYPEDEF)
|
if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
|
||||||
return NULL;
|
|
||||||
else
|
|
||||||
return SYMBOL_TYPE (sym);
|
return SYMBOL_TYPE (sym);
|
||||||
|
|
||||||
|
/* Now search all static file-level symbols. Not strictly correct,
|
||||||
|
but more useful than an error. We do not try to guess any imported
|
||||||
|
namespace as even the fully specified namespace seach is is already
|
||||||
|
not C++ compliant and more assumptions could make it too magic. */
|
||||||
|
|
||||||
|
concatenated_name = alloca (strlen (parent_name) + 2
|
||||||
|
+ strlen (nested_name) + 1);
|
||||||
|
sprintf (concatenated_name, "%s::%s", parent_name, nested_name);
|
||||||
|
sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN);
|
||||||
|
if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
|
||||||
|
return SYMBOL_TYPE (sym);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
internal_error (__FILE__, __LINE__,
|
internal_error (__FILE__, __LINE__,
|
||||||
|
20
gdb/symtab.c
20
gdb/symtab.c
@ -1054,7 +1054,6 @@ lookup_symbol_aux (const char *name, const struct block *block,
|
|||||||
{
|
{
|
||||||
struct symbol *sym;
|
struct symbol *sym;
|
||||||
const struct language_defn *langdef;
|
const struct language_defn *langdef;
|
||||||
struct objfile *objfile;
|
|
||||||
|
|
||||||
/* Make sure we do something sensible with is_a_field_of_this, since
|
/* Make sure we do something sensible with is_a_field_of_this, since
|
||||||
the callers that set this parameter to some non-null value will
|
the callers that set this parameter to some non-null value will
|
||||||
@ -1122,10 +1121,21 @@ lookup_symbol_aux (const char *name, const struct block *block,
|
|||||||
return sym;
|
return sym;
|
||||||
|
|
||||||
/* Now search all static file-level symbols. Not strictly correct,
|
/* Now search all static file-level symbols. Not strictly correct,
|
||||||
but more useful than an error. Do the symtabs first, then check
|
but more useful than an error. */
|
||||||
the psymtabs. If a psymtab indicates the existence of the
|
|
||||||
desired name as a file-level static, then do psymtab-to-symtab
|
return lookup_static_symbol_aux (name, domain);
|
||||||
conversion on the fly and return the found symbol. */
|
}
|
||||||
|
|
||||||
|
/* Search all static file-level symbols for NAME from DOMAIN. Do the symtabs
|
||||||
|
first, then check the psymtabs. If a psymtab indicates the existence of the
|
||||||
|
desired name as a file-level static, then do psymtab-to-symtab conversion on
|
||||||
|
the fly and return the found symbol. */
|
||||||
|
|
||||||
|
struct symbol *
|
||||||
|
lookup_static_symbol_aux (const char *name, const domain_enum domain)
|
||||||
|
{
|
||||||
|
struct objfile *objfile;
|
||||||
|
struct symbol *sym;
|
||||||
|
|
||||||
sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain);
|
sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain);
|
||||||
if (sym != NULL)
|
if (sym != NULL)
|
||||||
|
@ -886,6 +886,12 @@ extern struct symbol *lookup_symbol_aux_block (const char *name,
|
|||||||
const struct block *block,
|
const struct block *block,
|
||||||
const domain_enum domain);
|
const domain_enum domain);
|
||||||
|
|
||||||
|
/* Lookup a symbol only in the file static scope of all the objfiles. */
|
||||||
|
|
||||||
|
struct symbol *lookup_static_symbol_aux (const char *name,
|
||||||
|
const domain_enum domain);
|
||||||
|
|
||||||
|
|
||||||
/* lookup a symbol by name, within a specified block */
|
/* lookup a symbol by name, within a specified block */
|
||||||
|
|
||||||
extern struct symbol *lookup_block_symbol (const struct block *, const char *,
|
extern struct symbol *lookup_block_symbol (const struct block *, const char *,
|
||||||
|
@ -1,3 +1,21 @@
|
|||||||
|
2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
|
* gdb.cp/namespace.exp (whatis C::cOtherFileType)
|
||||||
|
(whatis ::C::cOtherFileType, whatis C::cOtherFileVar)
|
||||||
|
(whatis ::C::cOtherFileVar, print C::cOtherFileVar)
|
||||||
|
(print ::C::cOtherFileVar)
|
||||||
|
(whatis C::OtherFileClass::cOtherFileClassType)
|
||||||
|
(whatis ::C::OtherFileClass::cOtherFileClassType)
|
||||||
|
(print C::OtherFileClass::cOtherFileClassVar)
|
||||||
|
(print ::cOtherFileClassVar)
|
||||||
|
(print ::C::OtherFileClass::cOtherFileClassVar): New tests.
|
||||||
|
(ptype OtherFileClass, ptype ::C::OtherFileClass): Permit arbitrary
|
||||||
|
trailing content.
|
||||||
|
* gdb.cp/namespace1.cc (C::OtherFileClass::cOtherFileClassType)
|
||||||
|
(C::OtherFileClass::cOtherFileClassVar)
|
||||||
|
(C::OtherFileClass::cOtherFileClassVar_use, C::cOtherFileType)
|
||||||
|
(C::cOtherFileVar, C::cOtherFileVar_use): New.
|
||||||
|
|
||||||
2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com>
|
2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
Test PR c++/11703 and PR gdb/1448.
|
Test PR c++/11703 and PR gdb/1448.
|
||||||
|
@ -165,6 +165,70 @@ gdb_test "print BBB::Class::xyzq" \
|
|||||||
gdb_test "break BBB::Class::xyzq" \
|
gdb_test "break BBB::Class::xyzq" \
|
||||||
"Breakpoint.*at $hex: file.*namespace.cc, line 68\\."
|
"Breakpoint.*at $hex: file.*namespace.cc, line 68\\."
|
||||||
|
|
||||||
|
# Tests accessing static elements in namespace of other file.
|
||||||
|
|
||||||
|
gdb_test "whatis C::cOtherFileType" "type = short"
|
||||||
|
gdb_test "whatis ::C::cOtherFileType" "type = short"
|
||||||
|
gdb_test "whatis C::cOtherFileVar" "type = const C::cOtherFileType"
|
||||||
|
gdb_test "whatis ::C::cOtherFileVar" "type = const C::cOtherFileType"
|
||||||
|
gdb_test "print C::cOtherFileVar" "\\$\[0-9\].* = 319"
|
||||||
|
gdb_test "print ::C::cOtherFileVar" "\\$\[0-9\].* = 319"
|
||||||
|
|
||||||
|
if {[test_compiler_info {gcc-[0-3]-*}]
|
||||||
|
|| [test_compiler_info {gcc-4-[0-4]-*}]} {
|
||||||
|
# The type in class is missing in older GCCs.
|
||||||
|
setup_xfail *-*-*
|
||||||
|
}
|
||||||
|
gdb_test "whatis C::OtherFileClass::cOtherFileClassType" "type = short"
|
||||||
|
if {[test_compiler_info {gcc-[0-3]-*}]
|
||||||
|
|| [test_compiler_info {gcc-4-[0-4]-*}]} {
|
||||||
|
# The type in class is missing in older GCCs.
|
||||||
|
setup_xfail *-*-*
|
||||||
|
}
|
||||||
|
gdb_test "whatis ::C::OtherFileClass::cOtherFileClassType" "type = short"
|
||||||
|
|
||||||
|
set test "print C::OtherFileClass::cOtherFileClassVar"
|
||||||
|
gdb_test_multiple $test $test {
|
||||||
|
-re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" {
|
||||||
|
pass $test
|
||||||
|
}
|
||||||
|
-re "static field cOtherFileClassVar has been optimized out\r\n$gdb_prompt $" {
|
||||||
|
setup_kfail "c++/11702" "*-*-*"
|
||||||
|
fail $test
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# FSF GCC <=4.4 creates unqualified DIE "cOtherFileClassVar" ignoring the
|
||||||
|
# namespace the same way older GDB did.
|
||||||
|
set test "print ::cOtherFileClassVar"
|
||||||
|
set test2 "print ::C::OtherFileClass::cOtherFileClassVar"
|
||||||
|
gdb_test_multiple $test $test {
|
||||||
|
-re "No symbol \"cOtherFileClassVar\" in current context\\.\r\n$gdb_prompt $" {
|
||||||
|
pass $test
|
||||||
|
|
||||||
|
gdb_test_multiple $test2 $test2 {
|
||||||
|
-re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" {
|
||||||
|
pass $test2
|
||||||
|
}
|
||||||
|
-re "static field cOtherFileClassVar has been optimized out\r\n$gdb_prompt $" {
|
||||||
|
setup_kfail "c++/11702" "*-*-*"
|
||||||
|
fail $test2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
-re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" {
|
||||||
|
if {[test_compiler_info {gcc-[0-3]-*}]
|
||||||
|
|| [test_compiler_info {gcc-4-[0-4]-*}]} {
|
||||||
|
# Do not permit to XFAIL on recent GCCs.
|
||||||
|
setup_xfail *-*-*
|
||||||
|
}
|
||||||
|
fail $test
|
||||||
|
|
||||||
|
unresolved $test2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Test to see if the appropriate namespaces are in scope when trying
|
# Test to see if the appropriate namespaces are in scope when trying
|
||||||
# to print out stuff from within a function defined within a
|
# to print out stuff from within a function defined within a
|
||||||
# namespace.
|
# namespace.
|
||||||
@ -200,8 +264,8 @@ gdb_test "ptype C::NestedClass" "No symbol \"NestedClass\" in namespace \"C::C\"
|
|||||||
# Tests involving multiple files
|
# Tests involving multiple files
|
||||||
|
|
||||||
gdb_test "print cOtherFile" "\\$\[0-9\].* = 316"
|
gdb_test "print cOtherFile" "\\$\[0-9\].* = 316"
|
||||||
gdb_test "ptype OtherFileClass" "type = (class C::OtherFileClass \{\r\n public:|struct C::OtherFileClass \{)\r\n int z;\r\n\}"
|
gdb_test "ptype OtherFileClass" "type = (class C::OtherFileClass \{\r\n public:|struct C::OtherFileClass \{)\r\n int z;\r\n.*\}"
|
||||||
gdb_test "ptype ::C::OtherFileClass" "type = class C::OtherFileClass \{\r\n public:\r\n int z;\r\n\}"
|
gdb_test "ptype ::C::OtherFileClass" "type = class C::OtherFileClass \{\r\n public:\r\n int z;\r\n.*\}"
|
||||||
gdb_test "ptype C::OtherFileClass" "No symbol \"OtherFileClass\" in namespace \"C::C\"."
|
gdb_test "ptype C::OtherFileClass" "No symbol \"OtherFileClass\" in namespace \"C::C\"."
|
||||||
|
|
||||||
# Some anonymous namespace tests.
|
# Some anonymous namespace tests.
|
||||||
|
@ -21,7 +21,15 @@ namespace C
|
|||||||
class OtherFileClass {
|
class OtherFileClass {
|
||||||
public:
|
public:
|
||||||
int z;
|
int z;
|
||||||
|
|
||||||
|
typedef short cOtherFileClassType;
|
||||||
|
static const cOtherFileClassType cOtherFileClassVar = 318;
|
||||||
|
cOtherFileClassType cOtherFileClassVar_use ();
|
||||||
};
|
};
|
||||||
|
OtherFileClass::cOtherFileClassType OtherFileClass::cOtherFileClassVar_use ()
|
||||||
|
{
|
||||||
|
return cOtherFileClassVar;
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
int cXOtherFile = 29;
|
int cXOtherFile = 29;
|
||||||
@ -35,6 +43,13 @@ namespace C
|
|||||||
static OtherFileClass *c = new OtherFileClass();
|
static OtherFileClass *c = new OtherFileClass();
|
||||||
c->z = cOtherFile + cXOtherFile;
|
c->z = cOtherFile + cXOtherFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef short cOtherFileType;
|
||||||
|
static const cOtherFileType cOtherFileVar = 319;
|
||||||
|
cOtherFileType cOtherFileVar_use ()
|
||||||
|
{
|
||||||
|
return cOtherFileVar;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
12
gdb/valops.c
12
gdb/valops.c
@ -3284,8 +3284,16 @@ value_maybe_namespace_elt (const struct type *curtype,
|
|||||||
struct value *result;
|
struct value *result;
|
||||||
|
|
||||||
sym = cp_lookup_symbol_namespace (namespace_name, name,
|
sym = cp_lookup_symbol_namespace (namespace_name, name,
|
||||||
get_selected_block (0),
|
get_selected_block (0), VAR_DOMAIN);
|
||||||
VAR_DOMAIN);
|
|
||||||
|
if (sym == NULL)
|
||||||
|
{
|
||||||
|
char *concatenated_name = alloca (strlen (namespace_name) + 2
|
||||||
|
+ strlen (name) + 1);
|
||||||
|
|
||||||
|
sprintf (concatenated_name, "%s::%s", namespace_name, name);
|
||||||
|
sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN);
|
||||||
|
}
|
||||||
|
|
||||||
if (sym == NULL)
|
if (sym == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Reference in New Issue
Block a user