From nobody Fri May 3 20:48:24 2024 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616694836; cv=none; d=zohomail.com; s=zohoarc; b=JdU7aMQBrQGtDhsgIRVUPNSCnGea0euSFDsKULHDrl3cjpld6MYWq9scvPCmSXAe2XpHVJy0tTVvZwEfSfC1L+cVW05GYnhP6zWgTUnakiVivHP2k5sNyaA9SMp0sXYZryF9LfVRsn4aMxBPDfCaT11PuKQf8tq1m2ED0OyoN4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616694836; 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=ycg8ACmx+oz2JrD2UYc7cfYfGDjv6wZoEd8IS0MEszo=; b=OvJpEC2/0L7F3oPStwejVrFRpJ4Gsa2Dv5b3FjZ4XKpKz8tA83uSMeb08ObtoNX1Qo/4ugnOfJg0mKrYh5FC5ihzt3rfijnRvrajTdUOA0xsfx0YcM+SFSvhu/4oxX56Z2VkDqSaVSmAytWKOWFZwK1CwxgYyjIipHCchcoyLEU= 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 1616694836522814.8117306931647; Thu, 25 Mar 2021 10:53:56 -0700 (PDT) Received: from localhost ([::1]:42268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPUB9-0007XV-PR for importer@patchew.org; Thu, 25 Mar 2021 13:53:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPU88-0005km-Uv for qemu-devel@nongnu.org; Thu, 25 Mar 2021 13:50:48 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:53870) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lPU7v-0004p0-NI for qemu-devel@nongnu.org; Thu, 25 Mar 2021 13:50:48 -0400 Received: by mail-wm1-x332.google.com with SMTP id g20so1656171wmk.3 for ; Thu, 25 Mar 2021 10:50:27 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id s9sm8180794wmh.31.2021.03.25.10.50.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 10:50:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ycg8ACmx+oz2JrD2UYc7cfYfGDjv6wZoEd8IS0MEszo=; b=kZpSgh7lTVszEVfW6pMGvY+CNgiz2Ie6NIzXtj2KtOI3GTjhYHy+1SfFryJ7CDiVcu NtLQ6a9+kf6cHKEIlU0XsI46mBUnmiimsoRhnN9902TfgnS0vtfgxGfkBtwMCT1MBAhg Yxvfp6acu89I9tzrzbvNO4a/5CKD/110STPOindpvuFROznktq43W20v6MlDUNj8b9Hu ilnPgH+yinraLsNpqcESphcLgfk6WXR/FJYTE04TkqCyNpuW1nBoYv8OVaS4AYE/t+yO bZWMo+Z58mWhOOs41jL2R5KYrEIQX4pjtoW9JPVYGmG4IWRLShMjKGxLwTQ7FVYsls4c AFTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ycg8ACmx+oz2JrD2UYc7cfYfGDjv6wZoEd8IS0MEszo=; b=RUJ6LkmiDCbmX7bpQzth4voAa2np7NbY/eXnHFaGtDYHW0lLngwB+sCYeeCxsYJ9Yf X8WUYlnqN6RKf4IqiWISUiPwKXkNx6BzzcqNQDO9wFY0/A4qcZvR29kKakKfL6otYdV3 gMEvpa/mibNCxkiK0LiMZEds5oNkYI1boTHcltY1Wk5Q2pFyv/SKJBQlTPeDoxjKx2Vr jEZeRH5NogQTku7/yNDZ48hfSRECTZHNeaSwB+a48oT1WmV2qf1wjeivKneD7yYbkmrM fFsS4CXa56G4QIngWX8rjKidTDyIX0uKrRfLEcF+xjc1dpxB5budDAJtFclvDVfesgRe d2hA== X-Gm-Message-State: AOAM530/thSppo8bcnpmvswrFKOeCcz3kp3J3dzpKE13EoCTy4F2rVch k0Sgmxztq+a9u/OQ/poc0YaepYT7j8wpZNhp X-Google-Smtp-Source: ABdhPJzME/tudmK5F7sa7cQbG10JKgpcL1aqcw6lvF/vKH75YM5SLODjuKG6kIjqKgRPr8iVDCY/EQ== X-Received: by 2002:a1c:5f89:: with SMTP id t131mr8874691wmb.173.1616694625985; Thu, 25 Mar 2021 10:50:25 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH for-6.0 1/2] docs/system/gdb.rst: Add some more heading structure Date: Thu, 25 Mar 2021 17:50:22 +0000 Message-Id: <20210325175023.13838-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210325175023.13838-1-peter.maydell@linaro.org> References: <20210325175023.13838-1-peter.maydell@linaro.org> 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::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= 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" We're about to add a new section to gdb.rst. In preparation, add some more headings so it isn't just one huge run-on section. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- docs/system/gdb.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/system/gdb.rst b/docs/system/gdb.rst index 72b1e68f4ef..0bb1bedf1be 100644 --- a/docs/system/gdb.rst +++ b/docs/system/gdb.rst @@ -45,7 +45,11 @@ Here are some useful tips in order to use gdb on system = code: 3. Use ``set architecture i8086`` to dump 16 bit code. Then use ``x/10i $cs*16+$eip`` to dump the code at the PC position. =20 -Advanced debugging options: +Advanced debugging options +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D + +Changing single-stepping behaviour +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ =20 The default single stepping behavior is step with the IRQs and timer service routines off. It is set this way because when gdb executes a @@ -88,6 +92,8 @@ three commands you can query and set the single step beha= vior: sending: "qemu.sstep=3D0x5" received: "OK" =20 +Examining physical memory +^^^^^^^^^^^^^^^^^^^^^^^^^ =20 Another feature that QEMU gdbstub provides is to toggle the memory GDB works with, by default GDB will show the current process memory respecting --=20 2.20.1 From nobody Fri May 3 20:48:24 2024 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1616694925; cv=none; d=zohomail.com; s=zohoarc; b=EjcHA+1xLZ38WBeJJOWMekJBJLu3HF0nLVTodUcYc3lGjKzSMkh+0qYKxCGmfKjmswPl/JF9OIqF1mSGHuBkSJCkwN+QM3FgMf4+uHMs4t+ZIBJS1oloa0jOXirQGZNGPVZDEHpBuUzWhUUZprkSuAXLrIk7y4F8qZKc5QG43mE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616694925; 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=WlvLB8nfkzFPQhAaXU+2e02Q11xHv7FAk8MfuDRn5iE=; b=HKC9WI9/sCDnUXoNbL5KBKdeIigaeEHr6KX6FtB2OFNtyPmtLODKVD7qoWqcav7ok0ZMOIMvmuadoY1vKV26Wst7yUWKcdFHcMKlUs8lEyp4i9D18LvFvdHsBRbGetbdHEPeco7LioTlanUgNAQ78MJWgOyqLsP2hG6r0RNR99k= 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 1616694925825195.19061792331638; Thu, 25 Mar 2021 10:55:25 -0700 (PDT) Received: from localhost ([::1]:44988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPUCY-0000CA-VO for importer@patchew.org; Thu, 25 Mar 2021 13:55:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPU82-0005jt-A2 for qemu-devel@nongnu.org; Thu, 25 Mar 2021 13:50:43 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:33754) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lPU7v-0004ps-Ma for qemu-devel@nongnu.org; Thu, 25 Mar 2021 13:50:41 -0400 Received: by mail-wr1-x435.google.com with SMTP id o16so3225014wrn.0 for ; Thu, 25 Mar 2021 10:50:27 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id s9sm8180794wmh.31.2021.03.25.10.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 10:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WlvLB8nfkzFPQhAaXU+2e02Q11xHv7FAk8MfuDRn5iE=; b=jP2qmjJcRQMIsbhDSC6elqg4255hSgf4sirD7K2U/lUxUtzv7GDk7LClIVP3fmN+d2 IeclS23ypN9k4mwnSndOjDcw+P9AfBCis7brnt+Qm6FeIvelpmpBTwPIPYm0IFD84sil diDSyiX9Wp4S1HM8sC40boKWpCY22vjP1mREkGqIu6v+gBQVmtS5EnuqCV+LcME6eAcn wQ5AdTkCf/8isFA4UyHmMx/nemyu9XcaLP9Mr//FUZWOUbO3HyAmLvrWgokq7rbedaMb 9xfMFeZimFAf+eSQNHV9hbCNUpHX7XsWVkAfFVI86pPahjJIwpMD8nNBi/S0jmsnPhd+ nINQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WlvLB8nfkzFPQhAaXU+2e02Q11xHv7FAk8MfuDRn5iE=; b=YKLaqrFUxEr8nE/7HRfIRsv5iZ7H1AJcXsjIrtvhwOVjRcIRbjhZjdXUuDYLOnwF+o yzHmWC47g54fOdrGROm6WWzXAhmJVfePSDoBCIjZ/S4wknyHQh5wNPzOxFokImDz2+TE E0gIU5GZEbpNVi9CcBs16klDsz080eiMjirNY8xA03e2Pu8DtkGlZkm/u6Bvn4wLCynV vxzE9KEJVBTmwzh8c+5ctWePi9p+kgxZE+fBXbWBe3V2zuPRfnbiTgVNTmews6Kj4OG7 0/1rGuTgND7kpdL2HC+NyePsqn5p9Yj8QN5Qz5l/Xk3iSSnlcbClxhJuEmrZknlmATRA CUxA== X-Gm-Message-State: AOAM532CWHWsEWA09F2TNSvAkjekaYURr0dyydQ/ZmjRdcv5/JgcDkQH udoCTUrXvDHqdTBy80nr+/TRmck4Rj/Li3B/ X-Google-Smtp-Source: ABdhPJwAETPkr8b6YFU62BwugSeKF7SayvWViy3gSkd41mkzu0GrH/LYQoBAgoJZEgcn4iH+OflpcQ== X-Received: by 2002:a5d:404f:: with SMTP id w15mr10723997wrp.106.1616694626716; Thu, 25 Mar 2021 10:50:26 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH for-6.0 2/2] docs/system/gdb.rst: Document how to debug multicore machines Date: Thu, 25 Mar 2021 17:50:23 +0000 Message-Id: <20210325175023.13838-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210325175023.13838-1-peter.maydell@linaro.org> References: <20210325175023.13838-1-peter.maydell@linaro.org> 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::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= 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" Document how multicore machines appear to GDB when debugged via the debug stub. This is particularly non-intuitive for the "multiple heterogenous clusters" case, but unfortunately as far as I know there is no way with the remote protocol for the stub to tell gdb "I have 2 inferiors, please connect to both", so the user must set it all up manually. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- docs/system/gdb.rst | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/docs/system/gdb.rst b/docs/system/gdb.rst index 0bb1bedf1be..144d083df31 100644 --- a/docs/system/gdb.rst +++ b/docs/system/gdb.rst @@ -45,6 +45,61 @@ Here are some useful tips in order to use gdb on system = code: 3. Use ``set architecture i8086`` to dump 16 bit code. Then use ``x/10i $cs*16+$eip`` to dump the code at the PC position. =20 +Debugging multicore machines +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D + +GDB's abstraction for debugging targets with multiple possible +parallel flows of execution is a two layer one: it supports multiple +"inferiors", each of which can have multiple "threads". When the QEMU +machine has more than one CPU, QEMU exposes each CPU cluster as a +separate "inferior", where each CPU within the cluster is a separate +"thread". Most QEMU machine types have identical CPUs, so there is a +single cluster which has all the CPUs in it. A few machine types are +heterogenous and have multiple clusters: for example the ``sifive_u`` +machine has a cluster with one E51 core and a second cluster with four +U54 cores. Here the E51 is the only thread in the first inferior, and +the U54 cores are all threads in the second inferior. + +When you connect gdb to the gdbstub, it will automatically +connect to the first inferior; you can display the CPUs in this +cluster using the gdb ``info thread`` command, and switch between +them using gdb's usual thread-management commands. + +For multi-cluster machines, unfortunately gdb does not by default +handle multiple inferiors, and so you have to explicitly connect +to them. First, you must connect with the ``extended-remote`` +protocol, not ``remote``:: + + (gdb) target extended-remote localhost:1234 + +Once connected, gdb will have a single inferior, for the +first cluster. You need to create inferiors for the other +clusters and attach to them, like this:: + + (gdb) add-inferior + Added inferior 2 + (gdb) inferior 2 + [Switching to inferior 2 [] ()] + (gdb) attach 2 + Attaching to process 2 + warning: No executable has been specified and target does not support + determining executable automatically. Try using the "file" command. + 0x00000000 in ?? () + +Once you've done this, ``info threads`` will show CPUs in +all the clusters you have attached to:: + + (gdb) info threads + Id Target Id Frame + 1.1 Thread 1.1 (cortex-m33-arm-cpu cpu [running]) 0x00000000 in ?? () + * 2.1 Thread 2.2 (cortex-m33-arm-cpu cpu [halted ]) 0x00000000 in ?? () + +You probably also want to set gdb to ``schedule-multiple`` mode, +so that when you tell gdb to ``continue`` it resumes all CPUs, +not just those in the cluster you are currently working on:: + + (gdb) set schedule-multiple on + Advanced debugging options =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D =20 --=20 2.20.1