]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2003-05-09 David Carlton <carlton@bactrian.org>
authorDavid Carlton <carlton@bactrian.org>
Fri, 9 May 2003 18:28:53 +0000 (18:28 +0000)
committerDavid Carlton <carlton@bactrian.org>
Fri, 9 May 2003 18:28:53 +0000 (18:28 +0000)
* linespec.c (examine_compound_token): Handled classes nested
within classes, not just classes nested within namespaces.

2003-05-09  David Carlton  <carlton@bactrian.org>

* gdb.c++/breakpoint.cc: New.
* gdb.c++/breakpoint.exp: New.
* gdb.c++/namespace.exp: Update "print C::D::cd" for current
output.

gdb/ChangeLog
gdb/linespec.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.c++/breakpoint.cc [new file with mode: 0644]
gdb/testsuite/gdb.c++/breakpoint.exp [new file with mode: 0644]
gdb/testsuite/gdb.c++/namespace.exp

index c06000fef3dca6958db68b500cbc5c44ceb647b5..b1602015bfe00ae85b94ba3120941ea83c1fc56a 100644 (file)
@@ -1,3 +1,8 @@
+2003-05-09  David Carlton  <carlton@bactrian.org>
+
+       * linespec.c (examine_compound_token): Handled classes nested
+       within classes, not just classes nested within namespaces.
+
 2003-05-07  David Carlton  <carlton@bactrian.org>
 
        * valops.c (value_aggregate_elt): Add 'noside' argument.
index 1f0d65fbe7a66f79b40cd95aa8bfc868a127085b..230df36c1f354565f448594d8fe0c544c930d8fb 100644 (file)
@@ -801,6 +801,7 @@ examine_compound_token (char **argptr, int funfirstline,
                        char *saved_arg, char *current_component,
                        struct symtabs_and_lines *values)
 {
+  /* The namespace or class that we're nested within.  */
   const char *namespace = "";
 
   while (1)
@@ -817,57 +818,56 @@ examine_compound_token (char **argptr, int funfirstline,
 
       if (class_sym == NULL)
        return 0;
-
       t = check_typedef (SYMBOL_TYPE (class_sym));
 
-      switch (TYPE_CODE (t))
+      current_component = find_next_token (argptr);
+      if (*current_component == ':')
+       {
+         /* We're still in the process of reading types: we haven't
+            found the method at the bottom yet.  */
+         namespace = TYPE_TAG_NAME (t);
+       }
+      else
        {
-       case TYPE_CODE_STRUCT:
-       case TYPE_CODE_UNION:
-         /* Find the next token (everything up to end or next blank).  */
-
-         current_component = find_next_token (argptr);
-         copy = alloca (current_component - *argptr + 1);
-         memcpy (copy, *argptr, current_component - *argptr);
-         copy[current_component - *argptr] = '\0';
-         if (current_component != *argptr
-             && copy[current_component - *argptr - 1]
-             && (strchr (get_gdb_completer_quote_characters (),
-                         copy[current_component - *argptr - 1])
-                 != NULL))
-           copy[current_component - *argptr - 1] = '\0';
+         switch (TYPE_CODE (t))
+           {
+           case TYPE_CODE_STRUCT:
+           case TYPE_CODE_UNION:
+             /* Find the next token (everything up to end or next blank).  */
+
+             copy = alloca (current_component - *argptr + 1);
+             memcpy (copy, *argptr, current_component - *argptr);
+             copy[current_component - *argptr] = '\0';
+             if (current_component != *argptr
+                 && copy[current_component - *argptr - 1]
+                 && (strchr (get_gdb_completer_quote_characters (),
+                             copy[current_component - *argptr - 1])
+                     != NULL))
+               copy[current_component - *argptr - 1] = '\0';
              
-         while (*current_component == ' ' || *current_component == '\t')
-           current_component++;
-         *argptr = current_component;
+             while (*current_component == ' ' || *current_component == '\t')
+               current_component++;
+             *argptr = current_component;
 
-         *values = find_method (funfirstline, canonical, saved_arg, copy,
-                                t, class_sym);
+             *values = find_method (funfirstline, canonical, saved_arg, copy,
+                                    t, class_sym);
       
-         return 1;
-       case TYPE_CODE_NAMESPACE:
-         {
-           char *next_component = find_next_token (argptr);
-           namespace = TYPE_TAG_NAME (t);
-           if (*next_component == ':')
-             {
-               current_component = next_component;
-               break;
-             }
-           else
+             return 1;
+           case TYPE_CODE_NAMESPACE:
              {
                return decode_namespace (argptr, funfirstline,
                                         canonical,
-                                        next_component, namespace,
+                                        current_component,
+                                        TYPE_TAG_NAME (t),
                                         values);
              }
-         }
-       default:
-         /* FIXME: carlton/2002-11-19: Once this all settles down, this
-            case should be an error rather than a return 0; that will
-            allow us to make VALUES the return value rather than an
-            argument.  */
-         return 0;
+           default:
+             /* FIXME: carlton/2002-11-19: Once this all settles
+                down, this case should be an error rather than a
+                return 0; that will allow us to make VALUES the
+                return value rather than an argument.  */
+             return 0;
+           }
        }
     }
 }
