gdbstub/next (cleanups, softmmu, SVE)
v2 cover gdbstub/next (cleanups, softmmu, SVE)
Hi,
This is the next iteration of gdbstub/next. Apart from adding review tags there are a few new patches:
- now the 8.3.1 gating is there we can revert the disable of gdbstub-sha1
- addition of some softmmu tests (which exercise watchpoints)
- moving the SVE target representation to org.gnu.gdb.aarch64.sve
The final patch allows GDB to do SVE aware handling of pseudo registers rather than treating the set as a custom target description. The following still need review:
- target/arm: use official org.gnu.gdb.aarch64.sve layout for registers
- gdbstub: implement a softmmu based test
- Revert "tests/tcg/multiarch/Makefile.target: Disable run-gdbstub-sha1 test"
- configure: gate our use of GDB to 8.3.1 or above
Alex Bennée (8):
test/guest-debug: echo QEMU command as well
configure: gate our use of GDB to 8.3.1 or above
Revert "tests/tcg/multiarch/Makefile.target: Disable run-gdbstub-sha1
test"
gdbstub: implement a softmmu based test
gdbstub: drop CPUEnv from gdb_exit()
gdbstub: drop gdbserver_cleanup in favour of gdb_exit
gdbstub: ensure we clean-up when terminated
target/arm: use official org.gnu.gdb.aarch64.sve layout for registers
Lirong Yuan (1):
gdbstub: add support to Xfer:auxv:read: packet
configure | 7 +- include/exec/gdbstub.h | 14 +- bsd-user/syscall.c | 6 +- gdbstub.c | 65 +++++++-- linux-user/exit.c | 2 +- softmmu/runstate.c | 2 +- target/arm/arm-semi.c | 2 +- target/arm/gdbstub.c | 75 ++++------ target/arm/helper.c | 2 +- target/m68k/m68k-semi.c | 2 +- target/nios2/nios2-semi.c | 2 +- MAINTAINERS | 1 + tests/guest-debug/run-test.py | 35 +++-- tests/tcg/aarch64/Makefile.softmmu-target | 1 + tests/tcg/aarch64/gdbstub/test-sve-ioctl.py | 11 ++ tests/tcg/aarch64/system/boot.S | 1 + tests/tcg/i386/Makefile.softmmu-target | 1 + tests/tcg/i386/system/boot.S | 2 +- tests/tcg/multiarch/Makefile.target | 13 +- tests/tcg/multiarch/gdbstub/memory.py | 130 ++++++++++++++++++ .../multiarch/gdbstub/test-qxfer-auxv-read.py | 57 ++++++++ .../multiarch/system/Makefile.softmmu-target | 19 ++- tests/tcg/x86_64/Makefile.softmmu-target | 1 + tests/tcg/x86_64/system/boot.S | 2 +- 24 files changed, 371 insertions(+), 82 deletions(-) create mode 100644 tests/tcg/multiarch/gdbstub/memory.py create mode 100644 tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py
Signature · 1 line
2.20.1
PATCH v2 1/9 test/guest-debug: echo QEMU command as well
This helps with debugging.
Message-Id: <[email protected]>
--- tests/guest-debug/run-test.py | 1 + 1 file changed, 1 insertion(+)
tests/guest-debug/run-test.py +1 -0
@@ -53,6 +53,7 @@ if __name__ == '__main__': cmd = "%s %s -g %s %s" % (args.qemu, args.qargs, socket_name, args.binary) + print("QEMU CMD: %s" % (cmd)) inferior = subprocess.Popen(shlex.split(cmd)) # Now launch gdb with our test and collect the result
Signature · 1 line
2.20.1
PATCH v2 2/9 configure: gate our use of GDB to 8.3.1 or above
In reply to Alex BennéeThe support of socket based debugging which we need for linux-user testing is only really stable as of 8.3.1 so lets gate our use of GDB on having a relatively modern version.
For direct testing you can just point to a locally compiled version of gdb via configure, e.g.:
../../configure --gdb=$HOME/src/binutils-gdb.git/builds/all/install/bin/gdb
Message-Id: <[email protected]>
---
v2
- reword intention
--- configure | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
configure +5 -2
@@ -6676,8 +6676,11 @@ if test "$plugins" = "yes" ; then fi fi -if test -n "$gdb_bin" ; then - echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak +if test -n "$gdb_bin"; then + gdb_version=$($gdb_bin --version | head -n 1) + if version_ge ${gdb_version##* } 8.3.1; then + echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak + fi fi if test "$secret_keyring" = "yes" ; then
Signature · 1 line
2.20.1
PATCH v2 3/9 Revert "tests/tcg/multiarch/Makefile.target: Disable run-gdbstub-sha1 test"
In reply to Alex BennéeWe won't attempt to run the test now it's gated on a newer version of gdb.
This reverts commit a930cadd83b4681a98ce72abf530a791ee2e42a6.
--- tests/tcg/multiarch/Makefile.target | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
tests/tcg/multiarch/Makefile.target +1 -3
@@ -54,9 +54,7 @@ run-gdbstub-sha1: sha1 --bin $< --test $(MULTIARCH_SRC)/gdbstub/sha1.py, \ "basic gdbstub support") -# Disable this for now -- it provokes a gdb internal-error on -# Ubuntu gdb 8.1.1-0ubuntu1. -# EXTRA_RUNS += run-gdbstub-sha1 +EXTRA_RUNS += run-gdbstub-sha1 endif
Signature · 1 line
2.20.1
PATCH v2 4/9 gdbstub: implement a softmmu based test
In reply to Alex BennéeThis adds a new tests that allows us to test softmmu only features including watchpoints. To do achieve this we need to:
- add _exit: labels to the boot codes
- write a memory.py test case
- plumb the test case into the build system
- tweak the run_test script to:
- re-direct output when asked
- use socket based connection for all tests
- add a small pause before connection
--- tests/guest-debug/run-test.py | 36 +++-- tests/tcg/aarch64/Makefile.softmmu-target | 1 + tests/tcg/aarch64/system/boot.S | 1 + tests/tcg/i386/Makefile.softmmu-target | 1 + tests/tcg/i386/system/boot.S | 2 +- tests/tcg/multiarch/gdbstub/memory.py | 130 ++++++++++++++++++ .../multiarch/system/Makefile.softmmu-target | 19 ++- tests/tcg/x86_64/Makefile.softmmu-target | 1 + tests/tcg/x86_64/system/boot.S | 2 +- 9 files changed, 181 insertions(+), 12 deletions(-) create mode 100644 tests/tcg/multiarch/gdbstub/memory.py
tests/guest-debug/run-test.py +27 -9
@@ -16,6 +16,7 @@ import subprocess import shutil import shlex import os +from time import sleep from tempfile import TemporaryDirectory def get_args():
@@ -27,10 +28,21 @@ def get_args(): required=True) parser.add_argument("--test", help="GDB test script", required=True) - parser.add_argument("--gdb", help="The gdb binary to use", default=None) + parser.add_argument("--gdb", help="The gdb binary to use", + default=None) + parser.add_argument("--output", help="A file to redirect output to") return parser.parse_args() + +def log(output, msg): + if output: + output.write(msg + "\n") + output.flush() + else: + print(msg) + + if __name__ == '__main__': args = get_args()
@@ -42,18 +54,25 @@ if __name__ == '__main__': if not args.gdb: print("We need gdb to run the test") exit(-1) + if args.output: + output = open(args.output, "w") + else: + output = None socket_dir = TemporaryDirectory("qemu-gdbstub") socket_name = os.path.join(socket_dir.name, "gdbstub.socket") # Launch QEMU with binary if "system" in args.qemu: - cmd = "%s %s %s -s -S" % (args.qemu, args.qargs, args.binary) + cmd = "%s %s %s -gdb unix:path=%s,server" % (args.qemu, + args.qargs, + args.binary, + socket_name) else: cmd = "%s %s -g %s %s" % (args.qemu, args.qargs, socket_name, args.binary) - print("QEMU CMD: %s" % (cmd)) + log(output, "QEMU CMD: %s" % (cmd)) inferior = subprocess.Popen(shlex.split(cmd)) # Now launch gdb with our test and collect the result
@@ -63,16 +82,15 @@ if __name__ == '__main__': # disable prompts in case of crash gdb_cmd += " -ex 'set confirm off'" # connect to remote - if "system" in args.qemu: - gdb_cmd += " -ex 'target remote localhost:1234'" - else: - gdb_cmd += " -ex 'target remote %s'" % (socket_name) + gdb_cmd += " -ex 'target remote %s'" % (socket_name) # finally the test script itself gdb_cmd += " -x %s" % (args.test) - print("GDB CMD: %s" % (gdb_cmd)) - result = subprocess.call(gdb_cmd, shell=True); + sleep(1) + log(output, "GDB CMD: %s" % (gdb_cmd)) + + result = subprocess.call(gdb_cmd, shell=True, stdout=output) # A negative result is the result of an internal gdb failure like # a crash. We force a return of 0 so we don't fail the test on
tests/tcg/aarch64/Makefile.softmmu-target +1 -0
@@ -15,6 +15,7 @@ CRT_PATH=$(AARCH64_SYSTEM_SRC) LINK_SCRIPT=$(AARCH64_SYSTEM_SRC)/kernel.ld LDFLAGS=-Wl,-T$(LINK_SCRIPT) TESTS+=$(AARCH64_TESTS) $(MULTIARCH_TESTS) +EXTRA_RUNS+=$(MULTIARCH_RUNS) CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC) LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
tests/tcg/aarch64/system/boot.S +1 -0
@@ -197,6 +197,7 @@ __start: bl main /* pass return value to sys exit */ +_exit: mov x1, x0 ldr x0, =0x20026 /* ADP_Stopped_ApplicationExit */ stp x0, x1, [sp, #-16]!
tests/tcg/i386/Makefile.softmmu-target +1 -0
@@ -19,6 +19,7 @@ CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC) LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc TESTS+=$(MULTIARCH_TESTS) +EXTRA_RUNS+=$(MULTIARCH_RUNS) # building head blobs .PRECIOUS: $(CRT_OBJS)
tests/tcg/i386/system/boot.S +1 -1
@@ -76,7 +76,7 @@ _start: */ call main - /* output any non-zero result in eax to isa-debug-exit device */ +_exit: /* output any non-zero result in eax to isa-debug-exit device */ test %al, %al jz 1f out %ax, $0xf4
tests/tcg/multiarch/gdbstub/memory.py new file +130 -0
130 lines not on this page · raw message
tests/tcg/multiarch/system/Makefile.softmmu-target +18 -1
@@ -7,8 +7,25 @@ # complications of building. # -MULTIARCH_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/multiarch/system +MULTIARCH_SRC=$(SRC_PATH)/tests/tcg/multiarch +MULTIARCH_SYSTEM_SRC=$(MULTIARCH_SRC)/system VPATH+=$(MULTIARCH_SYSTEM_SRC) MULTIARCH_TEST_SRCS=$(wildcard $(MULTIARCH_SYSTEM_SRC)/*.c) MULTIARCH_TESTS = $(patsubst $(MULTIARCH_SYSTEM_SRC)/%.c, %, $(MULTIARCH_TEST_SRCS)) + +ifneq ($(HAVE_GDB_BIN),) +GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py + +run-gdbstub-memory: memory + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(HAVE_GDB_BIN) \ + --qemu $(QEMU) \ + --output $<.gdb.out \ + --qargs \ + "-monitor none -display none -chardev file$(COMMA)path=$<.out$(COMMA)id=output $(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/memory.py, \ + "softmmu gdbstub support") + +MULTIARCH_RUNS += run-gdbstub-memory +endif
tests/tcg/x86_64/Makefile.softmmu-target +1 -0
@@ -19,6 +19,7 @@ CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC) LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc TESTS+=$(MULTIARCH_TESTS) +EXTRA_RUNS+=$(MULTIARCH_RUNS) # building head blobs .PRECIOUS: $(CRT_OBJS)
tests/tcg/x86_64/system/boot.S +1 -1
@@ -124,7 +124,7 @@ _start: /* don't worry about stack frame, assume everthing is garbage when we return */ call main - /* output any non-zero result in eax to isa-debug-exit device */ +_exit: /* output any non-zero result in eax to isa-debug-exit device */ test %al, %al jz 1f out %ax, $0xf4
Signature · 1 line
2.20.1
Re: [PATCH v2 4/9] gdbstub: implement a softmmu based test
Quoted 40 lines · Alex Bennée
This adds a new tests that allows us to test softmmu only features including watchpoints. To do achieve this we need to:
- add
_exit: labels to the boot codes
- write amemory.pytest case
- plumb the test case into the build system
- tweak therun_testscript to:
- re-direct output when asked
- use socket based connection for all tests
- add a small pause before connectionSigned-off-by Alex Bennée <[email protected]>--- tests/guest-debug/run-test.py | 36 +++-- tests/tcg/aarch64/Makefile.softmmu-target | 1 + tests/tcg/aarch64/system/boot.S | 1 + tests/tcg/i386/Makefile.softmmu-target | 1 + tests/tcg/i386/system/boot.S | 2 +- tests/tcg/multiarch/gdbstub/memory.py | 130 ++++++++++++++++++ .../multiarch/system/Makefile.softmmu-target | 19 ++- tests/tcg/x86_64/Makefile.softmmu-target | 1 + tests/tcg/x86_64/system/boot.S | 2 +- 9 files changed, 181 insertions(+), 12 deletions(-) create mode 100644 tests/tcg/multiarch/gdbstub/memory.pytests/guest-debug/run-test.py +1
-0@@ -16,6 +16,7 @@ import subprocess import shutil import shlex import os +from time import sleep from tempfile import TemporaryDirectory def get_args():@@ -27,10 +28,21 @@ def get_args(): required=True) parser.add_argument("--test", help="GDB test script",
tests/guest-debug/run-test.py def get_args(): · line 38
Quoted 10 lines
tests/guest-debug/run-test.py +5
-1required=True) - parser.add_argument("--gdb", help="The gdb binary to use", default=None) + parser.add_argument("--gdb", help="The gdb binary to use", + default=None) + parser.add_argument("--output", help="A file to redirect output to") return parser.parse_args() + +def log(output, msg):
Maybe simplify as:
def log(msg, out=sys.stdout):
output.write(msg + "\n")
output.flush()Quoted 19 lines
tests/guest-debug/run-test.py +11
-0+ if output: + output.write(msg + "\n") + output.flush() + else: + print(msg) + + if __name__ == '__main__': args = get_args()@@ -42,18 +54,25 @@ if __name__ == '__main__': if not args.gdb: print("We need gdb to run the test") exit(-1) + if args.output: + output = open(args.output, "w") + else: + output = None
tests/guest-debug/run-test.py if __name__ == '__main__': · line 70
Quoted 10 lines
tests/guest-debug/run-test.py +4
-1socket_dir = TemporaryDirectory("qemu-gdbstub") socket_name = os.path.join(socket_dir.name, "gdbstub.socket") # Launch QEMU with binary if "system" in args.qemu: - cmd = "%s %s %s -s -S" % (args.qemu, args.qargs, args.binary) + cmd = "%s %s %s -gdb unix:path=%s,server" % (args.qemu, + args.qargs, + args.binary, + socket_name)
What about Windows hosts?
Quoted 86 lines
tests/guest-debug/run-test.py +6
-7else: cmd = "%s %s -g %s %s" % (args.qemu, args.qargs, socket_name, args.binary) - print("QEMU CMD: %s" % (cmd)) + log(output, "QEMU CMD: %s" % (cmd)) inferior = subprocess.Popen(shlex.split(cmd)) # Now launch gdb with our test and collect the result@@ -63,16 +82,15 @@ if __name__ == '__main__': # disable prompts in case of crash gdb_cmd += " -ex 'set confirm off'" # connect to remote - if "system" in args.qemu: - gdb_cmd += " -ex 'target remote localhost:1234'" - else: - gdb_cmd += " -ex 'target remote %s'" % (socket_name) + gdb_cmd += " -ex 'target remote %s'" % (socket_name) # finally the test script itself gdb_cmd += " -x %s" % (args.test) - print("GDB CMD: %s" % (gdb_cmd)) - result = subprocess.call(gdb_cmd, shell=True); + sleep(1) + log(output, "GDB CMD: %s" % (gdb_cmd)) + + result = subprocess.call(gdb_cmd, shell=True, stdout=output) # A negative result is the result of an internal gdb failure like # a crash. We force a return of 0 so we don't fail the test ontests/tcg/aarch64/Makefile.softmmu-target +1
-0@@ -15,6 +15,7 @@ CRT_PATH=$(AARCH64_SYSTEM_SRC) LINK_SCRIPT=$(AARCH64_SYSTEM_SRC)/kernel.ld LDFLAGS=-Wl,-T$(LINK_SCRIPT) TESTS+=$(AARCH64_TESTS) $(MULTIARCH_TESTS) +EXTRA_RUNS+=$(MULTIARCH_RUNS) CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC) LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcctests/tcg/aarch64/system/boot.S +1
-0@@ -197,6 +197,7 @@ __start: bl main /* pass return value to sys exit */ +_exit: mov x1, x0 ldr x0, =0x20026 /* ADP_Stopped_ApplicationExit */ stp x0, x1, [sp, #-16]!tests/tcg/i386/Makefile.softmmu-target +1
-0@@ -19,6 +19,7 @@ CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC) LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc TESTS+=$(MULTIARCH_TESTS) +EXTRA_RUNS+=$(MULTIARCH_RUNS) # building head blobs .PRECIOUS: $(CRT_OBJS)tests/tcg/i386/system/boot.S +1
-1@@ -76,7 +76,7 @@ _start: */ call main - /* output any non-zero result in eax to isa-debug-exit device */ +_exit: /* output any non-zero result in eax to isa-debug-exit device */ test %al, %al jz 1f out %ax, $0xf4tests/tcg/multiarch/gdbstub/memory.py new file +0
-0
tests/tcg/multiarch/gdbstub/memory.py line 1
Quoted 1 line
tests/tcg/multiarch/gdbstub/memory.py new file +1
-0@@ -0,0 +1,130 @@ +from __future__ import print_function
Missing license.
Quoted 37 lines
tests/tcg/multiarch/gdbstub/memory.py new file +37
-0+# +# Test some of the softmmu debug features with the multiarch memory +# test. It is a port of the original vmlinux focused test case but +# using the "memory" test instead. +# +# This is launched via tests/guest-debug/run-test.py +# + +import gdb +import sys + +failcount = 0 + + +def report(cond, msg): + "Report success/fail of test" + if cond: + print("PASS: %s" % (msg)) + else: + print("FAIL: %s" % (msg)) + global failcount + failcount += 1 + + +def check_step(): + "Step an instruction, check it moved." + start_pc = gdb.parse_and_eval('$pc') + gdb.execute("si") + end_pc = gdb.parse_and_eval('$pc') + + return not (start_pc == end_pc) + + +# +# Currently it's hard to create a hbreak with the pure python API and +# manually matching PC to symbol address is a bit flaky thanks to +# function prologues. However internally QEMU's gdbstub treats them
tests/tcg/multiarch/gdbstub/memory.py line 48
Quoted 10 lines
tests/tcg/multiarch/gdbstub/memory.py new file +10
-0+# the same as normal breakpoints so it will do for now. +# +def check_break(sym_name): + "Setup breakpoint, continue and check we stopped." + sym, ok = gdb.lookup_symbol(sym_name) + bp = gdb.Breakpoint(sym_name, gdb.BP_BREAKPOINT) + + gdb.execute("c") + + # hopefully we came back
What if we don't? Not a blocking problem today, we'll figure if we need to improve that later.
Quoted 131 lines
tests/tcg/multiarch/gdbstub/memory.py new file +82
-0+ end_pc = gdb.parse_and_eval('$pc') + report(bp.hit_count == 1, + "break @ %s (%s %d hits)" % (end_pc, sym.value(), bp.hit_count)) + + bp.delete() + + +def do_one_watch(sym, wtype, text): + + wp = gdb.Breakpoint(sym, gdb.BP_WATCHPOINT, wtype) + gdb.execute("c") + report_str = "%s for %s" % (text, sym) + + if wp.hit_count > 0: + report(True, report_str) + wp.delete() + else: + report(False, report_str) + + +def check_watches(sym_name): + "Watch a symbol for any access." + + # Should hit for any read + do_one_watch(sym_name, gdb.WP_ACCESS, "awatch") + + # Again should hit for reads + do_one_watch(sym_name, gdb.WP_READ, "rwatch") + + # Finally when it is written + do_one_watch(sym_name, gdb.WP_WRITE, "watch") + + +def run_test(): + "Run through the tests one by one" + + print("Checking we can step the first few instructions") + step_ok = 0 + for i in range(3): + if check_step(): + step_ok += 1 + + report(step_ok == 3, "single step in boot code") + + # If we get here we have missed some of the other breakpoints. + print("Setup catch-all for _exit") + cbp = gdb.Breakpoint("_exit", gdb.BP_BREAKPOINT) + + check_break("main") + check_watches("test_data[128]") + + report(cbp.hit_count == 0, "didn't reach backstop") + +# +# This runs as the script it sourced (via -x, via run-test.py) +# +try: + inferior = gdb.selected_inferior() + arch = inferior.architecture() + print("ATTACHED: %s" % arch.name()) +except (gdb.error, AttributeError): + print("SKIPPING (not connected)", file=sys.stderr) + exit(0) + +if gdb.parse_and_eval('$pc') == 0: + print("SKIP: PC not set") + exit(0) + +try: + # These are not very useful in scripts + gdb.execute("set pagination off") + + # Run the actual tests + run_test() +except (gdb.error): + print("GDB Exception: %s" % (sys.exc_info()[0])) + failcount += 1 + pass + +# Finally kill the inferior and exit gdb with a count of failures +gdb.execute("kill") +exit(failcount)tests/tcg/multiarch/system/Makefile.softmmu-target +18
-1@@ -7,8 +7,25 @@ # complications of building. # -MULTIARCH_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/multiarch/system +MULTIARCH_SRC=$(SRC_PATH)/tests/tcg/multiarch +MULTIARCH_SYSTEM_SRC=$(MULTIARCH_SRC)/system VPATH+=$(MULTIARCH_SYSTEM_SRC) MULTIARCH_TEST_SRCS=$(wildcard $(MULTIARCH_SYSTEM_SRC)/*.c) MULTIARCH_TESTS = $(patsubst $(MULTIARCH_SYSTEM_SRC)/%.c, %, $(MULTIARCH_TEST_SRCS)) + +ifneq ($(HAVE_GDB_BIN),) +GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py + +run-gdbstub-memory: memory + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(HAVE_GDB_BIN) \ + --qemu $(QEMU) \ + --output $<.gdb.out \ + --qargs \ + "-monitor none -display none -chardev file$(COMMA)path=$<.out$(COMMA)id=output $(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/memory.py, \ + "softmmu gdbstub support") + +MULTIARCH_RUNS += run-gdbstub-memory +endiftests/tcg/x86_64/Makefile.softmmu-target +1
-0@@ -19,6 +19,7 @@ CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC) LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc TESTS+=$(MULTIARCH_TESTS) +EXTRA_RUNS+=$(MULTIARCH_RUNS) # building head blobs .PRECIOUS: $(CRT_OBJS)tests/tcg/x86_64/system/boot.S +0
-0
tests/tcg/x86_64/system/boot.S _start: · line 130
Quoted 8 lines
tests/tcg/x86_64/system/boot.S +1
-1@@ -124,7 +124,7 @@ _start: /* don't worry about stack frame, assume everthing is garbage when we return */ call main - /* output any non-zero result in eax to isa-debug-exit device */ +_exit: /* output any non-zero result in eax to isa-debug-exit device */ test %al, %al jz 1f out %ax, $0xf4
LGTM. With license:
PATCH v2 5/9 gdbstub: add support to Xfer:auxv:read: packet
In reply to Alex BennéeFrom: Lirong Yuan <[email protected]>
This allows gdb to access the target’s auxiliary vector, which can be helpful for telling system libraries important details about the hardware, operating system, and process.
[AJB: minor tweaks to test case, update MAINTAINERS]
Message-Id: <[email protected]>
Message-Id: <[email protected]>
--- gdbstub.c | 54 ++++++++++++++++++ MAINTAINERS | 1 + tests/tcg/multiarch/Makefile.target | 9 +++ .../multiarch/gdbstub/test-qxfer-auxv-read.py | 57 +++++++++++++++++++ 4 files changed, 121 insertions(+) create mode 100644 tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py
gdbstub.c +54 -0
@@ -2172,6 +2172,12 @@ static void handle_query_supported(GdbCmdContext *gdb_ctx, void *user_ctx) ";ReverseStep+;ReverseContinue+"); } +#ifdef CONFIG_USER_ONLY +if (gdbserver_state.c_cpu->opaque) { +g_string_append (gdbserver_state.str_buf,";qXfer:auxv:read+" ); + } +#endif +if (gdb_ctx->num_params &&strstr (gdb_ctx->params[0 ].data,"multiprocess+" )) { gdbserver_state.multiprocess = true;
@@ -2233,6 +2239,46 @@ static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_ctx) gdbserver_state.str_buf->len, true); } +#ifdef CONFIG_USER_ONLY +static void handle_query_xfer_auxv (GdbCmdContext *gdb_ctx,void *user_ctx) +{ +TaskState *ts; +unsigned long offset, len, saved_auxv, auxv_len; +const char *mem; + +if (gdb_ctx->num_params <2 ) { +put_packet ("E22" ); +return ; + } + + offset = gdb_ctx->params[0 ].val_ul; + len = gdb_ctx->params[1 ].val_ul; + ts = gdbserver_state.c_cpu->opaque; + saved_auxv = ts->info->saved_auxv; + auxv_len = ts->info->auxv_len; + mem = (const char *)(saved_auxv + offset); +if (offset > auxv_len) { +put_packet ("E00" ); +return ; + } + +if (len > (MAX_PACKET_LENGTH -5 ) /2 ) { + len = (MAX_PACKET_LENGTH -5 ) /2 ; + } + +if (len < auxv_len - offset) { +g_string_assign (gdbserver_state.str_buf,"m" ); +memtox (gdbserver_state.str_buf, mem, len); + }else { +g_string_assign (gdbserver_state.str_buf,"l" ); +memtox (gdbserver_state.str_buf, mem, auxv_len - offset); + } + +put_packet_binary (gdbserver_state.str_buf->str, + gdbserver_state.str_buf->len, true); +} +#endif +static void handle_query_attached (GdbCmdContext *gdb_ctx,void *user_ctx) {put_packet (GDB_ATTACHED );
@@ -2338,6 +2384,14 @@ static GdbCmdParseEntry gdb_gen_query_table[] = { .cmd_startswith = 1, .schema = "s:l,l0" }, +#ifdef CONFIG_USER_ONLY + { + .handler = handle_query_xfer_auxv, + .cmd = "Xfer:auxv:read::", + .cmd_startswith = 1, + .schema = "l,l0" + }, +#endif { .handler = handle_query_attached, .cmd = "Attached:",
MAINTAINERS +1 -0
@@ -2311,6 +2311,7 @@ R: Philippe Mathieu-Daudé <[email protected]> S: Maintained F: gdbstub* F: gdb-xml/ +F: tests/tcg/multiarch/gdbstub/ Memory API M: Paolo Bonzini <[email protected]>
tests/tcg/multiarch/Makefile.target +9 -0
@@ -55,6 +55,15 @@ run-gdbstub-sha1: sha1 "basic gdbstub support") EXTRA_RUNS += run-gdbstub-sha1 + +run-gdbstub-qxfer-auxv-read: sha1 + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(HAVE_GDB_BIN) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-auxv-read.py, \ + "basic gdbstub qXfer:auxv:read support") + +EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read endif
tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py new file +57 -0
57 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v2 6/9 gdbstub: drop CPUEnv from gdb_exit()
In reply to Alex Bennéegdb_exit() has never needed anything from env and I doubt we are going to start now.
Message-Id: <[email protected]>
--- include/exec/gdbstub.h | 2 +- bsd-user/syscall.c | 6 +++--- gdbstub.c | 2 +- linux-user/exit.c | 2 +- target/arm/arm-semi.c | 2 +- target/m68k/m68k-semi.c | 2 +- target/nios2/nios2-semi.c | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-)
include/exec/gdbstub.h +1 -1
@@ -46,7 +46,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);void gdb_do_syscallv (gdb_syscall_complete_cb cb,const char *fmt,va_list va);int use_gdb_syscalls (void );void gdb_set_stop_cpu (CPUState *cpu); -void gdb_exit (CPUArchState *,int ); +void gdb_exit (int );#ifdef CONFIG_USER_ONLY /** * gdb_handlesig: yield control to gdb
bsd-user/syscall.c +3 -3
@@ -333,7 +333,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,#ifdef CONFIG_GPROF _mcleanup ();#endif -gdb_exit (cpu_env, arg1); +gdb_exit (arg1);qemu_plugin_atexit_cb ();/* XXX: should free thread stack and CPU env */ _exit (arg1);
@@ -435,7 +435,7 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1,#ifdef CONFIG_GPROF _mcleanup ();#endif -gdb_exit (cpu_env, arg1); +gdb_exit (arg1);qemu_plugin_atexit_cb ();/* XXX: should free thread stack and CPU env */ _exit (arg1);
@@ -514,7 +514,7 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,#ifdef CONFIG_GPROF _mcleanup ();#endif -gdb_exit (cpu_env, arg1); +gdb_exit (arg1);qemu_plugin_atexit_cb ();/* XXX: should free thread stack and CPU env */ _exit (arg1);
gdbstub.c +1 -1
@@ -3068,7 +3068,7 @@ static void gdb_read_byte(uint8_t ch) }/* Tell the remote gdb that the process has exited. */ -void gdb_exit (CPUArchState *env,int code) +void gdb_exit (int code) {char buf[4 ];
linux-user/exit.c +1 -1
@@ -34,6 +34,6 @@ void preexit_cleanup(CPUArchState *env, int code)#ifdef CONFIG_GCOV __gcov_dump ();#endif -gdb_exit (env, code); +gdb_exit (code);qemu_plugin_atexit_cb (); }
target/arm/arm-semi.c +1 -1
@@ -1101,7 +1101,7 @@ target_ulong do_arm_semihosting(CPUARMState *env)*/ ret = (args == ADP_Stopped_ApplicationExit) ?0 :1 ; } -gdb_exit (env, ret); +gdb_exit (ret);exit (ret);case TARGET_SYS_SYNCCACHE :/*
target/m68k/m68k-semi.c +1 -1
@@ -195,7 +195,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr) args = env->dregs[1 ];switch (nr) {case HOSTED_EXIT : -gdb_exit (env, env->dregs[0 ]); +gdb_exit (env->dregs[0 ]);exit (env->dregs[0 ]);case HOSTED_OPEN :GET_ARG (0 );
target/nios2/nios2-semi.c +1 -1
@@ -215,7 +215,7 @@ void do_nios2_semihosting(CPUNios2State *env) args = env->regs[R_ARG1 ];switch (nr) {case HOSTED_EXIT : -gdb_exit (env, env->regs[R_ARG0 ]); +gdb_exit (env->regs[R_ARG0 ]);exit (env->regs[R_ARG0 ]);case HOSTED_OPEN :GET_ARG (0 );
Signature · 1 line
2.20.1
Re: [PATCH v2 6/9] gdbstub: drop CPUEnv from gdb_exit()
Le 18/12/2020 à 12:27, Alex Bennée a écrit :
Quoted 118 lines
gdb_exit()has never needed anything from env and I doubt we are going to start now.Signed-off-by Alex Bennée <[email protected]>Reviewed-by Richard Henderson <[email protected]>Message-Id: <[email protected]>
Signed-off-by Alex Bennée <[email protected]>--- include/exec/gdbstub.h | 2 +- bsd-user/syscall.c | 6 +++--- gdbstub.c | 2 +- linux-user/exit.c | 2 +- target/arm/arm-semi.c | 2 +- target/m68k/m68k-semi.c | 2 +- target/nios2/nios2-semi.c | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-)include/exec/gdbstub.h +1
-1@@ -46,7 +46,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);void gdb_do_syscallv (gdb_syscall_complete_cb cb,const char *fmt,va_list va);int use_gdb_syscalls (void );void gdb_set_stop_cpu (CPUState *cpu); -void gdb_exit (CPUArchState *,int ); +void gdb_exit (int );#ifdef CONFIG_USER_ONLY /** * gdb_handlesig: yield control to gdb bsd-user/syscall.c +3
-3@@ -333,7 +333,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,#ifdef CONFIG_GPROF _mcleanup ();#endif -gdb_exit (cpu_env, arg1); +gdb_exit (arg1);qemu_plugin_atexit_cb ();/* XXX: should free thread stack and CPU env */ _exit (arg1);@@ -435,7 +435,7 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1,#ifdef CONFIG_GPROF _mcleanup ();#endif -gdb_exit (cpu_env, arg1); +gdb_exit (arg1);qemu_plugin_atexit_cb ();/* XXX: should free thread stack and CPU env */ _exit (arg1);@@ -514,7 +514,7 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,#ifdef CONFIG_GPROF _mcleanup ();#endif -gdb_exit (cpu_env, arg1); +gdb_exit (arg1);qemu_plugin_atexit_cb ();/* XXX: should free thread stack and CPU env */ _exit (arg1);gdbstub.c +1
-1@@ -3068,7 +3068,7 @@ static void gdb_read_byte(uint8_t ch) }/* Tell the remote gdb that the process has exited. */ -void gdb_exit (CPUArchState *env,int code) +void gdb_exit (int code) {char buf[4 ];linux-user/exit.c +1
-1@@ -34,6 +34,6 @@ void preexit_cleanup(CPUArchState *env, int code)#ifdef CONFIG_GCOV __gcov_dump ();#endif -gdb_exit (env, code); +gdb_exit (code);qemu_plugin_atexit_cb (); }target/arm/arm-semi.c +1
-1@@ -1101,7 +1101,7 @@ target_ulong do_arm_semihosting(CPUARMState *env)*/ ret = (args == ADP_Stopped_ApplicationExit) ?0 :1 ; } -gdb_exit (env, ret); +gdb_exit (ret);exit (ret);case TARGET_SYS_SYNCCACHE :/* target/m68k/m68k-semi.c +1
-1@@ -195,7 +195,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr) args = env->dregs[1 ];switch (nr) {case HOSTED_EXIT : -gdb_exit (env, env->dregs[0 ]); +gdb_exit (env->dregs[0 ]);exit (env->dregs[0 ]);case HOSTED_OPEN :GET_ARG (0 );target/nios2/nios2-semi.c +0
-0
target/nios2/nios2-semi.c void do_nios2_semihosting(CPUNios2State *env) · line 221
Quoted 8 lines
target/nios2/nios2-semi.c +1
-1@@ -215,7 +215,7 @@ void do_nios2_semihosting(CPUNios2State *env) args = env->regs[R_ARG1 ];switch (nr) {case HOSTED_EXIT : -gdb_exit (env, env->regs[R_ARG0 ]); +gdb_exit (env->regs[R_ARG0 ]);exit (env->regs[R_ARG0 ]);case HOSTED_OPEN :GET_ARG (0 );
Re: [PATCH v2 6/9] gdbstub: drop CPUEnv from gdb_exit()
In reply to Alex BennéeQuoted 7 lines · Alex Bennée
gdb_exit()has never needed anything from env and I doubt we are going to start now.Signed-off-by Alex Bennée <[email protected]>Reviewed-by Richard Henderson <[email protected]>Message-Id: <[email protected]>
Signed-off-by Alex Bennée <[email protected]>
Quoted 9 lines
--- include/exec/gdbstub.h | 2 +- bsd-user/syscall.c | 6 +++--- gdbstub.c | 2 +- linux-user/exit.c | 2 +- target/arm/arm-semi.c | 2 +- target/m68k/m68k-semi.c | 2 +- target/nios2/nios2-semi.c | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-)
PATCH v2 7/9 gdbstub: drop gdbserver_cleanup in favour of gdb_exit
In reply to Alex BennéeDespite it's name it didn't actually clean-up so let us document gdb_exit() better and use that.
Message-Id: <[email protected]>
--- include/exec/gdbstub.h | 14 +++++++++++--- gdbstub.c | 7 ------- softmmu/runstate.c | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-)
include/exec/gdbstub.h +11 -3
@@ -46,7 +46,17 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);void gdb_do_syscallv (gdb_syscall_complete_cb cb,const char *fmt,va_list va);int use_gdb_syscalls (void );void gdb_set_stop_cpu (CPUState *cpu); -void gdb_exit (int ); + +/** +* gdb_exit: exit gdb session, reporting inferior status +* @code: exit code reported +* +* This closes the session and sends a final packet to GDB reporting +* the exit status of the program. It also cleans up any connections +* detritus before returning. +*/ +void gdb_exit (int code); +#ifdef CONFIG_USER_ONLY /** * gdb_handlesig: yield control to gdb
@@ -187,8 +197,6 @@ static inline uint8_t * gdb_get_reg_ptr(GByteArray *buf, int len)*/ int gdbserver_start (const char *port_or_device); -void gdbserver_cleanup (void ); -/** * gdb_has_xml: * This is an ugly hack to cope with both new and old gdb.
gdbstub.c +0 -7
@@ -3547,13 +3547,6 @@ int gdbserver_start(const char *device)return 0 ; } -void gdbserver_cleanup (void ) -{ -if (gdbserver_state.init) { -put_packet ("W00" ); - } -} -static void register_types (void ) {type_register_static (&char_gdb_type_info);
softmmu/runstate.c +1 -1
@@ -775,7 +775,7 @@ void qemu_init_subsystems(void)void qemu_cleanup (void ) { -gdbserver_cleanup (); +gdb_exit (0 );/* * cleaning up the migration object cancels any existing migration
Signature · 1 line
2.20.1
Re: [PATCH v2 7/9] gdbstub: drop gdbserver_cleanup in favour of gdb_exit
Quoted 5 lines · Alex Bennée
Despite it's name it didn't actually clean-up so let us document
gdb_exit()better and use that.Signed-off-by Alex Bennée <[email protected]>Reviewed-by Richard Henderson <[email protected]>
Quoted 7 lines
Message-Id: <[email protected]>
Signed-off-by Alex Bennée <[email protected]>--- include/exec/gdbstub.h | 14 +++++++++++--- gdbstub.c | 7 ------- softmmu/runstate.c | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-)
PATCH v2 8/9 gdbstub: ensure we clean-up when terminated
In reply to Alex BennéeIf you kill the inferior from GDB we end up leaving our socket lying around. Fix this by calling gdb_exit() first.
Message-Id: <[email protected]>
--- gdbstub.c | 2 ++ 1 file changed, 2 insertions(+)
gdbstub.c +2 -0
@@ -1978,6 +1978,7 @@ static void handle_v_kill(GdbCmdContext *gdb_ctx, void *user_ctx)/* Kill the target */ put_packet ("OK" );error_report ("QEMU: Terminated via GDBstub" ); +gdb_exit (0 );exit (0 ); }
@@ -2539,6 +2540,7 @@ static int gdb_handle_packet(const char *line_buf)case 'k' :/* Kill the target */ error_report ("QEMU: Terminated via GDBstub" ); +gdb_exit (0 );exit (0 );case 'D' : {
Signature · 1 line
2.20.1
Re: [PATCH v2 8/9] gdbstub: ensure we clean-up when terminated
Quoted 10 lines · Alex Bennée
If you kill the inferior from GDB we end up leaving our socket lying around. Fix this by calling
gdb_exit()first.Signed-off-by Alex Bennée <[email protected]>Reviewed-by Richard Henderson <[email protected]>Message-Id: <[email protected]>
Signed-off-by Alex Bennée <[email protected]>--- gdbstub.c | 2 ++ 1 file changed, 2 insertions(+)
PATCH v2 9/9 target/arm: use official org.gnu.gdb.aarch64.sve layout for registers
In reply to Alex BennéeWhile GDB can work with any XML description given to it there is special handling for SVE registers on the GDB side which makes the users life a little better. The changes aren't that major and all the registers save the $vg reported the same. All that changes is:
- report org.gnu.gdb.aarch64.sve
- use gdb nomenclature for names and types
- minor re-ordering of the types to match reference
- re-enable ieee_half (as we know gdb supports it now)
- $vg is now a 64 bit int
- check $vN and $zN aliasing in test
[NOTE: there seems a limitation on the indexing of the pseudo $vN registers which I'm not sure if it's intentional]
--- target/arm/gdbstub.c | 75 ++++++++------------- target/arm/helper.c | 2 +- tests/tcg/aarch64/gdbstub/test-sve-ioctl.py | 11 +++ 3 files changed, 41 insertions(+), 47 deletions(-)
target/arm/gdbstub.c +29 -46
@@ -195,22 +195,17 @@ static const struct TypeSize vec_lanes[] = { { "uint128", 128, 'q', 'u' }, { "int128", 128, 'q', 's' },/* 64 bit */ + { "ieee_double", 64, 'd', 'f' }, { "uint64", 64, 'd', 'u' }, { "int64", 64, 'd', 's' }, - { "ieee_double", 64, 'd', 'f' },/* 32 bit */ + { "ieee_single", 32, 's', 'f' }, { "uint32", 32, 's', 'u' }, { "int32", 32, 's', 's' }, - { "ieee_single", 32, 's', 'f' },/* 16 bit */ + { "ieee_half", 16, 'h', 'f' }, { "uint16", 16, 'h', 'u' }, { "int16", 16, 'h', 's' }, -/* -* TODO: currently there is no reliable way of telling -* if the remote gdb actually understands ieee_half so -* we don't expose it in the target description for now. -* { "ieee_half", 16, 'h', 'f' }, -*/ /* bytes */ { "uint8", 8, 'b', 'u' }, { "int8", 8, 'b', 's' },
@@ -223,17 +218,16 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg)GString *s =g_string_new (NULL );DynamicGDBXMLInfo *info = &cpu->dyn_svereg_xml;g_autoptr (GString) ts =g_string_new ("" ); -int i, bits, reg_width = (cpu->sve_max_vq *128 ); +int i, j, bits, reg_width = (cpu->sve_max_vq *128 ); info->num =0 ;g_string_printf (s,"<?xml version=\"1.0\"?>" );g_string_append_printf (s,"<!DOCTYPE target SYSTEM \"gdb-target.dtd\">" ); -g_string_append_printf (s,"<feature name=\"org.qemu.gdb.aarch64.sve\">" ); +g_string_append_printf (s,"<feature name=\"org.gnu.gdb.aarch64.sve\">" );/* First define types and totals in a whole VL */ for (i =0 ; i <ARRAY_SIZE (vec_lanes); i++) {int count = reg_width / vec_lanes[i].size; -g_string_printf (ts,"vq%d%c%c" , count, - vec_lanes[i].sz, vec_lanes[i].suffix); +g_string_printf (ts,"svev%c%c" , vec_lanes[i].sz, vec_lanes[i].suffix);g_string_append_printf (s,"<vector id=\"%s\" type=\"%s\" count=\"%d\"/>" , ts->str, vec_lanes[i].gdb_type, count);
@@ -243,39 +237,37 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg)* signed and potentially float versions of each size from 128 to * 8 bits. */ -for (bits =128 ; bits >=8 ; bits /=2 ) { -int count = reg_width / bits; -g_string_append_printf (s,"<union id=\"vq%dn\">" , count); -for (i =0 ; i <ARRAY_SIZE (vec_lanes); i++) { -if (vec_lanes[i].size == bits) { -g_string_append_printf (s,"<field name=\"%c\" type=\"vq%d%c%c\"/>" , - vec_lanes[i].suffix, - count, - vec_lanes[i].sz, vec_lanes[i].suffix); +for (bits =128 , i =0 ; bits >=8 ; bits /=2 , i++) { +const char suf[] = {'q' ,'d' ,'s' ,'h' ,'b' }; +g_string_append_printf (s,"<union id=\"svevn%c\">" , suf[i]); +for (j =0 ; j <ARRAY_SIZE (vec_lanes); j++) { +if (vec_lanes[j].size == bits) { +g_string_append_printf (s,"<field name=\"%c\" type=\"svev%c%c\"/>" , + vec_lanes[j].suffix, + vec_lanes[j].sz, vec_lanes[j].suffix); } }g_string_append (s,"</union>" ); }/* And now the final union of unions */ -g_string_append (s,"<union id=\"vq\">" ); -for (bits =128 ; bits >=8 ; bits /=2 ) { -int count = reg_width / bits; -for (i =0 ; i <ARRAY_SIZE (vec_lanes); i++) { -if (vec_lanes[i].size == bits) { -g_string_append_printf (s,"<field name=\"%c\" type=\"vq%dn\"/>" , - vec_lanes[i].sz, count); -break ; - } - } +g_string_append (s,"<union id=\"svev\">" ); +for (bits =128 , i =0 ; bits >=8 ; bits /=2 , i++) { +const char suf[] = {'q' ,'d' ,'s' ,'h' ,'b' }; +g_string_append_printf (s,"<field name=\"%c\" type=\"svevn%c\"/>" , + suf[i], suf[i]); }g_string_append (s,"</union>" ); +/* Finally the sve prefix type */ +g_string_append_printf (s, +"<vector id=\"svep\" type=\"uint8\" count=\"%d\"/>" , + reg_width /8 ); +/* Then define each register in parts for each vq */ for (i =0 ; i <32 ; i++) {g_string_append_printf (s,"<reg name=\"z%d\" bitsize=\"%d\"" -" regnum=\"%d\" group=\"vector\"" -" type=\"vq\"/>" , +" regnum=\"%d\" type=\"svev\"/>" , i, reg_width, base_reg++); info->num++; }
@@ -287,31 +279,22 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg)" regnum=\"%d\" group=\"float\"" " type=\"int\"/>", base_reg++); info->num +=2 ; -/* -* Predicate registers aren't so big they are worth splitting up -* but we do need to define a type to hold the array of quad -* references. -*/ -g_string_append_printf (s, -"<vector id=\"vqp\" type=\"uint16\" count=\"%d\"/>" , - cpu->sve_max_vq); +for (i =0 ; i <16 ; i++) {g_string_append_printf (s,"<reg name=\"p%d\" bitsize=\"%d\"" -" regnum=\"%d\" group=\"vector\"" -" type=\"vqp\"/>" , +" regnum=\"%d\" type=\"svep\"/>" , i, cpu->sve_max_vq *16 , base_reg++); info->num++; }g_string_append_printf (s,"<reg name=\"ffr\" bitsize=\"%d\"" " regnum=\"%d\" group=\"vector\"" -" type=\"vqp\"/>" , +" type=\"svep\"/>" , cpu->sve_max_vq *16 , base_reg++);g_string_append_printf (s,"<reg name=\"vg\" bitsize=\"64\"" -" regnum=\"%d\" group=\"vector\"" -" type=\"uint32\"/>" , +" regnum=\"%d\" type=\"int\"/>" , base_reg++); info->num +=2 ;g_string_append_printf (s,"</feature>" );
target/arm/helper.c +1 -1
@@ -276,7 +276,7 @@ static int arm_gdb_get_svereg(CPUARMState *env, GByteArray *buf, int reg)* while the ZCR works in Vector Quads (VQ) which is 128bit chunks. */ int vq =sve_zcr_len_for_el (env,arm_current_el (env)) +1 ; -return gdb_get_reg32 (buf, vq *2 ); +return gdb_get_reg64 (buf, vq *2 ); }default :/* gdbstub asked for something out our range */
tests/tcg/aarch64/gdbstub/test-sve-ioctl.py +11 -0
@@ -40,6 +40,17 @@ class TestBreakpoint(gdb.Breakpoint): except gdb.error: report(False, "checking zregs (out of range)") + # check the v pseudo regs - I'm not sure if them capping out + # at [15] is intentional though. + try: + for i in range(0, 16): + val_z = gdb.parse_and_eval("$z0.b.u[%d]" % i) + val_v = gdb.parse_and_eval("$v0.b.u[%d]" % i) + report(int(val_z) == int(val_v), + "v0.b.u[%d] == z0.b.u[%d]" % (i, i)) + except gdb.error: + report(False, "checking vregs (out of range)") + def run_test(): "Run through the tests one by one"
Signature · 1 line
2.20.1
Re: [PATCH v2 9/9] target/arm: use official org.gnu.gdb.aarch64.sve layout for registers
Quoted 12 lines · Alex Bennée
While GDB can work with any XML description given to it there is special handling for SVE registers on the GDB side which makes the users life a little better. The changes aren't that major and all the registers save the $vg reported the same. All that changes is:
- report org.gnu.gdb.aarch64.sve
- use gdb nomenclature for names and types
- minor re-ordering of the types to match reference
- re-enableieee_half(as we know gdb supports it now)
- $vg is now a 64 bit int
- check $vN and $zN aliasing in test
Quoted 2 lines
[NOTE: there seems a limitation on the indexing of the pseudo $vN registers which I'm not sure if it's intentional]
It is (v registers are the aliased vector registers, not an alternative to the z register).
tests/tcg/aarch64/gdbstub/test-sve-ioctl.py class TestBreakpoint(gdb.Breakpoint): · line 44
Quoted 3 lines
tests/tcg/aarch64/gdbstub/test-sve-ioctl.py +2
-0+ # check the v pseudo regs - I'm not sure if them capping out + # at [15] is intentional though.
I'm going to change this comment to:
Check the aliased V registers are set and GDB has correctly created them for us having recognised and handled SVE.
Quoted 12 lines
tests/tcg/aarch64/gdbstub/test-sve-ioctl.py +9
-0+ try: + for i in range(0, 16): + val_z = gdb.parse_and_eval("$z0.b.u[%d]" % i) + val_v = gdb.parse_and_eval("$v0.b.u[%d]" % i) + report(int(val_z) == int(val_v), + "v0.b.u[%d] == z0.b.u[%d]" % (i, i)) + except gdb.error: + report(False, "checking vregs (out of range)") + def run_test(): "Run through the tests one by one"
Signature · 1 line
Alex Bennée