From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org
Subject: [PULL 11/21] scripts/qemugdb: coroutine: Handle target absence gracefully
Date: Wed, 7 Oct 2026 18:32:52 +0200 [thread overview]
Message-ID: <20261007163302.332250-12-kwolf@redhat.com> (raw)
In-Reply-To: <20261007163302.332250-1-kwolf@redhat.com>
From: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
init_coredump() picks the core dump and the executable out of fixed lines
of 'info files' output. With no target loaded that output is empty, and
'qemu bt' dies with:
IndexError: list index out of range
Search the whole output for the core dump file instead, and take the
executable from gdb.current_progspace(), which doesn't need parsing at
all. Neither can raise if the pattern isn't there, so an unexpected
output format now just means "not a coredump" rather than a traceback.
That alone only moves the problem to gdb.execute("bt"), whose gdb.error
escapes invoke() and still gets reported as a python traceback. At the
same time plain 'bt' just prints 'No stack.'. Let's mimick this
behaviour and simply report an error if there's no selected thread.
Fixes: 42f3c143c3a0 ("scripts/qemugdb: coroutine: Add option for obtaining detailed trace in coredump")
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Message-ID: <20260804151743.937694-8-andrey.drobyshev@virtuozzo.com>
Tested-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
scripts/qemugdb/coroutine.py | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/scripts/qemugdb/coroutine.py b/scripts/qemugdb/coroutine.py
index 9148264de3c..3e0b37b73ea 100644
--- a/scripts/qemugdb/coroutine.py
+++ b/scripts/qemugdb/coroutine.py
@@ -322,16 +322,14 @@ def coroutine_to_jmpbuf(co):
def init_coredump():
global coredump
- files = gdb.execute('info files', False, True).split('\n')
+ files = gdb.execute('info files', False, True)
- if not 'core dump' in files[1]:
+ match = re.search(r"core dump file:\s*`([^']+)'", files)
+ if match is None:
return False
- core_path = re.search("`(.*)'", files[2]).group(1)
- exec_path = re.match('^Symbols from "(.*)".$', files[0]).group(1)
-
if coredump is None:
- coredump = Coredump(core_path, exec_path)
+ coredump = Coredump(match.group(1), gdb.current_progspace().filename)
return True
@@ -362,6 +360,9 @@ def invoke(self, arg, from_tty):
return self._usage()
detailed = True if argc == 2 else False
+ if gdb.selected_thread() is None:
+ raise gdb.GdbError('No stack.')
+
is_coredump = init_coredump()
if detailed and not is_coredump:
gdb.write('--detailed is only valid when debugging core dumps\n')
@@ -400,6 +401,9 @@ def invoke(self, arg, from_tty):
return self._usage()
detailed = True if argc == 1 else False
+ if gdb.selected_thread() is None:
+ raise gdb.GdbError('No stack.')
+
is_coredump = init_coredump()
if detailed and not is_coredump:
gdb.write('--detailed is only valid when debugging core dumps\n')
--
2.56.0
next prev parent reply other threads:[~2026-10-07 16:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 16:32 [PULL 00/21] Block layer patches Kevin Wolf
2026-10-07 16:32 ` [PULL 01/21] block-common: fix BDRV_WANT_PRECISE duplicating BDRV_WANT_OFFSET_VALID Kevin Wolf
2026-10-07 16:32 ` [PULL 02/21] block/throttle-groups: fix crash when enabling I/O limits on a busy disk Kevin Wolf
2026-10-07 16:32 ` [PULL 03/21] block: fix bdrv_next() skipping monitor-owned nodes Kevin Wolf
2026-10-07 16:32 ` [PULL 04/21] block: allocate aligned write buffer for 'truncate -m full' Kevin Wolf
2026-10-07 16:32 ` [PULL 05/21] scripts/qemugdb: coroutine: Fix selected frame leak on error path Kevin Wolf
2026-10-07 16:32 ` [PULL 06/21] scripts/qemugdb: coroutine: Get rid of fallback pattern when dumping backtrace Kevin Wolf
2026-10-07 16:32 ` [PULL 07/21] scripts/qemugdb: coroutine: Only attempt to restore regs in coredump Kevin Wolf
2026-10-07 16:32 ` [PULL 08/21] scripts/qemugdb: coroutine: Don't unwind past the outermost frame Kevin Wolf
2026-10-07 16:32 ` [PULL 09/21] scripts/qemugdb: coroutine: Fix patching pt_regs in the coredump Kevin Wolf
2026-10-07 16:32 ` [PULL 10/21] scripts/qemugdb: coroutine: Fix '--detailed' description Kevin Wolf
2026-10-07 16:32 ` Kevin Wolf [this message]
2026-10-07 16:32 ` [PULL 12/21] scripts/qemugdb: coroutine: Speed up coroutine lookup in a coredump Kevin Wolf
2026-10-07 16:32 ` [PULL 13/21] scripts/qemugdb: coroutine: Don't touch the coredump for a plain backtrace Kevin Wolf
2026-10-07 16:32 ` [PULL 14/21] iotests: remove unused 'owner=' variable assignment Kevin Wolf
2026-10-07 16:32 ` [PULL 15/21] hw/block/fdc: account for read and write requests Kevin Wolf
2026-10-07 16:32 ` [PULL 16/21] iotests: annotate TestRunner.shared_self for mypy 2.4 Kevin Wolf
2026-10-07 16:32 ` [PULL 17/21] file-posix: add statx(STATX_DIOALIGN) support Kevin Wolf
2026-10-07 16:32 ` [PULL 18/21] qcow2: do not clear the dirty bit when reopening a read-only node Kevin Wolf
2026-10-07 16:33 ` [PULL 19/21] block: reject a reopen of an unusable node instead of crashing Kevin Wolf
2026-10-07 16:33 ` [PULL 20/21] block: Fix corruption from broken RMW atomicity Kevin Wolf
2026-10-07 16:33 ` [PULL 21/21] block: Remove now redundant bdrv_wait_serialising_requests() calls Kevin Wolf
2026-10-09 12:29 ` [PULL 00/21] Block layer patches Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261007163302.332250-12-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.