From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 91939 invoked by alias); 10 Apr 2018 02:08:30 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 91845 invoked by uid 89); 10 Apr 2018 02:08:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=vladimir, qemu, H*r:sk:t20-v6s, stacks X-HELO: mail-pl0-f66.google.com Received: from mail-pl0-f66.google.com (HELO mail-pl0-f66.google.com) (209.85.160.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Apr 2018 02:08:28 +0000 Received: by mail-pl0-f66.google.com with SMTP id t20-v6so3536124ply.9 for ; Mon, 09 Apr 2018 19:08:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=MPSmlHwvphaii6x0nkd0iNTrotlX8ggixbc14fJXCrw=; b=KtDh2JVKB9+UzI1l8Y1O4YUs2vfnajzkHPr5R+kCrnV0QPfi5Jzgqw8xmCZiNAoF5o Y2aZ8unwoTjuMAptmznqbusj9kLP+ep5RX/jY8Zty40ZkJhh3gtVhOyuweaJIAzucdR0 4KV20aU41OXb3Dp6pcn1zfrnSHr0vMm4ZPsXfVx2pbh1rjyPuqBTTffHtG1p5wt7ob/L HK0V1kLL5UiymHiTjuZc8ghnB3Z45wjKXoQzFdnmnrDHv2aFXiroCaT0V0w5PT/JkdHv JFSwD5/d3vRP96FttuY7g09gDll6WmUK8MdI59gi53/fkCodnaQpdsJz/0HGmhaouHyr URTA== X-Gm-Message-State: AElRT7EMlN/dFq5AHvegAfdJX+osPN28HzXcoW790H81y3DYlb9hXG1W eM0kJ1BgOo17c25ldOTRA/iCIEHJ X-Google-Smtp-Source: AIpwx4+2hefcSV6bWL1u3kUufsJxnuuAUpXJKxOcBQynZVuNe2Tf9Q/l4CfrdFOKqLpkkwSb1NzLtA== X-Received: by 2002:a17:902:102a:: with SMTP id b39-v6mr41463450pla.112.1523326106593; Mon, 09 Apr 2018 19:08:26 -0700 (PDT) Received: from localhost (1-65-149-183.static.netvigator.com. [1.65.149.183]) by smtp.gmail.com with ESMTPSA id c62sm2969958pfk.179.2018.04.09.19.08.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Apr 2018 19:08:25 -0700 (PDT) Date: Tue, 10 Apr 2018 02:08:00 -0000 From: Stefan Hajnoczi To: Vladimir Sementsov-Ogievskiy Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, gdb@sourceware.org Subject: Re: [Qemu-devel] [PATCH] scripts/qemugdb: support coroutine backtrace in coredumps Message-ID: <20180410020823.GB11203@stefanha-x1.localdomain> References: <20180404103440.19546-1-stefanha@redhat.com> <008ac6e8-1e68-b0f6-7e75-77453721d031@virtuozzo.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="i0/AhcQY5QxfSsSZ" Content-Disposition: inline In-Reply-To: <008ac6e8-1e68-b0f6-7e75-77453721d031@virtuozzo.com> User-Agent: Mutt/1.9.2 (2017-12-15) X-SW-Source: 2018-04/txt/msg00005.txt.bz2 --i0/AhcQY5QxfSsSZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 2439 On Mon, Apr 09, 2018 at 04:01:24PM +0300, Vladimir Sementsov-Ogievskiy wrot= e: > 04.04.2018 13:34, Stefan Hajnoczi wrote: > > Use the 'select-frame' GDB command to switch stacks instead of manually > > setting the debugged thread's registers (this only works when debugging > > a live process, not in a coredump). > >=20 > > Cc: Vladimir Sementsov-Ogievskiy > > Signed-off-by: Stefan Hajnoczi > > --- > > Vladimir: Does this work for you? > >=20 > > scripts/qemugdb/coroutine.py | 6 ++---- > > 1 file changed, 2 insertions(+), 4 deletions(-) > >=20 > > diff --git a/scripts/qemugdb/coroutine.py b/scripts/qemugdb/coroutine.py > > index ab699794ab..ed96434aee 100644 > > --- a/scripts/qemugdb/coroutine.py > > +++ b/scripts/qemugdb/coroutine.py > > @@ -77,13 +77,11 @@ def bt_jmpbuf(jmpbuf): > > for i in regs: > > old[i] =3D gdb.parse_and_eval('(uint64_t)$%s' % i) > > - for i in regs: > > - gdb.execute('set $%s =3D %s' % (i, regs[i])) > > + gdb.execute('select-frame %s %s' % (regs['rsp'], regs['rip'])) > > gdb.execute('bt') > > - for i in regs: > > - gdb.execute('set $%s =3D %s' % (i, old[i])) > > + gdb.execute('select-frame %s %s' % (old['rsp'], old['rip'])) > > def coroutine_to_jmpbuf(co): > > coroutine_pointer =3D co.cast(gdb.lookup_type('CoroutineUContext'= ).pointer()) >=20 > strange, but it doesn't work. it prints the same backtrace, as if I just > call bt. > (I applied it onto "[PATCH 2/4] scripts/qemugdb: improve "qemu coroutine" > command") >=20 > also, I can just call select-frame with zeros or any garbage in gdb, with > same effect: > (gdb) select-frame 0 0 > (gdb) bt >=20 > and get same backtrace. >=20 > so, bt command not related to selected frame. also, up and down commands > don't help too, they go to frames in current bt, instead of moving > relatively to selected frame. I wonder what the point of select-frame is then... I have CCed the GDB mailing list. Maybe someone can help us. Context: QEMU implements coroutines using jmpbuf. We'd like to print coroutine call stacks in GDB and have a script that works when a process is being debugged (it sets the registers). Now we'd like to extend the script to work on core dumps where it's not possible to set registers (since there is no process being debugged). Is there a way to backtrace an arbitrary call stack in a core dump? Stefan --i0/AhcQY5QxfSsSZ Content-Type: application/pgp-signature; name="signature.asc" Content-length: 455 -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJazByXAAoJEJykq7OBq3PI9TEH/jIozpJTO3kOtpzgYRSApTW6 p/k4xuQ051XgdOXGF+YXkl4LDOD4dbD33Dr8aAxnRJOy1SmNetnSozU8GXFNQDic NKp+J2QjWpTNdEE0TYKGwhXxZyBwGz8AbeNvkS6blrEVZOPSIm7asR4OmhMAVWST FPFaEftZFqUFv0kurEx3CQRSH+g+anJ/q+VQKD6pPXfqRAhOLoL0M+A3syU8V9Wx xqOgkFt7gXVlpikxMjohgWAPMNWPzzu5LXssKzSz8yDYv/BnZ7BEaTuOf+QgiYSt 67kMiLNxMb4LT5i9niB95Ui7b63NORlcSk/Iu8Z5sSkf6FDRs48Wvjx9KLGB0ys= =IOqm -----END PGP SIGNATURE----- --i0/AhcQY5QxfSsSZ--