From 88358dd0af5a781493eb5e98666f28b8bd486391 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Tue, 27 Mar 2012 07:37:31 -0700 Subject: [PATCH] Add more tests to gdb.ada/operator_bp.exp This patch adds testing of the FILE:OP:LINENO linespec (where OP is the name of an Ada operator) as well as testing of the FILE:OP linespec. gdb/testsuite/ChangeLog: * gdb.ada/operator_bp/ops.adb: Add source line markers. * gdb.ada/operator_bp.exp: Add testing of FILE:OP:LINENO as well as FILE:OP linespecs where OP is the name of an Ada operator. --- gdb/testsuite/gdb.ada/operator_bp.exp | 57 +++++++++++++++++++++++++++++ gdb/testsuite/gdb.ada/operator_bp/ops.adb | 36 +++++++++--------- 2 files changed, 75 insertions(+), 18 deletions(-) diff --git a/gdb/testsuite/gdb.ada/operator_bp.exp b/gdb/testsuite/gdb.ada/operator_bp.exp index 18cf46d..3c20f39 100644 --- a/gdb/testsuite/gdb.ada/operator_bp.exp +++ b/gdb/testsuite/gdb.ada/operator_bp.exp @@ -88,4 +88,61 @@ foreach op { "+" "-" "*" "/" "mod" "rem" "**" "<" "<=" ">" ">=" "=" "and" "or" " "continue to ops.\"$op\"" } +# Repeat the test, but qualify the operators with a filename and +# line number. + +clean_restart ${testfile} + +runto "ops_test.adb:$bp_location" + +foreach op { "+" "-" } { + set lineno [gdb_get_line_number "STOP \"$op\"" ${testdir}/ops.adb] + set op_re [string_to_regexp $op] + gdb_test "break ops.adb:\"$op\":$lineno" \ + "Breakpoint $decimal at $hex: ops\\.adb:\"$op_re\":$lineno\. \\(2 locations\\)" +} + +foreach op { "*" "/" "mod" "rem" "**" "<" "<=" ">" ">=" "=" "and" "or" "xor" "&" "abs" "not"} { + set lineno [gdb_get_line_number "STOP \"$op\"" ${testdir}/ops.adb] + set op_re [string_to_regexp $op] + gdb_test "break ops.adb:\"$op\":$lineno" \ + "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.adb:\"$op\":LINE" +} + +# Repeat the test, but qualify the operators with a filename alone. + +clean_restart ${testfile} + +runto "ops_test.adb:$bp_location" + +foreach op { "+" "-" } { + set op_re [string_to_regexp $op] + gdb_test "break ops.adb:\"$op\"" \ + "Breakpoint $decimal at $hex: ops\\.adb:\"$op_re\". \\(2 locations\\)" +} + +foreach op { "*" "/" "mod" "rem" "**" "<" "<=" ">" ">=" "=" "and" "or" "xor" "&" "abs" "not"} { + set op_re [string_to_regexp $op] + gdb_test "break ops.adb:\"$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.adb:\"$op\"" +} + diff --git a/gdb/testsuite/gdb.ada/operator_bp/ops.adb b/gdb/testsuite/gdb.ada/operator_bp/ops.adb index e7d94dc..fe9168c 100644 --- a/gdb/testsuite/gdb.ada/operator_bp/ops.adb +++ b/gdb/testsuite/gdb.ada/operator_bp/ops.adb @@ -22,38 +22,38 @@ package body Ops is function "+" (I1, I2 : Int) return Int is begin - return Int (IntRep (I1) + IntRep (I2)); + return Int (IntRep (I1) + IntRep (I2)); -- STOP "+" end; function "-" (I1, I2 : Int) return Int is begin - return Int (IntRep (I1) - IntRep (I2)); + return Int (IntRep (I1) - IntRep (I2)); -- STOP "-" end; function "*" (I1, I2 : Int) return Int is begin - return Int (IntRep (I1) * IntRep (I2)); + return Int (IntRep (I1) * IntRep (I2)); -- STOP "*" end; function "/" (I1, I2 : Int) return Int is begin - return Int (IntRep (I1) / IntRep (I2)); + return Int (IntRep (I1) / IntRep (I2)); -- STOP "/" end; function "mod" (I1, I2 : Int) return Int is begin - return Int (IntRep (I1) mod IntRep (I2)); + return Int (IntRep (I1) mod IntRep (I2)); -- STOP "mod" end; function "rem" (I1, I2 : Int) return Int is begin - return Int (IntRep (I1) rem IntRep (I2)); + return Int (IntRep (I1) rem IntRep (I2)); -- STOP "rem" end; function "**" (I1, I2 : Int) return Int is Result : IntRep := 1; begin - for J in 1 .. IntRep (I2) loop + for J in 1 .. IntRep (I2) loop -- STOP "**" Result := IntRep (I1) * Result; end loop; return Int (Result); @@ -61,57 +61,57 @@ package body Ops is function "<" (I1, I2 : Int) return Boolean is begin - return IntRep (I1) < IntRep (I2); + return IntRep (I1) < IntRep (I2); -- STOP "<" end; function "<=" (I1, I2 : Int) return Boolean is begin - return IntRep (I1) <= IntRep (I2); + return IntRep (I1) <= IntRep (I2); -- STOP "<=" end; function ">" (I1, I2 : Int) return Boolean is begin - return IntRep (I1) > IntRep (I2); + return IntRep (I1) > IntRep (I2); -- STOP ">" end; function ">=" (I1, I2 : Int) return Boolean is begin - return IntRep (I1) >= IntRep (I2); + return IntRep (I1) >= IntRep (I2); -- STOP ">=" end; function "=" (I1, I2 : Int) return Boolean is begin - return IntRep (I1) = IntRep (I2); + return IntRep (I1) = IntRep (I2); -- STOP "=" end; function "and" (I1, I2 : Int) return Int is begin - return Int (IntRep (I1) and IntRep (I2)); + return Int (IntRep (I1) and IntRep (I2)); -- STOP "and" end; function "or" (I1, I2 : Int) return Int is begin - return Int (IntRep (I1) or IntRep (I2)); + return Int (IntRep (I1) or IntRep (I2)); -- STOP "or" end; function "xor" (I1, I2 : Int) return Int is begin - return Int (IntRep (I1) xor IntRep (I2)); + return Int (IntRep (I1) xor IntRep (I2)); -- STOP "xor" end; function "&" (I1, I2 : Int) return Int is begin - return Int (IntRep (I1) and IntRep (I2)); + return Int (IntRep (I1) and IntRep (I2)); -- STOP "&" end; function "abs" (I1 : Int) return Int is begin - return Int (abs IntRep (I1)); + return Int (abs IntRep (I1)); -- STOP "abs" end; function "not" (I1 : Int) return Int is begin - return Int (not IntRep (I1)); + return Int (not IntRep (I1)); -- STOP "not" end; function "+" (I1 : Int) return Int is -- 1.7.1