New Ada testcase for breakpoints on operators.

gdb/testsuite/ChangeLog:

        * gdb.ada/operator_bp: New testcase.
This commit is contained in:
Joel Brobecker 2012-03-02 20:36:41 +00:00
parent c0eac87f84
commit 8bbc467ad4
5 changed files with 324 additions and 0 deletions

View File

@ -1,3 +1,7 @@
2012-03-02 Joel Brobecker <brobecker@adacore.com>
* gdb.ada/operator_bp: New testcase.
2012-03-02 Joel Brobecker <brobecker@adacore.com>
* gdb.ada/info_locals_renaming: New testcase.

View File

@ -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\""
}

View File

@ -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;

View File

@ -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;

View File

@ -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;