* Makefile.in (c-typeprint.o): Depend on gdb_assert_h.
* c-typeprint.c: #include "gdb_assert.h"
* gdbtypes.c (recursive_dump_type): Handle TYPE_CODE_NAMESPACE.
* c-typeprint.c (c_type_print_varspec_prefix): Ditto.
(c_type_print_varspec_suffix): Ditto.
(c_type_print_base): Ditto.
* typeprint.c (print_type_scalar): Ditto.
* printcmd.c (print_formatted): Ditto.
* language.c (structured_type): Ditto.
* cp-support.c (cp_check_namespace_symbol): Allocate type via
init_type.
* gdbtypes.c (init_type): Handle TYPE_CODE_NAMESPACE.
* valops.c (value_namespace_elt): Handle sym == NULL.
2002-11-24 David Carlton <carlton@bactrian.org>
* gdb.c++/namespace.exp: Eliminate some of the single quotes, and
duplicate some of the single quote tests without the quotes.
Change "print E::ce" test.
Add some ptype <namespace> tests.
* carlton_runnamespace: Use different files for compiler with and
without debug info.
+2002-11-24 David Carlton <carlton@bactrian.org>
+
+ * Makefile.in (c-typeprint.o): Depend on gdb_assert_h.
+ * c-typeprint.c: #include "gdb_assert.h"
+ * gdbtypes.c (recursive_dump_type): Handle TYPE_CODE_NAMESPACE.
+ * c-typeprint.c (c_type_print_varspec_prefix): Ditto.
+ (c_type_print_varspec_suffix): Ditto.
+ (c_type_print_base): Ditto.
+ * typeprint.c (print_type_scalar): Ditto.
+ * printcmd.c (print_formatted): Ditto.
+ * language.c (structured_type): Ditto.
+ * cp-support.c (cp_check_namespace_symbol): Allocate type via
+ init_type.
+ * gdbtypes.c (init_type): Handle TYPE_CODE_NAMESPACE.
+ * valops.c (value_namespace_elt): Handle sym == NULL.
+
2002-11-22 David Carlton <carlton@math.stanford.edu>
* linespec.c (examine_compound_token): Rewrite as switch
c-typeprint.o: c-typeprint.c $(defs_h) $(gdb_obstack_h) $(bfd_h) $(symtab_h) \
$(gdbtypes_h) $(expression_h) $(value_h) $(gdbcore_h) $(target_h) \
$(language_h) $(demangle_h) $(c_lang_h) $(typeprint_h) $(cp_abi_h) \
- $(gdb_string_h)
+ $(gdb_string_h) $(gdb_assert_h)
c-valprint.o: c-valprint.c $(defs_h) $(gdb_string_h) $(symtab_h) \
$(gdbtypes_h) $(expression_h) $(value_h) $(valprint_h) $(language_h) \
$(c_lang_h) $(cp_abi_h)
#include "gdb_string.h"
#include <errno.h>
+#include "gdb_assert.h"
/* Flag indicating target was compiled by HP compiler */
extern int hp_som_som_object_present;
case TYPE_CODE_COMPLEX:
case TYPE_CODE_TYPEDEF:
case TYPE_CODE_TEMPLATE:
+ case TYPE_CODE_NAMESPACE:
/* These types need no prefix. They are listed here so that
gcc -Wall will reveal any types that haven't been handled. */
break;
case TYPE_CODE_COMPLEX:
case TYPE_CODE_TYPEDEF:
case TYPE_CODE_TEMPLATE:
+ case TYPE_CODE_NAMESPACE:
/* These types do not need a suffix. They are listed so that
gcc -Wall will report types that may not have been considered. */
break;
}
break;
+ case TYPE_CODE_NAMESPACE:
+ gdb_assert (TYPE_NAME (type) != NULL);
+ fputs_filtered ("namespace ", stream);
+ fputs_filtered (TYPE_NAME (type), stream);
+ break;
+
default:
/* Handle types not explicitly handled by the other cases,
such as fundamental types. For these, just print whatever
if (sym == NULL)
{
- struct type *type = alloc_type (objfile);
- INIT_CPLUS_SPECIFIC (type);
- TYPE_TAG_NAME (type) = obsavestring (name, len, &objfile->type_obstack);
- TYPE_NAME (type) = TYPE_TAG_NAME (type);
- TYPE_CODE (type) = TYPE_CODE_NAMESPACE;
- TYPE_LENGTH (type) = 0;
-
+ struct type *type = init_type (TYPE_CODE_NAMESPACE, 0, 0,
+ name_copy, objfile);
+ TYPE_TAG_NAME (type) = TYPE_NAME (type);
+
sym = obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
memset (sym, 0, sizeof (struct symbol));
SYMBOL_LANGUAGE (sym) = language_cplus;
/* C++ fancies. */
- if (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
+ if (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
+ || code == TYPE_CODE_NAMESPACE)
{
INIT_CPLUS_SPECIFIC (type);
}
case TYPE_CODE_TEMPLATE_ARG:
printf_filtered ("(TYPE_CODE_TEMPLATE_ARG)");
break;
+ case TYPE_CODE_NAMESPACE:
+ printf_filtered ("(TYPE_CODE_NAMESPACE)");
+ break;
default:
printf_filtered ("(UNKNOWN TYPE CODE)");
break;
case language_c:
case language_cplus:
case language_objc:
- return (TYPE_CODE (type) == TYPE_CODE_STRUCT) ||
- (TYPE_CODE (type) == TYPE_CODE_UNION) ||
- (TYPE_CODE (type) == TYPE_CODE_ARRAY);
+ return (TYPE_CODE (type) == TYPE_CODE_STRUCT)
+ || (TYPE_CODE (type) == TYPE_CODE_UNION)
+ || (TYPE_CODE (type) == TYPE_CODE_ARRAY)
+ || (TYPE_CODE (type) == TYPE_CODE_NAMESPACE);
case language_pascal:
return (TYPE_CODE(type) == TYPE_CODE_STRUCT) ||
(TYPE_CODE(type) == TYPE_CODE_UNION) ||
|| TYPE_CODE (type) == TYPE_CODE_ARRAY
|| TYPE_CODE (type) == TYPE_CODE_STRING
|| TYPE_CODE (type) == TYPE_CODE_STRUCT
- || TYPE_CODE (type) == TYPE_CODE_UNION)
+ || TYPE_CODE (type) == TYPE_CODE_UNION
+ || TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
/* If format is 0, use the 'natural' format for
* that type of value. If the type is non-scalar,
* we have to use language rules to print it as
+2002-11-24 David Carlton <carlton@bactrian.org>
+
+ * gdb.c++/namespace.exp: Eliminate some of the single quotes, and
+ duplicate some of the single quote tests without the quotes.
+ Change "print E::ce" test.
+ Add some ptype <namespace> tests.
+ * carlton_runnamespace: Use different files for compiler with and
+ without debug info.
+
2002-11-22 David Carlton <carlton@math.stanford.edu>
* gdb.c++/namespace.exp: Change a couple of tests to not use
# info. Maybe eventually I should run this on one which generates
# stabs info, too?
-EXTRACOMPPATH=/usr/local/testbed/gcc3/bin
+EXTRADEBUGPATH=/usr/local/testbed/gcc3/bin
echo "Running tests using regular compiler."
-runtest namespace.exp 2>&1 | grep -v "^Test Run By" > /tmp/namespaceout
+runtest gdb.c++/namespace.exp 2>&1 | grep -v "^Test Run By" > /tmp/namespaceout
diff -u {carlton_,/tmp/}namespaceout
echo "Running tests using compiler with extra debug info."
-PATH=${EXTRACOMPPATH}:${PATH} runtest namespace.exp 2>&1 | grep -v "^Test Run By" > /tmp/namespaceout
-diff -u {carlton_,/tmp/}namespaceout
+PATH=${EXTRADEBUGPATH}:${PATH} runtest gdb.c++/namespace.exp 2>&1 | grep -v "^Test Run By" > /tmp/namespacedebugout
+diff -u {carlton_,/tmp/}namespacedebugout
echo "Done."
# Access a data item inside a namespace using colons and
# single quotes. :-(
-# NOTE: carlton/2002-11-22: the colons are becoming less necessary.
+# NOTE: carlton/2002-11-24: the colons are becoming less necessary (or
+# even desirable.) For tests where it should still work with colons,
+# I'm including versions both with and without colons; for tests that
+# shouldn't work with colons, I'm only including one version.
send_gdb "print 'AAA::c'\n"
gdb_expect {
# Call a function in a namespace
+send_gdb "print 'AAA::xyzq'('x')\n"
+gdb_expect {
+ -re "\\$\[0-9\]* = 97 'a'\r\n$gdb_prompt $" {
+ pass "print 'AAA::xyzq'('x')"
+ }
+ -re ".*$gdb_prompt $" { fail "print 'AAA::xyzq'('x')" }
+ timeout { fail "(timeout) print 'AAA::xyzq'('x')" }
+}
+
send_gdb "print AAA::xyzq('x')\n"
gdb_expect {
-re "\\$\[0-9\]* = 97 'a'\r\n$gdb_prompt $" {
timeout { fail "(timeout) print 'BBB::CCC::xyzq'('x')" }
}
+send_gdb "print BBB::CCC::xyzq('x')\n"
+gdb_expect {
+ -re "\\$\[0-9\]* = 122 'z'\r\n$gdb_prompt $" {
+ pass "print 'BBB::CCC::xyzq'('x')"
+ }
+ -re ".*$gdb_prompt $" { fail "print BBB::CCC::xyzq('x')" }
+ timeout { fail "(timeout) print BBB::CCC::xyzq('x')" }
+}
+
# Break on a function in a nested namespace
send_gdb "break BBB::CCC::xyzq\n"
timeout { fail "(timeout) print 'BBB::Class::xyzq'" }
}
+send_gdb "print BBB::Class::xyzq\n"
+gdb_expect {
+ -re "\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex <BBB::Class::xyzq\\(char\\)>\r\n$gdb_prompt $" {
+ pass "print BBB::Class::xyzq"
+ }
+ -re ".*$gdb_prompt $" { fail "print BBB::Class::xyzq" }
+ timeout { fail "(timeout) print BBB::Class::xyzq" }
+}
+
# Break on a function in a class in a namespace
send_gdb "break BBB::Class::xyzq\n"
# to print out stuff from within a function defined within a
# namespace.
-if ![runto "'C::D::marker2'"] then {
+if ![runto "C::D::marker2"] then {
perror "couldn't run to marker2"
continue
}
gdb_test "print c" "\\$\[0-9\].* = 1" "print c"
gdb_test "print cc" "No symbol \"cc\" in current context." "print cc"
-gdb_test "print 'C::cc'" "\\$\[0-9\].* = 2" "print C::cc"
+gdb_test "print 'C::cc'" "\\$\[0-9\].* = 2" "print 'C::cc'"
+gdb_test "print C::cc" "\\$\[0-9\].* = 2" "print C::cc"
gdb_test "print cd" "\\$\[0-9\].* = 3" "print cd"
-gdb_test "print 'C::D::cd'" "\\$\[0-9\].* = 3" "print C::D::cd"
-gdb_test "print 'E::cde'" "\\$\[0-9\].* = 5" "print E::cde"
+gdb_test "print 'C::D::cd'" "\\$\[0-9\].* = 3" "print 'C::D::cd'"
+gdb_test "print C::D::cd" "\\$\[0-9\].* = 3" "print C::D::cd"
+gdb_test "print 'E::cde'" "\\$\[0-9\].* = 5" "print 'E::cde'"
+gdb_test "print E::cde" "\\$\[0-9\].* = 5" "print E::cde"
gdb_test "print shadow" "\\$\[0-9\].* = 13" "print shadow"
-
-# NOTE: carlton/2002-10-17: This one won't get fixed until namespaces
-# are first-class objects. The PR isn't right, either.
-
-setup_kfail "gdb/827"
-gdb_test "print 'E::ce'" "No symbol \"E::ce\" in current context." "print E::ce"
+gdb_test "print E::ce" "No symbol \"ce\" in namespace \"C::D::E\"." "print E::ce"
+gdb_test "ptype C" "type = namespace C::C" "ptype C::C"
+gdb_test "ptype E" "type = namespace C::D::E" "ptype C::D::E"
# Some anonymous namespace tests.
gdb_test "print cX" "\\$\[0-9\].* = 6" "print cX"
-gdb_test "print 'F::cXf'" "\\$\[0-9\].* = 7" "print F::cXf"
-gdb_test "print 'F::cXfX'" "\\$\[0-9\].* = 8" "print F::cXfX"
+gdb_test "print 'F::cXf'" "\\$\[0-9\].* = 7" "print 'F::cXf'"
+gdb_test "print F::cXf" "\\$\[0-9\].* = 7" "print F::cXf"
+gdb_test "print 'F::cXfX'" "\\$\[0-9\].* = 8" "print 'F::cXfX'"
+gdb_test "print F::cXfX" "\\$\[0-9\].* = 8" "print F::cXfX"
gdb_test "print X" "\\$\[0-9\].* = 9" "print X"
-gdb_test "print 'G::Xg'" "\\$\[0-9\].* = 10" "print G::Xg"
-gdb_test "print 'G::XgX'" "\\$\[0-9\].* = 11" "print G::XgX"
+gdb_test "print 'G::Xg'" "\\$\[0-9\].* = 10" "print 'G::Xg'"
+gdb_test "print G::Xg" "\\$\[0-9\].* = 10" "print G::Xg"
+gdb_test "print 'G::XgX'" "\\$\[0-9\].* = 11" "print 'G::XgX'"
+gdb_test "print G::XgX" "\\$\[0-9\].* = 11" "print G::XgX"
# Test namespace renaming.
setup_kfail "gdb/830"
-gdb_test "print 'I::h'" "\\$\[0-9\].* = 14" "print I::h"
+gdb_test "print I::h" "\\$\[0-9\].* = 14" "print I::h"
# Test using directives.
setup_kfail "gdb/829"
gdb_test "print j" "\\$\[0-9\].* = 15" "print j"
setup_kfail "gdb/829"
-gdb_test "print 'L::k'" "\\$\[0-9\].* = 16" "print L::k"
+gdb_test "print L::k" "\\$\[0-9\].* = 16" "print L::k"
setup_kfail "gdb/829"
gdb_test "print k" "No symbol \"k\" in current context." "print k"
setup_kfail "gdb/829"
gdb_test "print cdm" "\\$\[0-9\].* = 17" "print cdm"
setup_kfail "gdb/829"
-gdb_test "print 'Q::o'" "\\$\[0-9\].* = 18" "print Q::o"
+gdb_test "print Q::o" "\\$\[0-9\].* = 18" "print Q::o"
setup_kfail "gdb/829"
gdb_test "print o" "No symbol \"o\" in current context." "print o"
case TYPE_CODE_MEMBER:
case TYPE_CODE_METHOD:
case TYPE_CODE_REF:
+ case TYPE_CODE_NAMESPACE:
error ("internal error: unhandled type in print_type_scalar");
break;
cp_free_usings (usings);
+ /* FIXME: carlton/2002-11-24: Should this really be here, or should
+ it be in c-exp.y like the other similar messages? Hmm... */
+
+ if (sym == NULL)
+ error ("No symbol \"%s\" in namespace \"%s\".", name, namespace_name);
+
return value_of_variable (sym, block);
}