# This is to allow the tests to work if there's a properly named symbol for
# the function, even if there's no libc debug info.
-set saw_watch_trigger 0
-set saw_function 0
-set is_supported 1
-set message "continue until memset watchpoint hits"
-set watch_trigger \
+# ARRAY_RE is the array whose modification is caught by the
+# watchpoint. SOURCE_FUNCTION is the function that modifies the
+# array, as written in the source of the test program. FUNCTION_RE
+# matches the name of the symbol that actually implements
+# SOURCE_FUNCTION (e.g., memcpy may be implemented with memmove, so we
+# may want to expect both). OLD_VALUE_RE and NEW_VALUE_RE match the
+# old/new values when the watchpoint triggers.
+
+proc continue_to_watchpoint {array_re source_function function_re
+ old_value_re new_value_re} {
+ set saw_watch_trigger 0
+ set saw_function 0
+ set is_supported 1
+ set watch_trigger_re \
[multi_line \
"Continuing\\." \
"" \
- "(Hardware w|W)atchpoint ${decimal}: -location a\\\[28\\\]" \
+ "(Hardware w|W)atchpoint ${::decimal}: -location ${array_re}\\\[28\\\]" \
"" \
- "Old value = 104 'h'" \
- "New value = 0 '\\\\000'"]
-gdb_test_multiple "continue" $message {
- -re $watch_trigger {
- set saw_watch_trigger 1
- exp_continue
- }
- -re ".*memset.* \\(\\) at .*:$decimal\r\n" {
- set saw_function 1
- exp_continue
- }
- -re ".*memset.* \\(\\) from .*libc\[^\r\n\]+\r\n" {
- set saw_function 1
- exp_continue
- }
- -re "in \\?\\? \\(\\) from .*libc\[^\r\n\]+\r\n" {
- set is_supported 0
- unsupported "symbol for memset not found"
- exp_continue
- }
- -re "$gdb_prompt $" {
- if { $is_supported } {
- setup_kfail breakpoints/31665 arm*-*-linux*
- gdb_assert { $saw_watch_trigger && $saw_function } $message
+ "Old value = ${old_value_re}" \
+ "New value = ${new_value_re}"]
+ gdb_test_multiple "continue" \
+ "continue until $source_function watchpoint hits" {
+ -re $watch_trigger_re {
+ set saw_watch_trigger 1
+ exp_continue
+ }
+ -re ".*${function_re}.* \\(\\) at .*:$::decimal\r\n" {
+ set saw_function 1
+ exp_continue
+ }
+ -re ".*${function_re}.* \\(\\) from .*libc\[^\r\n\]+\r\n" {
+ set saw_function 1
+ exp_continue
+ }
+ -re "in \\?\\? \\(\\) from .*libc\[^\r\n\]+\r\n" {
+ set is_supported 0
+ unsupported "symbol for ${source_function} not found"
+ exp_continue
+ }
+ -re -wrap "" {
+ if { $is_supported } {
+ setup_kfail breakpoints/31665 arm*-*-linux*
+ gdb_assert { $saw_watch_trigger && $saw_function } \
+ $gdb_test_name
+ }
}
}
}
+continue_to_watchpoint "a" "memset" "memset" "104 'h'" "0 '\\\\000'"
+
# Note: Some architectures use memmove for memcpy.
-set saw_watch_trigger 0
-set saw_function 0
-set is_supported 1
-set message "continue until memcpy watchpoint hits"
-set watch_trigger \
- [multi_line \
- "Continuing\\." \
- "" \
- "(Hardware w|W)atchpoint ${decimal}: -location b\\\[28\\\]" \
- "" \
- "Old value = 101 'e'" \
- "New value = 114 'r'"]
-gdb_test_multiple "continue" $message {
- -re $watch_trigger {
- set saw_watch_trigger 1
- exp_continue
- }
- -re ".*(memcpy|memmove).* \\(\\) at .*:$decimal\r\n" {
- set saw_function 1
- exp_continue
- }
- -re ".*(memcpy|memmove).* \\(\\) from .*libc\[^\r\n\]+\r\n" {
- set saw_function 1
- exp_continue
- }
- -re "in \\?\\? \\(\\) from .*libc\[^\r\n\]+\r\n" {
- set is_supported 0
- unsupported "symbol for memcpy not found"
- exp_continue
- }
- -re "$gdb_prompt $" {
- if { $is_supported } {
- setup_kfail breakpoints/31665 arm*-*-linux*
- gdb_assert { $saw_watch_trigger && $saw_function } $message
- }
- }
-}
+continue_to_watchpoint "b" "memcpy" "(memcpy|memmove)" "101 'e'" "114 'r'"
# Note: Some architectures use memcpy for memmove.
-set saw_watch_trigger 0
-set saw_function 0
-set is_supported 1
-set message "continue until memmove watchpoint hits"
-set watch_trigger \
- [multi_line \
- "Continuing\\." \
- "" \
- "(Hardware w|W)atchpoint ${decimal}: -location c\\\[28\\\]" \
- "" \
- "Old value = 100 'd'" \
- "New value = 114 'r'"]
-gdb_test_multiple "continue" $message {
- -re $watch_trigger {
- set saw_watch_trigger 1
- exp_continue
- }
- -re ".*(memcpy|memmove).* \\(\\) at .*:$decimal\r\n" {
- set saw_function 1
- exp_continue
- }
- -re ".*(memcpy|memmove).* \\(\\) from .*libc\[^\r\n\]+\r\n" {
- set saw_function 1
- exp_continue
- }
- -re "in \\?\\? \\(\\) from .*libc\[^\r\n\]+\r\n" {
- set is_supported 0
- unsupported "symbol for memmove not found"
- exp_continue
- }
- -re "$gdb_prompt $" {
- if { $is_supported } {
- setup_kfail breakpoints/31665 arm*-*-linux*
- gdb_assert { $saw_watch_trigger && $saw_function } $message
- }
- }
-}
+continue_to_watchpoint "c" "memmove" "(memcpy|memmove)" "100 'd'" "114 'r'"