1 # Copyright
2020-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 # This test
-case tests the scenario
for the crash fixed by commit ee3c5f8968
17 #
"Fix GDB crash when registers cannot be modified":
18 # $ valgrind
/usr
/bin
/sleep 10000
19 #
==31595== Memcheck
, a memory error detector
20 #
==31595== Command
: /usr
/bin
/sleep 10000
22 # $ gdb
/usr
/bin
/sleep
23 #
(gdb
) target remote | vgdb
--pid
=31595
24 # Remote debugging using | vgdb
--pid
=31595
26 # $hex in __GI___nanosleep
() at nanosleep.c
:27
27 #
27 return SYSCALL_CANCEL
(nanosleep
, requested_time
, remaining
);
28 #
(gdb
) p printf
("bla")
29 # terminate called after throwing an instance of
'gdb_exception_error'
30 # Aborted
(core dumped
)
32 # Valgrind gdbserver requires gdb with xml support.
33 require allow_xml_test
37 require
{!is_remote target
}
40 if {[build_executable $testfile.exp $testfile $srcfile
{debug
}] == -1} {
44 set active_at_startup
0
45 if { [vgdb_start $active_at_startup
] == -1 } {
49 # Determine whether we
're at nanosleep.
50 gdb_test_multiple "bt 1" "do printf" {
51 -re -wrap "nanosleep.*" {
52 # If gdb doesn't crash
, we
get something like
:
53 #
(gdb
) p printf
("bla")
54 # Could not write register
"rdi"; remote failure reply 'E.
55 # ERROR changing register rdi regno
5
56 # gdb commands changing registers
(pc
, sp
, ...
) (e.g.
'jump',
57 #
set pc
, calling from gdb a function in the debugged process
, ...
)
58 # can only be accepted
if the thread is VgTs_Runnable or VgTs_Yielding
60 # Thread
status is VgTs_WaitSys
63 gdb_test "p (int)printf (\"bla\")" \
64 "can only be accepted if the thread is .*" \
68 # For some reason the error condition does not trigger if we're not
69 # at nanosleep at the point that we
're connecting to vgdb. See also
70 # comment at "exec sleep 1" in vgdb_start.
71 unsupported $gdb_test_name