aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2008-02-05 22:20:51 +0000
committerJoel Brobecker <brobecker@gnat.com>2008-02-05 22:20:51 +0000
commit439048e8fe50ff5958be88f571d850a3fbfcb17e (patch)
tree9dce22d9c39344ef6e769e19962c3b0e382c6e70 /gdb/testsuite
parent * language.h (struct language_defn): Add new field (diff)
downloadbinutils-gdb-439048e8fe50ff5958be88f571d850a3fbfcb17e.tar.gz
binutils-gdb-439048e8fe50ff5958be88f571d850a3fbfcb17e.tar.bz2
binutils-gdb-439048e8fe50ff5958be88f571d850a3fbfcb17e.zip
* gdb.ada/complete/pck.ads, gdb.ada/complete/pck.adb,
gdb.ada/complete/foo.adb: New files. * gdb.ada/complete.exp: New testcase.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.ada/complete.exp189
-rw-r--r--gdb/testsuite/gdb.ada/complete/foo.adb10
-rw-r--r--gdb/testsuite/gdb.ada/complete/pck.adb9
-rw-r--r--gdb/testsuite/gdb.ada/complete/pck.ads19
5 files changed, 233 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index f29e77cefc5..a12b7ec50f1 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2008-02-05 Joel Brobecker <brobecker@adacore.com>
+
+ * gdb.ada/complete/pck.ads, gdb.ada/complete/pck.adb,
+ gdb.ada/complete/foo.adb: New files.
+ * gdb.ada/complete.exp: New testcase.
+
2008-02-03 Doug Evans <dje@google.com>
* gdb.base/whatis-exp.exp: Fix expected result of whatis x+y, x-y, x*y.
diff --git a/gdb/testsuite/gdb.ada/complete.exp b/gdb/testsuite/gdb.ada/complete.exp
new file mode 100644
index 00000000000..78b1c3080df
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/complete.exp
@@ -0,0 +1,189 @@
+# Copyright 2005, 2007 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 3 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, see <http://www.gnu.org/licenses/>.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+load_lib "ada.exp"
+
+set testdir "complete"
+set testfile "${testdir}/foo"
+set srcfile ${srcdir}/${subdir}/${testfile}.adb
+set binfile ${objdir}/${subdir}/${testfile}
+
+file mkdir ${objdir}/${subdir}/${testdir}
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } {
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+set bp_location [gdb_get_line_number "START" ${testdir}/foo.adb]
+runto "foo.adb:$bp_location"
+
+set eol "\[\r\n\]*"
+
+# A convenience function that verifies that the "complete EXPR" command
+# returns the EXPECTED_OUTPUT.
+
+proc test_gdb_complete { expr expected_output } {
+ gdb_test "complete p $expr" \
+ "$expected_output" \
+ "complete p $expr"
+}
+
+# A convenience function that verifies that the "complete EXPR" command
+# does not genearte any output.
+
+proc test_gdb_no_completion { expr } {
+ # FIXME: brobecker/2007-12-27: How do you verify that the command
+ # output is actually really empty??? For now, the following does
+ # not verify this at all:
+ test_gdb_complete "$expr" ""
+}
+
+# A convenience function that joins all the arguments together,
+# with a regexp that matches zero-or-more end of lines in between
+# each argument. This function is ideal to write the expected output
+# of a GDB command that generates more than a couple of lines, as
+# this allows us to write each line as a separate string, which is
+# easier to read by a human being.
+
+proc multi_line { args } {
+ return [join $args "\[\r\n\]*"]
+}
+# Try a global variable, only one match should be found:
+
+test_gdb_complete "my_glob" \
+ "p my_global_variable"
+
+# A global variable, inside a nested package:
+
+test_gdb_complete "insi" \
+ "p inside_variable"
+
+# A global variable inside a nested package, but only giving part of
+# the fully qualified name (top level package name missing):
+
+test_gdb_no_completion "inner.insi"
+
+# An incomplete nested package name, were lies a single symbol:
+test_gdb_complete "pck.inne" \
+ "p pck.inner.inside_variable"
+
+# A fully qualified symbol name, mangled...
+test_gdb_complete "pck__inner__ins" \
+ "p pck__inner__inside_variable"
+
+# A fully qualified symbol name...
+test_gdb_complete "pck.inner.ins" \
+ "p pck.inner.inside_variable"
+
+# Make sure that "inside" is not returned as a possible completion
+# for "side"...
+test_gdb_no_completion "side"
+
+# Verify that "Exported_Capitalized" is not returned as a match for
+# "exported", since its symbol name contains capital letters.
+test_gdb_no_completion "exported"
+
+# check the "<...>" notation.
+test_gdb_complete "<Exported" \
+ "p <Exported_Capitalized>"
+
+# A global symbol, created by the binder, that starts with __gnat...
+test_gdb_complete "__gnat_ada_main_progra" \
+ "p __gnat_ada_main_program_name"
+
+# A global symbol, created by the binder, that starts with __gnat,
+# and using the '<' notation.
+test_gdb_complete "<__gnat_ada_main_prog" \
+ "p <__gnat_ada_main_program_name>"
+
+# A local variable
+test_gdb_complete "some" \
+ "p some_local_variable"
+
+# A local variable variable, but in a different procedure. No match
+# should be returned.
+test_gdb_no_completion "not_in_sco"
+
+# A fully qualified variable name that doesn't exist...
+test_gdb_no_completion "pck.ins"
+
+# A fully qualified variable name that does exist...
+test_gdb_complete "pck.my" \
+ "p pck.my_global_variable"
+
+# A fully qualified package name
+test_gdb_complete "pck.inne" \
+ "p pck.inner.inside_variable"
+
+# A fully qualified package name, with a dot at the end
+test_gdb_complete "pck.inner." \
+ "p pck.inner.inside_variable"
+
+# Two matches, from the global scope:
+test_gdb_complete "local_ident" \
+ [multi_line "p local_identical_one" \
+ "p local_identical_two" ]
+
+# Two matches, from the global scope, but using fully qualified names:
+test_gdb_complete "pck.local_ident" \
+ [multi_line "p pck.local_identical_one" \
+ "p pck.local_identical_two" ]
+
+# Two matches, from the global scope, but using mangled fully qualified
+# names:
+test_gdb_complete "pck__local_ident" \
+ [multi_line "p pck__local_identical_one" \
+ "p pck__local_identical_two" ]
+
+# Two matches, one from the global scope, the other from the local scope:
+test_gdb_complete "external_ident" \
+ [multi_line "p external_identical_one" \
+ "p external_identical_two" ]
+
+# Complete on the name of package.
+test_gdb_complete "pck" \
+ [multi_line "(p pck\\.ad\[sb\])?" \
+ "(p pck\\.ad\[sb\])?" \
+ "p pck.external_identical_one" \
+ "p pck.inner.inside_variable" \
+ "p pck.local_identical_one" \
+ "p pck.local_identical_two" \
+ "p pck.my_global_variable" \
+ "p pck.proc" ]
+
+# Complete on the name of a package followed by a dot:
+test_gdb_complete "pck." \
+ [multi_line "(p pck\\.ad\[sb\])?" \
+ "(p pck\\.ad\[sb\])?" \
+ "p pck.external_identical_one" \
+ "p pck.inner.inside_variable" \
+ "p pck.local_identical_one" \
+ "p pck.local_identical_two" \
+ "p pck.my_global_variable" \
+ "p pck.proc" ]
+
+# Complete a mangled symbol name, but using the '<...>' notation.
+test_gdb_complete "<pck__my" \
+ "p <pck__my_global_variable>"
+
+
diff --git a/gdb/testsuite/gdb.ada/complete/foo.adb b/gdb/testsuite/gdb.ada/complete/foo.adb
new file mode 100644
index 00000000000..3cf60b65dbc
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/complete/foo.adb
@@ -0,0 +1,10 @@
+with Pck; use Pck;
+
+procedure Foo is
+ Some_Local_Variable : Integer := 1;
+ External_Identical_Two : Integer := 74;
+begin
+ My_Global_Variable := Some_Local_Variable + 1; -- START
+ Proc (External_Identical_Two);
+end Foo;
+
diff --git a/gdb/testsuite/gdb.ada/complete/pck.adb b/gdb/testsuite/gdb.ada/complete/pck.adb
new file mode 100644
index 00000000000..4d7d797f1eb
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/complete/pck.adb
@@ -0,0 +1,9 @@
+package body Pck is
+
+ procedure Proc (I : Integer) is
+ Not_In_Scope : Integer := 77;
+ begin
+ Inner.Inside_Variable := Not_In_Scope + I;
+ end Proc;
+
+end Pck;
diff --git a/gdb/testsuite/gdb.ada/complete/pck.ads b/gdb/testsuite/gdb.ada/complete/pck.ads
new file mode 100644
index 00000000000..d897cbc5204
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/complete/pck.ads
@@ -0,0 +1,19 @@
+package Pck is
+
+ My_Global_Variable : Integer := 1;
+
+ Exported_Capitalized : Integer := 2;
+ pragma Export (C, Exported_Capitalized, "Exported_Capitalized");
+
+ Local_Identical_One : Integer := 4;
+ Local_Identical_Two : Integer := 8;
+
+ External_Identical_One : Integer := 19;
+
+ package Inner is
+ Inside_Variable : Integer := 3;
+ end Inner;
+
+ procedure Proc (I : Integer);
+
+end Pck;