From: Paolo Bonzini Date: Mon, 12 Oct 2015 08:02:54 +0000 (+0200) Subject: qemu-gdb: add $qemu_coroutine_sp and $qemu_coroutine_pc X-Git-Tag: TizenStudio_2.0_p2.3.2~120^2~1^2~100^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a201b0ff28d9fa0f965450c1ba7191eca69f9fd5;p=sdk%2Femulator%2Fqemu.git qemu-gdb: add $qemu_coroutine_sp and $qemu_coroutine_pc These can be useful to manually get a stack trace of a coroutine inside a core dump. Signed-off-by: Paolo Bonzini Message-id: 1444636974-19950-4-git-send-email-pbonzini@redhat.com Signed-off-by: Stefan Hajnoczi --- diff --git a/scripts/qemu-gdb.py b/scripts/qemu-gdb.py index d6f2e5a..ef2fd19 100644 --- a/scripts/qemu-gdb.py +++ b/scripts/qemu-gdb.py @@ -38,6 +38,9 @@ QemuCommand() coroutine.CoroutineCommand() mtree.MtreeCommand() +coroutine.CoroutineSPFunction() +coroutine.CoroutinePCFunction() + # Default to silently passing through SIGUSR1, because QEMU sends it # to itself a lot. gdb.execute('handle SIGUSR1 pass noprint nostop') diff --git a/scripts/qemugdb/coroutine.py b/scripts/qemugdb/coroutine.py index b5c8678..ab69979 100644 --- a/scripts/qemugdb/coroutine.py +++ b/scripts/qemugdb/coroutine.py @@ -15,6 +15,8 @@ import gdb +VOID_PTR = gdb.lookup_type('void').pointer() + def get_fs_base(): '''Fetch %fs base value using arch_prctl(ARCH_GET_FS). This is pthread_self().''' @@ -101,3 +103,17 @@ class CoroutineCommand(gdb.Command): return bt_jmpbuf(coroutine_to_jmpbuf(gdb.parse_and_eval(argv[0]))) + +class CoroutineSPFunction(gdb.Function): + def __init__(self): + gdb.Function.__init__(self, 'qemu_coroutine_sp') + + def invoke(self, addr): + return get_jmpbuf_regs(coroutine_to_jmpbuf(addr))['rsp'].cast(VOID_PTR) + +class CoroutinePCFunction(gdb.Function): + def __init__(self): + gdb.Function.__init__(self, 'qemu_coroutine_pc') + + def invoke(self, addr): + return get_jmpbuf_regs(coroutine_to_jmpbuf(addr))['rip'].cast(VOID_PTR)