Message ID | 20190204095725.27259-1-marcandre.lureau@redhat.com |
---|---|
State | New |
Headers | show |
Series | [v2] qemu-gdb: add a QObject pretty printer | expand |
Patchew URL: https://patchew.org/QEMU/20190204095725.27259-1-marcandre.lureau@redhat.com/ Hi, This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally. === TEST SCRIPT BEGIN === #!/bin/bash time make docker-test-mingw@fedora SHOW_ENV=1 J=14 === TEST SCRIPT END === Configure options: --enable-werror --target-list=x86_64-softmmu,aarch64-softmmu --prefix=/tmp/qemu-test/install --python=/usr/bin/python3 --cross-prefix=x86_64-w64-mingw32- --enable-trace-backends=simple --enable-gnutls --enable-nettle --enable-curl --enable-vnc --enable-bzip2 --enable-guest-agent --with-sdlabi=2.0 ERROR: unknown option --with-sdlabi=2.0 Try '/tmp/qemu-test/src/configure --help' for more information # QEMU configure log Mon Feb 4 10:12:13 UTC 2019 # Configured with: '/tmp/qemu-test/src/configure' '--enable-werror' '--target-list=x86_64-softmmu,aarch64-softmmu' '--prefix=/tmp/qemu-test/install' '--python=/usr/bin/python3' '--cross-prefix=x86_64-w64-mingw32-' '--enable-trace-backends=simple' '--enable-gnutls' '--enable-nettle' '--enable-curl' '--enable-vnc' '--enable-bzip2' '--enable-guest-agent' '--with-sdlabi=2.0' --- funcs: do_compiler do_cc compile_object check_define main lines: 92 122 617 634 0 x86_64-w64-mingw32-gcc -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -std=gnu99 -c -o config-temp/qemu-conf.o config-temp/qemu-conf.c config-temp/qemu-conf.c:2:2: error: #error __linux__ not defined #error __linux__ not defined ^~~~~ --- funcs: do_compiler do_cc compile_object check_define main lines: 92 122 617 686 0 x86_64-w64-mingw32-gcc -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -std=gnu99 -c -o config-temp/qemu-conf.o config-temp/qemu-conf.c config-temp/qemu-conf.c:2:2: error: #error __i386__ not defined #error __i386__ not defined ^~~~~ --- funcs: do_compiler do_cc compile_object check_define main lines: 92 122 617 689 0 x86_64-w64-mingw32-gcc -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -std=gnu99 -c -o config-temp/qemu-conf.o config-temp/qemu-conf.c config-temp/qemu-conf.c:2:2: error: #error __ILP32__ not defined #error __ILP32__ not defined ^~~~~ --- lines: 92 128 920 0 x86_64-w64-mingw32-gcc -mthreads -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -std=gnu99 -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -g -liberty /usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: cannot find -liberty collect2: error: ld returned 1 exit status Failed to run 'configure' Traceback (most recent call last): File "./tests/docker/docker.py", line 563, in <module> The full log is available at http://patchew.org/logs/20190204095725.27259-1-marcandre.lureau@redhat.com/testing.docker-mingw@fedora/?type=message. --- Email generated automatically by Patchew [http://patchew.org/]. Please send your feedback to patchew-devel@redhat.com
Is your subject accurate? To my (admittedly ignorant) eyes, the patch looks like an *Object* pretty-printer, not a *QObject* pretty-printer.
Hi On Mon, Feb 4, 2019 at 3:00 PM Markus Armbruster <armbru@redhat.com> wrote: > > Is your subject accurate? To my (admittedly ignorant) eyes, the patch > looks like an *Object* pretty-printer, not a *QObject* pretty-printer. > Yes Object, not QObject, sorry, the confusion will remain for a long time.. feel free to change commit message on commit, thanks
diff --git a/scripts/qemu-gdb.py b/scripts/qemu-gdb.py old mode 100644 new mode 100755 index 690827e6fc..1ec666e841 --- a/scripts/qemu-gdb.py +++ b/scripts/qemu-gdb.py @@ -21,6 +21,9 @@ import gdb import os, sys +if sys.version_info[0] < 3: + int = long + # Annoyingly, gdb doesn't put the directory of scripts onto the # module search path. Do it manually. @@ -47,3 +50,58 @@ coroutine.CoroutinePCFunction() # Default to silently passing through SIGUSR1, because QEMU sends it # to itself a lot. gdb.execute('handle SIGUSR1 pass noprint nostop') + + +def is_object(val): + def is_object_helper(type): + if str(type) == "Object": + return True + + while type.code == gdb.TYPE_CODE_TYPEDEF: + type = type.target() + + if type.code != gdb.TYPE_CODE_STRUCT: + return False + + fields = type.fields() + if len (fields) < 1: + return False + + first_field = fields[0] + return is_object_helper(first_field.type) + + type = val.type + if type.code != gdb.TYPE_CODE_PTR: + return False + type = type.target() + return is_object_helper (type) + + +def object_class_name(instance): + try: + inst = instance.cast(gdb.lookup_type("Object").pointer()) + klass = inst["class"] + typ = klass["type"] + return typ["name"].string() + except RuntimeError: + pass + + +class QObjectPrinter: + def __init__(self, val): + self.val = val + + def to_string(self): + name = object_class_name(self.val) + if name: + return ("0x%x [%s]")% (int(self.val), name) + return ("0x%x") % (int(self.val)) + + +def lookup_type(val): + if is_object(val): + return QObjectPrinter(val) + return None + + +gdb.pretty_printers.append(lookup_type)
Inspired by GObject/GType pretty printer. Example: machine_set_accel (obj=0x555556807550 [pc-i440fx-4.0-machine],... Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> --- v2: - simplify python 2 compatibility code, suggested by Eduardo scripts/qemu-gdb.py | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) mode change 100644 => 100755 scripts/qemu-gdb.py