diff options
author | Joel Brobecker <brobecker@gnat.com> | 2012-03-02 20:36:41 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2012-03-02 20:36:41 +0000 |
commit | 8bbc467ad401406cd8c640d5e8e738ce8d9289b1 (patch) | |
tree | 46f37b46cbf532a3604e392511f70fd2be13699e /gdb/testsuite/gdb.ada | |
parent | c0eac87f844a1e9c8338366d8d4647fcc2c9a2f5 (diff) | |
download | gdb-8bbc467ad401406cd8c640d5e8e738ce8d9289b1.zip gdb-8bbc467ad401406cd8c640d5e8e738ce8d9289b1.tar.gz gdb-8bbc467ad401406cd8c640d5e8e738ce8d9289b1.tar.bz2 |
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.exp | 88 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/operator_bp/ops.adb | 140 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/operator_bp/ops.ads | 52 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/operator_bp/ops_test.adb | 40 |
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 0000000..2be7e0a --- /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 0000000..e7d94dc --- /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 0000000..8724cb3 --- /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 0000000..481c04a --- /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; |