index 376952c0a38eb95373272fdff113544e4a55c51a..df5c7f76ed781d5f63c378029ffdf2cbd6716b47 100644 (file)
@@ -1,3 +1,10 @@
+2003-05-09  David Carlton  <carlton@bactrian.org>
+
+       * gdb.c++/breakpoint.cc: New.
+       * gdb.c++/breakpoint.exp: New.
+       * gdb.c++/namespace.exp: Update "print C::D::cd" for current
+       output.
+
 2003-05-07  David Carlton  <carlton@bactrian.org>
 
        * gdb.c++/namespace.exp: Update messages to match new parser
diff --git a/gdb/testsuite/gdb.c++/breakpoint.cc b/gdb/testsuite/gdb.c++/breakpoint.cc
new file mode 100644 (file)
index 0000000..89afea6
--- /dev/null
@@ -0,0 +1,44 @@
+/* Code to go along with tests in breakpoint.exp.
+   
+   Copyright 2003 Free Software Foundation, Inc.
+
+   Contributed by David Carlton <carlton@bactrian.org> and by Kealia,
+   Inc.
+
+   This file is part of GDB.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+class C1 {
+public:
+  class Nested {
+  public:
+    int
+    foo ()
+    {
+      return 1;
+    }
+  };
+};
+
+int main ()
+{
+  C1::Nested c1;
+
+  c1.foo();
+
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.c++/breakpoint.exp b/gdb/testsuite/gdb.c++/breakpoint.exp
new file mode 100644 (file)
index 0000000..3a132b0
--- /dev/null
@@ -0,0 +1,68 @@
+# Copyright 2003 Free Software Foundation, Inc.
+
+# 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# This file is part of the gdb testsuite.
+
+# This contains tests for breakpoints in C++.
+
+# NOTE: carlton/2003-05-09: It's not at all comprehensive right now,
+# and lots of the other files test breakpoints as well.  But I wanted
+# to add a test covering a bug I found in linespec.c:decode_compound,
+# and putting it in a separate file seemed natural.
+
+if $tracelevel then {
+        strace $tracelevel
+        }
+
+if { [skip_cplus_tests] } { continue }
+
+#
+# test running programs
+#
+set prms_id 0
+set bug_id 0
+
+set testfile "breakpoint"
+set srcfile ${testfile}.cc
+set binfile ${objdir}/${subdir}/${testfile}
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
+     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+if [get_compiler_info ${binfile} "c++"] {
+    return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+proc test_breakpoint {name} {
+    gdb_breakpoint "${name}"
+    gdb_test "continue" "Continuing.\r\n\r\nBreakpoint \[0-9\]*, ${name}.*" "continue to ${name}"
+}
+
+if ![runto_main] then {
+    perror "couldn't run to breakpoint"
+    continue
+}
+
+test_breakpoint "C1::Nested::foo"
+
+gdb_exit
+return 0
index b0ef10414b851a7867d20f09744a15ee3905302d..9d739cba4df4cfc149242030109b511d1693dee9 100644 (file)
@@ -240,7 +240,7 @@ gdb_test "print cc" "No symbol \"cc\" in current context."
 gdb_test "print 'C::cc'" "\\$\[0-9\].* = 2"
 gdb_test "print C::cc" "\\$\[0-9\].* = 2"
 gdb_test "print cd" "\\$\[0-9\].* = 3"
-gdb_test "print C::D::cd" "No type \"D\" within context \"C::C\"."
+gdb_test "print C::D::cd" "No type \"D\" within class or namespace \"C::C\"."
 gdb_test "print 'E::cde'" "\\$\[0-9\].* = 5"
 gdb_test "print E::cde" "\\$\[0-9\].* = 5"
 gdb_test "print shadow" "\\$\[0-9\].* = 13"