From nobody Mon Feb 9 14:34:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1764080576; cv=none; d=zohomail.com; s=zohoarc; b=AqfKtERTSfYyPGS4T+svuP9OPihleyJ1aNKI3QcSwL8Tnlormxv1p6TOiLr3BeWDVdxIAINm6OGpsdxniUtMlejzxTLgg+HHXPXVM60qZsRQi2xsAmNNUclFFlnRuNk48v4mTrTriWy0nGcJZbI6vL4hdMgLGq1HtcaApRnYKqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764080576; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gMGXypU8Nk0mBK6wTCs2cKN1n7L7ZbG+kaMs8D8iq6c=; b=GmhuWXbB+AyygXHAaEDQOtGpZBi3xWCpTqg2VPWoSByglQEXLVzchfEaIgSzmaWp3jx/b5OgSxQqHjgtjteSPmiiZI/1a0MBbYli63xZ4auukLORpyAM2nnUHYZ4/eK/fiW/Yqp46sU59TQmlCvGKJZgXg4JPQri2iwtN/FXURs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764080576922775.2903814828845; Tue, 25 Nov 2025 06:22:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vNtw1-0007Zb-3j; Tue, 25 Nov 2025 09:22:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vNtuq-0007DR-Sj for qemu-devel@nongnu.org; Tue, 25 Nov 2025 09:21:23 -0500 Received: from relay.virtuozzo.com ([130.117.225.111]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vNtun-0002Go-E2 for qemu-devel@nongnu.org; Tue, 25 Nov 2025 09:21:12 -0500 Received: from [130.117.225.5] (helo=dev005.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1vNtsz-003IJo-05; Tue, 25 Nov 2025 15:20:56 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=gMGXypU8Nk0mBK6wTCs2cKN1n7L7ZbG+kaMs8D8iq6c=; b=Ycb2i+w4CwHD JLWj3yHnQ0OFUBDIQiGTo/pHIUAjc0ZnUZpVg3FeHrkTqF/PzHSFTWyQ0BqRblfckaRmtPakWN/s3 gO/X5Lqz9xRj4qQsNmsYl9yKEc2KlMnwCo+17ghJGHPGPVaUKamC3SVVnJeUT09LMbkam7jwf6plj oeVel6sxRl3qeUMrpMlWwtT5+efjv0JzivxjcbfwrdaAaUNQ9a6QiHhxjsRsdNm0nso4YF6hd8a5d MJ2Nk3yTmzAawwurxunVrBNZb89jxlXWP4gitEgEwYwE9C8MIAPKq8QmHHeiRte1XzoEAXT7yxMgd 9fOwTTfhM4YQqW9sUSpsaQ==; From: andrey.drobyshev@virtuozzo.com To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, peterx@redhat.com, stefanha@redhat.com, vsementsov@yandex-team.ru, den@virtuozzo.com, andrey.drobyshev@virtuozzo.com Subject: [PATCH 1/4] scripts/qemugdb: mtree: Fix OverflowError in mtree with 128-bit addresses Date: Tue, 25 Nov 2025 16:21:02 +0200 Message-ID: <20251125142105.448289-2-andrey.drobyshev@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20251125142105.448289-1-andrey.drobyshev@virtuozzo.com> References: <20251125142105.448289-1-andrey.drobyshev@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=130.117.225.111; envelope-from=andrey.drobyshev@virtuozzo.com; helo=relay.virtuozzo.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1764080582486019200 Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev The 'qemu mtree' command fails with "OverflowError: int too big to convert" when memory regions have 128-bit addresses. Fix by changing conversion base from 16 to 0 (automatic detection based on string prefix). This works more reliably in GDB's embedded Python. Signed-off-by: Andrey Drobyshev Reviewed-by: Stefan Hajnoczi --- scripts/qemugdb/mtree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qemugdb/mtree.py b/scripts/qemugdb/mtree.py index 8fe42c3c12..77603c04b1 100644 --- a/scripts/qemugdb/mtree.py +++ b/scripts/qemugdb/mtree.py @@ -25,7 +25,7 @@ def int128(p): if p.type.code =3D=3D gdb.TYPE_CODE_STRUCT: return int(p['lo']) + (int(p['hi']) << 64) else: - return int(("%s" % p), 16) + return int(("%s" % p), 0) =20 class MtreeCommand(gdb.Command): '''Display the memory tree hierarchy''' --=20 2.43.5 From nobody Mon Feb 9 14:34:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1764081187; cv=none; d=zohomail.com; s=zohoarc; b=ZFrmLVe3Pf31uinjhCWdvneHQL6j7ZWtdOCAY6+50f2R01cwoZSgulftzIZiiKgtAemJQc9tBF3tp25QUhIWKAjjjitV3xTqUwdMLxNDvSoU+yYDG5At8oQev2mPqfA+wcadMVh2iASTwKgUUqwystA89CgDP+bEnQbgGAMsWeI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764081187; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yu8rxNLiMjUJ+cDvQqRD4uD4vrNkGyw0BtvapPeffJg=; b=K/hon/Su1Mt4pDuguhFnIN9fuIUO/yi4+Gs67GI/AvA40jUtSu7HqniYNuifVLBm5w2GvYTstvFkzkZ+NTgt40HxAdZ4zlzrXhoEFweTJ6dO1wnDANyKIW8Jl1bCSJRTD6ghIj4x1O5yy9IMslboGGlCT6BL4TThiwS0lWp2kQE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764081187223180.96923978708196; Tue, 25 Nov 2025 06:33:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vNtvz-0007RF-Gh; Tue, 25 Nov 2025 09:22:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vNtuu-0007FH-AN for qemu-devel@nongnu.org; Tue, 25 Nov 2025 09:21:29 -0500 Received: from relay.virtuozzo.com ([130.117.225.111]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vNtun-0002Gq-LE for qemu-devel@nongnu.org; Tue, 25 Nov 2025 09:21:12 -0500 Received: from [130.117.225.5] (helo=dev005.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1vNtsz-003IJo-0I; Tue, 25 Nov 2025 15:20:56 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=yu8rxNLiMjUJ+cDvQqRD4uD4vrNkGyw0BtvapPeffJg=; b=Dr1j9ytgwWEq SwPbbLxn6QYxu4ZT9/+GyoR9IcmOsV56lPUUDjoe3+CLMJntJ76vCUWxqxnO5nE8NHIzduLXaq3Ez apiSw+eZftEIurna1c4vzI0RQKS7JZ8dOtj3Vx5AjL/vLfFsE64NVCW4ekCwdSg3l55kHEPXdEZpE UoGUqTYXzZ2xPPpQviMerjSBIqCdPoOZrFPv1L56IjFwMfYHP5rCE5mz2yCUk/k1lJ6qUN5b/g71o Txex9r9t7fhUYds5dmItEW2ZPK0ImfF0cb4SEZwv5KkxroZrii/0jK68jFJjWKZyUr9LbYJWszLxo YTZ1jKj9kyy2xg7UwrPyDA==; From: andrey.drobyshev@virtuozzo.com To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, peterx@redhat.com, stefanha@redhat.com, vsementsov@yandex-team.ru, den@virtuozzo.com, andrey.drobyshev@virtuozzo.com Subject: [PATCH 2/4] scripts/qemugdb: timers: Fix KeyError in 'qemu timers' command Date: Tue, 25 Nov 2025 16:21:03 +0200 Message-ID: <20251125142105.448289-3-andrey.drobyshev@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20251125142105.448289-1-andrey.drobyshev@virtuozzo.com> References: <20251125142105.448289-1-andrey.drobyshev@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=130.117.225.111; envelope-from=andrey.drobyshev@virtuozzo.com; helo=relay.virtuozzo.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1764081190234019200 Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev Currently invoking 'qemu timers' command results into: "gdb.error: There is no member named last". Let's remove the legacy 'last' field from QEMUClock, as it was removed in v4.2.0 by the commit 3c2d4c8aa6a ("timer: last, remove last bits of last"). Signed-off-by: Andrey Drobyshev Reviewed-by: Stefan Hajnoczi --- scripts/qemugdb/timers.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/qemugdb/timers.py b/scripts/qemugdb/timers.py index 5714f92cc2..1219a96b32 100644 --- a/scripts/qemugdb/timers.py +++ b/scripts/qemugdb/timers.py @@ -36,10 +36,9 @@ def dump_timers(self, timer): =20 def process_timerlist(self, tlist, ttype): gdb.write("Processing %s timers\n" % (ttype)) - gdb.write(" clock %s is enabled:%s, last:%s\n" % ( + gdb.write(" clock %s is enabled:%s\n" % ( tlist['clock']['type'], - tlist['clock']['enabled'], - tlist['clock']['last'])) + tlist['clock']['enabled'])) if int(tlist['active_timers']) > 0: self.dump_timers(tlist['active_timers']) =20 --=20 2.43.5 From nobody Mon Feb 9 14:34:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1764080589; cv=none; d=zohomail.com; s=zohoarc; b=lHkWoxQWMYaT451LSeEiiFg0avNY/fifscp1a9Hie8+ZGeInKCwnbIecYoEpFcbE4w7tzK2k8mrjkWOK4mlkvRQATObeLKCJOtes8FX3tBLKe13iKuk83wci4OsEYEtrQu2vVWaiYcBArrUDM4M6bBYgguC5SMQM75EjbSrG1ck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764080589; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=a+tUUiQC5dHHaCTNVUg/RgFFKDMzkIDuPzrqjC0AfeE=; b=cZ7+kfRMSn5uda8/ULcv1O9cEDQQM78EO09AxoA10O2Vop3YCuWgzY/d6VUCULkxXt2juVNu1iNe/SKGWuu/DJsSiKW1yCWR//F3tCS2Q03Rm4wmCuH+acc4N3hi8ucGXiLqDGw8X84voq7vPoTvqUD4hKKnSIBaNzeY+A9eI1w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764080589251232.6908855700907; Tue, 25 Nov 2025 06:23:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vNtw2-0007cu-K0; Tue, 25 Nov 2025 09:22:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vNtuu-0007FG-AN for qemu-devel@nongnu.org; Tue, 25 Nov 2025 09:21:29 -0500 Received: from relay.virtuozzo.com ([130.117.225.111]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vNtun-0002Gs-IN for qemu-devel@nongnu.org; Tue, 25 Nov 2025 09:21:12 -0500 Received: from [130.117.225.5] (helo=dev005.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1vNtsz-003IJo-0V; Tue, 25 Nov 2025 15:20:56 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=a+tUUiQC5dHHaCTNVUg/RgFFKDMzkIDuPzrqjC0AfeE=; b=kng0Pw/3P2sF ceqrOthptDw7qn1y5fcgEUYZ151k7miN4llKRlh/yxTx3NjuWXk49XstTYtxtFmrW2ahmhOly6IKA Z8r5DU1kj2zbD9Oi9fOPQ4ir1gj5FA+BHZLX+WR3oYvzUoJNAZPx7fCiQRI0WNLNyJhSvgKI5XTs4 O+TUkILcyzgq7GJ9uo2lrhUvvFFjDg8H5Rb1+H4cpN+4+Vljvp7ADCT9zlHNQtrqJI96bawfALuzH 5BfjWQTR4HD4o/xQ88q6cdmQFMdeNC2wCD20wNwpkN257F+TPDrIYowZmEFPm3QNPpojbnoJv56KB HGD/X0kGiEsOLpuPv1+Plw==; From: andrey.drobyshev@virtuozzo.com To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, peterx@redhat.com, stefanha@redhat.com, vsementsov@yandex-team.ru, den@virtuozzo.com, andrey.drobyshev@virtuozzo.com Subject: [PATCH 3/4] scripts/qemugdb: timers: Improve 'qemu timers' command readability Date: Tue, 25 Nov 2025 16:21:04 +0200 Message-ID: <20251125142105.448289-4-andrey.drobyshev@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20251125142105.448289-1-andrey.drobyshev@virtuozzo.com> References: <20251125142105.448289-1-andrey.drobyshev@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=130.117.225.111; envelope-from=andrey.drobyshev@virtuozzo.com; helo=relay.virtuozzo.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1764080591652019200 Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev * Add the 'attributes' field from QEMUTimer; * Stringify the field's value in accordance with macros from include/qemu/timer.h; * Make timer expiration times human-readable by converting from nanoseconds to appropriate units (ms/s/min/hrs/days) and showing the scale factor (ns/us/ms/s). Signed-off-by: Andrey Drobyshev Reviewed-by: Stefan Hajnoczi --- scripts/qemugdb/timers.py | 49 +++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/scripts/qemugdb/timers.py b/scripts/qemugdb/timers.py index 1219a96b32..916c71b74a 100644 --- a/scripts/qemugdb/timers.py +++ b/scripts/qemugdb/timers.py @@ -21,14 +21,53 @@ def __init__(self): gdb.Command.__init__(self, 'qemu timers', gdb.COMMAND_DATA, gdb.COMPLETE_NONE) =20 + def _format_expire_time(self, expire_time, scale): + "Return human-readable expiry time (ns) with scale info." + secs =3D expire_time / 1e9 + + # Select unit and compute value + if secs < 1: + val, unit =3D secs * 1000, "ms" + elif secs < 60: + val, unit =3D secs, "s" + elif secs < 3600: + val, unit =3D secs / 60, "min" + elif secs < 86400: + val, unit =3D secs / 3600, "hrs" + else: + val, unit =3D secs / 86400, "days" + + scale_map =3D {1: "ns", 1000: "us", 1000000: "ms", + 1000000000: "s"} + scale_str =3D scale_map.get(scale, f"scale=3D{scale}") + return f"{val:.2f} {unit} [{scale_str}]" + + def _format_attribute(self, attr): + "Given QEMUTimer attributes value, return a human-readable string" + + # From include/qemu/timer.h + if attr =3D=3D 0: + value =3D 'NONE' + elif attr =3D=3D 1 << 0: + value =3D 'ATTR_EXTERNAL' + elif attr =3D=3D int(0xffffffff): + value =3D 'ATTR_ALL' + else: + value =3D 'UNKNOWN' + return f'{attr} <{value}>' + def dump_timers(self, timer): "Follow a timer and recursively dump each one in the list." # timer should be of type QemuTimer - gdb.write(" timer %s/%s (cb:%s,opq:%s)\n" % ( - timer['expire_time'], - timer['scale'], - timer['cb'], - timer['opaque'])) + scale =3D int(timer['scale']) + expire_time =3D int(timer['expire_time']) + attributes =3D int(timer['attributes']) + + time_str =3D self._format_expire_time(expire_time, scale) + attr_str =3D self._format_attribute(attributes) + + gdb.write(f" timer at {time_str} (attr:{attr_str}, " + f"cb:{timer['cb']}, opq:{timer['opaque']})\n") =20 if int(timer['next']) > 0: self.dump_timers(timer['next']) --=20 2.43.5 From nobody Mon Feb 9 14:34:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1764087394; cv=none; d=zohomail.com; s=zohoarc; b=RCJh9GiZzzs+yiQQoSlmycVQwCBv0RBVGE/nmxqOJnG5xwMOmED44a973cSwvPpPQGjIlFfy/nKRjdn+iZO+8QaQzHJY1JQKuLMuFTwYJIzx2NrR9qD2/qqLf8C2i+5vY4NNMdjd2uCZ/DR26wJJQ597fkNASQyeEzrpgsIAOBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764087394; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0ZzIpETCotko6Mfd/iA6fKVr3/KJRE0ECF6tAW/S2/E=; b=c0WfEoU6DgzsdSooGxjZkirJUfRIFKvlVtnu5RVb+oPNpV3+LJKGlnXQNEGbNrIfwetdh5ElcwiR3aBWZsbxG65lHjUOLioBALdBtSjKx5IQOJygwFneGXLOEdT1mmcXIGvW6MzJahXEqgTZwvsp9LrqPju3M8Z6hFEt0QtPVSg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764087394316292.9194859355646; Tue, 25 Nov 2025 08:16:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vNtw0-0007WX-97; Tue, 25 Nov 2025 09:22:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vNtuu-0007FI-At for qemu-devel@nongnu.org; Tue, 25 Nov 2025 09:21:29 -0500 Received: from relay.virtuozzo.com ([130.117.225.111]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vNtun-0002Gr-IA for qemu-devel@nongnu.org; Tue, 25 Nov 2025 09:21:13 -0500 Received: from [130.117.225.5] (helo=dev005.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1vNtsz-003IJo-0j; Tue, 25 Nov 2025 15:20:56 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=0ZzIpETCotko6Mfd/iA6fKVr3/KJRE0ECF6tAW/S2/E=; b=SniEUf6/J/tZ KZIgENN2FC24uqzTjfHLhjYtd9pAFvVeBWDcb3PWHOidQdT5rKw1IQ0J0cjf5jEkrVZZFOmhmZn1J +iUlLg/jUggLXaVMbEo+9t/cjNOknXmOjr4QVaP9EoO5Z2iWEOXDep/2KEJGcCYv4ltNSLm0eOmGh VWV1tMrMqwKBO9ENtKlH5Jf+QUxUdaUQZ3v3yNPR+d5T4y6QUKiBfwb0Op2BTRE8vlFSpV5YzYhlT wmPxqUktnHJapTTSPKVeYQBMnP++6Ho8CRoVCWJCD4lLo2a1zN9jXZ+3wSnxKT3jehv9al3TgrYmw uRlp9d9s1dk+kjPnFoSBSA==; From: andrey.drobyshev@virtuozzo.com To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, peterx@redhat.com, stefanha@redhat.com, vsementsov@yandex-team.ru, den@virtuozzo.com, andrey.drobyshev@virtuozzo.com Subject: [PATCH 4/4] scripts/qemugdb: coroutine: Add option for obtaining detailed trace in coredump Date: Tue, 25 Nov 2025 16:21:05 +0200 Message-ID: <20251125142105.448289-5-andrey.drobyshev@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20251125142105.448289-1-andrey.drobyshev@virtuozzo.com> References: <20251125142105.448289-1-andrey.drobyshev@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=130.117.225.111; envelope-from=andrey.drobyshev@virtuozzo.com; helo=relay.virtuozzo.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1764087400556019100 Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev Commit 772f86839f ("scripts/qemu-gdb: Support coroutine dumps in coredumps") introduced coroutine traces in coredumps using raw stack unwinding. While this works, this approach does not allow to view the function arguments in the corresponding stack frames. As an alternative, we can obtain saved registers from the coroutine's jmpbuf, copy the original coredump file into a temporary file, patch the saved registers into the tmp coredump's struct elf_prstatus and execute another gdb subprocess to get backtrace from the patched temporary coredump. While providing more detailed info, this alternative approach, however, is quite heavyweight as it takes significantly more time and disk space. So, instead of making it a new default, let's keep raw unwind the default behaviour, but add the '--detailed' option for 'qemu bt' and 'qemu coroutin= e' command which would enforce the new behaviour. That's how this looks: (gdb) qemu coroutine 0x7fda9335a508 #0 0x5602bdb41c26 in qemu_coroutine_switch<+214> () at ../util/coroutine= -ucontext.c:321 #1 0x5602bdb3e8fe in qemu_aio_coroutine_enter<+493> () at ../util/qemu-c= oroutine.c:293 #2 0x5602bdb3c4eb in co_schedule_bh_cb<+538> () at ../util/async.c:547 #3 0x5602bdb3b518 in aio_bh_call<+119> () at ../util/async.c:172 #4 0x5602bdb3b79a in aio_bh_poll<+457> () at ../util/async.c:219 #5 0x5602bdb10f22 in aio_poll<+1201> () at ../util/aio-posix.c:719 #6 0x5602bd8fb1ac in iothread_run<+123> () at ../iothread.c:63 #7 0x5602bdb18a24 in qemu_thread_start<+355> () at ../util/qemu-thread-p= osix.c:393 (gdb) qemu coroutine 0x7fda9335a508 --detailed patching core file /tmp/tmpq4hmk2qc found "CORE" at 0x10c48 assume pt_regs at 0x10cbc write r15 at 0x10cbc write r14 at 0x10cc4 write r13 at 0x10ccc write r12 at 0x10cd4 write rbp at 0x10cdc write rbx at 0x10ce4 write rip at 0x10d3c write rsp at 0x10d54 #0 0x00005602bdb41c26 in qemu_coroutine_switch (from_=3D0x7fda9335a508, = to_=3D0x7fda8400c280, action=3DCOROUTINE_ENTER) at ../util/coroutine-uconte= xt.c:321 #1 0x00005602bdb3e8fe in qemu_aio_coroutine_enter (ctx=3D0x5602bf7147c0,= co=3D0x7fda8400c280) at ../util/qemu-coroutine.c:293 #2 0x00005602bdb3c4eb in co_schedule_bh_cb (opaque=3D0x5602bf7147c0) at = ../util/async.c:547 #3 0x00005602bdb3b518 in aio_bh_call (bh=3D0x5602bf714a40) at ../util/as= ync.c:172 #4 0x00005602bdb3b79a in aio_bh_poll (ctx=3D0x5602bf7147c0) at ../util/a= sync.c:219 #5 0x00005602bdb10f22 in aio_poll (ctx=3D0x5602bf7147c0, blocking=3Dtrue= ) at ../util/aio-posix.c:719 #6 0x00005602bd8fb1ac in iothread_run (opaque=3D0x5602bf42b100) at ../io= thread.c:63 #7 0x00005602bdb18a24 in qemu_thread_start (args=3D0x5602bf7164a0) at ..= /util/qemu-thread-posix.c:393 #8 0x00007fda9e89f7f2 in start_thread (arg=3D) at pthread= _create.c:443 #9 0x00007fda9e83f450 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/= clone3.S:81 CC: Vladimir Sementsov-Ogievskiy CC: Peter Xu Originally-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Andrey Drobyshev Reviewed-by: Stefan Hajnoczi --- scripts/qemugdb/coroutine.py | 126 ++++++++++++++++++++++++++++++++--- 1 file changed, 115 insertions(+), 11 deletions(-) diff --git a/scripts/qemugdb/coroutine.py b/scripts/qemugdb/coroutine.py index e98fc48a4b..b1c7f96af5 100644 --- a/scripts/qemugdb/coroutine.py +++ b/scripts/qemugdb/coroutine.py @@ -10,6 +10,13 @@ # or later. See the COPYING file in the top-level directory. =20 import gdb +import os +import re +import struct +import shutil +import subprocess +import tempfile +import textwrap =20 VOID_PTR =3D gdb.lookup_type('void').pointer() =20 @@ -77,6 +84,65 @@ def symbol_lookup(addr): =20 return f"{func_str} at {path}:{line}" =20 +def write_regs_to_coredump(corefile, set_regs): + # asm/ptrace.h + pt_regs =3D ['r15', 'r14', 'r13', 'r12', 'rbp', 'rbx', 'r11', 'r10', + 'r9', 'r8', 'rax', 'rcx', 'rdx', 'rsi', 'rdi', 'orig_rax', + 'rip', 'cs', 'eflags', 'rsp', 'ss'] + + with open(corefile, 'r+b') as f: + gdb.write(f'patching core file {corefile}\n') + + while f.read(4) !=3D b'CORE': + pass + gdb.write(f'found "CORE" at 0x{f.tell():x}\n') + + # Looking for struct elf_prstatus and pr_reg field in it (an array + # of general purpose registers). See sys/procfs.h + + # lseek(f.fileno(), 4, SEEK_CUR): go to elf_prstatus + f.seek(4, 1) + # lseek(f.fileno(), 112, SEEK_CUR): offsetof(struct elf_prstatus, = pr_reg) + f.seek(112, 1) + + gdb.write(f'assume pt_regs at 0x{f.tell():x}\n') + for reg in pt_regs: + if reg in set_regs: + gdb.write(f'write {reg} at 0x{f.tell():x}\n') + f.write(struct.pack('q', set_regs[reg])) + else: + # lseek(f.fileno(), 8, SEEK_CUR): go to the next reg + f.seek(8, 1) + +def clone_coredump(source, target, set_regs): + shutil.copyfile(source, target) + write_regs_to_coredump(target, set_regs) + +def dump_backtrace_patched(regs): + files =3D gdb.execute('info files', False, True).split('\n') + executable =3D re.match('^Symbols from "(.*)".$', files[0]).group(1) + dump =3D re.search("`(.*)'", files[2]).group(1) + + with tempfile.NamedTemporaryFile(dir=3D'/tmp', delete=3DFalse) as f: + tmpcore =3D f.name + + clone_coredump(dump, tmpcore, regs) + + cmd =3D ['script', '-qec', + 'gdb -batch ' + + '-ex "set complaints 0" ' + + '-ex "set verbose off" ' + + '-ex "set style enabled on" ' + + '-ex "python print(\'----split----\')" ' + + f'-ex bt {executable} {tmpcore}', + '/dev/null'] + out =3D subprocess.check_output(cmd, stderr=3Dsubprocess.DEVNULL) + out =3D out.split(b'----split----')[1].decode('utf-8') + + os.remove(tmpcore) + + gdb.write(out) + def dump_backtrace(regs): ''' Backtrace dump with raw registers, mimic GDB command 'bt'. @@ -120,7 +186,7 @@ def dump_backtrace_live(regs): =20 selected_frame.select() =20 -def bt_jmpbuf(jmpbuf): +def bt_jmpbuf(jmpbuf, detailed=3DFalse): '''Backtrace a jmpbuf''' regs =3D get_jmpbuf_regs(jmpbuf) try: @@ -128,8 +194,12 @@ def bt_jmpbuf(jmpbuf): # but only works with live sessions. dump_backtrace_live(regs) except: - # If above doesn't work, fallback to poor man's unwind - dump_backtrace(regs) + if detailed: + # Obtain detailed trace by patching regs in copied coredump + dump_backtrace_patched(regs) + else: + # If above doesn't work, fallback to poor man's unwind + dump_backtrace(regs) =20 def co_cast(co): return co.cast(gdb.lookup_type('CoroutineUContext').pointer()) @@ -140,26 +210,60 @@ def coroutine_to_jmpbuf(co): =20 =20 class CoroutineCommand(gdb.Command): - '''Display coroutine backtrace''' + __doc__ =3D textwrap.dedent("""\ + Display coroutine backtrace + + Usage: qemu coroutine COROPTR [--detailed] + Show backtrace for a coroutine specified by COROPTR + + --detailed obtain detailed trace by copying coredump, patc= hing + regs in it, and runing gdb subprocess to get + backtrace from the patched coredump + """) + def __init__(self): gdb.Command.__init__(self, 'qemu coroutine', gdb.COMMAND_DATA, gdb.COMPLETE_NONE) =20 + def _usage(self): + gdb.write('usage: qemu coroutine [--detailed]\= n') + return + def invoke(self, arg, from_tty): argv =3D gdb.string_to_argv(arg) - if len(argv) !=3D 1: - gdb.write('usage: qemu coroutine \n') - return + argc =3D len(argv) + if argc =3D=3D 0 or argc > 2 or (argc =3D=3D 2 and argv[1] !=3D '-= -detailed'): + return self._usage() + detailed =3D True if argc =3D=3D 2 else False =20 - bt_jmpbuf(coroutine_to_jmpbuf(gdb.parse_and_eval(argv[0]))) + bt_jmpbuf(coroutine_to_jmpbuf(gdb.parse_and_eval(argv[0])), + detailed=3Ddetailed) =20 class CoroutineBt(gdb.Command): - '''Display backtrace including coroutine switches''' + __doc__ =3D textwrap.dedent("""\ + Display backtrace including coroutine switches + + Usage: qemu bt [--detailed] + + --detailed obtain detailed trace by copying coredump, patc= hing + regs in it, and runing gdb subprocess to get + backtrace from the patched coredump + """) + def __init__(self): gdb.Command.__init__(self, 'qemu bt', gdb.COMMAND_STACK, gdb.COMPLETE_NONE) =20 + def _usage(self): + gdb.write('usage: qemu bt [--detailed]\n') + return + def invoke(self, arg, from_tty): + argv =3D gdb.string_to_argv(arg) + argc =3D len(argv) + if argc > 1 or (argc =3D=3D 1 and argv[0] !=3D '--detailed'): + return self._usage() + detailed =3D True if argc =3D=3D 1 else False =20 gdb.execute("bt") =20 @@ -178,8 +282,8 @@ def invoke(self, arg, from_tty): co_ptr =3D co["base"]["caller"] if co_ptr =3D=3D 0: break - gdb.write("Coroutine at " + str(co_ptr) + ":\n") - bt_jmpbuf(coroutine_to_jmpbuf(co_ptr)) + gdb.write("\nCoroutine at " + str(co_ptr) + ":\n") + bt_jmpbuf(coroutine_to_jmpbuf(co_ptr), detailed=3Ddetailed) =20 class CoroutineSPFunction(gdb.Function): def __init__(self): --=20 2.43.5