[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 15/17] testing: Enhance gdb probe script
From: |
Alex Bennée |
Subject: |
[PULL 15/17] testing: Enhance gdb probe script |
Date: |
Thu, 24 Oct 2024 10:56:01 +0100 |
From: Gustavo Romero <gustavo.romero@linaro.org>
Use list and set comprehension to simplify code. Also, gently handle
invalid gdb filenames.
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20241015145848.387281-1-gustavo.romero@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20241023113406.1284676-16-alex.bennee@linaro.org>
diff --git a/scripts/probe-gdb-support.py b/scripts/probe-gdb-support.py
index 6dc58d06c7..6bcadce150 100644
--- a/scripts/probe-gdb-support.py
+++ b/scripts/probe-gdb-support.py
@@ -19,58 +19,61 @@
import argparse
import re
-from subprocess import check_output, STDOUT
+from subprocess import check_output, STDOUT, CalledProcessError
+import sys
-# mappings from gdb arch to QEMU target
-mappings = {
- "alpha" : "alpha",
+# Mappings from gdb arch to QEMU target
+MAP = {
+ "alpha" : ["alpha"],
"aarch64" : ["aarch64", "aarch64_be"],
- "armv7": "arm",
+ "armv7": ["arm"],
"armv8-a" : ["aarch64", "aarch64_be"],
- "avr" : "avr",
+ "avr" : ["avr"],
# no hexagon in upstream gdb
- "hppa1.0" : "hppa",
- "i386" : "i386",
- "i386:x86-64" : "x86_64",
- "Loongarch64" : "loongarch64",
- "m68k" : "m68k",
- "MicroBlaze" : "microblaze",
+ "hppa1.0" : ["hppa"],
+ "i386" : ["i386"],
+ "i386:x86-64" : ["x86_64"],
+ "Loongarch64" : ["loongarch64"],
+ "m68k" : ["m68k"],
+ "MicroBlaze" : ["microblaze"],
"mips:isa64" : ["mips64", "mips64el"],
- "or1k" : "or1k",
- "powerpc:common" : "ppc",
+ "or1k" : ["or1k"],
+ "powerpc:common" : ["ppc"],
"powerpc:common64" : ["ppc64", "ppc64le"],
- "riscv:rv32" : "riscv32",
- "riscv:rv64" : "riscv64",
- "s390:64-bit" : "s390x",
+ "riscv:rv32" : ["riscv32"],
+ "riscv:rv64" : ["riscv64"],
+ "s390:64-bit" : ["s390x"],
"sh4" : ["sh4", "sh4eb"],
- "sparc": "sparc",
- "sparc:v8plus": "sparc32plus",
- "sparc:v9a" : "sparc64",
+ "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)
+ try:
+ gdb_out = check_output([gdb,
+ "-ex", "set architecture",
+ "-ex", "quit"], stderr=STDOUT, encoding="utf-8")
+ except (OSError) as e:
+ sys.exit(e)
+ except CalledProcessError as e:
+ sys.exit(f'{e}. Output:\n\n{e.output}')
+
+ found_gdb_archs = re.search(r'Valid arguments are (.*)', gdb_out)
- m = re.search(r"Valid arguments are (.*)",
- gdb_out.decode("utf-8"))
+ targets = set()
+ if found_gdb_archs:
+ gdb_archs = found_gdb_archs.group(1).split(", ")
+ mapped_gdb_archs = [arch for arch in gdb_archs if arch in MAP]
- valid_arches = set()
+ targets = {target for arch in mapped_gdb_archs for target in MAP[arch]}
- 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)
+ # QEMU targets
+ return targets
- return valid_arches
def main() -> None:
parser = argparse.ArgumentParser(description='Probe GDB Architectures')
--
2.39.5
- [PULL 00/17] testing, gdbstub and plugin updates, Alex Bennée, 2024/10/24
- [PULL 03/17] MAINTAINERS: mention my testing/next tree, Alex Bennée, 2024/10/24
- [PULL 04/17] meson: hide tsan related warnings, Alex Bennée, 2024/10/24
- [PULL 11/17] MAINTAINERS: mention my gdbstub/next tree, Alex Bennée, 2024/10/24
- [PULL 14/17] tests/tcg/aarch64: Use raw strings for regexes in test-mte.py, Alex Bennée, 2024/10/24
- [PULL 15/17] testing: Enhance gdb probe script,
Alex Bennée <=
- [PULL 17/17] plugins: fix qemu_plugin_reset, Alex Bennée, 2024/10/24
- [PULL 02/17] tests/docker: add NOFETCH env variable for testing, Alex Bennée, 2024/10/24
- [PULL 06/17] scripts/ci: remove architecture checks for build-environment updates, Alex Bennée, 2024/10/24
- [PULL 08/17] accel/tcg: add tracepoints for cpu_loop_exit_atomic, Alex Bennée, 2024/10/24
- [PULL 07/17] tests/tcg/x86_64: Add cross-modifying code test, Alex Bennée, 2024/10/24
- [PULL 13/17] tests/tcg: enable basic testing for aarch64_be-linux-user, Alex Bennée, 2024/10/24
- [PULL 09/17] dockerfiles: fix default targets for debian-loongarch-cross, Alex Bennée, 2024/10/24
- [PULL 05/17] docs/devel: update tsan build documentation, Alex Bennée, 2024/10/24
- [PULL 01/17] tests/docker: Fix microblaze atomics, Alex Bennée, 2024/10/24
- [PULL 10/17] gitlab: make check-[dco|patch] a little more verbose, Alex Bennée, 2024/10/24