1 # Copyright
(C
) 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 # Test that we can access memory
while the inferior is running.
20 if {[build_executable
"failed to prepare" $testfile $srcfile {debug}] == -1} {
24 # The test proper. NON_STOP indicates whether we
're testing in
25 # non-stop, or all-stop mode.
27 proc test { non_stop } {
28 global srcfile binfile
33 save_vars { GDBFLAGS } {
34 append GDBFLAGS " -ex \"set non-stop $non_stop\""
35 clean_restart ${binfile}
42 # If debugging with target remote, check whether the all-stop variant
43 # of the RSP is being used. If so, we can't run the background tests.
45 && [target_info
exists gdb_protocol
]
46 && ([target_info gdb_protocol
] == "remote"
47 ||
[target_info gdb_protocol
] == "extended-remote")} {
49 if {![is_target_non_stop
]} {
50 unsupported
"can't issue commands while target is running"
57 if {$non_stop
== "off"} {
60 set cmd
"continue -a &"
62 gdb_test_multiple $cmd
"continuing" {
63 -re
"Continuing\.\r\n$gdb_prompt " {
68 # Check we can read
/write variables.
70 # Check that we can read the counter
variable, and that the
71 # counter is increasing
, meaning the process really is running.
75 [get_integer_valueof
"global_counter" 0 \
76 "get global_counter once"]
80 [get_integer_valueof
"global_counter" 0 \
81 "get global_counter twice"]
83 gdb_assert
{$global_counter1
!= 0 \
84 && $global_counter2
!= 0 \
85 && $global_counter1
!= $global_counter2
} \
88 # Check that we can write variables.
90 gdb_test
"print global_var" " = 123" \
91 "print global_var before writing"
92 gdb_test
"print global_var = 321" " = 321" \
94 gdb_test
"print global_var" " = 321" \
95 "print global_var after writing"
96 gdb_test
"print global_var = 123" " = 123" \
97 "write to global_var again"
99 # Check we can
set a breakpoint
while the process is running. The
100 # breakpoint should hit immediately.
103 gdb_test_multiple
"b maybe_stop_here" "" {
104 -re
"Breakpoint $decimal at $any: file $any${srcfile}, line $decimal.\r\n$gdb_prompt " {
108 gdb_test_multiple
"" "breakpoint hits" {
109 -re
"Breakpoint $decimal, maybe_stop_here \\(\\) at $any${srcfile}:$decimal\r\n" {
110 pass
"$gdb_test_name"
115 foreach non_stop
{ "off" "on" } {
116 set stop_mode
[expr
($non_stop
=="off")?"all-stop":"non-stop"]
117 with_test_prefix
"$stop_mode" {