From nobody Tue Feb 10 11:15:54 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1610472277; cv=none; d=zohomail.com; s=zohoarc; b=P32nzeCQhqbePpjUv8fTT5eS5BjM/59ktf2Uket62lOiz3k+UiI2pmgDAL9LnGbgsJ05P3uWUC5sl9ue/lsYbU1ZcIGBrrvVy8HyPoS+MvqXyJWQySuLF4G3ueJ09iG1oRN6doHsxzGVISHzMWZKyqa3FzGKHDIRacVcKytevOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610472277; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MYwXQkjkGyHa6d3oKH/TvhkJ1MzQV0+oIcuJEspAGwE=; b=GDEW5BKy3/xIxrYDF5TwFbChpk5ikfEKbGoD8MyNpSHT2tgF2+ygzUemngh2LAALxLc++kuzYl7CaLZW+Fxz221qI8WJKmRW3tnaqFeB77nbnps9/RuclwecyIbeR+Zj9L/6TwJnxy7Xsaq+EVTMzp3fnjaE8LTBuW6epfMQhSc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161047227780145.83652421213901; Tue, 12 Jan 2021 09:24:37 -0800 (PST) Received: from localhost ([::1]:39032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzNPI-0005ef-Hw for importer@patchew.org; Tue, 12 Jan 2021 12:24:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzNG7-0003eT-Nm for qemu-devel@nongnu.org; Tue, 12 Jan 2021 12:15:07 -0500 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]:44341) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kzNG4-0004tR-0E for qemu-devel@nongnu.org; Tue, 12 Jan 2021 12:15:07 -0500 Received: by mail-ej1-x62e.google.com with SMTP id w1so4547247ejf.11 for ; Tue, 12 Jan 2021 09:15:01 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id k22sm397302edv.33.2021.01.12.09.15.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 09:15:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MYwXQkjkGyHa6d3oKH/TvhkJ1MzQV0+oIcuJEspAGwE=; b=ViXJ9PCJdFmPqnYCysr6cD1igywMN69t76NSAaktnE6Sdtotd6NogzP0UAWY/crok8 6gOtvU9hwgdf9tXepB0A0imcp0vZHgMSuhN4CWToYCA41Ce4912DaStc3VrzcU66FPV1 zpj5roRuxHXuosAmgCbZGVcbRJGN32GhE7fFHKZ5hZ5fUJOD61+RemwcOtE3KQ/s7zst xyoBNl3Pw+YaKAggEu0lyeB/1aBdcoH8FfEfzTnV8BBhLlBzq0UDXUyirOztC0mOO40W e0Gd4Sa9ZxFw6oaT7eC6TGWl2oglYWXlTMniqDAw835ZXP+EsGikOYMm7qCDaCvWaJDe 3oXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=MYwXQkjkGyHa6d3oKH/TvhkJ1MzQV0+oIcuJEspAGwE=; b=mvHqoJi1bIZPaXBLpsWBinGTDev3HgoKNB3jd/YjXVb4vWfTRomykYdMdgQgJFNhPR Ez898B7W6ilkqFtPpN2UrQehMN3s/fmX+B2gbpHa/+X51lUWFB9A5B9IrOq81mnv1pD5 uKeMMFadUPTvVxs/Rcx0zQ9Nd9RTmLuAxTuJxS4IcK3I5rm5Y+9xNkb6I8MyqWYPUO0a sho1oYJCaGXgbUB7EMnO+JxQMVOqePuiQwpQOOBeSYGYyeTh5bjL5f2rJUQnIVs1XU3Q VT80tqpHq9yY/Xeck6QbduFph2WCSIE2eY5phMB0VIA+nvlvFvkjfvufP5hMKXC05BnE lFjA== X-Gm-Message-State: AOAM533ZTGGKkon7w7OGJ8pbGJlWWXsCqmDnZW4efRBxpBW1sB6VB9e6 6oPzA+zrPJKrRcAB7Ik/zfN06vBzdxZKPg== X-Google-Smtp-Source: ABdhPJytCZ1DpCPRuGLOv8G8yKUlQqXDC6g+c02ypGjd3LYbIQba5twZ2/VcGsvh5jQuq2L/2ErYHA== X-Received: by 2002:a17:906:8292:: with SMTP id h18mr4030953ejx.481.1610471701162; Tue, 12 Jan 2021 09:15:01 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 10/20] scripts/gdb: implement 'qemu bt' Date: Tue, 12 Jan 2021 18:14:40 +0100 Message-Id: <20210112171450.791427-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210112171450.791427-1-pbonzini@redhat.com> References: <20210112171450.791427-1-pbonzini@redhat.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=2a00:1450:4864:20::62e; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x62e.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxim Levitsky Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Maxim Levitsky This script first runs the regular gdb's 'bt' command, and then if we are i= n a coroutine it prints the coroutines backtraces in the order in which they were called. Signed-off-by: Maxim Levitsky Message-Id: <20201217155436.927320-3-mlevitsk@redhat.com> Signed-off-by: Paolo Bonzini --- 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() =20 coroutine.CoroutineSPFunction() coroutine.CoroutinePCFunction() +coroutine.CoroutineBt() =20 # 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): =20 selected_frame.select() =20 +def co_cast(co): + return co.cast(gdb.lookup_type('CoroutineUContext').pointer()) + def coroutine_to_jmpbuf(co): - coroutine_pointer =3D co.cast(gdb.lookup_type('CoroutineUContext').poi= nter()) + coroutine_pointer =3D co_cast(co) return coroutine_pointer['env']['__jmpbuf'] =20 =20 @@ -107,6 +110,29 @@ class CoroutineCommand(gdb.Command): =20 bt_jmpbuf(coroutine_to_jmpbuf(gdb.parse_and_eval(argv[0]))) =20 +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()") =3D=3D False: + return + + co_ptr =3D gdb.parse_and_eval("qemu_coroutine_self()") + + while True: + co =3D co_cast(co_ptr) + 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)) + class CoroutineSPFunction(gdb.Function): def __init__(self): gdb.Function.__init__(self, 'qemu_coroutine_sp') --=20 2.29.2