From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZlY4Y-0002N2-EX for qemu-devel@nongnu.org; Mon, 12 Oct 2015 04:03:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZlY4X-0006cy-68 for qemu-devel@nongnu.org; Mon, 12 Oct 2015 04:03:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42142) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZlY4X-0006cm-1v for qemu-devel@nongnu.org; Mon, 12 Oct 2015 04:03:05 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id AEDC6461C3 for ; Mon, 12 Oct 2015 08:03:04 +0000 (UTC) From: Paolo Bonzini Date: Mon, 12 Oct 2015 10:02:54 +0200 Message-Id: <1444636974-19950-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1444636974-19950-1-git-send-email-pbonzini@redhat.com> References: <1444636974-19950-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 3/3] qemu-gdb: add $qemu_coroutine_sp and $qemu_coroutine_pc List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com These can be useful to manually get a stack trace of a coroutine inside a core dump. Signed-off-by: Paolo Bonzini --- scripts/qemu-gdb.py | 3 +++ scripts/qemugdb/coroutine.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) 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) -- 2.5.0