summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2012-03-02 20:36:39 +0000
committerJoel Brobecker <brobecker@gnat.com>2012-03-02 20:36:39 +0000
commit90ae5369ee6e0b9f4119b410bdfcc42cb7a7175f (patch)
treee5ec170a52e81e34a1272282b73efb18e04cbfe5 /gdb/testsuite/gdb.ada
parent901ce86e6b0a621625bdf3ce0964a7993aff6968 (diff)
downloadgdb-90ae5369ee6e0b9f4119b410bdfcc42cb7a7175f.tar.gz
New Ada testcase for breakpoints on operators.
gdb/testsuite/ChangeLog: * gdb.ada/operator_bp: New testcase.
Diffstat (limited to 'gdb/testsuite/gdb.ada')
-rw-r--r--gdb/testsuite/gdb.ada/operator_bp.exp88
-rw-r--r--gdb/testsuite/gdb.ada/operator_bp/ops.adb140
-rw-r--r--gdb/testsuite/gdb.ada/operator_bp/ops.ads52
-rw-r--r--gdb/testsuite/gdb.ada/operator_bp/ops_test.adb40
4 files changed, 320 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/operator_bp.exp b/gdb/testsuite/gdb.ada/operator_bp.exp
new file mode 100644
index 00000000000..2be7e0a9350
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/operator_bp.exp
@@ -0,0 +1,88 @@
+# Copyright 2012 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/>.
+
+load_lib "ada.exp"
+
+if { [skip_ada_tests] } { return -1 }
+
+set testdir "operator_bp"
+set testfile "${testdir}/ops_test"
+set srcfile ${srcdir}/${subdir}/${testfile}.adb
+set binfile ${objdir}/${subdir}/${testfile}
+
+file mkdir ${objdir}/${subdir}/${testdir}
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "BEGIN" ${testdir}/ops_test.adb]
+runto "ops_test.adb:$bp_location"
+
+# Set breakpoints for all operators, using just the operator name in quotes.
+
+foreach op { "+" "-" } {
+ set op_re [string_to_regexp $op]
+ gdb_test "break \"$op\"" \
+ "Breakpoint $decimal at $hex: \"$op_re\"\. \\(2 locations\\)"
+}
+
+foreach op { "*" "/" "mod" "rem" "**" "<" "<=" ">" ">=" "=" "and" "or" "xor" "&" "abs" "not"} {
+ set op_re [string_to_regexp $op]
+ gdb_test "break \"$op\"" \
+ "Breakpoint $decimal at $hex: file .*ops.adb, line $decimal."
+}
+
+# Make sure we stop correctly in each operator function.
+
+foreach op { "+" "-" "*" "/" "mod" "rem" "**" "<" "<=" ">" ">=" "=" "and" "or" "xor" "&" "abs" "not"} {
+ set op_re [string_to_regexp $op]
+ gdb_test "continue" \
+ "Breakpoint $decimal, ops\\.\"$op_re\" .*"\
+ "continue to \"$op\""
+}
+
+# Perform the same test, but using the qualified name of the operator,
+# instead of the just the operator name (as in 'break ops."+"').
+
+clean_restart ${testfile}
+
+runto "ops_test.adb:$bp_location"
+
+# Set breakpoints for all operators, using just the operator name in quotes.
+
+foreach op { "+" "-" } {
+ set op_re [string_to_regexp $op]
+ gdb_test "break ops.\"$op\"" \
+ "Breakpoint $decimal at $hex: ops\\.\"$op_re\"\. \\(2 locations\\)"
+}
+
+foreach op { "*" "/" "mod" "rem" "**" "<" "<=" ">" ">=" "=" "and" "or" "xor" "&" "abs" "not"} {
+ set op_re [string_to_regexp $op]
+ gdb_test "break ops.\"$op\"" \
+ "Breakpoint $decimal at $hex: file .*ops.adb, line $decimal."
+}
+
+# Make sure we stop correctly in each operator function.
+
+foreach op { "+" "-" "*" "/" "mod" "rem" "**" "<" "<=" ">" ">=" "=" "and" "or" "xor" "&" "abs" "not"} {
+ set op_re [string_to_regexp $op]
+ gdb_test "continue" \
+ "Breakpoint $decimal, ops\\.\"$op_re\" .*"\
+ "continue to ops.\"$op\""
+}
+
+
diff --git a/gdb/testsuite/gdb.ada/operator_bp/ops.adb b/gdb/testsuite/gdb.ada/operator_bp/ops.adb
new file mode 100644
index 00000000000..e7d94dc7f9b
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/operator_bp/ops.adb
@@ -0,0 +1,140 @@
+-- Copyright 2012 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/>.
+
+package body Ops is
+
+ function Make (X: Natural) return Int is
+ begin
+ return Int (X);
+ end Make;
+
+ function "+" (I1, I2 : Int) return Int is
+ begin
+ return Int (IntRep (I1) + IntRep (I2));
+ end;
+
+ function "-" (I1, I2 : Int) return Int is
+ begin
+ return Int (IntRep (I1) - IntRep (I2));
+ end;
+
+ function "*" (I1, I2 : Int) return Int is
+ begin
+ return Int (IntRep (I1) * IntRep (I2));
+ end;
+
+ function "/" (I1, I2 : Int) return Int is
+ begin
+ return Int (IntRep (I1) / IntRep (I2));
+ end;
+
+ function "mod" (I1, I2 : Int) return Int is
+ begin
+ return Int (IntRep (I1) mod IntRep (I2));
+ end;
+
+ function "rem" (I1, I2 : Int) return Int is
+ begin
+ return Int (IntRep (I1) rem IntRep (I2));
+ end;
+
+ function "**" (I1, I2 : Int) return Int is
+ Result : IntRep := 1;
+ begin
+ for J in 1 .. IntRep (I2) loop
+ Result := IntRep (I1) * Result;
+ end loop;
+ return Int (Result);
+ end;
+
+ function "<" (I1, I2 : Int) return Boolean is
+ begin
+ return IntRep (I1) < IntRep (I2);
+ end;
+
+ function "<=" (I1, I2 : Int) return Boolean is
+ begin
+ return IntRep (I1) <= IntRep (I2);
+ end;
+
+ function ">" (I1, I2 : Int) return Boolean is
+ begin
+ return IntRep (I1) > IntRep (I2);
+ end;
+
+ function ">=" (I1, I2 : Int) return Boolean is
+ begin
+ return IntRep (I1) >= IntRep (I2);
+ end;
+
+ function "=" (I1, I2 : Int) return Boolean is
+ begin
+ return IntRep (I1) = IntRep (I2);
+ end;
+
+ function "and" (I1, I2 : Int) return Int is
+ begin
+ return Int (IntRep (I1) and IntRep (I2));
+ end;
+
+ function "or" (I1, I2 : Int) return Int is
+ begin
+ return Int (IntRep (I1) or IntRep (I2));
+ end;
+
+ function "xor" (I1, I2 : Int) return Int is
+ begin
+ return Int (IntRep (I1) xor IntRep (I2));
+ end;
+
+ function "&" (I1, I2 : Int) return Int is
+ begin
+ return Int (IntRep (I1) and IntRep (I2));
+ end;
+
+ function "abs" (I1 : Int) return Int is
+ begin
+ return Int (abs IntRep (I1));
+ end;
+
+ function "not" (I1 : Int) return Int is
+ begin
+ return Int (not IntRep (I1));
+ end;
+
+ function "+" (I1 : Int) return Int is
+ begin
+ return Int (IntRep (I1));
+ end;
+
+ function "-" (I1 : Int) return Int is
+ begin
+ return Int (-IntRep (I1));
+ end;
+
+ procedure Dummy (I1 : Int) is
+ begin
+ null;
+ end Dummy;
+
+ procedure Dummy (B1 : Boolean) is
+ begin
+ null;
+ end Dummy;
+
+end Ops;
+
+
+
diff --git a/gdb/testsuite/gdb.ada/operator_bp/ops.ads b/gdb/testsuite/gdb.ada/operator_bp/ops.ads
new file mode 100644
index 00000000000..8724cb33cf6
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/operator_bp/ops.ads
@@ -0,0 +1,52 @@
+-- Copyright 2012 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/>.
+
+package Ops is
+ type Int is private;
+
+ function Make (X: Natural) return Int;
+
+ function "+" (I1, I2 : Int) return Int;
+ function "-" (I1, I2 : Int) return Int;
+ function "*" (I1, I2 : Int) return Int;
+ function "/" (I1, I2 : Int) return Int;
+ function "mod" (I1, I2 : Int) return Int;
+ function "rem" (I1, I2 : Int) return Int;
+ function "**" (I1, I2 : Int) return Int;
+ function "<" (I1, I2 : Int) return Boolean;
+ function "<=" (I1, I2 : Int) return Boolean;
+ function ">" (I1, I2 : Int) return Boolean;
+ function ">=" (I1, I2 : Int) return Boolean;
+ function "=" (I1, I2 : Int) return Boolean;
+ function "and" (I1, I2 : Int) return Int;
+ function "or" (I1, I2 : Int) return Int;
+ function "xor" (I1, I2 : Int) return Int;
+ function "&" (I1, I2 : Int) return Int;
+ function "abs" (I1 : Int) return Int;
+ function "not" (I1 : Int) return Int;
+ function "+" (I1 : Int) return Int;
+ function "-" (I1 : Int) return Int;
+
+ procedure Dummy (B1 : Boolean);
+ procedure Dummy (I1 : Int);
+
+private
+
+ type IntRep is mod 2**31;
+ type Int is new IntRep;
+
+end Ops;
+
+
diff --git a/gdb/testsuite/gdb.ada/operator_bp/ops_test.adb b/gdb/testsuite/gdb.ada/operator_bp/ops_test.adb
new file mode 100644
index 00000000000..481c04af007
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/operator_bp/ops_test.adb
@@ -0,0 +1,40 @@
+-- Copyright 2012 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/>.
+
+with Ops; use Ops;
+procedure Ops_Test is
+
+begin
+ Dummy (Make (31) + Make (11)); -- BEGIN
+ Dummy (Make (31) - Make (11));
+ Dummy (Make (31) * Make (11));
+ Dummy (Make (31) / Make (11));
+ Dummy (Make (31) mod Make (11));
+ Dummy (Make (31) rem Make (11));
+ Dummy (Make (31) ** Make (11));
+ Dummy (Make (31) < Make (11));
+ Dummy (Make (31) <= Make (11));
+ Dummy (Make (31) > Make (11));
+ Dummy (Make (31) >= Make (11));
+ Dummy (Make (31) = Make (11));
+ Dummy (Make (31) and Make (11));
+ Dummy (Make (31) or Make (11));
+ Dummy (Make (31) xor Make (11));
+ Dummy (Make (31) & Make (11));
+ Dummy (abs (Make (42)));
+ Dummy (not Make (11));
+ Dummy (+ Make (11));
+ Dummy (- Make (11));
+end Ops_Test;