1"""Test that gdbstub has access to proc mappings.
2
3This runs as a sourced script (via -x, via run-test.py)."""
4from __future__ import print_function
5import gdb
6from test_gdbstub import main, report
7
8
9def run_test():
10    """Run through the tests one by one"""
11    try:
12        mappings = gdb.execute("info proc mappings", False, True)
13    except gdb.error as exc:
14        exc_str = str(exc)
15        if "Not supported on this target." in exc_str:
16            # Detect failures due to an outstanding issue with how GDB handles
17            # the x86_64 QEMU's target.xml, which does not contain the
18            # definition of orig_rax. Skip the test in this case.
19            print("SKIP: {}".format(exc_str))
20            return
21        raise
22    report(isinstance(mappings, str), "Fetched the mappings from the inferior")
23    # Broken with host page size > guest page size
24    # report("/sha1" in mappings, "Found the test binary name in the mappings")
25
26
27main(run_test)
28