Fix: Null pointer dereference in ldlex.l
[binutils-gdb.git] / gdb / testsuite / gdb.base / watch-before-fork.exp
bloba9e212026bfb7acb2e9f63261bfeeda27fc51180
1 # Copyright 2021-2023 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # Regression test for PR gdb/28621. Test that GDB does not misreport
17 # a watchpoint hit when a previous watchpoint hit is immediately
18 # followed by a catchpoint hit.
20 # This test uses "awatch".
21 require allow_hw_watchpoint_access_tests
23 standard_testfile
25 if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
26 return
29 # Check that fork catchpoints are supported. Returns 1 if they are.
30 # Returns 0 and issues unsupported if they are not supported. If it
31 # couldn't be determined, returns 0 (but does not call unsupported).
33 proc_with_prefix catch_fork_supported {} {
34 clean_restart $::testfile
36 if { ![runto_main] } {
37 return 0
40 # Verify that the system supports "catch fork".
41 gdb_test "catch fork" "Catchpoint \[0-9\]* \\(fork\\)" "insert first fork catchpoint"
42 set has_fork_catchpoints -1
43 gdb_test_multiple "continue" "continue to first fork catchpoint" {
44 -re -wrap ".*Your system does not support this type\r\nof catchpoint.*" {
45 set has_fork_catchpoints 0
46 pass $gdb_test_name
48 -re -wrap ".*Catchpoint.*" {
49 set has_fork_catchpoints 1
50 pass $gdb_test_name
54 if {$has_fork_catchpoints == 1} {
55 return 1
56 } elseif {$has_fork_catchpoints == -1} {
57 return 0
58 } else {
59 unsupported "catch fork not supported"
60 return 0
64 # The test proper.
66 proc_with_prefix test {} {
67 clean_restart $::testfile
69 if { ![runto_main] } {
70 return 0
73 gdb_test "awatch global_var" \
74 "Hardware access \\(read/write\\) watchpoint .*: global_var.*" \
75 "watchpoint on global variable"
77 gdb_test "continue" \
78 "Hardware access \\(read/write\\) watchpoint .*: global_var.*" \
79 "continue to watchpoint"
81 set seen_watchpoint 0
82 gdb_test_multiple "continue" "continue to catch fork" {
83 -re "watchpoint" {
84 set seen_watchpoint 1
85 exp_continue
87 -re "$::gdb_prompt " {
88 gdb_assert { !$seen_watchpoint } $gdb_test_name
93 if {![catch_fork_supported] } {
94 return
97 test