]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2002-11-24 David Carlton <carlton@bactrian.org>
authorDavid Carlton <carlton@bactrian.org>
Sun, 24 Nov 2002 18:47:19 +0000 (18:47 +0000)
committerDavid Carlton <carlton@bactrian.org>
Sun, 24 Nov 2002 18:47:19 +0000 (18:47 +0000)
* 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.

12 files changed:
gdb/ChangeLog
gdb/Makefile.in
gdb/c-typeprint.c
gdb/cp-support.c
gdb/gdbtypes.c
gdb/language.c
gdb/printcmd.c
gdb/testsuite/ChangeLog
gdb/testsuite/carlton_runnamespace
gdb/testsuite/gdb.c++/namespace.exp
gdb/typeprint.c
gdb/valops.c

index a942ce4ba2bbf45a0138a872bfa7d9286f609759..26ea576e5ea8ad582ab5e5787139f9056ada00b0 100644 (file)
@@ -1,3 +1,19 @@
+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
index 3d3428476a07b4292e0d7d392bcf32e3f0b5d0a5..3c79b81a55cf904eb9927ac5fcc44a5e0e897873 100644 (file)
@@ -1566,7 +1566,7 @@ c-lang.o: c-lang.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
 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)
index 6c5e815e2af2446df95e357b47812b97bfd9561b..e29973866603b63dbed20f92d5aa8d36584e221c 100644 (file)
@@ -37,6 +37,7 @@
 
 #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;
@@ -281,6 +282,7 @@ c_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
     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;
@@ -613,6 +615,7 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
     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;
@@ -1171,6 +1174,12 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
        }
       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
index f5dfedb24ec326ea3062afa2a7c887596868b7ca..43ed49c3d3ff392cf1256af8c50e157aa4b30722 100644 (file)
@@ -463,13 +463,10 @@ cp_check_namespace_symbol (const char *name, int len)
 
   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;
index c9cae4cda8dea919329cee7c2e65fd33736f97b2..1df5c21c9e26a3c7228a58006980dd009a6f4d9b 100644 (file)
@@ -1879,7 +1879,8 @@ init_type (enum type_code code, int length, int flags, char *name,
 
   /* 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);
     }
@@ -3104,6 +3105,9 @@ recursive_dump_type (struct type *type, int spaces)
     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;
index 8eee8f6d4a56ca7429d48fe73e432aab8ca83feb..3941920108036ab9fe93fe17396df700e2d1ff5e 100644 (file)
@@ -910,9 +910,10 @@ structured_type (struct type *type)
     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) ||
index 71ad8a166c20b99256c4734f789c8be37618fa07..b4753d000f75589bf9c75925e0cc15a6d732d059 100644 (file)
@@ -321,7 +321,8 @@ print_formatted (struct value *val, register int format, int size,
          || 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
index 3fd752f204135e4cad1da31b70c600d2ff893a70..20ea0920900a086e1c78e110279e921ac2a3c60f 100644 (file)
@@ -1,3 +1,12 @@
+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
index 37a836422f37b1ad6217e7384966bfbda7eb7e50..4ec2202d4702d5b4069cdedc87cc973e62234c07 100755 (executable)
@@ -5,13 +5,13 @@
 # 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."
index ce1e088dd8041cf7cfa0a99056a90884920c6cd0..354668c5df8ae1c6dbae05b443ce083e23ecd99e 100644 (file)
@@ -78,7 +78,10 @@ gdb_test "up" ".*main.*" "up from marker1"
 # 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 {
@@ -131,6 +134,15 @@ 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 $" {
@@ -162,6 +174,15 @@ gdb_expect {
    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"
@@ -184,6 +205,15 @@ gdb_expect {
    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"
@@ -199,38 +229,42 @@ gdb_expect {
 # 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.
 
@@ -241,13 +275,13 @@ gdb_test "print 'I::h'" "\\$\[0-9\].* = 14" "print I::h"
 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"
 
index c4262d99016f81ee5d5dd33350df732de6ce0f95..787737cfe95fa3c62d5c30bf8ab2217faf696a5b 100644 (file)
@@ -317,6 +317,7 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream)
     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;
 
index ce5faed3d59b0d5cc1e68baf8348629038deeda1..bddb999529fff2061e07a121eb26a80a04c92935 100644 (file)
@@ -3284,6 +3284,12 @@ value_namespace_elt (const struct type *curtype,
 
   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);
 }