]>
git.proxmox.com Git - mirror_qemu.git/blob - tests/tcg/multiarch/gdbstub/prot-none.py
1 """Test that GDB can access PROT_NONE pages.
3 This runs as a sourced script (via -x, via run-test.py).
5 SPDX-License-Identifier: GPL-2.0-or-later
8 from test_gdbstub
import main
, report
11 def probe_proc_self_mem():
12 buf
= ctypes
.create_string_buffer(b
'aaa')
14 with
open("/proc/self/mem", "rb") as fp
:
15 fp
.seek(ctypes
.addressof(buf
))
16 return fp
.read(3) == b
'aaa'
22 """Run through the tests one by one"""
23 if not probe_proc_self_mem
:
24 print("SKIP: /proc/self/mem is not usable")
26 gdb
.Breakpoint("break_here")
27 gdb
.execute("continue")
28 val
= gdb
.parse_and_eval("*(char[2] *)q").string()
29 report(val
== "42", "{} == 42".format(val
))
30 gdb
.execute("set *(char[3] *)q = \"24\"")
31 gdb
.execute("continue")
32 exitcode
= int(gdb
.parse_and_eval("$_exitcode"))
33 report(exitcode
== 0, "{} == 0".format(exitcode
))