From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by sourceware.org (Postfix) with ESMTPS id 7CCAD3858C78 for ; Mon, 7 Mar 2022 10:49:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7CCAD3858C78 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f44.google.com with SMTP id v2-20020a7bcb42000000b0037b9d960079so11091201wmj.0 for ; Mon, 07 Mar 2022 02:49:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=fqNtIGBI9CdfY2KtLoBrsUJJUf8N++JGIl4B+xgJ5Dg=; b=TpH130TAoA7zPI/7x+jyrosUfF1HBUuF0UiimAFgne5FjcI8NDRzi2vmWgdll/Yvtf 93ppKlO+iqqSyfyjXR9SWSC6+YAYSa1+i2oOdecRB4a754W2TDU9bXv/H3wnqrtcLeV9 MxK4SvonSvnhlnS2WWvjHA3DPwQmpd4n2lIp/2SVrHEyvTpijgCgTkdJJymWHDmV9GcE 45+UHaSEJdGy5/FKUJ7xqyDP6A2uGE3U3ivlmtp3epn71t6N3KmNRG3dqNl49FfTewfn /W4O+6wjIJEEDIYhq+QpQ378z2+sh5AE4xctk+1R+IMnL053YdtFehEmjpGSbN9cXZPK 8M8Q== X-Gm-Message-State: AOAM532Lxm3dZJhTx4nLqhYBxvq2eefxTVjuUMjEtOoiKLPpCONXB9uv AjFfFkZl/0lHNkOlOJj4kO3etUrOsgw= X-Google-Smtp-Source: ABdhPJyNIyFvw1MciCQLRROo4paTn6DKwQdIA385TQgJ91sMNuH3kb9Fc6hU6UVoBX3DN6+jexsF+g== X-Received: by 2002:a1c:f315:0:b0:381:1f6d:6ca6 with SMTP id q21-20020a1cf315000000b003811f6d6ca6mr17817059wmq.25.1646650190299; Mon, 07 Mar 2022 02:49:50 -0800 (PST) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id i5-20020a1c3b05000000b00382871cf734sm18552271wma.25.2022.03.07.02.49.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Mar 2022 02:49:49 -0800 (PST) Message-ID: Date: Mon, 7 Mar 2022 10:49:47 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: How to backtrace an separate stack? Content-Language: en-US To: Stefan Hajnoczi , gdb@sourceware.org Cc: qemu-devel@nongnu.org, "Dr. David Alan Gilbert" , tom@tromey.com References: From: Pedro Alves In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Mar 2022 10:49:53 -0000 On 2022-03-03 11:22, Stefan Hajnoczi wrote: > Hi, > The QEMU emulator uses coroutines with separate stacks. It can be > challenging to debug coroutines that have yielded because GDB is not > aware of them (no thread is currently executing them). > > QEMU has a GDB Python script that helps. It "creates" a stack frame for > a given coroutine by temporarily setting register values and then using > the "bt" command. This works on a live process under ptrace control but > not for coredumps where registers can't be set. > > Here is the script (or see the bottom of this email for an inline copy > of the relevant code): > https://gitlab.com/qemu-project/qemu/-/blob/master/scripts/qemugdb/coroutine.py > > I hoped that "select-frame address ADDRESS" could be used instead so > this would work on coredumps too. Unfortunately "select-frame" only > searches stack frames that GDB is already aware of, so it cannot be used > to backtrace coroutine stacks. > > Is there a way to backtrace a stack at an arbitrary address in GDB? I don't think there's an easy/great answer. Maybe it could be done with a Python unwinder [1]? See gdb.python/py-unwind-user-regs.py in the GDB testsuite for an example you could probably start with. As for something built-in to GDB, this reminded me of a discussion a while ago around a "frame create" command. Here were my thoughts back then, I think still valid: https://sourceware.org/legacy-ml/gdb-patches/2015-09/msg00658.html [1] https://sourceware.org/gdb/onlinedocs/gdb/Unwinding-Frames-in-Python.html