aboutsummaryrefslogtreecommitdiff
path: root/scripts/probe-gdb-support.py
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2023-03-09 16:54:51 +0000
committerPeter Maydell <peter.maydell@linaro.org>2023-03-09 16:54:51 +0000
commitb1224d8395de9be79c8cddbc2f60d29d9f1c10fe (patch)
treee1ed07b1201271f34307f27dde9f0fa7fe405b86 /scripts/probe-gdb-support.py
parent66a6aa8f9a56a6317e074b1f5e269fecdf4ad782 (diff)
parent412ae12647d1086c713e13841fd25d10d5418c7f (diff)
downloadqemu-b1224d8395de9be79c8cddbc2f60d29d9f1c10fe.zip
qemu-b1224d8395de9be79c8cddbc2f60d29d9f1c10fe.tar.gz
qemu-b1224d8395de9be79c8cddbc2f60d29d9f1c10fe.tar.bz2
Merge tag 'pull-gdbstub-070323-3' of https://gitlab.com/stsquad/qemu into staging
gdbstub refactor: - split user and softmmu code - use cleaner headers for tb_flush, target_ulong - probe for gdb multiarch support at configure - make syscall handling target independent - add update guest debug of accel ops # -----BEGIN PGP SIGNATURE----- # # iQEzBAABCgAdFiEEZoWumedRZ7yvyN81+9DbCVqeKkQFAmQHomMACgkQ+9DbCVqe # KkTtFAf/aEyKY0iUNxtB4/oV1L2VnLaZi+iKoZT4RQgrhOhzr5WV6/3/V05cw1RJ # SIwcl8wB4gowYILs44eM/Qzcixiugl++2rvM4YVXiQyWKzkH6sY4X2iFuPGTwHLp # y+E7RM77QNS7M9xYaVkdsQawnbsgjG67wZKbb88aaekFEn61UuDg1V2Nqa2ICy7Y # /8yGIB2ixDfXOF0z4g8NOG44BXTDBtJbcEzf5GMz6D4HGnPZUbENy1nT0OcBk3zK # PqKPNkPFZ360pqA9MtougjZ3xTBb7Afe9nRRMquV2RoFmkkY2otSjdPBFQu5GBlm # NyTXEzjIQ6tCZlbS0eqdPVrUHHUx9g== # =Al36 # -----END PGP SIGNATURE----- # gpg: Signature made Tue 07 Mar 2023 20:45:23 GMT # gpg: using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44 # gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>" [full] # Primary key fingerprint: 6685 AE99 E751 67BC AFC8 DF35 FBD0 DB09 5A9E 2A44 * tag 'pull-gdbstub-070323-3' of https://gitlab.com/stsquad/qemu: (30 commits) gdbstub: move update guest debug to accel ops gdbstub: Build syscall.c once stubs: split semihosting_get_target from system only stubs gdbstub: Adjust gdb_do_syscall to only use uint32_t and uint64_t gdbstub: Remove gdb_do_syscallv gdbstub: split out softmmu/user specifics for syscall handling include: split target_long definition from cpu-defs testing: probe gdb for supported architectures ahead of time gdbstub: only compile gdbstub twice for whole build gdbstub: move syscall handling to new file gdbstub: move register helpers into standalone include gdbstub: don't use target_ulong while handling registers gdbstub: fix address type of gdb_set_cpu_pc gdbstub: specialise stub_can_reverse gdbstub: introduce gdb_get_max_cpus gdbstub: specialise target_memory_rw_debug gdbstub: specialise handle_query_attached gdbstub: abstract target specific details from gdb_put_packet_binary gdbstub: rationalise signal mapping in softmmu gdbstub: move chunks of user code into own files ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/probe-gdb-support.py')
-rwxr-xr-xscripts/probe-gdb-support.py88
1 files changed, 88 insertions, 0 deletions
diff --git a/scripts/probe-gdb-support.py b/scripts/probe-gdb-support.py
new file mode 100755
index 0000000..5755255
--- /dev/null
+++ b/scripts/probe-gdb-support.py
@@ -0,0 +1,88 @@
+#!/usr/bin/env python3
+# coding: utf-8
+#
+# Probe gdb for supported architectures.
+#
+# This is required to support testing of the gdbstub as its hard to
+# handle errors gracefully during the test. Instead this script when
+# passed a GDB binary will probe its architecture support and return a
+# string of supported arches, stripped of guff.
+#
+# Copyright 2023 Linaro Ltd
+#
+# Author: Alex Bennée <alex.bennee@linaro.org>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or later.
+# See the COPYING file in the top-level directory.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import argparse
+import re
+from subprocess import check_output, STDOUT
+
+# mappings from gdb arch to QEMU target
+mappings = {
+ "alpha" : "alpha",
+ "aarch64" : ["aarch64", "aarch64_be"],
+ "armv7": "arm",
+ "armv8-a" : ["aarch64", "aarch64_be"],
+ "avr" : "avr",
+ "cris" : "cris",
+ # no hexagon in upstream gdb
+ "hppa1.0" : "hppa",
+ "i386" : "i386",
+ "i386:x86-64" : "x86_64",
+ "Loongarch64" : "loongarch64",
+ "m68k" : "m68k",
+ "MicroBlaze" : "microblaze",
+ "mips:isa64" : ["mips64", "mips64el"],
+ "nios2" : "nios2",
+ "or1k" : "or1k",
+ "powerpc:common" : "ppc",
+ "powerpc:common64" : ["ppc64", "ppc64le"],
+ "riscv:rv32" : "riscv32",
+ "riscv:rv64" : "riscv64",
+ "s390:64-bit" : "s390x",
+ "sh4" : ["sh4", "sh4eb"],
+ "sparc": "sparc",
+ "sparc:v8plus": "sparc32plus",
+ "sparc:v9a" : "sparc64",
+ # no tricore in upstream gdb
+ "xtensa" : ["xtensa", "xtensaeb"]
+}
+
+def do_probe(gdb):
+ gdb_out = check_output([gdb,
+ "-ex", "set architecture",
+ "-ex", "quit"], stderr=STDOUT)
+
+ m = re.search(r"Valid arguments are (.*)",
+ gdb_out.decode("utf-8"))
+
+ valid_arches = set()
+
+ if m.group(1):
+ for arch in m.group(1).split(", "):
+ if arch in mappings:
+ mapping = mappings[arch]
+ if isinstance(mapping, str):
+ valid_arches.add(mapping)
+ else:
+ for entry in mapping:
+ valid_arches.add(entry)
+
+ return valid_arches
+
+def main() -> None:
+ parser = argparse.ArgumentParser(description='Probe GDB Architectures')
+ parser.add_argument('gdb', help='Path to GDB binary.')
+
+ args = parser.parse_args()
+
+ supported = do_probe(args.gdb)
+
+ print(" ".join(supported))
+
+if __name__ == '__main__':
+ main()