[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/20] scripts/gdb: implement 'qemu bt'
From: |
Paolo Bonzini |
Subject: |
[PULL 10/20] scripts/gdb: implement 'qemu bt' |
Date: |
Tue, 12 Jan 2021 18:14:40 +0100 |
From: Maxim Levitsky <mlevitsk@redhat.com>
This script first runs the regular gdb's 'bt' command, and then if we are in a
coroutine it prints the coroutines backtraces in the order in which they
were called.
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20201217155436.927320-3-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
scripts/qemu-gdb.py | 1 +
scripts/qemugdb/coroutine.py | 28 +++++++++++++++++++++++++++-
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/scripts/qemu-gdb.py b/scripts/qemu-gdb.py
index e0bfa7b5a4..4d2a9f6c43 100644
--- a/scripts/qemu-gdb.py
+++ b/scripts/qemu-gdb.py
@@ -40,6 +40,7 @@ timers.TimersCommand()
coroutine.CoroutineSPFunction()
coroutine.CoroutinePCFunction()
+coroutine.CoroutineBt()
# Default to silently passing through SIGUSR1, because QEMU sends it
# to itself a lot.
diff --git a/scripts/qemugdb/coroutine.py b/scripts/qemugdb/coroutine.py
index e1399211e6..7db46d4b68 100644
--- a/scripts/qemugdb/coroutine.py
+++ b/scripts/qemugdb/coroutine.py
@@ -88,8 +88,11 @@ def bt_jmpbuf(jmpbuf):
selected_frame.select()
+def co_cast(co):
+ return co.cast(gdb.lookup_type('CoroutineUContext').pointer())
+
def coroutine_to_jmpbuf(co):
- coroutine_pointer = co.cast(gdb.lookup_type('CoroutineUContext').pointer())
+ coroutine_pointer = co_cast(co)
return coroutine_pointer['env']['__jmpbuf']
@@ -107,6 +110,29 @@ class CoroutineCommand(gdb.Command):
bt_jmpbuf(coroutine_to_jmpbuf(gdb.parse_and_eval(argv[0])))
+class CoroutineBt(gdb.Command):
+ '''Display backtrace including coroutine switches'''
+ def __init__(self):
+ gdb.Command.__init__(self, 'qemu bt', gdb.COMMAND_STACK,
+ gdb.COMPLETE_NONE)
+
+ def invoke(self, arg, from_tty):
+
+ gdb.execute("bt")
+
+ if gdb.parse_and_eval("qemu_in_coroutine()") == False:
+ return
+
+ co_ptr = gdb.parse_and_eval("qemu_coroutine_self()")
+
+ while True:
+ co = co_cast(co_ptr)
+ co_ptr = co["base"]["caller"]
+ if co_ptr == 0:
+ break
+ gdb.write("Coroutine at " + str(co_ptr) + ":\n")
+ bt_jmpbuf(coroutine_to_jmpbuf(co_ptr))
+
class CoroutineSPFunction(gdb.Function):
def __init__(self):
gdb.Function.__init__(self, 'qemu_coroutine_sp')
--
2.29.2
- [PULL 07/20] whpx: move whpx_lapic_state from header to c file, (continued)
- [PULL 07/20] whpx: move whpx_lapic_state from header to c file, Paolo Bonzini, 2021/01/12
- [PULL 02/20] whpx: rename whp-dispatch to whpx-internal.h, Paolo Bonzini, 2021/01/12
- [PULL 06/20] maintainers: Add me as Windows Hosted Continuous Integration maintainer, Paolo Bonzini, 2021/01/12
- [PULL 04/20] cirrus/msys2: Exit powershell with $LastExitCode, Paolo Bonzini, 2021/01/12
- [PULL 03/20] whpx: move internal definitions to whpx-internal.h, Paolo Bonzini, 2021/01/12
- [PULL 18/20] configure: move Cocoa incompatibility checks to Meson, Paolo Bonzini, 2021/01/12
- [PULL 20/20] target/i386: Use X86Seg enum for segment registers, Paolo Bonzini, 2021/01/12
- [PULL 05/20] cirrus/msys2: Cache msys2 mingw in a better way., Paolo Bonzini, 2021/01/12
- [PULL 09/20] scripts/gdb: fix 'qemu coroutine' when users selects a non topmost stack frame, Paolo Bonzini, 2021/01/12
- [PULL 08/20] meson: fix Cocoa option in summary, Paolo Bonzini, 2021/01/12
- [PULL 10/20] scripts/gdb: implement 'qemu bt',
Paolo Bonzini <=
- [PULL 11/20] Docs/RCU: Correct sample code of qatomic_rcu_set, Paolo Bonzini, 2021/01/12
- [PULL 14/20] cocoa: do not enable coreaudio automatically, Paolo Bonzini, 2021/01/12
- [PULL 12/20] meson: Propagate gnutls dependency, Paolo Bonzini, 2021/01/12
- [PULL 13/20] virtio-scsi: trace events, Paolo Bonzini, 2021/01/12
- [PULL 15/20] gtk: remove CONFIG_GTK_GL, Paolo Bonzini, 2021/01/12
- [PULL 16/20] configure: move X11 detection to Meson, Paolo Bonzini, 2021/01/12
- [PULL 17/20] configure: move GTK+ detection to Meson, Paolo Bonzini, 2021/01/12
- [PULL 19/20] configure: quote command line arguments in config.status, Paolo Bonzini, 2021/01/12
- Re: [PULL 00/20] Misc patches for 2021-01-12, no-reply, 2021/01/12
- Re: [PULL 00/20] Misc patches for 2021-01-12, Peter Maydell, 2021/01/13