[gdbserver] Fix s390x -m31 gdbserver build
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-watch.exp
index b3ba8445971183a1f936bf9d49a42b8f0c3b4446..23cc178d71a95a94ac2b621b76a1f0d8ecb06e58 100644 (file)
@@ -1,51 +1,37 @@
-# Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2007
-# Free Software Foundation, Inc.
+# Copyright 1999-2019 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 2 of the License, or
+# 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, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+# Test Machine interface (MI) operations
 #
-# Test essential Machine interface (MI) operations
-#
-# Verify that, using the MI, we can run a simple program and perform basic
-# debugging activities like: insert breakpoints, run the program,
-# step, next, continue until it ends and, last but not least, quit.
-#
-# The goal is not to test gdb functionality, which is done by other tests,
-# but to verify the correct output response to MI operations.
+# Test MI watchpoint commands.
 #
+# The goal is not to test gdb functionality, which is done by other
+# tests, but to verify the correct output response to MI operations.
 
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
-    continue
-}
 
-set testfile "basics"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
-     untested mi-watch.exp
+standard_testfile basics.c
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+     untested "failed to compile"
      return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
-
 proc test_watchpoint_creation_and_listing {} {
     global mi_gdb_prompt
     global srcfile
@@ -64,7 +50,7 @@ proc test_watchpoint_creation_and_listing {} {
              "break-watch operation"
 
     mi_gdb_test "222-break-list" \
-           "222\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[bkpt=\{number=\"2\",type=\".*watchpoint\",disp=\"keep\",enabled=\"y\",addr=\"\",what=\"C\",times=\"0\"\}\\\]\}" \
+           "222\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[bkpt=\{number=\"2\",type=\".*watchpoint\",disp=\"keep\",enabled=\"y\",what=\"C\",thread-groups=\\\[\"i1\"\\\],times=\"0\",original-location=\"C\"\}\\\]\}" \
                 "list of watchpoints"
 
 }
@@ -88,7 +74,7 @@ proc test_awatch_creation_and_listing {} {
              "break-watch -a operation"
 
     mi_gdb_test "444-break-list" \
-           "444\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"3\",type=\"watchpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"$line_main_body\",times=\"0\"\},.*\}\\\]\}" \
+           "444\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"3\",type=\"watchpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"$line_main_body\",thread-groups=\\\[\"i1\"\\\],times=\"0\"\},.*\}\\\]\}" \
                 "list of watchpoints awatch"
 
     mi_gdb_test "777-break-delete 3" \
@@ -107,15 +93,15 @@ proc test_rwatch_creation_and_listing {} {
 
     # Insert a read watchpoint and list it.
     # Tests:
-    # -break-insert -r B
+    # -break-watch -r B
     # -break-list
 
     mi_gdb_test "200-break-watch -r C" \
              "200\\^done,bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"$line_main_body\",times=\"0\"\}" \
-             "break-insert -r operation"
+             "break-watch -r operation"
 
     mi_gdb_test "300-break-list" \
-           "300\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"$line_main_body\",times=\"0\"\},.*\}\\\}\}" \
+           "300\\^done,BreakpointTable=\{.*,hdr=\\\[.*\\\],body=\\\[bkpt=\{number=\"5\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*basics.c\",line=\"$line_main_body\",thread-groups=\\\[\"i1\"\\\],times=\"0\"\},.*\}\\\}\}" \
                 "list of breakpoints"
 
     mi_gdb_test "177-break-delete 4" \
@@ -137,42 +123,68 @@ proc test_watchpoint_triggering {} {
     # -exec-continue (Here wp triggers)
     # -exec-continue (Here wp goes out of scope)
 
-    send_gdb "222-exec-continue\n"
-    gdb_expect {
-      -re "222\\^running\r\n$mi_gdb_prompt" {
-        gdb_expect {
-           -re "222\\*stopped,reason=\"watchpoint-trigger\",wpt=\{number=\"2\",exp=\"C\"\},value=\{old=\".*\",new=\"3\"\},thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee4\",args=\\\[\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_return_0\"\}\r\n$mi_gdb_prompt$" {
-            pass "watchpoint trigger"
-          }
-          -re ".*$mi_gdb_prompt$" {fail "watchpoint trigger (2)"}
-          timeout {fail "watchpoint trigger (timeout 2)"}
-        }
-      }
-      -re ".*$mi_gdb_prompt$" {fail "watchpoint trigger (1)"}
-      timeout {fail "watchpoint trigger (timeout 1)"}
+    mi_execute_to "exec-continue" "watchpoint-trigger" "callee4" "" \
+        ".*basics.c" $line_callee4_return_0 \
+        {"" "wpt=\{number=\"2\",exp=\"C\"\},value=\{old=\".*\",new=\"3\"\}"} \
+        "watchpoint trigger"
+
+    mi_execute_to "exec-continue" "watchpoint-scope" "callee3" ".*" \
+        ".*basics.c" $line_callee3_close_brace \
+        {"" "wpnum=\"2\""} \
+        "watchpoint trigger"
+}
+
+proc test_watchpoint_all {mi_mode type} {
+    upvar srcdir srcdir
+    upvar subdir subdir
+    upvar binfile binfile
+
+    if {$type == "hw" && [target_info exists gdb,no_hardware_watchpoints] } {
+       return
     }
 
-    send_gdb "223-exec-continue\n"
-    gdb_expect {
-      -re "223\\^running\r\n$mi_gdb_prompt" {
-        gdb_expect {
-           -re "\[\r\n\]*223\\*stopped,reason=\"watchpoint-scope\",wpnum=\"2\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee3_close_brace\"\}\r\n$mi_gdb_prompt$" {
-            pass "wp out of scope"
-          }
-          -re ".*$mi_gdb_prompt$" {fail "wp out of scope (2)"}
-          timeout {fail "wp out of scope (timeout 2)"}
-        }
-      }
-      -re ".*$mi_gdb_prompt$" {fail "wp out of scope (1)"}
-      timeout {fail "wp out of scope (timeout 1)"}
+    mi_gdb_exit
+
+    if {$mi_mode == "separate"} {
+       set start_ops "separate-mi-tty"
+    } else {
+       set start_ops ""
     }
+    if [mi_gdb_start $start_ops] {
+       return
+    }
+
+    if {$type == "sw"} {
+       set option 0
+    } else {
+       set option 1
+    }
+    mi_gdb_test "567-gdb-set can-use-hw-watchpoints $option" \
+       "567\\^done" \
+       "hw watchpoints toggle"
+
+    mi_delete_breakpoints
+    mi_gdb_reinitialize_dir $srcdir/$subdir
+    mi_gdb_load ${binfile}
+
+    mi_runto callee4
+    test_watchpoint_creation_and_listing
+    #test_rwatch_creation_and_listing
+    #test_awatch_creation_and_listing
+    test_watchpoint_triggering
 }
 
-mi_runto callee4
-test_watchpoint_creation_and_listing
-#test_rwatch_creation_and_listing
-#test_awatch_creation_and_listing
-test_watchpoint_triggering
+if [gdb_debug_enabled] {
+  # gdb debug doesn't work for separate-mi-tty.
+  set modes {"main"}
+} else {
+  set modes {"main" "separate"}
+}
 
-mi_gdb_exit
-return 0
+# Run the tests twice, once using software watchpoints, and another
+# with hardware watchpoints.
+foreach_with_prefix mi-mode $modes {
+    foreach_with_prefix wp-type {"sw" "hw"} {
+       test_watchpoint_all ${mi-mode} ${wp-type}
+    }
+}
This page took 0.036565 seconds and 4 git commands to generate.