This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit] New Ada testcase for breakpoints on operators.


As mentioned on the Archer list, a testcase that checks breakpoints
on Ada operators...

gdb/testsuite/ChangeLog:

        * gdb.ada/operator_bp: New testcase.

Tested on x86_64-linux.  Checked in.

---
 gdb/testsuite/ChangeLog                        |    4 +
 gdb/testsuite/gdb.ada/operator_bp.exp          |   88 +++++++++++++++
 gdb/testsuite/gdb.ada/operator_bp/ops.adb      |  140 ++++++++++++++++++++++++
 gdb/testsuite/gdb.ada/operator_bp/ops.ads      |   52 +++++++++
 gdb/testsuite/gdb.ada/operator_bp/ops_test.adb |   40 +++++++
 5 files changed, 324 insertions(+), 0 deletions(-)
 create mode 100644 gdb/testsuite/gdb.ada/operator_bp.exp
 create mode 100644 gdb/testsuite/gdb.ada/operator_bp/ops.adb
 create mode 100644 gdb/testsuite/gdb.ada/operator_bp/ops.ads
 create mode 100644 gdb/testsuite/gdb.ada/operator_bp/ops_test.adb

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 799e04d..1ed442f 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,9 @@
 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.
 
 2012-03-02  Tom Tromey  <tromey@redhat.com>
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;
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]