aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/linespec.c80
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.c++/breakpoint.cc44
-rw-r--r--gdb/testsuite/gdb.c++/breakpoint.exp68
-rw-r--r--gdb/testsuite/gdb.c++/namespace.exp2
6 files changed, 165 insertions, 41 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c06000f..b160201 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 1f0d65f..230df36 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -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;
+ }
}
}
}
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 376952c..df5c7f7 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -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
index 0000000..89afea6
--- /dev/null
+++ b/gdb/testsuite/gdb.c++/breakpoint.cc
@@ -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
index 0000000..3a132b0
--- /dev/null
+++ b/gdb/testsuite/gdb.c++/breakpoint.exp
@@ -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
diff --git a/gdb/testsuite/gdb.c++/namespace.exp b/gdb/testsuite/gdb.c++/namespace.exp
index b0ef104..9d739cb 100644
--- a/gdb/testsuite/gdb.c++/namespace.exp
+++ b/gdb/testsuite/gdb.c++/namespace.exp
@@ -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"