From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793109; cv=none; d=zohomail.com; s=zohoarc; b=n6sbc4PxlxRcJ290gzp2TWDshbkA0783t+n7igqVE1nF882QrdGzpINqS5fenIdahv29gOqOjyAse81l0ivyN3L4ZtesUWf29NsntGAkEcdQKutBQJXeiebcwT8RbEYXs3/AYPf4muF1Ds8eMBo+3a9lFYwoyD/kaUPa+ICDs3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793109; 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; bh=Rv8ecp5MNNYaYzflXkXYlG6pC6Fau5qFV5g6norDKWY=; b=B44AiWOdEiuqduFmkKKJvQNSuf+o86w4zYFaA5pAXY4pYCk4zDoMoCgPKSGm/ZfeQy62dpjvFqfBzW5tSQeoJyx+TO+cvZbUH81K7q0nik8esPXupZGjRMPVHNGdStT4rVMhEHQLMt17Ggc5LxvsJJe0DWSPsKi6U17Q3/fzc+k= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793109169477.16695627181525; Mon, 31 Jul 2023 01:45:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOW3-0007G6-Re; Mon, 31 Jul 2023 04:44:35 -0400 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 1qQOVv-00079D-JW for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:44:28 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOVs-0004SZ-Kr for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:44:27 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-686f94328a4so2338323b3a.0 for ; Mon, 31 Jul 2023 01:44:24 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.44.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:44:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793063; x=1691397863; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Rv8ecp5MNNYaYzflXkXYlG6pC6Fau5qFV5g6norDKWY=; b=PZDp+BBAvc0KSB56DsQmUvjKSFua+VZ9zJv0Qx2cAelbx6oWm2A0BCqnTznDCYOsGT 9C/ylIUMVvvzeIZPr6sUP2C5NV7YBwxDzj0GMLnazLIdJWgEv+zt1Amv29lD1aGuK/io tLXNLpawYWT5S2pS2V0ngHDeqkjhqHr6WUd3TXkSg8jsX2VItf1/yPkZwJALZ2T54ZX0 1DfHgW94Ua/0Msj3wxgIeAW9i8Wr0Ks7WlQavTsyENI2dm5luHnIlNv7CpHebGGWoCHz PhY6U71DsRup2LP0zN7VAoz+34qvXpMw7DAh4zvlZXGVb0Rgz1uf1XnarZOmdA3Qt11m PP9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793063; x=1691397863; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Rv8ecp5MNNYaYzflXkXYlG6pC6Fau5qFV5g6norDKWY=; b=UcfbaE/lrvnRU/E5uV49hcE08+98Ml7o5o24lDxODJYeLPQlJhoB3Zilol6C6J93q/ 2OFP9ugWExAuJXdlK9hlndnbRvseBlCWWoBvMoCSRfK1nMBXgWxVa0DKBPit5xoiWZcu ymRUm4Cbji8xjWbs6OGAhGyGrEcDR5bwyT8bGc1V4oGvPopxz39i53FF07QMdfva0l56 FSDzC1/jkJCBdDTFRPO6ZBk+B+6Ycxy5P/GGAmUoVZ7vMOV3c65Xt+rBG9r31uXUqGaQ FeP3Rov7a+u3fwWlS6n9IxIGDXVwzCF8STz/UvW2+cg3R/JDWz1/+e71Yxl++x/Nd3eo w6bA== X-Gm-Message-State: ABy/qLYHz/7QYTbMQMbVPHn6paSXxwDzwuIkJvnZEz+TmfEbnzpMC3Mc Y6hit98YWr/HJujMKtHzgaHMPw== X-Google-Smtp-Source: APBJJlGS/uBh757PghIh1LcVXhYRgj49gAZ0Q+WNPNFD5s7fgIOIJxRogywBE58O/HDzE59o2ynz1A== X-Received: by 2002:a05:6a20:160b:b0:133:bf18:ef7b with SMTP id l11-20020a056a20160b00b00133bf18ef7bmr10943503pzj.24.1690793063098; Mon, 31 Jul 2023 01:44:23 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 01/24] contrib/plugins: Use GRWLock in execlog Date: Mon, 31 Jul 2023 17:43:28 +0900 Message-ID: <20230731084354.115015-2-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::434; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x434.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793111834100003 Content-Type: text/plain; charset="utf-8" execlog had the following comment: > As we could have multiple threads trying to do this we need to > serialise the expansion under a lock. Threads accessing already > created entries can continue without issue even if the ptr array > gets reallocated during resize. However, when the ptr array gets reallocated, the other threads may have a stale reference to the old buffer. This results in use-after-free. Use GRWLock to properly fix this issue. Fixes: 3d7caf145e ("contrib/plugins: add execlog to log instruction executi= on and memory access") Signed-off-by: Akihiko Odaki Reviewed-by: Alex Benn=C3=A9e --- contrib/plugins/execlog.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c index 7129d526f8..ce67acf145 100644 --- a/contrib/plugins/execlog.c +++ b/contrib/plugins/execlog.c @@ -19,7 +19,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGI= N_VERSION; =20 /* Store last executed instruction on each vCPU as a GString */ static GPtrArray *last_exec; -static GMutex expand_array_lock; +static GRWLock expand_array_lock; =20 static GPtrArray *imatches; static GArray *amatches; @@ -28,18 +28,16 @@ static GArray *amatches; * Expand last_exec array. * * As we could have multiple threads trying to do this we need to - * serialise the expansion under a lock. Threads accessing already - * created entries can continue without issue even if the ptr array - * gets reallocated during resize. + * serialise the expansion under a lock. */ static void expand_last_exec(int cpu_index) { - g_mutex_lock(&expand_array_lock); + g_rw_lock_writer_unlock(&expand_array_lock); while (cpu_index >=3D last_exec->len) { GString *s =3D g_string_new(NULL); g_ptr_array_add(last_exec, s); } - g_mutex_unlock(&expand_array_lock); + g_rw_lock_writer_unlock(&expand_array_lock); } =20 /** @@ -51,8 +49,10 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin= _meminfo_t info, GString *s; =20 /* Find vCPU in array */ + g_rw_lock_reader_lock(&expand_array_lock); g_assert(cpu_index < last_exec->len); s =3D g_ptr_array_index(last_exec, cpu_index); + g_rw_lock_reader_unlock(&expand_array_lock); =20 /* Indicate type of memory access */ if (qemu_plugin_mem_is_store(info)) { @@ -80,10 +80,14 @@ static void vcpu_insn_exec(unsigned int cpu_index, void= *udata) GString *s; =20 /* Find or create vCPU in array */ + g_rw_lock_reader_lock(&expand_array_lock); if (cpu_index >=3D last_exec->len) { + g_rw_lock_reader_unlock(&expand_array_lock); expand_last_exec(cpu_index); + g_rw_lock_reader_lock(&expand_array_lock); } s =3D g_ptr_array_index(last_exec, cpu_index); + g_rw_lock_reader_unlock(&expand_array_lock); =20 /* Print previous instruction in cache */ if (s->len) { --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793132; cv=none; d=zohomail.com; s=zohoarc; b=Eedp86zJE9LMMSrb6PVi0TtK/gkMfqoozSt6a8RKm2xBrdExO7SSEP8um4nNmrByVlQrRRWN9G9MpoItgcI/ukzn7oBgYHzjO5GqcQbfLVIB8nQudB4vehVEEO7xOar98CI6cwBc9Ftadc4RlIxWC8gslo4uKhnk8c5jzYcPX3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793132; 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; bh=VkgSGwMXDjUkTeTAm5YYf6l6h2mj4NduaQleFrB8R9Y=; b=dwThgm4J3JnB9ae073MMC0VzaZuO9S6TFQNS+TpAvASmuy61rmuVhfjYSVsPmb9WlzDNQ35oTsHFioTJAunlKNZT7l11uMZALuM8s8/M2xiHSNnMevilbhU2bcljPofgB7NqVfIA+7E/pZnSKlgufH9adLb0iCO9i2ka0wyqE+U= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793132566734.7628404964162; Mon, 31 Jul 2023 01:45:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOW6-0007Ia-Hh; Mon, 31 Jul 2023 04:44:38 -0400 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 1qQOW3-0007G1-0w for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:44:35 -0400 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOW0-0004UD-V9 for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:44:34 -0400 Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-76af2cb7404so294673585a.0 for ; Mon, 31 Jul 2023 01:44:32 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.44.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:44:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793072; x=1691397872; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VkgSGwMXDjUkTeTAm5YYf6l6h2mj4NduaQleFrB8R9Y=; b=5UK9/A8rpMnrGdvfjZ2TBJxwVehxPdYe6V3yj5b/vvub3fGAUPjMSWRWHjJaTzkR82 Qn0zGsVmjkmb5Gu/NyfW+l5BEYyzHkXi3lm1fySYmydMDWFjsCsuAUS+7GkewYtBJ2Nn Va/WXLsJCvfA+/adL7WYzwfzYFB5WhKCI1i3qjPycKZUbhuUcePFHqGhJ4LcjMby2tdX zS1bu6S51Yxov4aVhKDVqFjl2MHB/PqSAt8LfVGJNXJNIAQwUINoHBE4yERuZRpwV4en 6nAaQt4qbyPPr99xEKRcWnRP4IhQpO/KWMxadT1xNlcVIlQxeK2IXmkHXZ7YhmBgLCnv Qe1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793072; x=1691397872; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VkgSGwMXDjUkTeTAm5YYf6l6h2mj4NduaQleFrB8R9Y=; b=icheKX8/R8JvT7Mgd7FeO9hH1KVyiV9G9y4j6KNZogeW6l/flbxUxoOc04gE8Uh8hi oFI2+kQHyYU4vYkgpJFRl46MVepG7VSNg+9BM/MrGGjdHCE6kf/Tdq2tDcoa9mw/KqPQ A5t2C0JJMbC5B61AlM1613ynHsz/17y43dW60CWFpvyRl4LW0aBufJYpviV6a1AjkjWC 5TjIVCc9gVKfPDL5oxkUjyadXIrv6qeaXBFlqBh9eD+zOOa52WpQM6t8ABZ6pfPHOsSN QJE+Y0EEPzUU7jtwt51Xn7+mp3WhP8YDHeV6dXKHiR0kM5tOzoTYfcrT6tpOkayCyXFy s7eQ== X-Gm-Message-State: ABy/qLZ4tgjnouIFzDnMVTur8kpWlgbrMX4NZAGa2tGOhWb2H1Obo+/8 Zlp9EZgqe0vpOelCWoSOhdY2Aw== X-Google-Smtp-Source: APBJJlEgu1SZVKwLEqrb59FQIA4gzFwmerM2s4pqVp9VU5zP6SrViNqlNYqqR9MUvwu5RMdrIeoJww== X-Received: by 2002:a05:620a:454b:b0:76c:a564:c8b5 with SMTP id u11-20020a05620a454b00b0076ca564c8b5mr5029111qkp.7.1690793072114; Mon, 31 Jul 2023 01:44:32 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 02/24] gdbstub: Introduce GDBFeature structure Date: Mon, 31 Jul 2023 17:43:29 +0900 Message-ID: <20230731084354.115015-3-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::733; envelope-from=akihiko.odaki@daynix.com; helo=mail-qk1-x733.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793134598100007 Content-Type: text/plain; charset="utf-8" Before this change, the information from a XML file was stored in an array that is not descriptive. Introduce a dedicated structure type to make it easier to understand and to extend with more fields. Signed-off-by: Akihiko Odaki Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- MAINTAINERS | 2 +- meson.build | 2 +- include/exec/gdbstub.h | 9 ++++-- gdbstub/gdbstub.c | 4 +-- stubs/gdbstub.c | 6 ++-- scripts/feature_to_c.py | 44 ++++++++++++++++++++++++++ scripts/feature_to_c.sh | 69 ----------------------------------------- 7 files changed, 58 insertions(+), 78 deletions(-) create mode 100755 scripts/feature_to_c.py delete mode 100644 scripts/feature_to_c.sh diff --git a/MAINTAINERS b/MAINTAINERS index 12e59b6b27..514ac74101 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2826,7 +2826,7 @@ F: include/exec/gdbstub.h F: include/gdbstub/* F: gdb-xml/ F: tests/tcg/multiarch/gdbstub/ -F: scripts/feature_to_c.sh +F: scripts/feature_to_c.py F: scripts/probe-gdb-support.py =20 Memory API diff --git a/meson.build b/meson.build index 98e68ef0b1..5c633f7e01 100644 --- a/meson.build +++ b/meson.build @@ -3683,7 +3683,7 @@ common_all =3D static_library('common', dependencies: common_all.dependencies(), name_suffix: 'fa') =20 -feature_to_c =3D find_program('scripts/feature_to_c.sh') +feature_to_c =3D find_program('scripts/feature_to_c.py') =20 if targetos =3D=3D 'darwin' entitlement =3D find_program('scripts/entitlement.sh') diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 7d743fe1e9..bd5bc91dda 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -10,6 +10,11 @@ #define GDB_WATCHPOINT_READ 3 #define GDB_WATCHPOINT_ACCESS 4 =20 +typedef struct GDBFeature { + const char *xmlname; + const char *xml; +} GDBFeature; + =20 /* Get or set a register. Returns the size of the register. */ typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg); @@ -38,7 +43,7 @@ void gdb_set_stop_cpu(CPUState *cpu); */ extern bool gdb_has_xml; =20 -/* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */ -extern const char *const xml_builtin[][2]; +/* in gdbstub-xml.c, generated by scripts/feature_to_c.py */ +extern const GDBFeature gdb_features[]; =20 #endif diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 6911b73c07..fad70200d8 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -407,11 +407,11 @@ static const char *get_feature_xml(const char *p, con= st char **newp, } } for (i =3D 0; ; i++) { - name =3D xml_builtin[i][0]; + name =3D gdb_features[i].xmlname; if (!name || (strncmp(name, p, len) =3D=3D 0 && strlen(name) =3D= =3D len)) break; } - return name ? xml_builtin[i][1] : NULL; + return name ? gdb_features[i].xml : NULL; } =20 static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) diff --git a/stubs/gdbstub.c b/stubs/gdbstub.c index 2b7aee50d3..324d17f045 100644 --- a/stubs/gdbstub.c +++ b/stubs/gdbstub.c @@ -1,6 +1,6 @@ #include "qemu/osdep.h" -#include "exec/gdbstub.h" /* xml_builtin */ +#include "exec/gdbstub.h" /* gdb_features */ =20 -const char *const xml_builtin[][2] =3D { - { NULL, NULL } +const GDBFeature gdb_features[] =3D { + { NULL } }; diff --git a/scripts/feature_to_c.py b/scripts/feature_to_c.py new file mode 100755 index 0000000000..5a5b49367b --- /dev/null +++ b/scripts/feature_to_c.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 + +import os, sys + +def writeliteral(indent, bytes): + sys.stdout.write(' ' * indent) + sys.stdout.write('"') + quoted =3D True + + for c in bytes: + if not quoted: + sys.stdout.write('\n') + sys.stdout.write(' ' * indent) + sys.stdout.write('"') + quoted =3D True + + if c =3D=3D b'"'[0]: + sys.stdout.write('\\"') + elif c =3D=3D b'\\'[0]: + sys.stdout.write('\\\\') + elif c =3D=3D b'\n'[0]: + sys.stdout.write('\\n"') + quoted =3D False + elif c >=3D 32 and c < 127: + sys.stdout.write(c.to_bytes(1, 'big').decode()) + else: + sys.stdout.write(f'\{c:03o}') + + if quoted: + sys.stdout.write('"') + +sys.stdout.write('#include "qemu/osdep.h"\n#include "exec/gdbstub.h"\n\nco= nst GDBFeature gdb_features[] =3D {\n') + +for input in sys.argv[1:]: + with open(input, 'rb') as file: + read =3D file.read() + + sys.stdout.write(' {\n') + writeliteral(8, bytes(os.path.basename(input), 'utf-8')) + sys.stdout.write(',\n') + writeliteral(8, read) + sys.stdout.write('\n },\n') + +sys.stdout.write(' { NULL }\n};\n') diff --git a/scripts/feature_to_c.sh b/scripts/feature_to_c.sh deleted file mode 100644 index c1f67c8f6a..0000000000 --- a/scripts/feature_to_c.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh - -# Convert text files to compilable C arrays. -# -# Copyright (C) 2007 Free Software Foundation, Inc. -# -# This file is part of GDB. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . - -if test -z "$1"; then - echo "Usage: $0 INPUTFILE..." - exit 1 -fi - -for input; do - arrayname=3Dxml_feature_$(echo $input | sed 's,.*/,,; s/[-.]/_/g') - - ${AWK:-awk} 'BEGIN { n =3D 0 - printf "#include \"qemu/osdep.h\"\n" - print "static const char '$arrayname'[] =3D {" - for (i =3D 0; i < 255; i++) - _ord_[sprintf("%c", i)] =3D i - } { - split($0, line, ""); - printf " " - for (i =3D 1; i <=3D length($0); i++) { - c =3D line[i] - if (c =3D=3D "'\''") { - printf "'\''\\'\'''\'', " - } else if (c =3D=3D "\\") { - printf "'\''\\\\'\'', " - } else if (_ord_[c] >=3D 32 && _ord_[c] < 127) { - printf "'\''%s'\'', ", c - } else { - printf "'\''\\%03o'\'', ", _ord_[c] - } - if (i % 10 =3D=3D 0) - printf "\n " - } - printf "'\''\\n'\'', \n" - } END { - print " 0 };" - }' < $input -done - -echo -echo '#include "exec/gdbstub.h"' -echo "const char *const xml_builtin[][2] =3D {" - -for input; do - basename=3D$(echo $input | sed 's,.*/,,') - arrayname=3Dxml_feature_$(echo $input | sed 's,.*/,,; s/[-.]/_/g') - echo " { \"$basename\", $arrayname }," -done - -echo " { (char *)0, (char *)0 }" -echo "};" --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793115; cv=none; d=zohomail.com; s=zohoarc; b=ALt2uDJFv0nMqJHwikBlu1IT1dDBQaObYKgXS2svt/N54GPfR3Bps4yBXPZ//m4OXb+PkyoDm8BNUPw7YehNDXH/vVnNm2DJrwcM9UA0UkuOSFjBqMN/fEe9/cOCBNL3BWoDRhE/wcedL9IgvouUIiH4vE13MmnOR0K4MdFnzoM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793115; 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; bh=mAUxS0KeO+VW3iT7G7DIpYMmx9Vycw64xBFZFbBxFBY=; b=RrB1+R8Z0gm49w21ZWwYBVzcIjrXCqW7tdhb7VyUld0EQT+40cjiSadSpzc7LNb9WlvDZXekJDAzQ6H4WYZC2h2c26Lrfg0i2xAjSAvPK5g7+uhqJaNnPziNISCxIUCAPPpzu51I2cf9KKihDJXzZp0XKxo4MfRZkcDzsU8wFe8= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169079311510685.79708167267279; Mon, 31 Jul 2023 01:45:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOWC-0007LS-UC; Mon, 31 Jul 2023 04:44:44 -0400 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 1qQOWC-0007Kj-13 for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:44:44 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOWA-0004Vi-AK for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:44:43 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-686ba97e4feso4278639b3a.0 for ; Mon, 31 Jul 2023 01:44:42 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.44.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:44:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793081; x=1691397881; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mAUxS0KeO+VW3iT7G7DIpYMmx9Vycw64xBFZFbBxFBY=; b=sZAYMXRQ2QP58O7r7eLfLf8bIc5vVQO9DWQlq0Aj7mnVTxdhjXocdms5g+rSp8iqUC lA3xlXJ+2Gwn89LpI7mCrxFnVUqoOyaCH2bQtKCFiERUNxpoMvM2YXtRD1LqD9MHFMJE yAtWti54NEdg9AueYEHGa9PgEWe9RMwolD6WGFYcCjKqBBTli7cpg8Ga3hbE5TnA4rLE cnVfPPNXd7d8Vel3ANoOffEH4KBAzGUWyGSEjm4/NqK/7l6XY7CiDG4tQDkLi//XprQC tTjY+nXZx6c5R33SXY+3FERz30nqjnTRYiOBRqriInDwEWNF0E8XDrZLSkvGbK9zc1zC 8Q4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793081; x=1691397881; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mAUxS0KeO+VW3iT7G7DIpYMmx9Vycw64xBFZFbBxFBY=; b=PcEC7aHW3yrekZwlWh+mgAl203xTdOY2XI1ePT8XOx2aQ+5nZ1qgd4EYEG4FzEyLxx nfkabSnoe+c3bsFdUIwtt8qh85hP6CIzePKFZXTS4A8Zd63wdihfaDD4H31aIFEtvxPH HdKHfbZAWRENzIhwASgDfP0Zd7Xqejh2ALu3sYb0bi4MRvVVuCpmb2skOYDpH3xuws4p x28Y8Oj1cz2R/27vAGzgw0W1m8i1ROkmRA8OhOh6sEAM/3mGu+G/VuaSig5XUqmIOb64 o8V/gb5gaU8qEc0xV3Kh/JHMqvGluwkrKL5KfRICGW5USNGH1YXiFBU1CpTMy2ZhIpEi gdVg== X-Gm-Message-State: ABy/qLbnPMYcco78puJG1WQZTnNEoAYFIvu1QkCiB1Fp6cu/Wkcy5DjK yBrKnBb943QZngS075mVuaZ2zg== X-Google-Smtp-Source: APBJJlEfNRDWb5o5QOCUiZse9TFpK7En7HOFMM5Uo1l8I9NrY9s4LILfkkaDU6f6ZALg1acFnqXFWA== X-Received: by 2002:a05:6a00:1351:b0:675:8f71:290a with SMTP id k17-20020a056a00135100b006758f71290amr12463128pfu.34.1690793081090; Mon, 31 Jul 2023 01:44:41 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 03/24] gdbstub: Add num_regs member to GDBFeature Date: Mon, 31 Jul 2023 17:43:30 +0900 Message-ID: <20230731084354.115015-4-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::42a; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793116782100003 Content-Type: text/plain; charset="utf-8" Currently the number of registers exposed to GDB is written as magic numbers in code. Derive the number of registers GDB actually see from XML files to replace the magic numbers in code later. Signed-off-by: Akihiko Odaki Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/exec/gdbstub.h | 1 + scripts/feature_to_c.py | 46 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index bd5bc91dda..22e5add5b1 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -13,6 +13,7 @@ typedef struct GDBFeature { const char *xmlname; const char *xml; + int num_regs; } GDBFeature; =20 =20 diff --git a/scripts/feature_to_c.py b/scripts/feature_to_c.py index 5a5b49367b..8eb8c81cf8 100755 --- a/scripts/feature_to_c.py +++ b/scripts/feature_to_c.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 =20 -import os, sys +import os, sys, xml.etree.ElementTree =20 def writeliteral(indent, bytes): sys.stdout.write(' ' * indent) @@ -35,10 +35,52 @@ def writeliteral(indent, bytes): with open(input, 'rb') as file: read =3D file.read() =20 + parser =3D xml.etree.ElementTree.XMLPullParser(['start', 'end']) + parser.feed(read) + events =3D parser.read_events() + event, element =3D next(events) + if event !=3D 'start': + sys.stderr.write(f'unexpected event: {event}\n') + exit(1) + if element.tag !=3D 'feature': + sys.stderr.write(f'unexpected start tag: {element.tag}\n') + exit(1) + + regnum =3D 0 + regnums =3D [] + tags =3D ['feature'] + for event, element in events: + if event =3D=3D 'end': + if element.tag !=3D tags[len(tags) - 1]: + sys.stderr.write(f'unexpected end tag: {element.tag}\n') + exit(1) + + tags.pop() + if element.tag =3D=3D 'feature': + break + elif event =3D=3D 'start': + if len(tags) < 2 and element.tag =3D=3D 'reg': + if 'regnum' in element.attrib: + regnum =3D int(element.attrib['regnum']) + + regnums.append(regnum) + regnum +=3D 1 + + tags.append(element.tag) + else: + raise Exception(f'unexpected event: {event}\n') + + if len(tags): + sys.stderr.write('unterminated feature tag\n') + exit(1) + + base_reg =3D min(regnums) + num_regs =3D max(regnums) - base_reg + 1 if len(regnums) else 0 + sys.stdout.write(' {\n') writeliteral(8, bytes(os.path.basename(input), 'utf-8')) sys.stdout.write(',\n') writeliteral(8, read) - sys.stdout.write('\n },\n') + sys.stdout.write(f',\n {num_regs},\n }},\n') =20 sys.stdout.write(' { NULL }\n};\n') --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793110; cv=none; d=zohomail.com; s=zohoarc; b=FZd1m7TVX5ptxJEfCOISY51DBj/Zpezh741Lcw/guxOElrkAuie8DUydxndrSlEGJG/wTMYKN+cGpgu7P5rYS8WOxImOX64Jv+c6Yr+qGYDNrY2+RYH9td9wkJqojGWtNyNecTQXtF/Yf6qrokO4gbasta3mI4zULlnAVtB2tHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793110; 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; bh=lVYJk6LGaltRcOKAehyT3A59XywRmFvsI/b8ir5GS3U=; b=Q49dIa+ucRLQEa1AdBq0SQFg8H+roRjwxW2pL0hDnUcTRBalB99NJRslwDOWWKUVlb6YWkYgK+7hPd1uDn0nrkRkzbVjCIiDoiZATrllz5eaqJ7ORMQhGbKdvjEU8N3iePsRsjXm7RI3SdBtm+LqZCUALEe1D05CGI2FsmVvjQc= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793110769997.7249114603635; Mon, 31 Jul 2023 01:45:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOWQ-0007kL-1S; Mon, 31 Jul 2023 04:44:58 -0400 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 1qQOWK-0007cS-Tb for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:44:52 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOWJ-0004We-8j for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:44:52 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-68706b39c4cso2207314b3a.2 for ; Mon, 31 Jul 2023 01:44:50 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.44.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:44:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793090; x=1691397890; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lVYJk6LGaltRcOKAehyT3A59XywRmFvsI/b8ir5GS3U=; b=BykZvVzeeIyleaCsCxlBPKsXbpHaujxGxlNK2l+O+9UnfFsnXUPXjxsozBMpcZNbc/ SE3MLTBKLLwM16qrqw8WwHliSIDdd5LAgJ6K1yAKA3v9bVjViZYWvX6oP7tKlgA5SsH9 +FIkewHecvcmp354i417hO5iq5/TX/e0ZrNM4o5r/tvw20lNKKRftFckzsQU6VKNoggn j/cEOHRN3sdBUh1sNijpdVAHLL+gt4CM1OIwDSeYJfW5PsXBASliS6MDwBDjUNlbvW0+ LOOyiPHALaISYNcfzqfBhprWMMTHIJtPVX6WDB0K/PXvr2fSl793tchbQtdG4KLNOSZN ONsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793090; x=1691397890; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lVYJk6LGaltRcOKAehyT3A59XywRmFvsI/b8ir5GS3U=; b=kfBPeBRS3su1V2e43+hU+iAmIPYIwJOl7tcPZcdwqPDcSDwuyMVdUQeD6Xnj8WBLhE zOSCWhNdu8km+o5dRrVGXezQ/QTJGJfURNWO2j/qpEBivSO1VzJqeIZ2SDeViqkDBvFi TvdEnYqEKbWw1Kl5l5QwTVbXmJIJQFt/KBH0ULy1yloLRgqKzg/OR02iN5s9x0++blxh ncKAa6cmrTDfcrLE8qy3v8souAE7GhLkmGO9S3TgV60HPCsCsJuVASfCSZyJtHaamSyo 9v1hdF1MmblZSEFVSiKYqDAQhrmY2IyqDuuFxGoUOA/bQ4kSvJTYyNEzuJRME+i76B5C P9oA== X-Gm-Message-State: ABy/qLbuOa4Lbb7JOIXN8LoS+5jHn4hrleAV1EKTHQyx+juICpmxELy/ WCeyj/R+GclyJpp8char2UIGzQ== X-Google-Smtp-Source: APBJJlEmSkhH610IOf78Ddg7wL5Fa2C8ae2uuFOWoonLbL1asCR2tM0pEqy9UiM56ZXl46akI/Z1tQ== X-Received: by 2002:a05:6a00:24d6:b0:686:254c:9d47 with SMTP id d22-20020a056a0024d600b00686254c9d47mr10490718pfv.30.1690793090111; Mon, 31 Jul 2023 01:44:50 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 04/24] gdbstub: Introduce gdb_find_static_feature() Date: Mon, 31 Jul 2023 17:43:31 +0900 Message-ID: <20230731084354.115015-5-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::42b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793111879100004 Content-Type: text/plain; charset="utf-8" This function is useful to determine the number of registers exposed to GDB from the XML name. Signed-off-by: Akihiko Odaki Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/exec/gdbstub.h | 2 ++ gdbstub/gdbstub.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 22e5add5b1..3115dc21c0 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -34,6 +34,8 @@ void gdb_register_coprocessor(CPUState *cpu, */ int gdbserver_start(const char *port_or_device); =20 +const GDBFeature *gdb_find_static_feature(const char *xmlname); + void gdb_set_stop_cpu(CPUState *cpu); =20 /** diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index fad70200d8..6d9cef5b95 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -414,6 +414,19 @@ static const char *get_feature_xml(const char *p, cons= t char **newp, return name ? gdb_features[i].xml : NULL; } =20 +const GDBFeature *gdb_find_static_feature(const char *xmlname) +{ + const GDBFeature *feature; + + for (feature =3D gdb_features; feature->xmlname; feature++) { + if (!strcmp(feature->xmlname, xmlname)) { + return feature; + } + } + + return NULL; +} + static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { CPUClass *cc =3D CPU_GET_CLASS(cpu); --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793130; cv=none; d=zohomail.com; s=zohoarc; b=hcJz4aq2cqk3v575poDxwETe0iiF123KEptlsV3o7QHpAY2JoF/liTY7YBmqisRmAH2OQCw8CAqpkNBPGFwJhSzEAKjORIZKEO6H3GXGAyQoguOmoLCqJ+eT+TVKBx6hpGHzlK9BbCejqI1DhjVRIKI4fRXdD5yqGsxEh8hKvto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793130; 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; bh=Z8QC8ufyB7xcDBCvHI4qa5+GakxSnSbOuWxZo6h21Sw=; b=P0TZ0pfzMDY4Ejgmg7RoFMDdS1sBfeLbZ8swsYWukzPf7guB/LpYCePFIT2tIVKPqZEFjNDeEAFw7SZwIAQpU3FTkLqCabTqYrvdYLPImXtUh9oG4IrI1qQJBNiTQPsEkmVg20+25acSHH1TaY5qCMbcRqTbHNSN0IxuoGmIu14= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793130889709.5011369708487; Mon, 31 Jul 2023 01:45:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOWY-0007ry-W6; Mon, 31 Jul 2023 04:45:07 -0400 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 1qQOWT-0007ot-VV for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:45:02 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOWS-0004Xw-Bn for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:45:01 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-686b9964ae2so2803422b3a.3 for ; Mon, 31 Jul 2023 01:45:00 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.44.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:44:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793099; x=1691397899; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z8QC8ufyB7xcDBCvHI4qa5+GakxSnSbOuWxZo6h21Sw=; b=gxR7Ttu22Iqb0VqXs37tl4tlLHU25qnpcDDxZGAU0myX3WhqdjAcSODi5D4BdWEhV9 q1NP4eldp7rRXuISIhAsTOT6j1nGAfjVhOD4AY1Tlpdntu8fnRFYCtgG6BsJcFAWhxBK pmNHmwAWY5/E92jOZDblL4SfwgT7aXg0wZHHRbk++R/6DXHmf0ksi0JnGV5sytXymYDW CskQXrlTqv3otcEo8jUkqHRFMmklqB9kQg2XIJ/PWSEoBF9GTOlOW+9dhj+4+78AwEPw w2sy3Vl0rUey4jzPlgGoATQ5USR23UgjFv4dPsdW8Sni7qOzDftnl6fPVYqDoVm5R3u2 /8MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793099; x=1691397899; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z8QC8ufyB7xcDBCvHI4qa5+GakxSnSbOuWxZo6h21Sw=; b=PW+wJlByACtz/TYbuNuubNBjcIurl+pBw6XVS4zJIbF/u1DalyMGsX9xXraZVVPm4i YlOt+hngTClv94vkQh7uqpaMNqHn8oCN1baYGGWxJRdWvzfqrhkjIU677uIsxDlf+opE xQwB2K5657qVGp9/U2j9Ni2colKn96Kc8F4zL13CmrXmCCaCNc7F0LLyf5xrAa1sLCHE R/iLFTCJXeeUmCeLnKbciqvfSr7JavHFcbWWcs6rv+RtTbGQouKUVS74RiSdzDM11XCe ZsHuV8ve7HODzY9yj7dXqn6sYMdS3UJSFPL467IsyVwaD/CPB97UpRge0uO3IEm9aCpu wJEg== X-Gm-Message-State: ABy/qLbpWljxTL2gbVOOF6UDjtK03k/Ii4f8WVjQr1uqQ8//+4Om4Vvi PzMkq8Tl9mVgG6X1ss9boXD73Q== X-Google-Smtp-Source: APBJJlHb4am5urBinc9EACtCaDLw8vzdkChKaTSTz/oic5Zk1jghpHuUG0giPtiisUhV6YED/Nk53Q== X-Received: by 2002:a05:6a20:552a:b0:13d:ee19:7717 with SMTP id ko42-20020a056a20552a00b0013dee197717mr1032425pzb.19.1690793099313; Mon, 31 Jul 2023 01:44:59 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 05/24] target/arm: Move the reference to arm-core.xml Date: Mon, 31 Jul 2023 17:43:32 +0900 Message-ID: <20230731084354.115015-6-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::429; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x429.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793133241100003 Content-Type: text/plain; charset="utf-8" Some subclasses overwrite gdb_core_xml_file member but others don't. Always initialize the member in the subclasses for consistency. This especially helps for AArch64; in a following change, the file specified by gdb_core_xml_file is always looked up even if it's going to be overwritten later. Looking up arm-core.xml results in an error as it will not be embedded in the AArch64 build. Signed-off-by: Akihiko Odaki --- target/arm/cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 93c28d50e5..d71a162070 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2354,7 +2354,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) cc->sysemu_ops =3D &arm_sysemu_ops; #endif cc->gdb_num_core_regs =3D 26; - cc->gdb_core_xml_file =3D "arm-core.xml"; cc->gdb_arch_name =3D arm_gdb_arch_name; cc->gdb_get_dynamic_xml =3D arm_gdb_get_dynamic_xml; cc->gdb_stop_before_watchpoint =3D true; @@ -2376,8 +2375,10 @@ static void arm_cpu_instance_init(Object *obj) static void cpu_register_class_init(ObjectClass *oc, void *data) { ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); + CPUClass *cc =3D CPU_CLASS(acc); =20 acc->info =3D data; + cc->gdb_core_xml_file =3D "arm-core.xml"; } =20 void arm_cpu_register(const ARMCPUInfo *info) --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793207; cv=none; d=zohomail.com; s=zohoarc; b=icCMJEAEhpSi4en8L9fUeLfE0P4Pp/k1FJzGbwJ1HhEKa2NLygYGGNCSgX/jY1ShHG2Z2Nqg2GEG4R0wjdVh5zU8AI7QmzpH3V/hHLYDAyfDVHgN0p7IvuxrVNYmyofpUS2SBSKYbHmFUbbL8E3BHvsa64pA3XkzAvjH3YsBzmk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793207; 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; bh=m/sJfuTbVU1tTqxIMATnHRjaDAmKZwDFBs7OL4JJfj0=; b=c3CC+Pk5NfpF4IOpsublpZ6B07wbDxAkL/A/yhDdcVNUcT83Trecg6mh/1SIK0BVbW7nCdU+lZeFPOU4BCscNxELd+XbP/G3NhUSsnqPeL26zIoN77WjG4e04imYY9hOmdgfsSBwbqsv4QohhH4S573pj1kIHh58mX5OKbBkFW4= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793207562585.9824646197328; Mon, 31 Jul 2023 01:46:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOWt-0008PO-T1; Mon, 31 Jul 2023 04:45:27 -0400 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 1qQOWh-0008ET-EH for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:45:15 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOWd-0004kY-0q for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:45:15 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-68706d67ed9so2352184b3a.2 for ; Mon, 31 Jul 2023 01:45:09 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:45:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793108; x=1691397908; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m/sJfuTbVU1tTqxIMATnHRjaDAmKZwDFBs7OL4JJfj0=; b=LTpzI+F3rb+GPTPixunDZyrqaqcyFRa1tv+UndweTmTCf5UHHde7L7ksIKd0mmFHhb Ykvk6oF3jva2EgFTWiEm3PRrtV3vtFD6FfWxfleZ67nHCQfXjmgPKM9LoHZySn4msUhQ EjwI2QTlWvzG8Ooi8kjBiR6VlrpedviNW/UQC+Pkdjs8fB5DOA593ZgBqTiSQUF9v5yq xXVdKOKDQSdXg7OSbSW3zSB5+1zDHovIAqm6kQIcHrIQjo3NngNmQ6RrZb40f61A6TR9 qecysaO4RPwRRpRkhzGIdPOS4ED13yDzf2SvPCtoaa5Ar6tFw6A4aVrcPfmnBVqJEEZV C3OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793108; x=1691397908; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m/sJfuTbVU1tTqxIMATnHRjaDAmKZwDFBs7OL4JJfj0=; b=QVOK6zvJ2P0T/RYEbb/x4UTekqRhUmu/iy1UgJvmGN6OcT9SAOfMezqC4cEbJvSWAm 3LEBKYqkddlel4t04yEA15Mf01rtASRPUGiWIWYU789KDejL6mleY64LwkyBD21Aw2Vy UP3CivQxbd+QvJfOz4J/UOwBMBi8S+qv9O8GGJXPwyVvqceWUcXHplxGzNLP4vVq7sA/ Cuq/y+5nyF13TaKghY5ZdiZO9L/Fh/wu60WVAfuI+6ssNXcAqvq8WBdOPIVynoIfDkR4 ytFnh/1DPknzyTderx+n0kqfieMp3UpQu70bjsb1lU3If/xMk1psZryRRX3lRyOHLEA2 BWqQ== X-Gm-Message-State: ABy/qLYPbHDLN7GEquyggKXmGBYW+bHlIjGkB1XdRQ4ABohGcQQ6BeGG ZoSMLQcchcKx0Vr+xjGRJuPMAA== X-Google-Smtp-Source: APBJJlF04yKMy2evlGsgY6CmUDBaKhQtndlsI6dfDrOncx8kHMxYrKya4dWsxU2mxaftPgWZbpS4iA== X-Received: by 2002:a05:6a00:2403:b0:686:2668:796f with SMTP id z3-20020a056a00240300b006862668796fmr11059952pfh.32.1690793108303; Mon, 31 Jul 2023 01:45:08 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 06/24] hw/core/cpu: Replace gdb_core_xml_file with gdb_core_feature Date: Mon, 31 Jul 2023 17:43:33 +0900 Message-ID: <20230731084354.115015-7-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::432; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x432.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793208665100003 Content-Type: text/plain; charset="utf-8" This is a tree-wide change to replace gdb_core_xml_file, the path to GDB XML file with gdb_core_feature, the pointer to GDBFeature. This also replaces the values assigned to gdb_num_core_regs with the num_regs member of GDBFeature where applicable to remove magic numbers. A following change will utilize additional information provided by GDBFeature to simplify XML file lookup. Signed-off-by: Akihiko Odaki --- include/hw/core/cpu.h | 5 +++-- target/s390x/cpu.h | 2 -- gdbstub/gdbstub.c | 6 +++--- target/arm/cpu.c | 4 ++-- target/arm/cpu64.c | 4 ++-- target/arm/tcg/cpu32.c | 3 ++- target/avr/cpu.c | 4 ++-- target/hexagon/cpu.c | 2 +- target/i386/cpu.c | 7 +++---- target/loongarch/cpu.c | 4 ++-- target/m68k/cpu.c | 7 ++++--- target/microblaze/cpu.c | 4 ++-- target/ppc/cpu_init.c | 4 ++-- target/riscv/cpu.c | 7 ++++--- target/rx/cpu.c | 4 ++-- target/s390x/cpu.c | 4 ++-- 16 files changed, 36 insertions(+), 35 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index fdcbe87352..84219c1885 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -23,6 +23,7 @@ #include "hw/qdev-core.h" #include "disas/dis-asm.h" #include "exec/cpu-common.h" +#include "exec/gdbstub.h" #include "exec/hwaddr.h" #include "exec/memattrs.h" #include "qapi/qapi-types-run-state.h" @@ -127,7 +128,7 @@ struct SysemuCPUOps; * breakpoint. Used by AVR to handle a gdb mis-feature with * its Harvard architecture split code and data. * @gdb_num_core_regs: Number of core registers accessible to GDB. - * @gdb_core_xml_file: File name for core registers GDB XML description. + * @gdb_core_feature: GDB core feature description. * @gdb_stop_before_watchpoint: Indicates whether GDB expects the CPU to s= top * before the insn which triggers a watchpoint rather than after= it. * @gdb_arch_name: Optional callback that returns the architecture name kn= own @@ -163,7 +164,7 @@ struct CPUClass { int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg); vaddr (*gdb_adjust_breakpoint)(CPUState *cpu, vaddr addr); =20 - const char *gdb_core_xml_file; + const GDBFeature *gdb_core_feature; gchar * (*gdb_arch_name)(CPUState *cpu); const char * (*gdb_get_dynamic_xml)(CPUState *cpu, const char *xmlname= ); =20 diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index eb5b65b7d3..c5bac3230c 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -451,8 +451,6 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState *= env, vaddr *pc, #define S390_R13_REGNUM 15 #define S390_R14_REGNUM 16 #define S390_R15_REGNUM 17 -/* Total Core Registers. */ -#define S390_NUM_CORE_REGS 18 =20 static inline void setcc(S390CPU *cpu, uint64_t cc) { diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 6d9cef5b95..6f2e0cb06f 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -386,7 +386,7 @@ static const char *get_feature_xml(const char *p, const= char **newp, g_free(arch); } pstrcat(buf, buf_sz, "gdb_core_xml_file); + pstrcat(buf, buf_sz, cc->gdb_core_feature->xmlname); pstrcat(buf, buf_sz, "\"/>"); for (r =3D cpu->gdb_regs; r; r =3D r->next) { pstrcat(buf, buf_sz, "gdb_core_xml_file) { + if (cc->gdb_core_feature) { g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+"); } =20 @@ -1548,7 +1548,7 @@ static void handle_query_xfer_features(GArray *params= , void *user_ctx) =20 process =3D gdb_get_cpu_process(gdbserver_state.g_cpu); cc =3D CPU_GET_CLASS(gdbserver_state.g_cpu); - if (!cc->gdb_core_xml_file) { + if (!cc->gdb_core_feature) { gdb_put_packet(""); return; } diff --git a/target/arm/cpu.c b/target/arm/cpu.c index d71a162070..a206ab6b1b 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2353,7 +2353,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) #ifndef CONFIG_USER_ONLY cc->sysemu_ops =3D &arm_sysemu_ops; #endif - cc->gdb_num_core_regs =3D 26; cc->gdb_arch_name =3D arm_gdb_arch_name; cc->gdb_get_dynamic_xml =3D arm_gdb_get_dynamic_xml; cc->gdb_stop_before_watchpoint =3D true; @@ -2378,7 +2377,8 @@ static void cpu_register_class_init(ObjectClass *oc, = void *data) CPUClass *cc =3D CPU_CLASS(acc); =20 acc->info =3D data; - cc->gdb_core_xml_file =3D "arm-core.xml"; + cc->gdb_core_feature =3D gdb_find_static_feature("arm-core.xml"); + cc->gdb_num_core_regs =3D cc->gdb_core_feature->num_regs; } =20 void arm_cpu_register(const ARMCPUInfo *info) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 96158093cc..9c2a226159 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -754,8 +754,8 @@ static void aarch64_cpu_class_init(ObjectClass *oc, voi= d *data) =20 cc->gdb_read_register =3D aarch64_cpu_gdb_read_register; cc->gdb_write_register =3D aarch64_cpu_gdb_write_register; - cc->gdb_num_core_regs =3D 34; - cc->gdb_core_xml_file =3D "aarch64-core.xml"; + cc->gdb_core_feature =3D gdb_find_static_feature("aarch64-core.xml"); + cc->gdb_num_core_regs =3D cc->gdb_core_feature->num_regs; cc->gdb_arch_name =3D aarch64_gdb_arch_name; =20 object_class_property_add_bool(oc, "aarch64", aarch64_cpu_get_aarch64, diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c index 47d2e8e781..49a823ad58 100644 --- a/target/arm/tcg/cpu32.c +++ b/target/arm/tcg/cpu32.c @@ -1040,7 +1040,8 @@ static void arm_v7m_class_init(ObjectClass *oc, void = *data) =20 acc->info =3D data; cc->tcg_ops =3D &arm_v7m_tcg_ops; - cc->gdb_core_xml_file =3D "arm-m-profile.xml"; + cc->gdb_core_feature =3D gdb_find_static_feature("arm-m-profile.xml"); + cc->gdb_num_core_regs =3D cc->gdb_core_feature->num_regs; } =20 #ifndef TARGET_AARCH64 diff --git a/target/avr/cpu.c b/target/avr/cpu.c index 8f741f258c..217adc64cb 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -246,8 +246,8 @@ static void avr_cpu_class_init(ObjectClass *oc, void *d= ata) cc->gdb_read_register =3D avr_cpu_gdb_read_register; cc->gdb_write_register =3D avr_cpu_gdb_write_register; cc->gdb_adjust_breakpoint =3D avr_cpu_gdb_adjust_breakpoint; - cc->gdb_num_core_regs =3D 35; - cc->gdb_core_xml_file =3D "avr-cpu.xml"; + cc->gdb_core_feature =3D gdb_find_static_feature("avr-cpu.xml"); + cc->gdb_num_core_regs =3D cc->gdb_core_feature->num_regs; cc->tcg_ops =3D &avr_tcg_ops; } =20 diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index f155936289..b54162cbeb 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -391,7 +391,7 @@ static void hexagon_cpu_class_init(ObjectClass *c, void= *data) cc->gdb_write_register =3D hexagon_gdb_write_register; cc->gdb_num_core_regs =3D TOTAL_PER_THREAD_REGS; cc->gdb_stop_before_watchpoint =3D true; - cc->gdb_core_xml_file =3D "hexagon-core.xml"; + cc->gdb_core_feature =3D gdb_find_static_feature("hexagon-core.xml"); cc->disas_set_info =3D hexagon_cpu_disas_set_info; cc->tcg_ops =3D &hexagon_tcg_ops; } diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 97ad229d8b..069410985f 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7963,12 +7963,11 @@ static void x86_cpu_common_class_init(ObjectClass *= oc, void *data) =20 cc->gdb_arch_name =3D x86_gdb_arch_name; #ifdef TARGET_X86_64 - cc->gdb_core_xml_file =3D "i386-64bit.xml"; - cc->gdb_num_core_regs =3D 66; + cc->gdb_core_feature =3D gdb_find_static_feature("i386-64bit.xml"); #else - cc->gdb_core_xml_file =3D "i386-32bit.xml"; - cc->gdb_num_core_regs =3D 50; + cc->gdb_core_feature =3D gdb_find_static_feature("i386-32bit.xml"); #endif + cc->gdb_num_core_regs =3D cc->gdb_core_feature->num_regs; cc->disas_set_info =3D x86_disas_set_info; =20 dc->user_creatable =3D true; diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index ad93ecac92..b204cb279d 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -722,8 +722,8 @@ static void loongarch_cpu_class_init(ObjectClass *c, vo= id *data) cc->gdb_read_register =3D loongarch_cpu_gdb_read_register; cc->gdb_write_register =3D loongarch_cpu_gdb_write_register; cc->disas_set_info =3D loongarch_cpu_disas_set_info; - cc->gdb_num_core_regs =3D 35; - cc->gdb_core_xml_file =3D "loongarch-base64.xml"; + cc->gdb_core_feature =3D gdb_find_static_feature("loongarch-base64.xml= "); + cc->gdb_num_core_regs =3D cc->gdb_core_feature->num_regs; cc->gdb_stop_before_watchpoint =3D true; cc->gdb_arch_name =3D loongarch_gdb_arch_name; =20 diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 70d58471dc..2bd7238aa8 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -572,7 +572,6 @@ static void m68k_cpu_class_init(ObjectClass *c, void *d= ata) #endif cc->disas_set_info =3D m68k_cpu_disas_set_info; =20 - cc->gdb_num_core_regs =3D 18; cc->tcg_ops =3D &m68k_tcg_ops; } =20 @@ -580,7 +579,8 @@ static void m68k_cpu_class_init_cf_core(ObjectClass *c,= void *data) { CPUClass *cc =3D CPU_CLASS(c); =20 - cc->gdb_core_xml_file =3D "cf-core.xml"; + cc->gdb_core_feature =3D gdb_find_static_feature("cf-core.xml"); + cc->gdb_num_core_regs =3D cc->gdb_core_feature->num_regs; } =20 #define DEFINE_M68K_CPU_TYPE_CF(model) \ @@ -595,7 +595,8 @@ static void m68k_cpu_class_init_m68k_core(ObjectClass *= c, void *data) { CPUClass *cc =3D CPU_CLASS(c); =20 - cc->gdb_core_xml_file =3D "m68k-core.xml"; + cc->gdb_core_feature =3D gdb_find_static_feature("m68k-core.xml"); + cc->gdb_num_core_regs =3D cc->gdb_core_feature->num_regs; } =20 #define DEFINE_M68K_CPU_TYPE_M68K(model) \ diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 03c2c4db1f..47f37c2519 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -428,8 +428,8 @@ static void mb_cpu_class_init(ObjectClass *oc, void *da= ta) cc->sysemu_ops =3D &mb_sysemu_ops; #endif device_class_set_props(dc, mb_properties); - cc->gdb_num_core_regs =3D 32 + 25; - cc->gdb_core_xml_file =3D "microblaze-core.xml"; + cc->gdb_core_feature =3D gdb_find_static_feature("microblaze-core.xml"= ); + cc->gdb_num_core_regs =3D cc->gdb_core_feature->num_regs; =20 cc->disas_set_info =3D mb_disas_set_info; cc->tcg_ops =3D &mb_tcg_ops; diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 02b7aad9b0..eb56226865 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -7381,9 +7381,9 @@ static void ppc_cpu_class_init(ObjectClass *oc, void = *data) =20 cc->gdb_arch_name =3D ppc_gdb_arch_name; #if defined(TARGET_PPC64) - cc->gdb_core_xml_file =3D "power64-core.xml"; + cc->gdb_core_feature =3D gdb_find_static_feature("power64-core.xml"); #else - cc->gdb_core_xml_file =3D "power-core.xml"; + cc->gdb_core_feature =3D gdb_find_static_feature("power-core.xml"); #endif cc->disas_set_info =3D ppc_disas_set_info; =20 diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 6b93b04453..36de35270d 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1031,11 +1031,11 @@ static void riscv_cpu_validate_misa_mxl(RISCVCPU *c= pu, Error **errp) #ifdef TARGET_RISCV64 case MXL_RV64: case MXL_RV128: - cc->gdb_core_xml_file =3D "riscv-64bit-cpu.xml"; + cc->gdb_core_feature =3D gdb_find_static_feature("riscv-64bit-cpu.= xml"); break; #endif case MXL_RV32: - cc->gdb_core_xml_file =3D "riscv-32bit-cpu.xml"; + cc->gdb_core_feature =3D gdb_find_static_feature("riscv-32bit-cpu.= xml"); break; default: g_assert_not_reached(); @@ -1045,6 +1045,8 @@ static void riscv_cpu_validate_misa_mxl(RISCVCPU *cpu= , Error **errp) error_setg(errp, "misa_mxl_max must be equal to misa_mxl"); return; } + + cc->gdb_num_core_regs =3D cc->gdb_core_feature->num_regs; } =20 /* @@ -2138,7 +2140,6 @@ static void riscv_cpu_class_init(ObjectClass *c, void= *data) cc->get_pc =3D riscv_cpu_get_pc; cc->gdb_read_register =3D riscv_cpu_gdb_read_register; cc->gdb_write_register =3D riscv_cpu_gdb_write_register; - cc->gdb_num_core_regs =3D 33; cc->gdb_stop_before_watchpoint =3D true; cc->disas_set_info =3D riscv_cpu_disas_set_info; #ifndef CONFIG_USER_ONLY diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 157e57da0f..b139265728 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -239,8 +239,8 @@ static void rx_cpu_class_init(ObjectClass *klass, void = *data) cc->gdb_write_register =3D rx_cpu_gdb_write_register; cc->disas_set_info =3D rx_cpu_disas_set_info; =20 - cc->gdb_num_core_regs =3D 26; - cc->gdb_core_xml_file =3D "rx-core.xml"; + cc->gdb_core_feature =3D gdb_find_static_feature("rx-core.xml"); + cc->gdb_num_core_regs =3D cc->gdb_core_feature->num_regs; cc->tcg_ops =3D &rx_tcg_ops; } =20 diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index df167493c3..2a2ff8cbdc 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -348,8 +348,8 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) s390_cpu_class_init_sysemu(cc); #endif cc->disas_set_info =3D s390_cpu_disas_set_info; - cc->gdb_num_core_regs =3D S390_NUM_CORE_REGS; - cc->gdb_core_xml_file =3D "s390x-core64.xml"; + cc->gdb_core_feature =3D gdb_find_static_feature("s390x-core64.xml"); + cc->gdb_num_core_regs =3D cc->gdb_core_feature->num_regs; cc->gdb_arch_name =3D s390_gdb_arch_name; =20 s390_cpu_model_class_register_props(oc); --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793194; cv=none; d=zohomail.com; s=zohoarc; b=B1Myb57y5nW0K7WN+xi2LEgvrSJUJAI9S8pisf9l6fjN319y8d64IUMpkO1uvSohGlxH+KWDzNQ4jbFa53EcP+xrO0sX8tosxqra2hIeJkwaX6KZQZCysH+nuqpLweAarXipK+Kjc6apBxqYWTyi5WrVRKnqqY4HPXThMyzDhlI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793194; 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; bh=67Ma4eHdBbKb/5ihWsqHmvXiK6diEIF9/ktb12uRyYo=; b=Fs9kkE64Vr5NzmK3/ZKBFn7y/IRJFdE0kurYH9LTPGGGzSOdEz3cf1mE7BUA/JmZNF5+yxhru5owaJMoEktDgO0BOtGK0kz5T5MVukL+NJ9FbHmUbfiVfazAN1EpGSj2KdQ37N03Y7iArm5KWuSHWE6dV/uXu/pHwOOjr9C5550= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793194374628.0965420353552; Mon, 31 Jul 2023 01:46:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOX4-0000wh-8H; Mon, 31 Jul 2023 04:45:38 -0400 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 1qQOX2-0000hf-7k for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:45:36 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOWt-0004mm-Sn for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:45:34 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-686ed1d2594so4109367b3a.2 for ; Mon, 31 Jul 2023 01:45:18 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.45.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:45:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793117; x=1691397917; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=67Ma4eHdBbKb/5ihWsqHmvXiK6diEIF9/ktb12uRyYo=; b=rh//WF9cqgIMNiM77XidMbd2QtU0s9ZfTf4Y/YHkFOkoaFsi3Gjy/ExAUviYowCSwU qnNeAVigOLLX7mf0JxqgH60YkfVCe+s7vd+w4qSpDRcuUqLbGFG64wrXA1MBZdShqP5e /vY4hbs2IrOx2w5lXgq6rMLSDwky7tkGPbHFSjuhf3ziwt1Yqkt0cRydH+1jMT+COcHX oHyDB/K92ZjlvjrcukmNY7/yCPuX7+VF3gOcYgt1rzp4ErEHHaBiB6jcD4HXfxVcF/uU HoVzK+oYxzdJ+Kjzw6zX6Ft74Z+v1cKyDUxgNtg778BNtimQ1TmGkd/sWv9Y3lnOqFH4 DIiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793117; x=1691397917; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=67Ma4eHdBbKb/5ihWsqHmvXiK6diEIF9/ktb12uRyYo=; b=Fk6r9APq3LJJnOyhDy1EiJWsOs10d5JaePF/YSGPtcn927DuEBxuGY2BzV2nq+PYoY pucjfUwkSFg+HByF5fbR15mx9MVyk3KYaUW+JpSXW3FHiZTqIKaTaIP+bTVgXh8kt/0O 1QR/zvwZ02t1hvs9vkvlhjjIN52XGudhJa3lsJxvRuIqyB4N+hzZa/fJHhKAkAMgVWBI fb64LzX0am4K4L7QtGhPFeP7iX+XMmg5tw3KDD5ctLt/sxbhfsq6eeUim7YmUK6YeTP5 +B2Wz2v60mA6LnYjSzzE4BJ8w2FaHWLNGPbUR6nubT09FkKqWtOGpGs2Fadcn33ndcsS /omA== X-Gm-Message-State: ABy/qLb7TKGrTlknj9BPQzp3ZxBWUJoAvT/7aNr6JkNCXhfIp3R6HiDi PmfUgsyLuaK61QfJ+SHDeHHI9Q== X-Google-Smtp-Source: APBJJlGauWCzOZaD8F+aEmJLKC/B3DbofMn6M9E2e1F/0Img98U5sB3vRPXK6vjt/54NK2c57bqu8A== X-Received: by 2002:a05:6a00:a01:b0:682:a6c5:6f28 with SMTP id p1-20020a056a000a0100b00682a6c56f28mr12024293pfh.32.1690793117602; Mon, 31 Jul 2023 01:45:17 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 07/24] target/arm: Use GDBFeature for dynamic XML Date: Mon, 31 Jul 2023 17:43:34 +0900 Message-ID: <20230731084354.115015-8-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::433; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x433.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793195604100003 Content-Type: text/plain; charset="utf-8" In preparation for a change to use GDBFeature as a parameter of gdb_register_coprocessor(), convert the internal representation of dynamic feature from plain XML to GDBFeature. Signed-off-by: Akihiko Odaki Acked-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu.h | 20 +++++------ target/arm/internals.h | 2 +- target/arm/gdbstub.c | 80 +++++++++++++++++++++++------------------- target/arm/gdbstub64.c | 11 +++--- 4 files changed, 60 insertions(+), 53 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 88e5accda6..d6c2378d05 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -136,23 +136,21 @@ enum { */ =20 /** - * DynamicGDBXMLInfo: - * @desc: Contains the XML descriptions. - * @num: Number of the registers in this XML seen by GDB. + * DynamicGDBFeatureInfo: + * @desc: Contains the feature descriptions. * @data: A union with data specific to the set of registers * @cpregs_keys: Array that contains the corresponding Key of * a given cpreg with the same order of the cpreg * in the XML description. */ -typedef struct DynamicGDBXMLInfo { - char *desc; - int num; +typedef struct DynamicGDBFeatureInfo { + GDBFeature desc; union { struct { uint32_t *keys; } cpregs; } data; -} DynamicGDBXMLInfo; +} DynamicGDBFeatureInfo; =20 /* CPU state for each instance of a generic timer (in cp15 c14) */ typedef struct ARMGenericTimer { @@ -881,10 +879,10 @@ struct ArchCPU { uint64_t *cpreg_vmstate_values; int32_t cpreg_vmstate_array_len; =20 - DynamicGDBXMLInfo dyn_sysreg_xml; - DynamicGDBXMLInfo dyn_svereg_xml; - DynamicGDBXMLInfo dyn_m_systemreg_xml; - DynamicGDBXMLInfo dyn_m_secextreg_xml; + DynamicGDBFeatureInfo dyn_sysreg_feature; + DynamicGDBFeatureInfo dyn_svereg_feature; + DynamicGDBFeatureInfo dyn_m_systemreg_feature; + DynamicGDBFeatureInfo dyn_m_secextreg_feature; =20 /* Timers used by the generic (architected) timer */ QEMUTimer *gt_timer[NUM_GTIMERS]; diff --git a/target/arm/internals.h b/target/arm/internals.h index 0f01bc32a8..8421a755af 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1388,7 +1388,7 @@ static inline uint64_t pmu_counter_mask(CPUARMState *= env) } =20 #ifdef TARGET_AARCH64 -int arm_gen_dynamic_svereg_xml(CPUState *cpu, int base_reg); +GDBFeature *arm_gen_dynamic_svereg_feature(CPUState *cpu, int base_reg); int aarch64_gdb_get_sve_reg(CPUARMState *env, GByteArray *buf, int reg); int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg); int aarch64_gdb_get_fpu_reg(CPUARMState *env, GByteArray *buf, int reg); diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index f421c5d041..cd35bac013 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -25,11 +25,11 @@ #include "internals.h" #include "cpregs.h" =20 -typedef struct RegisterSysregXmlParam { +typedef struct RegisterSysregFeatureParam { CPUState *cs; GString *s; int n; -} RegisterSysregXmlParam; +} RegisterSysregFeatureParam; =20 /* Old gdb always expect FPA registers. Newer (xml-aware) gdb only expect whatever the target description contains. Due to a historical mishap @@ -243,7 +243,7 @@ static int arm_gdb_get_sysreg(CPUARMState *env, GByteAr= ray *buf, int reg) const ARMCPRegInfo *ri; uint32_t key; =20 - key =3D cpu->dyn_sysreg_xml.data.cpregs.keys[reg]; + key =3D cpu->dyn_sysreg_feature.data.cpregs.keys[reg]; ri =3D get_arm_cp_reginfo(cpu->cp_regs, key); if (ri) { if (cpreg_field_is_64bit(ri)) { @@ -260,7 +260,8 @@ static int arm_gdb_set_sysreg(CPUARMState *env, uint8_t= *buf, int reg) return 0; } =20 -static void arm_gen_one_xml_sysreg_tag(GString *s, DynamicGDBXMLInfo *dyn_= xml, +static void arm_gen_one_feature_sysreg(GString *s, + DynamicGDBFeatureInfo *dyn_feature, ARMCPRegInfo *ri, uint32_t ri_key, int bitsize, int regnum) { @@ -268,25 +269,25 @@ static void arm_gen_one_xml_sysreg_tag(GString *s, Dy= namicGDBXMLInfo *dyn_xml, g_string_append_printf(s, " bitsize=3D\"%d\"", bitsize); g_string_append_printf(s, " regnum=3D\"%d\"", regnum); g_string_append_printf(s, " group=3D\"cp_regs\"/>"); - dyn_xml->data.cpregs.keys[dyn_xml->num] =3D ri_key; - dyn_xml->num++; + dyn_feature->data.cpregs.keys[dyn_feature->desc.num_regs] =3D ri_key; + dyn_feature->desc.num_regs++; } =20 -static void arm_register_sysreg_for_xml(gpointer key, gpointer value, - gpointer p) +static void arm_register_sysreg_for_feature(gpointer key, gpointer value, + gpointer p) { uint32_t ri_key =3D (uintptr_t)key; ARMCPRegInfo *ri =3D value; - RegisterSysregXmlParam *param =3D (RegisterSysregXmlParam *)p; + RegisterSysregFeatureParam *param =3D (RegisterSysregFeatureParam *)p; GString *s =3D param->s; ARMCPU *cpu =3D ARM_CPU(param->cs); CPUARMState *env =3D &cpu->env; - DynamicGDBXMLInfo *dyn_xml =3D &cpu->dyn_sysreg_xml; + DynamicGDBFeatureInfo *dyn_feature =3D &cpu->dyn_sysreg_feature; =20 if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_NO_GDB))) { if (arm_feature(env, ARM_FEATURE_AARCH64)) { if (ri->state =3D=3D ARM_CP_STATE_AA64) { - arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64, + arm_gen_one_feature_sysreg(s , dyn_feature, ri, ri_key, 64, param->n++); } } else { @@ -296,10 +297,10 @@ static void arm_register_sysreg_for_xml(gpointer key,= gpointer value, return; } if (ri->type & ARM_CP_64BIT) { - arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64, + arm_gen_one_feature_sysreg(s , dyn_feature, ri, ri_key= , 64, param->n++); } else { - arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 32, + arm_gen_one_feature_sysreg(s , dyn_feature, ri, ri_key= , 32, param->n++); } } @@ -307,21 +308,24 @@ static void arm_register_sysreg_for_xml(gpointer key,= gpointer value, } } =20 -static int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg) +static GDBFeature *arm_gen_dynamic_sysreg_feature(CPUState *cs, int base_r= eg) { ARMCPU *cpu =3D ARM_CPU(cs); GString *s =3D g_string_new(NULL); - RegisterSysregXmlParam param =3D {cs, s, base_reg}; + RegisterSysregFeatureParam param =3D {cs, s, base_reg}; + DynamicGDBFeatureInfo *dyn_feature =3D &cpu->dyn_sysreg_feature; + gsize num_regs =3D g_hash_table_size(cpu->cp_regs); =20 - cpu->dyn_sysreg_xml.num =3D 0; - cpu->dyn_sysreg_xml.data.cpregs.keys =3D g_new(uint32_t, g_hash_table_= size(cpu->cp_regs)); + dyn_feature->desc.num_regs =3D 0; + dyn_feature->data.cpregs.keys =3D g_new(uint32_t, num_regs); g_string_printf(s, ""); g_string_append_printf(s, "= "); g_string_append_printf(s, ""); - g_hash_table_foreach(cpu->cp_regs, arm_register_sysreg_for_xml, ¶m= ); + g_hash_table_foreach(cpu->cp_regs, arm_register_sysreg_for_feature, &p= aram); g_string_append_printf(s, ""); - cpu->dyn_sysreg_xml.desc =3D g_string_free(s, false); - return cpu->dyn_sysreg_xml.num; + dyn_feature->desc.xmlname =3D "system-registers.xml"; + dyn_feature->desc.xml =3D g_string_free(s, false); + return &dyn_feature->desc; } =20 #ifdef CONFIG_TCG @@ -413,7 +417,8 @@ static int arm_gdb_set_m_systemreg(CPUARMState *env, ui= nt8_t *buf, int reg) return 0; /* TODO */ } =20 -static int arm_gen_dynamic_m_systemreg_xml(CPUState *cs, int orig_base_reg) +static GDBFeature *arm_gen_dynamic_m_systemreg_feature(CPUState *cs, + int orig_base_reg) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; @@ -434,10 +439,11 @@ static int arm_gen_dynamic_m_systemreg_xml(CPUState *= cs, int orig_base_reg) } =20 g_string_append_printf(s, ""); - cpu->dyn_m_systemreg_xml.desc =3D g_string_free(s, false); - cpu->dyn_m_systemreg_xml.num =3D base_reg - orig_base_reg; + cpu->dyn_m_systemreg_feature.desc.xmlname =3D "arm-m-system.xml"; + cpu->dyn_m_systemreg_feature.desc.xml =3D g_string_free(s, false); + cpu->dyn_m_systemreg_feature.desc.num_regs =3D base_reg - orig_base_re= g; =20 - return cpu->dyn_m_systemreg_xml.num; + return &cpu->dyn_m_systemreg_feature.desc; } =20 #ifndef CONFIG_USER_ONLY @@ -455,7 +461,8 @@ static int arm_gdb_set_m_secextreg(CPUARMState *env, ui= nt8_t *buf, int reg) return 0; /* TODO */ } =20 -static int arm_gen_dynamic_m_secextreg_xml(CPUState *cs, int orig_base_reg) +static GDBFeature *arm_gen_dynamic_m_secextreg_feature(CPUState *cs, + int orig_base_reg) { ARMCPU *cpu =3D ARM_CPU(cs); GString *s =3D g_string_new(NULL); @@ -476,10 +483,11 @@ static int arm_gen_dynamic_m_secextreg_xml(CPUState *= cs, int orig_base_reg) } =20 g_string_append_printf(s, ""); - cpu->dyn_m_secextreg_xml.desc =3D g_string_free(s, false); - cpu->dyn_m_secextreg_xml.num =3D base_reg - orig_base_reg; + cpu->dyn_m_secextreg_feature.desc.xmlname =3D "arm-m-secext.xml"; + cpu->dyn_m_secextreg_feature.desc.xml =3D g_string_free(s, false); + cpu->dyn_m_secextreg_feature.desc.num_regs =3D base_reg - orig_base_re= g; =20 - return cpu->dyn_m_secextreg_xml.num; + return &cpu->dyn_m_secextreg_feature.desc; } #endif #endif /* CONFIG_TCG */ @@ -489,14 +497,14 @@ const char *arm_gdb_get_dynamic_xml(CPUState *cs, con= st char *xmlname) ARMCPU *cpu =3D ARM_CPU(cs); =20 if (strcmp(xmlname, "system-registers.xml") =3D=3D 0) { - return cpu->dyn_sysreg_xml.desc; + return cpu->dyn_sysreg_feature.desc.xml; } else if (strcmp(xmlname, "sve-registers.xml") =3D=3D 0) { - return cpu->dyn_svereg_xml.desc; + return cpu->dyn_svereg_feature.desc.xml; } else if (strcmp(xmlname, "arm-m-system.xml") =3D=3D 0) { - return cpu->dyn_m_systemreg_xml.desc; + return cpu->dyn_m_systemreg_feature.desc.xml; #ifndef CONFIG_USER_ONLY } else if (strcmp(xmlname, "arm-m-secext.xml") =3D=3D 0) { - return cpu->dyn_m_secextreg_xml.desc; + return cpu->dyn_m_secextreg_feature.desc.xml; #endif } return NULL; @@ -514,7 +522,7 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) */ #ifdef TARGET_AARCH64 if (isar_feature_aa64_sve(&cpu->isar)) { - int nreg =3D arm_gen_dynamic_svereg_xml(cs, cs->gdb_num_regs); + int nreg =3D arm_gen_dynamic_svereg_feature(cs, cs->gdb_num_re= gs)->num_regs; gdb_register_coprocessor(cs, aarch64_gdb_get_sve_reg, aarch64_gdb_set_sve_reg, nreg, "sve-registers.xml", 0); @@ -560,20 +568,20 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *c= pu) 1, "arm-m-profile-mve.xml", 0); } gdb_register_coprocessor(cs, arm_gdb_get_sysreg, arm_gdb_set_sysreg, - arm_gen_dynamic_sysreg_xml(cs, cs->gdb_num_re= gs), + arm_gen_dynamic_sysreg_feature(cs, cs->gdb_nu= m_regs)->num_regs, "system-registers.xml", 0); =20 #ifdef CONFIG_TCG if (arm_feature(env, ARM_FEATURE_M) && tcg_enabled()) { gdb_register_coprocessor(cs, arm_gdb_get_m_systemreg, arm_gdb_set_m_systemreg, - arm_gen_dynamic_m_systemreg_xml(cs, cs->gdb_num_regs), + arm_gen_dynamic_m_systemreg_feature(cs, cs->gdb_num_regs)->num= _regs, "arm-m-system.xml", 0); #ifndef CONFIG_USER_ONLY if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { gdb_register_coprocessor(cs, arm_gdb_get_m_secextreg, arm_gdb_set_m_secextreg, - arm_gen_dynamic_m_secextreg_xml(cs, cs->gdb_num_regs), + arm_gen_dynamic_m_secextreg_feature(cs, cs->gdb_num_regs)-= >num_regs, "arm-m-secext.xml", 0); } #endif diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index d7b79a6589..20483ef9bc 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -316,11 +316,11 @@ static void output_vector_union_type(GString *s, int = reg_width, g_string_append(s, ""); } =20 -int arm_gen_dynamic_svereg_xml(CPUState *cs, int orig_base_reg) +GDBFeature *arm_gen_dynamic_svereg_feature(CPUState *cs, int orig_base_reg) { ARMCPU *cpu =3D ARM_CPU(cs); GString *s =3D g_string_new(NULL); - DynamicGDBXMLInfo *info =3D &cpu->dyn_svereg_xml; + DynamicGDBFeatureInfo *info =3D &cpu->dyn_svereg_feature; int reg_width =3D cpu->sve_max_vq * 128; int pred_width =3D cpu->sve_max_vq * 16; int base_reg =3D orig_base_reg; @@ -375,7 +375,8 @@ int arm_gen_dynamic_svereg_xml(CPUState *cs, int orig_b= ase_reg) =20 g_string_append_printf(s, ""); =20 - info->desc =3D g_string_free(s, false); - info->num =3D base_reg - orig_base_reg; - return info->num; + info->desc.xmlname =3D "sve-registers.xml"; + info->desc.xml =3D g_string_free(s, false); + info->desc.num_regs =3D base_reg - orig_base_reg; + return &info->desc; } --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793215; cv=none; d=zohomail.com; s=zohoarc; b=GyTeaC17IsX1TZy7PqzFa0hvGFsWETNHpqbf89ppTJ7EsT8GwNGV1XGE2gRmLdyVt98wsMUJNmcqKPSEt5nNYbfmpLAyfwljWKYvzgmxahdoOjrrQits+3TrjPXoV0w/GBpRYkDXcY0nfjZfVTR0G6WIBhin2JqMzldaZxZXURg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793215; 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; bh=iYW1nIFGTA7fjkY/uj18ixbf7NM+vxI6KJp/a1kW3DM=; b=CP8FxPCz4TOdrOEi6eHjq9nuCToZp1hGmY5gFKHewssDoJpWDeQqU82AT0fOVJIJMTkAlpeljRX7A/uMXqYoLPBAZmlpH/cJsKAKyYO1dUGqGuFgBhiy/f07o9fcov6QhMO5BfeQ/gaZz3X32KT6kXt9cYEcnks8eC6+POprk+4= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793215753666.1667644677005; Mon, 31 Jul 2023 01:46:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOX6-0001Cs-AV; Mon, 31 Jul 2023 04:45:40 -0400 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 1qQOX2-0000hb-5q for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:45:36 -0400 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOWt-0004sU-Tb for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:45:31 -0400 Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-7653bd3ff2fso432864685a.3 for ; Mon, 31 Jul 2023 01:45:27 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.45.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:45:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793126; x=1691397926; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iYW1nIFGTA7fjkY/uj18ixbf7NM+vxI6KJp/a1kW3DM=; b=FCgiuReHkxvCMedZ1O9wOeLgAAAtREGyPlNLdCVVJ8f82wmV0yMwqZ5/6niswZFTy3 DTqVCtXuk4WVC+0PA6DvJZrQt7o6+ETOWPXu7JHji/sTG1ulIOGcRcZ403GjTkioFqWD EAo5VowSHMC4Hxlypd/oe7P416AOb1VYwHmdGMKmNsEJvN8k/0IjxxrcX7YmiRirNEi6 ZRBt8vx+AY2R9C3WsfzoREBZmbqHU2g6O8vOg7iaaKbNc6dVHXflOsF4HN9Ro9plFXaN d1Gbh/OluFrPCVJBucMn4bsdWf1um112AXwqtQrw+Dy+FyvhtCyk2zyV20clbS2XZbLT 4a4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793126; x=1691397926; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iYW1nIFGTA7fjkY/uj18ixbf7NM+vxI6KJp/a1kW3DM=; b=BHN2Tc1LXDevwlkQPwBa1bAyMnjsQ6/ZwtVBNEd+1MmQWfiwjPAhjWBw6usSulCySW CoR0jgiGCrY6SQoG2juGV56pk0/syGhFZfoAK6bVdeK64fk25kc4N4EyC/iANdzPtWVV U3ANSnn408dAqQoYsYsLXqf4HDKCufbsckjqcW1dwy+gjJ1PUOM+At/coPTxNWFfAcrt JZ75Xca1m4Nq/kZa9h/fN4sZ8IE/ZNQ+fzt9dc831YZkaExVXoPKvzcf9M2z/PJxu2YW cJjcF44di5joK8hI6Udl33oU+NTwfoDJGTa07dKSDs6qEmFj7pW0Oo7sYvXXlA/yl1Vp UqDQ== X-Gm-Message-State: ABy/qLbU3762B6Dxbpa8dZ/2JhuMm3339lwkh4XMGUJxjQE55YIQvvwo abkR2HD4z7aPQbe90AWngqxj4g== X-Google-Smtp-Source: APBJJlGEAClPWuuPChQAQnL+wQ5I3Z3zwpDommxcO1h5PxQnB4ei0G1BfSVCDR+41QWvIMmcc33ivg== X-Received: by 2002:a05:620a:450f:b0:768:1053:b1b3 with SMTP id t15-20020a05620a450f00b007681053b1b3mr14080627qkp.31.1690793126581; Mon, 31 Jul 2023 01:45:26 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 08/24] target/ppc: Use GDBFeature for dynamic XML Date: Mon, 31 Jul 2023 17:43:35 +0900 Message-ID: <20230731084354.115015-9-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::733; envelope-from=akihiko.odaki@daynix.com; helo=mail-qk1-x733.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793217750100003 Content-Type: text/plain; charset="utf-8" In preparation for a change to use GDBFeature as a parameter of gdb_register_coprocessor(), convert the internal representation of dynamic feature from plain XML to GDBFeature. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/ppc/cpu-qom.h | 3 +-- target/ppc/cpu.h | 2 +- target/ppc/cpu_init.c | 2 +- target/ppc/gdbstub.c | 13 +++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index be33786bd8..633fb402b5 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -186,8 +186,7 @@ struct PowerPCCPUClass { int bfd_mach; uint32_t l1_dcache_size, l1_icache_size; #ifndef CONFIG_USER_ONLY - unsigned int gdb_num_sprs; - const char *gdb_spr_xml; + GDBFeature gdb_spr; #endif const PPCHash64Options *hash64_opts; struct ppc_radix_page_info *radix_page_info; diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 25fac9577a..5f251bdffe 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1381,7 +1381,7 @@ int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t= *buf, int reg); int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg); #ifndef CONFIG_USER_ONLY hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu); +void ppc_gdb_gen_spr_feature(PowerPCCPU *cpu); const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name); #endif int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index eb56226865..938cd2b7e1 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -6673,7 +6673,7 @@ static void init_ppc_proc(PowerPCCPU *cpu) (*pcc->init_proc)(env); =20 #if !defined(CONFIG_USER_ONLY) - ppc_gdb_gen_spr_xml(cpu); + ppc_gdb_gen_spr_feature(cpu); #endif =20 /* MSR bits & flags consistency checks */ diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index ca39efdc35..adc647a24e 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -318,7 +318,7 @@ int ppc_cpu_gdb_write_register_apple(CPUState *cs, uint= 8_t *mem_buf, int n) } =20 #ifndef CONFIG_USER_ONLY -void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu) +void ppc_gdb_gen_spr_feature(PowerPCCPU *cpu) { PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); CPUPPCState *env =3D &cpu->env; @@ -346,7 +346,7 @@ void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu) num_regs++; } =20 - if (pcc->gdb_spr_xml) { + if (pcc->gdb_spr.xml) { return; } =20 @@ -371,8 +371,9 @@ void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu) =20 g_string_append(xml, ""); =20 - pcc->gdb_num_sprs =3D num_regs; - pcc->gdb_spr_xml =3D g_string_free(xml, false); + pcc->gdb_spr.num_regs =3D num_regs; + pcc->gdb_spr.xmlname =3D "power-spr.xml"; + pcc->gdb_spr.xml =3D g_string_free(xml, false); } =20 const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name) @@ -380,7 +381,7 @@ const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const= char *xml_name) PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cs); =20 if (strcmp(xml_name, "power-spr.xml") =3D=3D 0) { - return pcc->gdb_spr_xml; + return pcc->gdb_spr.xml; } return NULL; } @@ -618,6 +619,6 @@ void ppc_gdb_init(CPUState *cs, PowerPCCPUClass *pcc) } #ifndef CONFIG_USER_ONLY gdb_register_coprocessor(cs, gdb_get_spr_reg, gdb_set_spr_reg, - pcc->gdb_num_sprs, "power-spr.xml", 0); + pcc->gdb_spr.num_regs, "power-spr.xml", 0); #endif } --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793150; cv=none; d=zohomail.com; s=zohoarc; b=UoesBPX0Jhl9kFQXR1iRHO0CEPFzIpwakYxtgYcqwRYegSMj3A7Pc96L7F0fumS4gVExa6Kler4+8XkGYTk6dxrC4W9pdh62hQfQVdw9D60Y7hdG++64fMm/NjAZy0wfijuaLLTvHr727kVXrQhXYKM9YDLPY324rPdwHEabEgo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793150; 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; bh=UroyotoWH93LMRAYzk+jFEmO3Lkc/QezRKtbBAIRdSQ=; b=H+TsFh5zpyBVddxc41siOVBFYG1Q95r1DATWxqvwfxmID4ecHVoUvDb9K7bryG+1DfzRlYGZHu8HEoR7YK8MrCgwnXybW+5l5SvxrgMmctG8riEz/oXKHtbdtteiTyfpg1ETf6WGpCZf6LMoESgJznEljpYci3z5fZYRwMy0zp0= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793150363821.4901635473451; Mon, 31 Jul 2023 01:45:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOX9-0001S2-FM; Mon, 31 Jul 2023 04:45:43 -0400 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 1qQOX7-0001Gb-2f for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:45:41 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOX3-0004wh-Ly for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:45:40 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-686b9964ae2so2803929b3a.3 for ; Mon, 31 Jul 2023 01:45:37 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:45:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793136; x=1691397936; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UroyotoWH93LMRAYzk+jFEmO3Lkc/QezRKtbBAIRdSQ=; b=ndFNlVP1Oseovmo4Onh09EjdRmVe9n8ooDptnTyN9WMIorGrh2zddhysLDBdzqR8S2 cd+UUaBVgwFJq4YjGJtc4TeW1eZggL9TicD8RjlcK5BJkQJIY+Rdjx3i5M/y3Q9/HaKP CFXkcAWAiitXj33lUWcSir0PLvlfv0DqWkOAVWXT4T/em8pEqL5d514mBxgig7/eWzzE yZ5Jtu8EiG4FoYKshg/icNcD+xyziaYii3LygS1aMuuBYWalUn1GyQVSe334SUzDAIrs EBtYQPWfPI0BVyzjqok4Y7QDYe3jHEW0vTR1qRy2dP4mUh6mhYbfnTWqhmQF5LuYuF1g YbYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793136; x=1691397936; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UroyotoWH93LMRAYzk+jFEmO3Lkc/QezRKtbBAIRdSQ=; b=S0cdPArebQiT7jTcFsT5ETGpzYsNU6tHC1HLvXHx0jy8WYnMdhyHwFwZ046N4dbG1B IDk8SrU6aT4Zvp6k6k83BJGDdViVCPynDKz99jOSx37lhjZZVfitcdT8W7lmO2exLULl C5Cgpf+BJfAOhGYO5kmWQE6QW4IySWKRSn66mC7FFWPW/9xXL4xjce//XMR8zLMxbNo8 smkueIrS/CHhvhw8K3yl+H7m/4EJfygyQ6/C3F1jcIpJDGAszuLWY4dX8J9hDNksPg5N 4mV1fjfJZbzUJPS7XBHI2LwyUXx2iItfgeDsKmjM4Dho5tNEsj0MQu8OzcUFeeIkOSft Kwew== X-Gm-Message-State: ABy/qLZ/RTTqh0mmk0dubv++5EKvrC2FwI4rdsxeGU/OMVEoCPg6EHz8 lv8yXfPFTDTxGuhdfR6V0fzEOA== X-Google-Smtp-Source: APBJJlE2cCnFvnW+SATj2mGdDUIaxvAcWVYgvebFHl+oLYZXGSWELvqKormbsZGZHW/0jNvMXcMG2Q== X-Received: by 2002:aa7:88c3:0:b0:687:20d6:faea with SMTP id k3-20020aa788c3000000b0068720d6faeamr6259176pff.15.1690793136092; Mon, 31 Jul 2023 01:45:36 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 09/24] target/riscv: Use GDBFeature for dynamic XML Date: Mon, 31 Jul 2023 17:43:36 +0900 Message-ID: <20230731084354.115015-10-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::42b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793150792100001 Content-Type: text/plain; charset="utf-8" In preparation for a change to use GDBFeature as a parameter of gdb_register_coprocessor(), convert the internal representation of dynamic feature from plain XML to GDBFeature. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/riscv/cpu.h | 4 ++-- target/riscv/cpu.c | 4 ++-- target/riscv/gdbstub.c | 25 ++++++++++++++----------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 6ea22e0eea..f67751d5b7 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -391,8 +391,8 @@ struct ArchCPU { CPUNegativeOffsetState neg; CPURISCVState env; =20 - char *dyn_csr_xml; - char *dyn_vreg_xml; + GDBFeature dyn_csr_feature; + GDBFeature dyn_vreg_feature; =20 /* Configuration Settings */ RISCVCPUConfig cfg; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 36de35270d..ceca40cdd9 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1962,9 +1962,9 @@ static const char *riscv_gdb_get_dynamic_xml(CPUState= *cs, const char *xmlname) RISCVCPU *cpu =3D RISCV_CPU(cs); =20 if (strcmp(xmlname, "riscv-csr.xml") =3D=3D 0) { - return cpu->dyn_csr_xml; + return cpu->dyn_csr_feature.xml; } else if (strcmp(xmlname, "riscv-vector.xml") =3D=3D 0) { - return cpu->dyn_vreg_xml; + return cpu->dyn_vreg_feature.xml; } =20 return NULL; diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 524bede865..70c60ad8b1 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -212,7 +212,7 @@ static int riscv_gdb_set_virtual(CPURISCVState *cs, uin= t8_t *mem_buf, int n) return 0; } =20 -static int riscv_gen_dynamic_csr_xml(CPUState *cs, int base_reg) +static GDBFeature *riscv_gen_dynamic_csr_feature(CPUState *cs, int base_re= g) { RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; @@ -252,24 +252,27 @@ static int riscv_gen_dynamic_csr_xml(CPUState *cs, in= t base_reg) =20 g_string_append_printf(s, ""); =20 - cpu->dyn_csr_xml =3D g_string_free(s, false); + cpu->dyn_csr_feature.num_regs =3D CSR_TABLE_SIZE; + cpu->dyn_csr_feature.xmlname =3D "riscv-csr.xml"; + cpu->dyn_csr_feature.xml =3D g_string_free(s, false); =20 #if !defined(CONFIG_USER_ONLY) env->debugger =3D false; #endif =20 - return CSR_TABLE_SIZE; + return &cpu->dyn_csr_feature; } =20 -static int ricsv_gen_dynamic_vector_xml(CPUState *cs, int base_reg) +static GDBFeature *ricsv_gen_dynamic_vector_feature(CPUState *cs, int base= _reg) { RISCVCPU *cpu =3D RISCV_CPU(cs); GString *s =3D g_string_new(NULL); g_autoptr(GString) ts =3D g_string_new(""); int reg_width =3D cpu->cfg.vlen; - int num_regs =3D 0; int i; =20 + cpu->dyn_vreg_feature.num_regs =3D 32; + g_string_printf(s, ""); g_string_append_printf(s, "= "); g_string_append_printf(s, ""); @@ -293,19 +296,19 @@ static int ricsv_gen_dynamic_vector_xml(CPUState *cs,= int base_reg) g_string_append(s, ""); =20 /* Define vector registers */ - for (i =3D 0; i < 32; i++) { + for (i =3D 0; i < cpu->dyn_vreg_feature.num_regs; i++) { g_string_append_printf(s, "", i, reg_width, base_reg++); - num_regs++; } =20 g_string_append_printf(s, ""); =20 - cpu->dyn_vreg_xml =3D g_string_free(s, false); - return num_regs; + cpu->dyn_vreg_feature.xmlname =3D "riscv-vector.xml"; + cpu->dyn_vreg_feature.xml =3D g_string_free(s, false); + return &cpu->dyn_vreg_feature; } =20 void riscv_cpu_register_gdb_regs_for_features(CPUState *cs) @@ -323,7 +326,7 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState = *cs) int base_reg =3D cs->gdb_num_regs; gdb_register_coprocessor(cs, riscv_gdb_get_vector, riscv_gdb_set_vector, - ricsv_gen_dynamic_vector_xml(cs, base_reg= ), + ricsv_gen_dynamic_vector_feature(cs, base= _reg)->num_regs, "riscv-vector.xml", 0); } switch (env->misa_mxl_max) { @@ -345,7 +348,7 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState = *cs) if (cpu->cfg.ext_icsr) { int base_reg =3D cs->gdb_num_regs; gdb_register_coprocessor(cs, riscv_gdb_get_csr, riscv_gdb_set_csr, - riscv_gen_dynamic_csr_xml(cs, base_reg), + riscv_gen_dynamic_csr_feature(cs, base_re= g)->num_regs, "riscv-csr.xml", 0); } } --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793286; cv=none; d=zohomail.com; s=zohoarc; b=PNAG5HTuGqabXSyLkkiJdIo2MTx/tmfx4tN0109c1iH0MtdSA8x/MdCsMGk0j5e1lKeYgRq78EikB4k8PYIxZg7XBwVzEWILO+3TixKTUbx2kKTDZ0b34ESLnjbQO8uPL5WJSJ1E6nXJDzeoZv9bDbB26cqjwAFB3AIbikiExE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793286; 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; bh=pW/loRty6GyNNUTcSqTpNgKHcuroEgOl2+LaUK/hBVE=; b=kHSIX4lHY+Qa+pBCdDddrfRMt4dNWO3qs4QZxabj2A8i06JCyn1O6sL/m1gMjxAjz+HVp8A2nU8BFHmH+8BXiFy/ozwxNeyOrFWK4+8f7eYG57VvKKlpAh88tG7Geh2E/3OPAKDimkrF6cH9dqQlIt99o6hC8eOoIVGvvgS5TLE= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793286655279.4518365522674; Mon, 31 Jul 2023 01:48:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOXH-00023g-Sp; Mon, 31 Jul 2023 04:45:51 -0400 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 1qQOXF-0001sP-FK for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:45:49 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOXC-0004yg-Vf for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:45:49 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-687087d8ddaso3186639b3a.1 for ; Mon, 31 Jul 2023 01:45:46 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793146; x=1691397946; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pW/loRty6GyNNUTcSqTpNgKHcuroEgOl2+LaUK/hBVE=; b=vFXp/bUiXToHmIH8zSyN262iBd3umW7MZRBkmsuj9r5stBCNrEVLbM+64CfN//jfEZ 2bv+l/PZgBkPDZ2WJk2dLyEakdnbgkmL2+InppV0WXTDfJjzlkKeduMqKk0GE+ljkLqn jsmeiUI9FVpJ8V6+dTIvqyKjkOy00DkwipLYpNocGFZYw6PEZ/Bx3DHlT+rmjjqcElu+ DLknWdRnN21Esozn042vUUMoTxQK1IU05f6PBr7A6L9UGqP4jBkjiPzSeFwuQifkGVz/ x+iFHXypiL4BiljFomK8CqyhzPRxEa/6BECCJZOg5VvOAjnf4Nhr4htltb6Lyur1oyNs qt2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793146; x=1691397946; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pW/loRty6GyNNUTcSqTpNgKHcuroEgOl2+LaUK/hBVE=; b=XeyL+nNrl/sj3WZdfOfpUqbmJTvh4by6a5Io3ij5yAl+YhczuJJMScqOmTTjwYItHM WUJ6v7Wm6WeUZ2Kdf0YHcMM9/MtTRAyZPoViq+N4gAsaLYBJmYyPoSQhibtTQXyf/N24 fvJjPw7n1r8y6RzhUsEYZGoyjYe32nOFg5V8kiaI14eGvhAi5BtnnRXtSxtcg//5+JFr O6B+hXxdOwfdfOUuo/QX7PctBRqUijUZcQrHWt2YHPMJT5YU5WiemTW/e0bZdu3A9rRH 6vmzCJ1Xn59SWLTW/mgsdPUFs2aZFFKuMHQ7+aSWHHkS2dDNdyhEYw3HtJqxaNA1Tbae kwvA== X-Gm-Message-State: ABy/qLZZgzr4y2fBJRZ7BP65e3eXTt7eYF0vAxsDAJ6qUkT5kqB3BASb SJE5th63Oh+xG8uWSjNWO5uQ8g== X-Google-Smtp-Source: APBJJlFC09bS1mIXTUkIHtgpeIjIogsnnijWtrhTFA+NhbufEUfV3p+g+UtdScRh+mL8uNz7ULA2/A== X-Received: by 2002:a05:6a20:4289:b0:12b:6898:2986 with SMTP id o9-20020a056a20428900b0012b68982986mr12401994pzj.1.1690793145690; Mon, 31 Jul 2023 01:45:45 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 10/24] gdbstub: Use GDBFeature for gdb_register_coprocessor Date: Mon, 31 Jul 2023 17:43:37 +0900 Message-ID: <20230731084354.115015-11-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::42a; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793287469100001 Content-Type: text/plain; charset="utf-8" This is a tree-wide change to introduce GDBFeature parameter to gdb_register_coprocessor(). The new parameter just replaces num_regs and xml parameters for now. GDBFeature will be utilized to simplify XML lookup in a following change. Signed-off-by: Akihiko Odaki Acked-by: Alex Benn=C3=A9e --- include/exec/gdbstub.h | 2 +- gdbstub/gdbstub.c | 13 +++++++------ target/arm/gdbstub.c | 36 ++++++++++++++++++++---------------- target/hexagon/cpu.c | 3 +-- target/loongarch/gdbstub.c | 2 +- target/m68k/helper.c | 6 +++--- target/microblaze/cpu.c | 5 +++-- target/ppc/gdbstub.c | 11 ++++++----- target/riscv/gdbstub.c | 20 ++++++++++++-------- target/s390x/gdbstub.c | 28 +++++++--------------------- 10 files changed, 61 insertions(+), 65 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 3115dc21c0..9b3da5b257 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -22,7 +22,7 @@ typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArr= ay *buf, int reg); typedef int (*gdb_set_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_r= eg, - int num_regs, const char *xml, int g_pos); + const GDBFeature *feature, int g_pos); =20 /** * gdbserver_start: start the gdb server diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 6f2e0cb06f..ab75f6686b 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -471,7 +471,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *m= em_buf, int reg) =20 void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_r= eg, - int num_regs, const char *xml, int g_pos) + const GDBFeature *feature, int g_pos) { GDBRegisterState *s; GDBRegisterState **p; @@ -479,25 +479,26 @@ void gdb_register_coprocessor(CPUState *cpu, p =3D &cpu->gdb_regs; while (*p) { /* Check for duplicates. */ - if (strcmp((*p)->xml, xml) =3D=3D 0) + if (strcmp((*p)->xml, feature->xmlname) =3D=3D 0) return; p =3D &(*p)->next; } =20 s =3D g_new0(GDBRegisterState, 1); s->base_reg =3D cpu->gdb_num_regs; - s->num_regs =3D num_regs; + s->num_regs =3D feature->num_regs; s->get_reg =3D get_reg; s->set_reg =3D set_reg; - s->xml =3D xml; + s->xml =3D feature->xml; =20 /* Add to end of list. */ - cpu->gdb_num_regs +=3D num_regs; + cpu->gdb_num_regs +=3D feature->num_regs; *p =3D s; if (g_pos) { if (g_pos !=3D s->base_reg) { error_report("Error: Bad gdb register numbering for '%s', " - "expected %d got %d", xml, g_pos, s->base_reg); + "expected %d got %d", feature->xml, + g_pos, s->base_reg); } else { cpu->gdb_num_g_regs =3D cpu->gdb_num_regs; } diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index cd35bac013..ab4ffe6264 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -522,14 +522,15 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *c= pu) */ #ifdef TARGET_AARCH64 if (isar_feature_aa64_sve(&cpu->isar)) { - int nreg =3D arm_gen_dynamic_svereg_feature(cs, cs->gdb_num_re= gs)->num_regs; + GDBFeature *feature =3D + arm_gen_dynamic_svereg_feature(cs, cs->gdb_num_regs); gdb_register_coprocessor(cs, aarch64_gdb_get_sve_reg, - aarch64_gdb_set_sve_reg, nreg, - "sve-registers.xml", 0); + aarch64_gdb_set_sve_reg, feature, 0); } else { gdb_register_coprocessor(cs, aarch64_gdb_get_fpu_reg, aarch64_gdb_set_fpu_reg, - 34, "aarch64-fpu.xml", 0); + gdb_find_static_feature("aarch64-fpu.= xml"), + 0); } /* * Note that we report pauth information via the feature name @@ -540,19 +541,22 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *c= pu) if (isar_feature_aa64_pauth(&cpu->isar)) { gdb_register_coprocessor(cs, aarch64_gdb_get_pauth_reg, aarch64_gdb_set_pauth_reg, - 4, "aarch64-pauth.xml", 0); + gdb_find_static_feature("aarch64-paut= h.xml"), + 0); } #endif } else { if (arm_feature(env, ARM_FEATURE_NEON)) { gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, - 49, "arm-neon.xml", 0); + gdb_find_static_feature("arm-neon.xml= "), + 0); } else if (cpu_isar_feature(aa32_simd_r32, cpu)) { gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, - 33, "arm-vfp3.xml", 0); + gdb_find_static_feature("arm-vfp3.xml= "), + 0); } else if (cpu_isar_feature(aa32_vfp_simd, cpu)) { gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, - 17, "arm-vfp.xml", 0); + gdb_find_static_feature("arm-vfp.xml"= ), 0); } if (!arm_feature(env, ARM_FEATURE_M)) { /* @@ -560,29 +564,29 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *c= pu) * expose to gdb. */ gdb_register_coprocessor(cs, vfp_gdb_get_sysreg, vfp_gdb_set_s= ysreg, - 2, "arm-vfp-sysregs.xml", 0); + gdb_find_static_feature("arm-vfp-sysr= egs.xml"), + 0); } } if (cpu_isar_feature(aa32_mve, cpu) && tcg_enabled()) { gdb_register_coprocessor(cs, mve_gdb_get_reg, mve_gdb_set_reg, - 1, "arm-m-profile-mve.xml", 0); + gdb_find_static_feature("arm-m-profile-mv= e.xml"), + 0); } gdb_register_coprocessor(cs, arm_gdb_get_sysreg, arm_gdb_set_sysreg, - arm_gen_dynamic_sysreg_feature(cs, cs->gdb_nu= m_regs)->num_regs, - "system-registers.xml", 0); + arm_gen_dynamic_sysreg_feature(cs, cs->gdb_nu= m_regs), + 0); =20 #ifdef CONFIG_TCG if (arm_feature(env, ARM_FEATURE_M) && tcg_enabled()) { gdb_register_coprocessor(cs, arm_gdb_get_m_systemreg, arm_gdb_set_m_systemreg, - arm_gen_dynamic_m_systemreg_feature(cs, cs->gdb_num_regs)->num= _regs, - "arm-m-system.xml", 0); + arm_gen_dynamic_m_systemreg_feature(cs, cs->gdb_num_regs), 0); #ifndef CONFIG_USER_ONLY if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { gdb_register_coprocessor(cs, arm_gdb_get_m_secextreg, arm_gdb_set_m_secextreg, - arm_gen_dynamic_m_secextreg_feature(cs, cs->gdb_num_regs)-= >num_regs, - "arm-m-secext.xml", 0); + arm_gen_dynamic_m_secextreg_feature(cs, cs->gdb_num_regs),= 0); } #endif } diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index b54162cbeb..6732efc5de 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -342,8 +342,7 @@ static void hexagon_cpu_realize(DeviceState *dev, Error= **errp) =20 gdb_register_coprocessor(cs, hexagon_hvx_gdb_read_register, hexagon_hvx_gdb_write_register, - NUM_VREGS + NUM_QREGS, - "hexagon-hvx.xml", 0); + gdb_find_static_feature("hexagon-hvx.xml"), 0= ); =20 qemu_init_vcpu(cs); cpu_reset(cs); diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c index 0752fff924..2886b106bb 100644 --- a/target/loongarch/gdbstub.c +++ b/target/loongarch/gdbstub.c @@ -101,5 +101,5 @@ static int loongarch_gdb_set_fpu(CPULoongArchState *env, void loongarch_cpu_register_gdb_regs_for_features(CPUState *cs) { gdb_register_coprocessor(cs, loongarch_gdb_get_fpu, loongarch_gdb_set_= fpu, - 41, "loongarch-fpu.xml", 0); + gdb_find_static_feature("loongarch-fpu.xml"),= 0); } diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 0a1544cd68..675f2dcd5a 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -152,10 +152,10 @@ void m68k_cpu_init_gdb(M68kCPU *cpu) =20 if (m68k_feature(env, M68K_FEATURE_CF_FPU)) { gdb_register_coprocessor(cs, cf_fpu_gdb_get_reg, cf_fpu_gdb_set_re= g, - 11, "cf-fp.xml", 18); + gdb_find_static_feature("cf-fp.xml"), 18); } else if (m68k_feature(env, M68K_FEATURE_FPU)) { - gdb_register_coprocessor(cs, m68k_fpu_gdb_get_reg, - m68k_fpu_gdb_set_reg, 11, "m68k-fp.xml", = 18); + gdb_register_coprocessor(cs, m68k_fpu_gdb_get_reg, m68k_fpu_gdb_se= t_reg, + gdb_find_static_feature("m68k-fp.xml"), 1= 8); } /* TODO: Add [E]MAC registers. */ } diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 47f37c2519..c804622ab9 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -298,8 +298,9 @@ static void mb_cpu_initfn(Object *obj) =20 cpu_set_cpustate_pointers(cpu); gdb_register_coprocessor(CPU(cpu), mb_cpu_gdb_read_stack_protect, - mb_cpu_gdb_write_stack_protect, 2, - "microblaze-stack-protect.xml", 0); + mb_cpu_gdb_write_stack_protect, + gdb_find_static_feature("microblaze-stack-pro= tect.xml"), + 0); =20 set_float_rounding_mode(float_round_nearest_even, &env->fp_status); =20 diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index adc647a24e..a0da320e66 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -603,22 +603,23 @@ void ppc_gdb_init(CPUState *cs, PowerPCCPUClass *pcc) { if (pcc->insns_flags & PPC_FLOAT) { gdb_register_coprocessor(cs, gdb_get_float_reg, gdb_set_float_reg, - 33, "power-fpu.xml", 0); + gdb_find_static_feature("power-fpu.xml"),= 0); } if (pcc->insns_flags & PPC_ALTIVEC) { gdb_register_coprocessor(cs, gdb_get_avr_reg, gdb_set_avr_reg, - 34, "power-altivec.xml", 0); + gdb_find_static_feature("power-altivec.xm= l"), + 0); } if (pcc->insns_flags & PPC_SPE) { gdb_register_coprocessor(cs, gdb_get_spe_reg, gdb_set_spe_reg, - 34, "power-spe.xml", 0); + gdb_find_static_feature("power-spe.xml"),= 0); } if (pcc->insns_flags2 & PPC2_VSX) { gdb_register_coprocessor(cs, gdb_get_vsx_reg, gdb_set_vsx_reg, - 32, "power-vsx.xml", 0); + gdb_find_static_feature("power-vsx.xml"),= 0); } #ifndef CONFIG_USER_ONLY gdb_register_coprocessor(cs, gdb_get_spr_reg, gdb_set_spr_reg, - pcc->gdb_spr.num_regs, "power-spr.xml", 0); + &pcc->gdb_spr, 0); #endif } diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 70c60ad8b1..224c69ea99 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -317,29 +317,33 @@ void riscv_cpu_register_gdb_regs_for_features(CPUStat= e *cs) CPURISCVState *env =3D &cpu->env; if (env->misa_ext & RVD) { gdb_register_coprocessor(cs, riscv_gdb_get_fpu, riscv_gdb_set_fpu, - 32, "riscv-64bit-fpu.xml", 0); + gdb_find_static_feature("riscv-64bit-fpu.= xml"), + 0); } else if (env->misa_ext & RVF) { gdb_register_coprocessor(cs, riscv_gdb_get_fpu, riscv_gdb_set_fpu, - 32, "riscv-32bit-fpu.xml", 0); + gdb_find_static_feature("riscv-32bit-fpu.= xml"), + 0); } if (env->misa_ext & RVV) { int base_reg =3D cs->gdb_num_regs; gdb_register_coprocessor(cs, riscv_gdb_get_vector, riscv_gdb_set_vector, - ricsv_gen_dynamic_vector_feature(cs, base= _reg)->num_regs, - "riscv-vector.xml", 0); + ricsv_gen_dynamic_vector_feature(cs, base= _reg), + 0); } switch (env->misa_mxl_max) { case MXL_RV32: gdb_register_coprocessor(cs, riscv_gdb_get_virtual, riscv_gdb_set_virtual, - 1, "riscv-32bit-virtual.xml", 0); + gdb_find_static_feature("riscv-32bit-virt= ual.xml"), + 0); break; case MXL_RV64: case MXL_RV128: gdb_register_coprocessor(cs, riscv_gdb_get_virtual, riscv_gdb_set_virtual, - 1, "riscv-64bit-virtual.xml", 0); + gdb_find_static_feature("riscv-64bit-virt= ual.xml"), + 0); break; default: g_assert_not_reached(); @@ -348,7 +352,7 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState = *cs) if (cpu->cfg.ext_icsr) { int base_reg =3D cs->gdb_num_regs; gdb_register_coprocessor(cs, riscv_gdb_get_csr, riscv_gdb_set_csr, - riscv_gen_dynamic_csr_feature(cs, base_re= g)->num_regs, - "riscv-csr.xml", 0); + riscv_gen_dynamic_csr_feature(cs, base_re= g), + 0); } } diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c index 6fbfd41bc8..02c388dc32 100644 --- a/target/s390x/gdbstub.c +++ b/target/s390x/gdbstub.c @@ -69,8 +69,6 @@ int s390_cpu_gdb_write_register(CPUState *cs, uint8_t *me= m_buf, int n) /* the values represent the positions in s390-acr.xml */ #define S390_A0_REGNUM 0 #define S390_A15_REGNUM 15 -/* total number of registers in s390-acr.xml */ -#define S390_NUM_AC_REGS 16 =20 static int cpu_read_ac_reg(CPUS390XState *env, GByteArray *buf, int n) { @@ -98,8 +96,6 @@ static int cpu_write_ac_reg(CPUS390XState *env, uint8_t *= mem_buf, int n) #define S390_FPC_REGNUM 0 #define S390_F0_REGNUM 1 #define S390_F15_REGNUM 16 -/* total number of registers in s390-fpr.xml */ -#define S390_NUM_FP_REGS 17 =20 static int cpu_read_fp_reg(CPUS390XState *env, GByteArray *buf, int n) { @@ -132,8 +128,6 @@ static int cpu_write_fp_reg(CPUS390XState *env, uint8_t= *mem_buf, int n) #define S390_V15L_REGNUM 15 #define S390_V16_REGNUM 16 #define S390_V31_REGNUM 31 -/* total number of registers in s390-vx.xml */ -#define S390_NUM_VREGS 32 =20 static int cpu_read_vreg(CPUS390XState *env, GByteArray *buf, int n) { @@ -172,8 +166,6 @@ static int cpu_write_vreg(CPUS390XState *env, uint8_t *= mem_buf, int n) /* the values represent the positions in s390-cr.xml */ #define S390_C0_REGNUM 0 #define S390_C15_REGNUM 15 -/* total number of registers in s390-cr.xml */ -#define S390_NUM_C_REGS 16 =20 #ifndef CONFIG_USER_ONLY static int cpu_read_c_reg(CPUS390XState *env, GByteArray *buf, int n) @@ -206,8 +198,6 @@ static int cpu_write_c_reg(CPUS390XState *env, uint8_t = *mem_buf, int n) #define S390_VIRT_CPUTM_REGNUM 1 #define S390_VIRT_BEA_REGNUM 2 #define S390_VIRT_PREFIX_REGNUM 3 -/* total number of registers in s390-virt.xml */ -#define S390_NUM_VIRT_REGS 4 =20 static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int = n) { @@ -254,8 +244,6 @@ static int cpu_write_virt_reg(CPUS390XState *env, uint8= _t *mem_buf, int n) #define S390_VIRT_KVM_PFT_REGNUM 1 #define S390_VIRT_KVM_PFS_REGNUM 2 #define S390_VIRT_KVM_PFC_REGNUM 3 -/* total number of registers in s390-virt-kvm.xml */ -#define S390_NUM_VIRT_KVM_REGS 4 =20 static int cpu_read_virt_kvm_reg(CPUS390XState *env, GByteArray *mem_buf, = int n) { @@ -303,8 +291,6 @@ static int cpu_write_virt_kvm_reg(CPUS390XState *env, u= int8_t *mem_buf, int n) #define S390_GS_GSD_REGNUM 1 #define S390_GS_GSSM_REGNUM 2 #define S390_GS_GSEPLA_REGNUM 3 -/* total number of registers in s390-gs.xml */ -#define S390_NUM_GS_REGS 4 =20 static int cpu_read_gs_reg(CPUS390XState *env, GByteArray *buf, int n) { @@ -322,33 +308,33 @@ void s390_cpu_gdb_init(CPUState *cs) { gdb_register_coprocessor(cs, cpu_read_ac_reg, cpu_write_ac_reg, - S390_NUM_AC_REGS, "s390-acr.xml", 0); + gdb_find_static_feature("s390-acr.xml"), 0); =20 gdb_register_coprocessor(cs, cpu_read_fp_reg, cpu_write_fp_reg, - S390_NUM_FP_REGS, "s390-fpr.xml", 0); + gdb_find_static_feature("s390-fpr.xml"), 0); =20 gdb_register_coprocessor(cs, cpu_read_vreg, cpu_write_vreg, - S390_NUM_VREGS, "s390-vx.xml", 0); + gdb_find_static_feature("s390-vx.xml"), 0); =20 gdb_register_coprocessor(cs, cpu_read_gs_reg, cpu_write_gs_reg, - S390_NUM_GS_REGS, "s390-gs.xml", 0); + gdb_find_static_feature("s390-gs.xml"), 0); =20 #ifndef CONFIG_USER_ONLY gdb_register_coprocessor(cs, cpu_read_c_reg, cpu_write_c_reg, - S390_NUM_C_REGS, "s390-cr.xml", 0); + gdb_find_static_feature("s390-cr.xml"), 0); =20 gdb_register_coprocessor(cs, cpu_read_virt_reg, cpu_write_virt_reg, - S390_NUM_VIRT_REGS, "s390-virt.xml", 0); + gdb_find_static_feature("s390-virt.xml"), 0); =20 if (kvm_enabled()) { gdb_register_coprocessor(cs, cpu_read_virt_kvm_reg, cpu_write_virt_kvm_reg, - S390_NUM_VIRT_KVM_REGS, "s390-virt-kvm.xm= l", + gdb_find_static_feature("s390-virt-kvm.xm= l"), 0); } #endif --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793194; cv=none; d=zohomail.com; s=zohoarc; b=Bx1Fazq3IIIhemA0BB1nFgkFOvMVW7ikijtu2yE1XtIXnV0L/q3j6vggV3OAN/Fnure4W3VlD9WFGrsr1Ei4Tyif4eMA5hDFuVRwYJuqA8tRz01o12aKca2Qbb5LZGL8IO1UizOxBvTCApkjQ/T8f/f9GEea3hnc2oT4gCTyDek= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793194; 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; bh=4O5XiL9Naewl5HxRHqjpi1iQMXhF2obFyf/BgvZpyDA=; b=XQxvBrCAQQxVBAesB8O8c13byzNWRP8/NVwehm3AcohMSQEBd4dPmWRU7MU4cekMnBZ+m3lAbtYGbrLdd9ZeDoanEw2FBMSN018T16CGVN8xIJ6Ex/xFPyS5zPKcukUNPFfSObewSRSjiBwBlMmNiPshltwY3QhcdLdsgdjy/DA= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793194451151.08551355310965; Mon, 31 Jul 2023 01:46:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOXk-0002kh-MZ; Mon, 31 Jul 2023 04:46:21 -0400 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 1qQOXP-0002XH-FY for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:45:59 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOXM-000501-Jk for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:45:59 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-686bc261111so2975713b3a.3 for ; Mon, 31 Jul 2023 01:45:56 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:45:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793155; x=1691397955; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4O5XiL9Naewl5HxRHqjpi1iQMXhF2obFyf/BgvZpyDA=; b=GJVPZppDfKmYORLuER6EZt8krtL9nEB6KbU1E0vrA9yICHD19t+Sl0r1zzPJH9J2dd IvhK5cXJEHQtPnyQC6qPSZ7RQv8TT8BJhLRTZaFIc0ARFhaEQWT0BpwsZyOb0L03CZbF dQNiTsLBdsR5VzDIHnh8ejRK8wmTJBDYBHhhtznkAcYXuvQXNdhTQTuH8IYgaZFL7I3M eVdl/XWPzz1nrVlid/X16UIXd3bGTVIEtEhXNXe+ztpVIN3YLpzDa4JiJjeLdSFwdaEA /114FyCkYzTcia7wH0uMMpsMaMBq5DfC2/pgKQB5snMORo+bxpHZOAbRuZTqDVMekoJN ewZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793155; x=1691397955; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4O5XiL9Naewl5HxRHqjpi1iQMXhF2obFyf/BgvZpyDA=; b=kiv7esA2KAZHJoVsAzpSdDmzrUsnC6jOs2HeCzhROV3Y7fihe0vQo3btnyDmr12H0s 5WmcV9pedrnpJ0rjC26g4tPuwZ1HeCcqjpfT4y2knurSzcbaYQKCb7k0DA5Y38qJzY+o T/fbdmhbrKWihmn8f9C+ecSuB427PweEoxLKffW8bNkEC7UqSutcZ5Er6FfEbjGjhlpk 7TskScjqWbQIl3Qp5wRWvfkKkuqvbEY0dkowjYGZNwZpxkVKmYw/dHbycg4vd8Uw2jij k7eX7f4doSdySAGFD0ybHfjPbTW6g/IbHtcfp6yWaL8gv0+EkfGLGZujsesA1NYqGOom xUNw== X-Gm-Message-State: ABy/qLZNAMOK+rDr55MIcfzUxf0FnU6v1nRX1AIAbiGUSi6AukL91lLm PVH6rrGC6Is0FzptfhrgN8enZQ== X-Google-Smtp-Source: APBJJlFaXNhraOVLhdxG/o3w8DDHlzViclvmPWpZWDjTqqgWJd4IXLIrj7vVtLRc0eWTdaVZV4puaw== X-Received: by 2002:a05:6a00:22d3:b0:687:1604:39d2 with SMTP id f19-20020a056a0022d300b00687160439d2mr10574023pfj.10.1690793154902; Mon, 31 Jul 2023 01:45:54 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 11/24] gdbstub: Use GDBFeature for GDBRegisterState Date: Mon, 31 Jul 2023 17:43:38 +0900 Message-ID: <20230731084354.115015-12-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::42d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793195486100001 Content-Type: text/plain; charset="utf-8" Simplify GDBRegisterState by replacing num_regs and xml members with one member that points to GDBFeature. Signed-off-by: Akihiko Odaki --- gdbstub/gdbstub.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index ab75f6686b..182efe7e0f 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -47,10 +47,9 @@ =20 typedef struct GDBRegisterState { int base_reg; - int num_regs; gdb_get_reg_cb get_reg; gdb_set_reg_cb set_reg; - const char *xml; + const GDBFeature *feature; struct GDBRegisterState *next; } GDBRegisterState; =20 @@ -390,7 +389,7 @@ static const char *get_feature_xml(const char *p, const= char **newp, pstrcat(buf, buf_sz, "\"/>"); for (r =3D cpu->gdb_regs; r; r =3D r->next) { pstrcat(buf, buf_sz, "xml); + pstrcat(buf, buf_sz, r->feature->xml); pstrcat(buf, buf_sz, "\"/>"); } pstrcat(buf, buf_sz, ""); @@ -438,7 +437,7 @@ static int gdb_read_register(CPUState *cpu, GByteArray = *buf, int reg) } =20 for (r =3D cpu->gdb_regs; r; r =3D r->next) { - if (r->base_reg <=3D reg && reg < r->base_reg + r->num_regs) { + if (r->base_reg <=3D reg && reg < r->base_reg + r->feature->num_re= gs) { return r->get_reg(env, buf, reg - r->base_reg); } } @@ -456,7 +455,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *m= em_buf, int reg) } =20 for (r =3D cpu->gdb_regs; r; r =3D r->next) { - if (r->base_reg <=3D reg && reg < r->base_reg + r->num_regs) { + if (r->base_reg <=3D reg && reg < r->base_reg + r->feature->num_re= gs) { return r->set_reg(env, mem_buf, reg - r->base_reg); } } @@ -479,17 +478,16 @@ void gdb_register_coprocessor(CPUState *cpu, p =3D &cpu->gdb_regs; while (*p) { /* Check for duplicates. */ - if (strcmp((*p)->xml, feature->xmlname) =3D=3D 0) + if ((*p)->feature =3D=3D feature) return; p =3D &(*p)->next; } =20 s =3D g_new0(GDBRegisterState, 1); s->base_reg =3D cpu->gdb_num_regs; - s->num_regs =3D feature->num_regs; s->get_reg =3D get_reg; s->set_reg =3D set_reg; - s->xml =3D feature->xml; + s->feature =3D feature; =20 /* Add to end of list. */ cpu->gdb_num_regs +=3D feature->num_regs; --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793280; cv=none; d=zohomail.com; s=zohoarc; b=B70TgvlgKk89E0ZMP+JhooFpv25JvLtqYLWt094Kx5Iof5cXmuJNi/WP+argLXv6ZdWSeM/E+Ff1s8KolewjrceOqqC3Tx5ZHOi/uEipgGM30TjWrRmXxua8Hh9cn1eeKtD3RdbDIbHDRyzNmRjucoMwqz6MT8AZZhj95f2L2XQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793280; 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; bh=2cCfolvh7idEXgF4TdLd2iHCvw9onhY6ET+lKLovyso=; b=JcdZiLJ1HqU2IEood2sqpZk5Bbw3cBsoloejO3iDvJRrDc8oSU4zTlt8Yovlp+RAx6e0eWUuTbT51euNroiN87KrZZdM2+I/FICbNMT6Zogd+OvRirtwvUcO4B9bSmrpQV/mwzwS2MaZr2F1+VZR8ZHHvBN+r9+FepgyydnnyJA= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793280472918.8887408360756; Mon, 31 Jul 2023 01:48:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOY0-0003i5-UF; Mon, 31 Jul 2023 04:46:36 -0400 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 1qQOXW-0002fd-Py for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:46:07 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOXV-00050w-2x for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:46:06 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-686bc261111so2975861b3a.3 for ; Mon, 31 Jul 2023 01:46:04 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:46:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793164; x=1691397964; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2cCfolvh7idEXgF4TdLd2iHCvw9onhY6ET+lKLovyso=; b=SP9NjlmknQRt8bmqOt4+KZgBltXZrqoplF5HNUbp1ftNii9+BBx8WsYRJcjGeLNn/1 FbK6CKC2czHwrzuCR76MTeafDEXOtKGxNUoAsCoESgBIyXZrfyJrdx14Ch3OJWVNcnts E6q3oLO/PxBU8PmWiVc7y8YwUD7Kx3dSKy4TuSFTfCK1GRnOvh2cPhavYSXfyyv3YOUe 9XO/ckQ734cPkVbhf64rYBMQJmkIUKltmnEuLdXZNVCCv/BWhD9WA8HypmNm5k9xwBq4 EAjUDI/BjMnd6XDFf5MV04HP2l8vQMsq84YDD0vl3CbvSLyuFqck6QMElaa3AGOT19n/ 8ESQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793164; x=1691397964; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2cCfolvh7idEXgF4TdLd2iHCvw9onhY6ET+lKLovyso=; b=Vb2CnaqPbHpzmPyx/BSxHlH92K801A9Gr5u/BdmTNVbu30umBy/OIz480vxslHcJbD EZtswbWK0QoEDlvJgPEW0mTV6FRfDbdCbJvOrLrfsmjALId1zWmlWw2euaIPmfQti9Pg UjQApzXyennWyLcgO7ua1Jh/v/iMoaCntEFe3dtfJ8q9K2D7u/3g7k+WDKSSPlZCsl9K Qocf9KtdACO/M2uUnW4oeG/XWZPkq0mPyP7Zlt8PhAmGroFUvi5XaEr2D2Ia9z16lDCg f/ajPI71sMogOXfGS2ZiF+GRUNEYK+0DiEw/wcW1k6+AhoVNlxVKEZZ7mAWNFhofnYFs 68vg== X-Gm-Message-State: ABy/qLaeJtQ0uoG+xIrWeuIG/lblyUkKsDKfOuuAhqw+ODq5NRVKWceF 86hdAZqsPVJpIg57wdDcC35Xew== X-Google-Smtp-Source: APBJJlFMxBusi1wYx3a81pCvpSrp8aDs7saPi8oPhnUOMgwU6xu9h9csse0tazK95hVbdV7IY51PDg== X-Received: by 2002:a05:6a20:4299:b0:133:2fb2:917d with SMTP id o25-20020a056a20429900b001332fb2917dmr10174620pzj.5.1690793163948; Mon, 31 Jul 2023 01:46:03 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 12/24] gdbstub: Simplify XML lookup Date: Mon, 31 Jul 2023 17:43:39 +0900 Message-ID: <20230731084354.115015-13-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::436; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x436.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793281490100003 Content-Type: text/plain; charset="utf-8" Now we know all instances of GDBFeature that is used in CPU so we can traverse them to find XML. This removes the need for a CPU-specific lookup function for dynamic XMLs. Signed-off-by: Akihiko Odaki --- gdbstub/gdbstub.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 182efe7e0f..e5bb2c89ba 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -354,8 +354,7 @@ static const char *get_feature_xml(const char *p, const= char **newp, GDBProcess *process) { size_t len; - int i; - const char *name; + GDBRegisterState *r; CPUState *cpu =3D gdb_get_first_cpu_in_process(process); CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 @@ -364,15 +363,12 @@ static const char *get_feature_xml(const char *p, con= st char **newp, len++; *newp =3D p + len; =20 - name =3D NULL; if (strncmp(p, "target.xml", len) =3D=3D 0) { char *buf =3D process->target_xml; const size_t buf_sz =3D sizeof(process->target_xml); =20 /* Generate the XML description for this CPU. */ if (!buf[0]) { - GDBRegisterState *r; - pstrcat(buf, buf_sz, "" "" @@ -389,28 +385,22 @@ static const char *get_feature_xml(const char *p, con= st char **newp, pstrcat(buf, buf_sz, "\"/>"); for (r =3D cpu->gdb_regs; r; r =3D r->next) { pstrcat(buf, buf_sz, "feature->xml); + pstrcat(buf, buf_sz, r->feature->xmlname); pstrcat(buf, buf_sz, "\"/>"); } pstrcat(buf, buf_sz, ""); } return buf; } - if (cc->gdb_get_dynamic_xml) { - char *xmlname =3D g_strndup(p, len); - const char *xml =3D cc->gdb_get_dynamic_xml(cpu, xmlname); - - g_free(xmlname); - if (xml) { - return xml; - } + if (strncmp(p, cc->gdb_core_feature->xmlname, len) =3D=3D 0) { + return cc->gdb_core_feature->xml; } - for (i =3D 0; ; i++) { - name =3D gdb_features[i].xmlname; - if (!name || (strncmp(name, p, len) =3D=3D 0 && strlen(name) =3D= =3D len)) - break; + for (r =3D cpu->gdb_regs; r; r =3D r->next) { + if (strncmp(p, r->feature->xmlname, len) =3D=3D 0) { + return r->feature->xml; + } } - return name ? gdb_features[i].xml : NULL; + return NULL; } =20 const GDBFeature *gdb_find_static_feature(const char *xmlname) --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793338; cv=none; d=zohomail.com; s=zohoarc; b=eldRqhTqk3bYy5M28wGdhNcuz/DJ/i4fNYoIegFvMJtRcKp1DO3dC9mlBAYCVOzV3zb8SIcdbD93y7Nod+LgxSAc6Mp/EwRS+U84tiCXhAOdxQ09VeE9HK7LSfzrTTBb8QK3SvVgYtEfHHRKh5Xme+DK5y5mGlHc22OmNWeEdWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793338; 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; bh=LRyAX1EjgNmPApmrJcX5mTkwHPCoDyvZ+ze9fNelUew=; b=N+qmydoje20+MiMcunbxeuCIP8t4fFZfxl2drkB3tjJqYlkwtR/RY8vuEuVr0jGTfW6+VfTErljJm11RJr2++L65jZOSFnIaJ3y0pvyVlr8ChBUYpJehLy3aCDbTDW4ES7fRpxka6jQaKKhkancCFm6iGJTVEqOIu1U4RCyg9to= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793338673880.255438687955; Mon, 31 Jul 2023 01:48:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOY2-00041i-J7; Mon, 31 Jul 2023 04:46:38 -0400 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 1qQOXh-0002qi-Mt for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:46:20 -0400 Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOXd-000522-Sm for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:46:17 -0400 Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-76571dae5feso358468885a.1 for ; Mon, 31 Jul 2023 01:46:13 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.46.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:46:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793173; x=1691397973; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LRyAX1EjgNmPApmrJcX5mTkwHPCoDyvZ+ze9fNelUew=; b=TUd0k+JmhghMnDwcakCbBjYhs95cJScMF1Za+VFRI740Pg2pIYcQxdU1oT3l/Jg3nb 3KP53yNHypD8aMcoDZIMo38+6aYY6Hk+QUmzz3AuamY/YfgBG+cgzbDSnYS0o1mHQHzr ipoGtW0hOIAsDNQr3JdSr78whrKIw7jHHr0EZpVQlLELYLyggMdJbLycYnDDQGP6Gifu cfS7d+HCZqsl8BdBLs9qyxywYr940Hz2+MT7ACQZWsP0IbRRSbUMRwuq72ZoZYDvzcC7 kRGOGxrTE+lOqde6SHi8+uVKyBXPgVctQWqr0fQ0IpQ3RmNYO/AaqrBmnEkTTLpm3e9p /p2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793173; x=1691397973; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LRyAX1EjgNmPApmrJcX5mTkwHPCoDyvZ+ze9fNelUew=; b=G0eNTsyaMb5b6QfYbp6JgLYXbXmWV459OhKxpdo8mrqklNUHrUEbabNG8iDOeFifYh EXEsyeXT6vX0/YSkTxGyY3oaONTwq6oYiOwp3NCI8IbVu1SsyrNNHg+aMbCnARt9KBbV BIJGazQi+9tr892CHtubFvr3l/hLMJ6ONu9b0viYW61Ww6H+oYTirW9gPu/IcqcZkNZQ +QtaeenHJ76hzq/yzR5PEydkRW0U2W7JPL6HSLqqWeAStdmqobG4lpJ6zMYvqMBBKo3f 27HN4VvPgEYWsf4zxf5CQ5ddSbWWBxcHId4DW8iwnkBbzs1ACl+8QJQWw7ZJls+sHJdf uLXQ== X-Gm-Message-State: ABy/qLY0OAmRbbQR8G/bEiVKIWKOlG7Al5SEbodfQuPDO601ux2Y/Hvi 1CphC21WXuaA3G824KPbXPa9tA== X-Google-Smtp-Source: APBJJlF2wLoCJXwRo0PBjYKkVL/AFJYL42hAw5FbCMzcH15m1NYUYszPR7jl+QxHlN9OJi/owlPikQ== X-Received: by 2002:a05:620a:e90:b0:76c:b02b:cd73 with SMTP id w16-20020a05620a0e9000b0076cb02bcd73mr2477410qkm.74.1690793173015; Mon, 31 Jul 2023 01:46:13 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 13/24] hw/core/cpu: Remove gdb_get_dynamic_xml member Date: Mon, 31 Jul 2023 17:43:40 +0900 Message-ID: <20230731084354.115015-14-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::729; envelope-from=akihiko.odaki@daynix.com; helo=mail-qk1-x729.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793340486100003 Content-Type: text/plain; charset="utf-8" This function is no longer used. Signed-off-by: Akihiko Odaki Reviewed-by: Alex Benn=C3=A9e --- include/hw/core/cpu.h | 4 ---- target/arm/cpu.h | 6 ------ target/ppc/cpu.h | 1 - target/arm/cpu.c | 1 - target/arm/gdbstub.c | 18 ------------------ target/ppc/cpu_init.c | 3 --- target/ppc/gdbstub.c | 10 ---------- target/riscv/cpu.c | 14 -------------- 8 files changed, 57 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 84219c1885..9323d26f84 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -133,9 +133,6 @@ struct SysemuCPUOps; * before the insn which triggers a watchpoint rather than after= it. * @gdb_arch_name: Optional callback that returns the architecture name kn= own * to GDB. The caller must free the returned string with g_free. - * @gdb_get_dynamic_xml: Callback to return dynamically generated XML for = the - * gdb stub. Returns a pointer to the XML contents for the specified XML= file - * or NULL if the CPU doesn't have a dynamically generated content for i= t. * @disas_set_info: Setup architecture specific components of disassembly = info * @adjust_watchpoint_address: Perform a target-specific adjustment to an * address before attempting to match it against watchpoints. @@ -166,7 +163,6 @@ struct CPUClass { =20 const GDBFeature *gdb_core_feature; gchar * (*gdb_arch_name)(CPUState *cpu); - const char * (*gdb_get_dynamic_xml)(CPUState *cpu, const char *xmlname= ); =20 void (*disas_set_info)(CPUState *cpu, disassemble_info *info); =20 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index d6c2378d05..09bf82034d 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1131,12 +1131,6 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *c= pu, vaddr addr, int arm_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); =20 -/* Returns the dynamically generated XML for the gdb stub. - * Returns a pointer to the XML contents for the specified XML file or NULL - * if the XML name doesn't match the predefined one. - */ -const char *arm_gdb_get_dynamic_xml(CPUState *cpu, const char *xmlname); - int arm_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, DumpState *s); int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 5f251bdffe..3dc6e545e3 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1382,7 +1382,6 @@ int ppc_cpu_gdb_write_register_apple(CPUState *cpu, u= int8_t *buf, int reg); #ifndef CONFIG_USER_ONLY hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); void ppc_gdb_gen_spr_feature(PowerPCCPU *cpu); -const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name); #endif int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, DumpState *s); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index a206ab6b1b..f51612070d 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2354,7 +2354,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) cc->sysemu_ops =3D &arm_sysemu_ops; #endif cc->gdb_arch_name =3D arm_gdb_arch_name; - cc->gdb_get_dynamic_xml =3D arm_gdb_get_dynamic_xml; cc->gdb_stop_before_watchpoint =3D true; cc->disas_set_info =3D arm_disas_set_info; =20 diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index ab4ffe6264..100a6eed15 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -492,24 +492,6 @@ static GDBFeature *arm_gen_dynamic_m_secextreg_feature= (CPUState *cs, #endif #endif /* CONFIG_TCG */ =20 -const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) -{ - ARMCPU *cpu =3D ARM_CPU(cs); - - if (strcmp(xmlname, "system-registers.xml") =3D=3D 0) { - return cpu->dyn_sysreg_feature.desc.xml; - } else if (strcmp(xmlname, "sve-registers.xml") =3D=3D 0) { - return cpu->dyn_svereg_feature.desc.xml; - } else if (strcmp(xmlname, "arm-m-system.xml") =3D=3D 0) { - return cpu->dyn_m_systemreg_feature.desc.xml; -#ifndef CONFIG_USER_ONLY - } else if (strcmp(xmlname, "arm-m-secext.xml") =3D=3D 0) { - return cpu->dyn_m_secextreg_feature.desc.xml; -#endif - } - return NULL; -} - void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) { CPUState *cs =3D CPU(cpu); diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 938cd2b7e1..a3153c4e9f 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -7370,9 +7370,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, void = *data) #endif =20 cc->gdb_num_core_regs =3D 71; -#ifndef CONFIG_USER_ONLY - cc->gdb_get_dynamic_xml =3D ppc_gdb_get_dynamic_xml; -#endif #ifdef USE_APPLE_GDB cc->gdb_read_register =3D ppc_cpu_gdb_read_register_apple; cc->gdb_write_register =3D ppc_cpu_gdb_write_register_apple; diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index a0da320e66..19c4935260 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -375,16 +375,6 @@ void ppc_gdb_gen_spr_feature(PowerPCCPU *cpu) pcc->gdb_spr.xmlname =3D "power-spr.xml"; pcc->gdb_spr.xml =3D g_string_free(xml, false); } - -const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name) -{ - PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cs); - - if (strcmp(xml_name, "power-spr.xml") =3D=3D 0) { - return pcc->gdb_spr.xml; - } - return NULL; -} #endif =20 #if !defined(CONFIG_USER_ONLY) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index ceca40cdd9..66c8c0dc57 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1957,19 +1957,6 @@ static gchar *riscv_gdb_arch_name(CPUState *cs) } } =20 -static const char *riscv_gdb_get_dynamic_xml(CPUState *cs, const char *xml= name) -{ - RISCVCPU *cpu =3D RISCV_CPU(cs); - - if (strcmp(xmlname, "riscv-csr.xml") =3D=3D 0) { - return cpu->dyn_csr_feature.xml; - } else if (strcmp(xmlname, "riscv-vector.xml") =3D=3D 0) { - return cpu->dyn_vreg_feature.xml; - } - - return NULL; -} - #ifndef CONFIG_USER_ONLY static int64_t riscv_get_arch_id(CPUState *cs) { @@ -2147,7 +2134,6 @@ static void riscv_cpu_class_init(ObjectClass *c, void= *data) cc->get_arch_id =3D riscv_get_arch_id; #endif cc->gdb_arch_name =3D riscv_gdb_arch_name; - cc->gdb_get_dynamic_xml =3D riscv_gdb_get_dynamic_xml; cc->tcg_ops =3D &riscv_tcg_ops; =20 object_class_property_add(c, "mvendorid", "uint32", cpu_get_mvendorid, --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793319; cv=none; d=zohomail.com; s=zohoarc; b=kWW8DeMdYm5kEz69uzvNXjF+Lqjo43E6rWtliuf/5uwFSPT3ajxYSfDoqshH0LMQgCUJNrqCTYvekmjzkjoCqCa/MzhGSPmgxLO4U1YmJ5HcSe4RtfqtHVSBMMunNFUGkV+1J+K6NSv7IW0BVl0toJiRW9qDWUPOvukNIf9RSx0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793319; 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; bh=YVDhI8G3XKQpdTKkzfZwxCOShys46nkH8J+TNtUodNs=; b=EK9TtamaJbLP5wW/CRPncxi6y/Wt5pofkSQIaw4zli2WCl3E9D7Eu8KLvC/zSCTphSAWJ/jiSOcA7HWLvwDbafAdarP+tHc+XDeKFeVGFinz2XJGj0tupHXfFY+vsMaGwxtzgUTonzivJlU3FDxME49UCcfHeSLiaA/bJ6VAOjM= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793319463238.10070068871335; Mon, 31 Jul 2023 01:48:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOY1-0003lw-Ak; Mon, 31 Jul 2023 04:46:37 -0400 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 1qQOXo-0002uj-Na for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:46:26 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOXn-000537-31 for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:46:24 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-686ba97e4feso4280088b3a.0 for ; Mon, 31 Jul 2023 01:46:22 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.46.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:46:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793182; x=1691397982; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YVDhI8G3XKQpdTKkzfZwxCOShys46nkH8J+TNtUodNs=; b=Qq6IkFihp/e4yvxXsyLxNHOGpLnKdliXR0ZAoli2RYnnFbwsfCOikD0T/RvzUHtpPu Jae53C8HsgcPLy7aSvsqUs8Pmca/ZmBtgaZtN4/+A1k1ezPGRqOvJBGmHcoqUtwDi8+Z VUF99HRZ71RaqkwAxqTkeXwOKLItyfvKZq++hB0wb+/Dcwr4U5E57lS+79vcNzzVw8yB 34WFykauxL8zqUUtyFQThps7xnv21EyNW7ySHTpqlYD50yRBVIQLEkWXLgpy3+VxoFF/ dEhFUb5wgVviCb+E742leC7Cb/8MaC3Sse4Gozx3z1XKSb0c/9kXkOzVK39KdqNOUbc9 7X9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793182; x=1691397982; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YVDhI8G3XKQpdTKkzfZwxCOShys46nkH8J+TNtUodNs=; b=AZeVnWZHoeGxNHQSqlaisP5TN8tcCELIFQmr10IO/HgDr18155OTNiQwyoa3U9OXbP 3c2ijR5TwyfU4R3qj5Xk92NumoPA+Uj4PECze/QQ3+P5IolnBcLrxRf+y+LVL/cLAjy2 QQmD4aL23vp9hg78Ie1r0VUb/O/vZcl2hga8WW+cudd1QmHevo70wRmULnS995jTthxR /MHSoAL5yrW36L8L0xMkIzu1BxCzm0Ms3f14pm2xTJ4whIOqrpiWsblQQyevEdRmyw3T omxCRm0o0TjZ4/xWnCIoVHyd0CBWhSdlJxE53xj/9D31JqQUDTEdLPW3IQrry1nshDG6 FOyw== X-Gm-Message-State: ABy/qLaTwqXS/jPtRUd6srh6YYI0hPq9ojTZdIOZLQlgCPyxud0tGkWL aURQOr3Xh+GAmWhz6zh452MpBQ== X-Google-Smtp-Source: APBJJlH0Y0jIbFL2MuYmKot0VnFWzDKlfE/mcBhR0eg7oE9a99MSoZM1t7WwhAqiV8ye1aO92Y3SUg== X-Received: by 2002:a05:6a00:1351:b0:675:8f71:290a with SMTP id k17-20020a056a00135100b006758f71290amr12466989pfu.34.1690793181961; Mon, 31 Jul 2023 01:46:21 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 14/24] gdbstub: Add members to identify registers to GDBFeature Date: Mon, 31 Jul 2023 17:43:41 +0900 Message-ID: <20230731084354.115015-15-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::433; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x433.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793321634100003 Content-Type: text/plain; charset="utf-8" These members will be used to help plugins to identify registers. The added members in instances of GDBFeature dynamically generated by CPUs will be filled in later changes. Signed-off-by: Akihiko Odaki --- include/exec/gdbstub.h | 2 ++ scripts/feature_to_c.py | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 9b3da5b257..6da4af9612 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -13,6 +13,8 @@ typedef struct GDBFeature { const char *xmlname; const char *xml; + const char *name; + const char * const *regs; int num_regs; } GDBFeature; =20 diff --git a/scripts/feature_to_c.py b/scripts/feature_to_c.py index 8eb8c81cf8..11b1bc05c9 100755 --- a/scripts/feature_to_c.py +++ b/scripts/feature_to_c.py @@ -46,7 +46,9 @@ def writeliteral(indent, bytes): sys.stderr.write(f'unexpected start tag: {element.tag}\n') exit(1) =20 + feature_name =3D element.attrib['name'] regnum =3D 0 + regnames =3D [] regnums =3D [] tags =3D ['feature'] for event, element in events: @@ -63,6 +65,7 @@ def writeliteral(indent, bytes): if 'regnum' in element.attrib: regnum =3D int(element.attrib['regnum']) =20 + regnames.append(element.attrib['name']) regnums.append(regnum) regnum +=3D 1 =20 @@ -81,6 +84,15 @@ def writeliteral(indent, bytes): writeliteral(8, bytes(os.path.basename(input), 'utf-8')) sys.stdout.write(',\n') writeliteral(8, read) - sys.stdout.write(f',\n {num_regs},\n }},\n') + sys.stdout.write(',\n') + writeliteral(8, bytes(feature_name, 'utf-8')) + sys.stdout.write(',\n (const char * const []) {\n') + + for index, regname in enumerate(regnames): + sys.stdout.write(f' [{regnums[index] - base_reg}] =3D\n= ') + writeliteral(16, bytes(regname, 'utf-8')) + sys.stdout.write(',\n') + + sys.stdout.write(f' }},\n {num_regs},\n }},\n') =20 sys.stdout.write(' { NULL }\n};\n') --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793347; cv=none; d=zohomail.com; s=zohoarc; b=WqSo1gr8Ou/APdUjdpUte2zmJWtNL8SkQ0pgApjYSbhIbiXsIzu0QOUE2e3aunLpmaP2/fGI//FrSPVVQo3sI2Ih/kCBvWCTS45L9H2AIslIT1FqIEuCz2ZBsy3uLEVUJ0PD/SdRAqWkRf6KkUpHw/J5lq23DrbleGKepnDADOc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793347; 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; bh=KlLyNz2EVMU9S4fs/o4J37H6wtwszDT/+6W4fMi8NHI=; b=cnbSmK/e6dRkgsRNS2OlN33H5M99yU92lZEUbB6cSaHGc5xslx8nWrmVkjHAofBV9gL9QnS7lNeh4ssYJF8zT2Y9Vm8Hgb8kr7/e0er4llQG4SJaFVMZ716zZLup3+Gt3Twyx4iPQrsxO3sT8JWVl8AgqTR0c1sTsumQ5rWOiig= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169079334723614.17382287011776; Mon, 31 Jul 2023 01:49:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOY3-0004Av-EC; Mon, 31 Jul 2023 04:46:39 -0400 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 1qQOXy-0003T5-Nv for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:46:35 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOXw-00055y-DO for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:46:34 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-55fcc15e109so2437478a12.3 for ; Mon, 31 Jul 2023 01:46:32 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.46.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:46:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793191; x=1691397991; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KlLyNz2EVMU9S4fs/o4J37H6wtwszDT/+6W4fMi8NHI=; b=fn5aOlNO+lR//hLYr/z6yhrEcLcazpFsajIq8hrQtcABL2+xx6wQf5HmRUtwkvATGc nlMl3PoSnBFv9Bv8Apnw1NbGb4hD0TWtBvaWtbQgpRq5B/E77yI+TSE/sfezYcG1eovo DCfO8Hmk1QpLMT71KkkSxt+l+itkmieHKyASAayWNBQWSr0AL7tgjk3TJw6bvSTnj/vY UGmSsCVqayq0faB13EP95bSFRM6ZWXFqPwZQCM9ZobT+QeD58jWyKeaZy1stF52DgHcy ERAtGbeDojQuXj0OpvqlSHC3CRZlUhinNsyHXJgD0S7NLPmF96MSbUpo7KUk2JB1KhLx JA0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793191; x=1691397991; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KlLyNz2EVMU9S4fs/o4J37H6wtwszDT/+6W4fMi8NHI=; b=cZDfsyJzeZipGGy7Ut4gwrVMSlEBlapuaOKapfLR0V68TTCUIlyTNa8AeZz4nLN2om FBxn1i53HhSCJj4I5VGZ2y+k2aEZD841Sg39smRSys7bKKdLfjSoSvpR70+S3c2ykZnj pkUgaWnWJJdwBaE9gMHjx79LkZykaYOCY0Cgn/ej6LFVw2M8OJiU4KqFP29nJHC+IT2P 19ClF2QV5zBHpt9o4/xxYsCRZNc7qb7buw9P/kZKeGtpZ/GvU6wRfgvTos2AjBbHcMId j7HDR0K57KBMcVolSLPclljOrM2PJToHVoIKUfrVl70isJjKFhT+XuK1k8q7Dm/p6Tv2 KPrg== X-Gm-Message-State: ABy/qLbLXk6ZzokFmHt90ZY/jEX604MbneyBxurrRn4da5iaBrvXouRv Wtj4GtiA9WP/ycxq9/s5PwEYlw== X-Google-Smtp-Source: APBJJlHGvpNsETGTwq0mtROsBUroG4nrkYSkJD40PaBshN9RoFr5aQ6bmrVDPKT3K7UzrGU//pWsCA== X-Received: by 2002:a05:6a20:8f0c:b0:137:a9d7:de12 with SMTP id b12-20020a056a208f0c00b00137a9d7de12mr10330974pzk.59.1690793190951; Mon, 31 Jul 2023 01:46:30 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 15/24] target/arm: Fill new members of GDBFeature Date: Mon, 31 Jul 2023 17:43:42 +0900 Message-ID: <20230731084354.115015-16-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::52d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x52d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793348599100001 Content-Type: text/plain; charset="utf-8" These members will be used to help plugins to identify registers. Signed-off-by: Akihiko Odaki --- target/arm/gdbstub.c | 46 +++++++++++++++++++++++++++--------------- target/arm/gdbstub64.c | 42 +++++++++++++++++++++++++------------- 2 files changed, 58 insertions(+), 30 deletions(-) diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 100a6eed15..56d24028f6 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -270,6 +270,7 @@ static void arm_gen_one_feature_sysreg(GString *s, g_string_append_printf(s, " regnum=3D\"%d\"", regnum); g_string_append_printf(s, " group=3D\"cp_regs\"/>"); dyn_feature->data.cpregs.keys[dyn_feature->desc.num_regs] =3D ri_key; + ((const char **)dyn_feature->desc.regs)[dyn_feature->desc.num_regs] = =3D ri->name; dyn_feature->desc.num_regs++; } =20 @@ -316,6 +317,8 @@ static GDBFeature *arm_gen_dynamic_sysreg_feature(CPUSt= ate *cs, int base_reg) DynamicGDBFeatureInfo *dyn_feature =3D &cpu->dyn_sysreg_feature; gsize num_regs =3D g_hash_table_size(cpu->cp_regs); =20 + dyn_feature->desc.name =3D "org.qemu.gdb.arm.sys.regs"; + dyn_feature->desc.regs =3D g_new(const char *, num_regs); dyn_feature->desc.num_regs =3D 0; dyn_feature->data.cpregs.keys =3D g_new(uint32_t, num_regs); g_string_printf(s, ""); @@ -418,30 +421,34 @@ static int arm_gdb_set_m_systemreg(CPUARMState *env, = uint8_t *buf, int reg) } =20 static GDBFeature *arm_gen_dynamic_m_systemreg_feature(CPUState *cs, - int orig_base_reg) + int base_reg) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; GString *s =3D g_string_new(NULL); - int base_reg =3D orig_base_reg; - int i; + const char **regs =3D g_new(const char *, ARRAY_SIZE(m_sysreg_def)); + int i =3D 0; + int j; =20 g_string_printf(s, ""); g_string_append_printf(s, "= "); g_string_append_printf(s, "\n"); =20 - for (i =3D 0; i < ARRAY_SIZE(m_sysreg_def); i++) { - if (arm_feature(env, m_sysreg_def[i].feature)) { + for (j =3D 0; j < ARRAY_SIZE(m_sysreg_def); j++) { + if (arm_feature(env, m_sysreg_def[j].feature)) { + regs[i] =3D m_sysreg_def[j].name; g_string_append_printf(s, "\n", - m_sysreg_def[i].name, base_reg++); + m_sysreg_def[j].name, base_reg + i++); } } =20 g_string_append_printf(s, ""); + cpu->dyn_m_systemreg_feature.desc.name =3D "org.gnu.gdb.arm.m-system"; cpu->dyn_m_systemreg_feature.desc.xmlname =3D "arm-m-system.xml"; cpu->dyn_m_systemreg_feature.desc.xml =3D g_string_free(s, false); - cpu->dyn_m_systemreg_feature.desc.num_regs =3D base_reg - orig_base_re= g; + cpu->dyn_m_systemreg_feature.desc.regs =3D regs; + cpu->dyn_m_systemreg_feature.desc.num_regs =3D i; =20 return &cpu->dyn_m_systemreg_feature.desc; } @@ -462,30 +469,37 @@ static int arm_gdb_set_m_secextreg(CPUARMState *env, = uint8_t *buf, int reg) } =20 static GDBFeature *arm_gen_dynamic_m_secextreg_feature(CPUState *cs, - int orig_base_reg) + int base_reg) { ARMCPU *cpu =3D ARM_CPU(cs); GString *s =3D g_string_new(NULL); - int base_reg =3D orig_base_reg; - int i; + const char **regs =3D g_new(const char *, ARRAY_SIZE(m_sysreg_def) * 2= ); + int i =3D 0; + int j; =20 g_string_printf(s, ""); g_string_append_printf(s, "= "); g_string_append_printf(s, "= \n"); =20 - for (i =3D 0; i < ARRAY_SIZE(m_sysreg_def); i++) { + for (j =3D 0; j < ARRAY_SIZE(m_sysreg_def); j++) { + regs[i] =3D g_strconcat(m_sysreg_def[j].name, "_ns", NULL); g_string_append_printf(s, - "\n", - m_sysreg_def[i].name, base_reg++); + "\n", + regs[i], base_reg + i); + i++; + regs[i] =3D g_strconcat(m_sysreg_def[j].name, "_s", NULL); g_string_append_printf(s, - "\n", - m_sysreg_def[i].name, base_reg++); + "\n", + regs[i], base_reg + i); + i++; } =20 g_string_append_printf(s, ""); + cpu->dyn_m_secextreg_feature.desc.name =3D "org.gnu.gdb.arm.secext"; cpu->dyn_m_secextreg_feature.desc.xmlname =3D "arm-m-secext.xml"; cpu->dyn_m_secextreg_feature.desc.xml =3D g_string_free(s, false); - cpu->dyn_m_secextreg_feature.desc.num_regs =3D base_reg - orig_base_re= g; + cpu->dyn_m_secextreg_feature.desc.regs =3D regs; + cpu->dyn_m_secextreg_feature.desc.num_regs =3D i; =20 return &cpu->dyn_m_secextreg_feature.desc; } diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 20483ef9bc..c5ed7c0aa3 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -316,15 +316,21 @@ static void output_vector_union_type(GString *s, int = reg_width, g_string_append(s, ""); } =20 -GDBFeature *arm_gen_dynamic_svereg_feature(CPUState *cs, int orig_base_reg) +GDBFeature *arm_gen_dynamic_svereg_feature(CPUState *cs, int base_reg) { ARMCPU *cpu =3D ARM_CPU(cs); GString *s =3D g_string_new(NULL); DynamicGDBFeatureInfo *info =3D &cpu->dyn_svereg_feature; + const char **regs; int reg_width =3D cpu->sve_max_vq * 128; int pred_width =3D cpu->sve_max_vq * 16; - int base_reg =3D orig_base_reg; - int i; + int i =3D 0; + int j; + + info->desc.name =3D "org.gnu.gdb.aarch64.sve"; + info->desc.num_regs =3D 32 + 16 + 4; + regs =3D g_new(const char *, info->desc.num_regs); + info->desc.regs =3D regs; =20 g_string_printf(s, ""); g_string_append_printf(s, "= "); @@ -339,44 +345,52 @@ GDBFeature *arm_gen_dynamic_svereg_feature(CPUState *= cs, int orig_base_reg) pred_width / 8); =20 /* Define the vector registers. */ - for (i =3D 0; i < 32; i++) { + for (j =3D 0; j < 32; j++) { + regs[i] =3D g_strdup_printf("z%d", j); g_string_append_printf(s, - "", - i, reg_width, base_reg++); + regs[i], reg_width, base_reg + i); + i++; } =20 /* fpscr & status registers */ + regs[i] =3D "fpsr"; g_string_append_printf(s, "", base_reg++); + " type=3D\"int\"/>", base_reg + i++); + regs[i] =3D "fpcr"; g_string_append_printf(s, "", base_reg++); + " type=3D\"int\"/>", base_reg + i++); =20 /* Define the predicate registers. */ - for (i =3D 0; i < 16; i++) { + for (j =3D 0; j < 16; j++) { + regs[i] =3D g_strdup_printf("p%d", j); g_string_append_printf(s, - "", - i, pred_width, base_reg++); + regs[i], pred_width, base_reg + i); + i++; } + regs[i] =3D "ffr"; g_string_append_printf(s, "", - pred_width, base_reg++); + pred_width, base_reg + i++); =20 /* Define the vector length pseudo-register. */ + regs[i] =3D "vg"; g_string_append_printf(s, "", - base_reg++); + base_reg + i++); =20 g_string_append_printf(s, ""); =20 info->desc.xmlname =3D "sve-registers.xml"; info->desc.xml =3D g_string_free(s, false); - info->desc.num_regs =3D base_reg - orig_base_reg; + assert(info->desc.num_regs =3D=3D i); return &info->desc; } --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793275; cv=none; d=zohomail.com; s=zohoarc; b=F3t20YFwR7ptt6yd5/ScyWe3GqkqvSTE1QEPhDdfOsQrgV6FO3oJkKT/0uPP0EyLZUQPbPrsi5TPArsxtsze35zZxjWx7R2Yfw8aMT5SXLqQnNOselYgQ8DnJO9cncw7aflI4hUaz94zH3/q9Ml9aEb20K24FW1BS/zrywhx6Ho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793275; 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; bh=ANoP9Fpb4WsMF0Xvgw/Yso2QUviba5iZTbYCAi6ODvM=; b=G43YlXq5/5G+0rn2EXoyJhm+UfRJXsSnxIMVrRW/IKvRMw6ctyTKk/XrqfVmqJJG5gyTkVAbdPzj5Us0qSm3Cog1EUf/no+2YJWCLuFPetu+E7wG31nHaul/Pyg5z2ffNXd26d3oagmrfeIRTyO9QDir7wlZjVS/r2nW8d5mNMU= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793275252646.285447404135; Mon, 31 Jul 2023 01:47:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOYS-0005R9-PQ; Mon, 31 Jul 2023 04:47:06 -0400 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 1qQOYA-0004lE-GZ for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:46:48 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOY5-00057W-73 for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:46:43 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-686f19b6dd2so2660890b3a.2 for ; Mon, 31 Jul 2023 01:46:40 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:46:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793200; x=1691398000; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ANoP9Fpb4WsMF0Xvgw/Yso2QUviba5iZTbYCAi6ODvM=; b=0yconEKzvH6iMivH8TVS1PccUnN5hRxSWAfLCX0uRxT+jSYfIZrLGyRyMTsQ4B85WS iS/9TevFK1qxkLJav5HBR2cEW8s+yWBV0YaGKX6ByHkJKkzkqqg82Xe0iI3W2zrMBtia mwlJNTjQaR2uxyfwehuN4MfKMHqrSyfXNEEs28yqHXWM1s4Ba3hT7gwat66rShm6JyOK djpkupwmEmKVjwONvvs4OCZqB5bVsjJgXDGimRSJNBi2WMe2VIp9KNHrZKL7RErO1SUT zbsxZmX5VJ5/fjirEmGNUelThco4t5IOIfXuVymxwsoGPWoKSTdAh6h6YiUXZrJJ3buF +M1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793200; x=1691398000; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ANoP9Fpb4WsMF0Xvgw/Yso2QUviba5iZTbYCAi6ODvM=; b=Cl5y2LULLQvyGEC5+uxtIsczIjISf8yHGTWD2LSdkA9SmllXv+5ozMSh3nLc4CQXDi mlSBIxFwY9ubQgCWVf9z2Gt9iBG6CAnbjKSk0SvDLo1yPZzkCJstQ0vN0rrHYPjmd/MB fR1ZiTlbPC/mZODTE2i4Kb5CNir6BIJ3imWX9ykYuilRid1Ax/JoYnS5GG93dx5nyH/6 gDfW/mXLCHR580zVcT7qSGKUzg/i3tG8cb+OjebAADK8HIK+9A0PjQMHnedDGaGF+O28 wJhvbtDElItuVSvrAWR57DxylEJU++eJhNiGpUv2j+ogaYO6h7Ms8GC9emewhisIYnMN Bs0Q== X-Gm-Message-State: ABy/qLYGJCUU/pxB7QfMEJTZu4FWQ9kY7w1qXHCiEcj2ybDASV3lrG/V IP5TAKe3JUNRa0Rvf0yqztLPXg== X-Google-Smtp-Source: APBJJlGqgcWI52kGX5FDVyWHcYVegjUSKTSw98VXjn25LmP/9ZYyTct+mU1oS+j1/xeQwY1xDgZMFQ== X-Received: by 2002:a05:6a00:1785:b0:679:bc89:e45 with SMTP id s5-20020a056a00178500b00679bc890e45mr10732242pfg.6.1690793199926; Mon, 31 Jul 2023 01:46:39 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 16/24] target/ppc: Fill new members of GDBFeature Date: Mon, 31 Jul 2023 17:43:43 +0900 Message-ID: <20230731084354.115015-17-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::42f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793277293100003 Content-Type: text/plain; charset="utf-8" These members will be used to help plugins to identify registers. Signed-off-by: Akihiko Odaki --- target/ppc/gdbstub.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index 19c4935260..ac4ed12371 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -323,7 +323,7 @@ void ppc_gdb_gen_spr_feature(PowerPCCPU *cpu) PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); CPUPPCState *env =3D &cpu->env; GString *xml; - char *spr_name; + const char **regs; unsigned int num_regs =3D 0; int i; =20 @@ -350,6 +350,7 @@ void ppc_gdb_gen_spr_feature(PowerPCCPU *cpu) return; } =20 + regs =3D g_new(const char *, num_regs); xml =3D g_string_new(""); g_string_append(xml, ""); g_string_append(xml, ""); @@ -361,9 +362,8 @@ void ppc_gdb_gen_spr_feature(PowerPCCPU *cpu) continue; } =20 - spr_name =3D g_ascii_strdown(spr->name, -1); - g_string_append_printf(xml, "gdb_id] =3D g_ascii_strdown(spr->name, -1); + g_string_append_printf(xml, "gdb_id= ]); =20 g_string_append_printf(xml, " bitsize=3D\"%d\"", TARGET_LONG_BITS); g_string_append(xml, " group=3D\"spr\"/>"); @@ -371,6 +371,8 @@ void ppc_gdb_gen_spr_feature(PowerPCCPU *cpu) =20 g_string_append(xml, ""); =20 + pcc->gdb_spr.name =3D "org.qemu.power.spr"; + pcc->gdb_spr.regs =3D regs; pcc->gdb_spr.num_regs =3D num_regs; pcc->gdb_spr.xmlname =3D "power-spr.xml"; pcc->gdb_spr.xml =3D g_string_free(xml, false); --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793387; cv=none; d=zohomail.com; s=zohoarc; b=SHnRV0aK7eBlOknCTRUsS4cOmDGfGmFJxVpBmBLlO0QplULaJW2UkpQ2hg0FsRWOZsRVIEH3Gu7/OYOVFytGsdn+6ClKq2G4s+ztQvWPmF3OJu2LA1G5vvfn4gm8nXdmL6HpbLuPLdUQYEfe1r/K7nk4hKsMePbzW1n5vRR53Jw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793387; 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; bh=i68gTXndm5g2JBfGSVbcpcLCWh9EafQ06rBdOr/hNg8=; b=EF/QVzhF2yt+a/GSgUCXKtib5lFBwoYEKUs9fKxXPfjTv7ERq/f5X9IyU8Qi4gLFG+Z7lCdKSv109a8yXCt1U3NZUt6x0tNhnwPFmQ+docMX5F+Rkd13XLWh5/6O1IlCUoT+tQuKY41zc3gQ/eZwNJkBQYcE6HXUusLoJhRRF8E= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793387452915.1293947079914; Mon, 31 Jul 2023 01:49:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOYu-0006I6-DJ; Mon, 31 Jul 2023 04:47:32 -0400 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 1qQOYH-0004tq-Q7 for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:46:56 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOYE-000591-E9 for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:46:53 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-53fbf2c42bfso3175913a12.3 for ; Mon, 31 Jul 2023 01:46:49 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.46.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:46:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793209; x=1691398009; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i68gTXndm5g2JBfGSVbcpcLCWh9EafQ06rBdOr/hNg8=; b=nC6x/hrDw7RM2hyF01kPWOTN+B1vxbMARwlG2R+cm3uzFEtTGTvvv0hAHUbOiWJSm1 +oZD6x/27ed4ARu5S8X8QI6AXv590W8WESkEvqBL+kNvnQFwNBc2v6geEX4g89mtkatO aaT/WoMCebIPOX05W7SrSC2Y0YD+Xw8sBSjHpHLp90kU9kQijGZFI7zp67qHR+CP093V 8lfb7qbBkqRvL1/gLBZSv5PjkhCH8PO4SyULmD7E+8SvDp9CgFCcZyhfmC8Kl+7+fRnQ 8cwgClpr3Cqdfn0sJZEndReB0DNsCIOPZwA9VRaa9X7UET6eGJ8jG3/tqiW+I0eRG5ZV mIug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793209; x=1691398009; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i68gTXndm5g2JBfGSVbcpcLCWh9EafQ06rBdOr/hNg8=; b=JeGYvznYUOAd9u0iJwYqzckRjg5i/YPedUr8Ef/ae9GSR/38qdbu1r8DkyHwkq8q5S FFb7TxQ24UDYqzpy1dNM3SWuODmOuA005sHeaDDvUhzFYQdCWDQSWqqka2wUfC5Hp3OD mKf4KxOVRm25f4tte0sxhv5BBtAPtbTOe9Qz3frYk9BuJ2Qaz+fYvvUfbrjjx1Evt6ah D9y3XKXBU4Op8FFG7u/w7ujjtU4uVrm9PsK9rRkOryzr2ZEKG+HVRb4V+oDi4lXN5cO8 J+8EX778c7Cb1qrVt3f5Vw1nNew5nYml7Siah1B1VcLLDTjMQVaj3gKs2K1nJ4FJAr1i gFNg== X-Gm-Message-State: ABy/qLYgJqLHAGckfDKqu/g9GPOM3DecNJL183qQP8QZ8ksv8LYGU0MN Hhx/c5t9BvzEGSTlk9EForTE8Q== X-Google-Smtp-Source: APBJJlGZcLds9//79Mo+76iCBHc3jp3+Z0ypqGuVU/Ww43E+kmyH9WV6RDVLVGfmft7WqgMHYa9iyg== X-Received: by 2002:a05:6a20:5510:b0:11d:8a8f:655d with SMTP id ko16-20020a056a20551000b0011d8a8f655dmr9020629pzb.4.1690793208923; Mon, 31 Jul 2023 01:46:48 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 17/24] target/riscv: Fill new members of GDBFeature Date: Mon, 31 Jul 2023 17:43:44 +0900 Message-ID: <20230731084354.115015-18-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::52b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x52b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793387967100001 Content-Type: text/plain; charset="utf-8" These members will be used to help plugins to identify registers. Signed-off-by: Akihiko Odaki --- target/riscv/gdbstub.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 224c69ea99..b3d4d4de3e 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -217,6 +217,7 @@ static GDBFeature *riscv_gen_dynamic_csr_feature(CPUSta= te *cs, int base_reg) RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; GString *s =3D g_string_new(NULL); + const char **regs =3D g_new(const char *, CSR_TABLE_SIZE); riscv_csr_predicate_fn predicate; int bitsize =3D 16 << env->misa_mxl_max; int i; @@ -240,11 +241,10 @@ static GDBFeature *riscv_gen_dynamic_csr_feature(CPUS= tate *cs, int base_reg) } predicate =3D csr_ops[i].predicate; if (predicate && (predicate(env, i) =3D=3D RISCV_EXCP_NONE)) { - if (csr_ops[i].name) { - g_string_append_printf(s, "", base_reg + i); } @@ -252,6 +252,8 @@ static GDBFeature *riscv_gen_dynamic_csr_feature(CPUSta= te *cs, int base_reg) =20 g_string_append_printf(s, ""); =20 + cpu->dyn_csr_feature.name =3D "org.gnu.gdb.riscv.csr"; + cpu->dyn_csr_feature.regs =3D regs; cpu->dyn_csr_feature.num_regs =3D CSR_TABLE_SIZE; cpu->dyn_csr_feature.xmlname =3D "riscv-csr.xml"; cpu->dyn_csr_feature.xml =3D g_string_free(s, false); @@ -268,10 +270,12 @@ static GDBFeature *ricsv_gen_dynamic_vector_feature(C= PUState *cs, int base_reg) RISCVCPU *cpu =3D RISCV_CPU(cs); GString *s =3D g_string_new(NULL); g_autoptr(GString) ts =3D g_string_new(""); + const char **regs; int reg_width =3D cpu->cfg.vlen; int i; =20 cpu->dyn_vreg_feature.num_regs =3D 32; + regs =3D g_new(const char *, cpu->dyn_vreg_feature.num_regs); =20 g_string_printf(s, ""); g_string_append_printf(s, "= "); @@ -297,15 +301,18 @@ static GDBFeature *ricsv_gen_dynamic_vector_feature(C= PUState *cs, int base_reg) =20 /* Define vector registers */ for (i =3D 0; i < cpu->dyn_vreg_feature.num_regs; i++) { + regs[i] =3D g_strdup_printf("v%d", i); g_string_append_printf(s, - "", - i, reg_width, base_reg++); + regs[i], reg_width, base_reg++); } =20 g_string_append_printf(s, ""); =20 + cpu->dyn_vreg_feature.name =3D "org.gnu.gdb.riscv.vector"; + cpu->dyn_vreg_feature.regs =3D regs; cpu->dyn_vreg_feature.xmlname =3D "riscv-vector.xml"; cpu->dyn_vreg_feature.xml =3D g_string_free(s, false); return &cpu->dyn_vreg_feature; --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793333; cv=none; d=zohomail.com; s=zohoarc; b=bcuCjqbfxGMGV59oAyd0dJYsmKN/9v9UcmcVj988OMczVSisRCuDLfDy+NMMUZGyeFMdODgejVrAyXgPBTkrKEkkaqPuH/Wl0uFQLoYGlYZw1FLTxnc9otgYVWz7/3XLFp680IlEZC+xG6Xa/quCkd1WRfYws9KQ18YRKJugW4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793333; 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; bh=59ObXK0ZJjenKJeYl20I0RL/nn9H9tkN+ApmQ7QUtVA=; b=nM6iN/bmiBDzIJvGY5B2bHIkYrcWO3I+kH+LzVLo0efoyiFt+uQITdwF+6qQ51MibeEUSVGHVr0da5jG5UodYt+nRV59sMxEtQuv0fUG4cnK7gXhspvliNDCAQJLql6YecDyQ7NZS4GDOJ2hALE9f+rJ2Fgp7yr39a/Pfzwefc4= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793333182887.7185037023922; Mon, 31 Jul 2023 01:48:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOYw-0006gX-Ud; Mon, 31 Jul 2023 04:47:35 -0400 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 1qQOYW-0005ee-3L for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:47:09 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOYO-0005Af-3B for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:47:07 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-686ba29ccb1so2602687b3a.1 for ; Mon, 31 Jul 2023 01:46:59 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793219; x=1691398019; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=59ObXK0ZJjenKJeYl20I0RL/nn9H9tkN+ApmQ7QUtVA=; b=Nf5XnFy3CttnxRz1KJMScqJcedRxD4Ee3rmOdiirCNyU6lenBoY1rshGdF/jM/7Hqn TKnX+bA6BZ9PDAwmb6isgwPiLFxTEPcgEWqbQ2VJxwIfej7y0J96nEqHrEA/lVN+r3Dq Qxsj0uOHU0pFQfvXY3emxpnVDA5TX0uI6rKqcWaHODWl56+0BR49yzeyIWjAmWV2Ux2N R8nPNu5mPnuon3smLBg/GrAdlA+3siIuJMWXzunS5QzEDBULK0ShYQIf3c7EgdSfkpbh wCKMDcRhuwg8T73SXSMr+a5ZEICYaTLoLrN/n/EtaYqxOpGYnyrIO9jkaIf6UkmhF0Hn 5iwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793219; x=1691398019; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=59ObXK0ZJjenKJeYl20I0RL/nn9H9tkN+ApmQ7QUtVA=; b=dVH5VGFdaNYeSYlUGC0Hwpkwyl4Yg1l9XjhAmJlVInqBhIgpYEt/IZj8JZmsDT4Eyp KViF2EY8WzQ5tfvjzAvW5mMoAU4CZH5Jw4tOiREWZfs4lPHk5BrOMl3EHJ+huBVp3Ezk 6tTsiBtxljzuCoyQYdxYqwnVgviQ7D6l5mJVhnZ5kT5DXSkrMIhdgwnvuWrejm0YqHY0 tvBLOx3fLkAvnvZhV+dXSSBF8rXULZ1rMkuzVPdPMQKELxu3n3t/9QNmrox27WQr6ylV 1+Jn8G9oA1VR8yBVbVpygj0aZgFT62q8Wa9DM/i9jc0N9DV4DY2op11xfNUh2AHmqacz qbOQ== X-Gm-Message-State: ABy/qLaNvOzD+XDb1jPoZP2EZi4fHSp9D+dfQdANkEIS/4mQHERabwrZ r5rRgRvnGOX2zCiWh2RllD39sw== X-Google-Smtp-Source: APBJJlFnoHhOS0xKKUmtHdJR9DtQVNt6TmCVl7RvGid7z3txj9dA5j44QiyPtfpKOo//jCxOXSOp+w== X-Received: by 2002:a05:6a00:301b:b0:686:b732:8792 with SMTP id ay27-20020a056a00301b00b00686b7328792mr10077718pfb.8.1690793218345; Mon, 31 Jul 2023 01:46:58 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 18/24] hw/core/cpu: Add a parameter to gdb_read_register/gdb_write_register Date: Mon, 31 Jul 2023 17:43:45 +0900 Message-ID: <20230731084354.115015-19-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::42f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793334463100003 Content-Type: text/plain; charset="utf-8" gdbstub has a static variable named gdb_has_xml that tells if workarounds for old GDB versions are required when manipulating registers for GDB. Now we are reusing the infrastructure to manipulate registers for plugins. Plugins will not need these workarounds even when an old GDB is attached. Converting the static variable to a function parameter would allow to apply or not to apply workarounds depending on the context. This change adds the new parameter and replaces references to gdb_has_xml with it. New code to pass different values to the functions will be added later. Signed-off-by: Akihiko Odaki --- include/hw/core/cpu.h | 6 ++++-- target/alpha/cpu.h | 6 ++++-- target/arm/cpu.h | 13 +++++++++---- target/avr/cpu.h | 6 ++++-- target/cris/cpu.h | 9 ++++++--- target/hexagon/internal.h | 6 ++++-- target/hppa/cpu.h | 6 ++++-- target/i386/cpu.h | 6 ++++-- target/loongarch/internals.h | 6 ++++-- target/m68k/cpu.h | 6 ++++-- target/microblaze/cpu.h | 6 ++++-- target/mips/internal.h | 6 ++++-- target/openrisc/cpu.h | 6 ++++-- target/ppc/cpu.h | 12 ++++++++---- target/riscv/cpu.h | 6 ++++-- target/rx/cpu.h | 6 ++++-- target/s390x/s390x-internal.h | 6 ++++-- target/sh4/cpu.h | 6 ++++-- target/sparc/cpu.h | 6 ++++-- target/tricore/cpu.h | 6 ++++-- target/xtensa/cpu.h | 6 ++++-- gdbstub/gdbstub.c | 4 ++-- hw/core/cpu-common.c | 6 ++++-- target/alpha/gdbstub.c | 6 ++++-- target/arm/gdbstub.c | 14 ++++++++------ target/arm/gdbstub64.c | 6 ++++-- target/avr/gdbstub.c | 6 ++++-- target/cris/gdbstub.c | 9 ++++++--- target/hexagon/gdbstub.c | 6 ++++-- target/hppa/gdbstub.c | 6 ++++-- target/i386/gdbstub.c | 10 +++++----- target/loongarch/gdbstub.c | 6 ++++-- target/m68k/gdbstub.c | 6 ++++-- target/microblaze/gdbstub.c | 6 ++++-- target/mips/gdbstub.c | 6 ++++-- target/nios2/cpu.c | 6 ++++-- target/openrisc/gdbstub.c | 6 ++++-- target/ppc/gdbstub.c | 22 +++++++++++++--------- target/riscv/gdbstub.c | 6 ++++-- target/rx/gdbstub.c | 6 ++++-- target/s390x/gdbstub.c | 6 ++++-- target/sh4/gdbstub.c | 6 ++++-- target/sparc/gdbstub.c | 6 ++++-- target/tricore/gdbstub.c | 6 ++++-- target/xtensa/gdbstub.c | 6 ++++-- 45 files changed, 205 insertions(+), 110 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 9323d26f84..9428e57e7c 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -157,8 +157,10 @@ struct CPUClass { int64_t (*get_arch_id)(CPUState *cpu); void (*set_pc)(CPUState *cpu, vaddr value); vaddr (*get_pc)(CPUState *cpu); - int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg); - int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg); + int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); + int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); vaddr (*gdb_adjust_breakpoint)(CPUState *cpu, vaddr addr); =20 const GDBFeature *gdb_core_feature; diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h index 13306665af..46bd9bc37b 100644 --- a/target/alpha/cpu.h +++ b/target/alpha/cpu.h @@ -279,8 +279,10 @@ bool alpha_cpu_exec_interrupt(CPUState *cpu, int int_r= eq); hwaddr alpha_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); #endif /* !CONFIG_USER_ONLY */ void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags); -int alpha_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int alpha_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int alpha_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int alpha_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); =20 #define cpu_list alpha_cpu_list =20 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 09bf82034d..3dfa29c3aa 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1128,8 +1128,11 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *c= pu, vaddr addr, MemTxAttrs *attrs); #endif /* !CONFIG_USER_ONLY */ =20 -int arm_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int arm_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); + +int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); =20 int arm_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, DumpState *s); @@ -1137,8 +1140,10 @@ int arm_cpu_write_elf32_note(WriteCoreDumpFunction f= , CPUState *cs, int cpuid, DumpState *s); =20 #ifdef TARGET_AARCH64 -int aarch64_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int aarch64_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq); void aarch64_sve_change_el(CPUARMState *env, int old_el, int new_el, bool el0_a64); diff --git a/target/avr/cpu.h b/target/avr/cpu.h index 7225174668..006e79e018 100644 --- a/target/avr/cpu.h +++ b/target/avr/cpu.h @@ -157,8 +157,10 @@ extern const struct VMStateDescription vms_avr_cpu; void avr_cpu_do_interrupt(CPUState *cpu); bool avr_cpu_exec_interrupt(CPUState *cpu, int int_req); hwaddr avr_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int avr_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int avr_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int avr_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int avr_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); int avr_print_insn(bfd_vma addr, disassemble_info *info); vaddr avr_cpu_gdb_adjust_breakpoint(CPUState *cpu, vaddr addr); =20 diff --git a/target/cris/cpu.h b/target/cris/cpu.h index 8e37c6e50d..d3a62c5480 100644 --- a/target/cris/cpu.h +++ b/target/cris/cpu.h @@ -198,9 +198,12 @@ hwaddr cris_cpu_get_phys_page_debug(CPUState *cpu, vad= dr addr); =20 void cris_cpu_dump_state(CPUState *cs, FILE *f, int flags); =20 -int crisv10_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int cris_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int cris_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int crisv10_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int cris_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int cris_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); =20 void cris_initialize_tcg(void); void cris_initialize_crisv10_tcg(void); diff --git a/target/hexagon/internal.h b/target/hexagon/internal.h index d732b6bb3c..cdd4bb7d26 100644 --- a/target/hexagon/internal.h +++ b/target/hexagon/internal.h @@ -31,8 +31,10 @@ } \ } while (0) =20 -int hexagon_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int hexagon_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int hexagon_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int hexagon_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); int hexagon_hvx_gdb_read_register(CPUHexagonState *env, GByteArray *mem_bu= f, int n); int hexagon_hvx_gdb_write_register(CPUHexagonState *env, uint8_t *mem_buf,= int n); =20 diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 9fe79b1242..a983540dd2 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -321,8 +321,10 @@ static inline void cpu_hppa_change_prot_id(CPUHPPAStat= e *env) { } void cpu_hppa_change_prot_id(CPUHPPAState *env); #endif =20 -int hppa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int hppa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int hppa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int hppa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); void hppa_cpu_dump_state(CPUState *cs, FILE *f, int); #ifndef CONFIG_USER_ONLY hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr); diff --git a/target/i386/cpu.h b/target/i386/cpu.h index e0771a1043..d177f500b8 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2057,8 +2057,10 @@ void x86_cpu_get_memory_mapping(CPUState *cpu, Memor= yMappingList *list, =20 void x86_cpu_dump_state(CPUState *cs, FILE *f, int flags); =20 -int x86_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int x86_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int x86_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int x86_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); =20 void x86_cpu_list(void); int cpu_x86_support_mca_broadcast(CPUX86State *env); diff --git a/target/loongarch/internals.h b/target/loongarch/internals.h index 7b0f29c942..a2ff8b3e3d 100644 --- a/target/loongarch/internals.h +++ b/target/loongarch/internals.h @@ -77,8 +77,10 @@ hwaddr loongarch_cpu_get_phys_page_debug(CPUState *cpu, = vaddr addr); uint64_t read_fcc(CPULoongArchState *env); void write_fcc(CPULoongArchState *env, uint64_t val); =20 -int loongarch_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int= n); -int loongarch_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n= ); +int loongarch_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int= n, + bool has_xml); +int loongarch_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml); void loongarch_cpu_register_gdb_regs_for_features(CPUState *cs); =20 #endif diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index cf70282717..b59d076c0c 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -179,8 +179,10 @@ bool m68k_cpu_exec_interrupt(CPUState *cpu, int int_re= q); hwaddr m68k_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); #endif /* !CONFIG_USER_ONLY */ void m68k_cpu_dump_state(CPUState *cpu, FILE *f, int flags); -int m68k_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int m68k_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); =20 void m68k_tcg_init(void); void m68k_cpu_init_gdb(M68kCPU *cpu); diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h index f6cab6ce19..8840bf17f3 100644 --- a/target/microblaze/cpu.h +++ b/target/microblaze/cpu.h @@ -368,8 +368,10 @@ G_NORETURN void mb_cpu_do_unaligned_access(CPUState *c= s, vaddr vaddr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr); void mb_cpu_dump_state(CPUState *cpu, FILE *f, int flags); -int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); int mb_cpu_gdb_read_stack_protect(CPUArchState *cpu, GByteArray *buf, int = reg); int mb_cpu_gdb_write_stack_protect(CPUArchState *cpu, uint8_t *buf, int re= g); =20 diff --git a/target/mips/internal.h b/target/mips/internal.h index 1d0c026c7d..b5462f53a9 100644 --- a/target/mips/internal.h +++ b/target/mips/internal.h @@ -92,8 +92,10 @@ extern const char fregnames[32][4]; extern const struct mips_def_t mips_defs[]; extern const int mips_defs_number; =20 -int mips_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int mips_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int mips_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int mips_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); =20 #define USEG_LIMIT ((target_ulong)(int32_t)0x7FFFFFFFUL) #define KSEG0_BASE ((target_ulong)(int32_t)0x80000000UL) diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index ce4d605eb7..8c2089db92 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -312,8 +312,10 @@ struct ArchCPU { =20 void cpu_openrisc_list(void); void openrisc_cpu_dump_state(CPUState *cpu, FILE *f, int flags); -int openrisc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg= ); -int openrisc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int openrisc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int openrisc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); void openrisc_translate_init(void); int print_insn_or1k(bfd_vma addr, disassemble_info *info); =20 diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 3dc6e545e3..0849ee6e1f 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1375,10 +1375,14 @@ static inline bool vhyp_cpu_in_nested(PowerPCCPU *c= pu) #endif /* CONFIG_USER_ONLY */ =20 void ppc_cpu_dump_state(CPUState *cpu, FILE *f, int flags); -int ppc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int ppc_cpu_gdb_read_register_apple(CPUState *cpu, GByteArray *buf, int re= g); -int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); -int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg); +int ppc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int ppc_cpu_gdb_read_register_apple(CPUState *cpu, GByteArray *buf, int re= g, + bool has_xml); +int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); +int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); #ifndef CONFIG_USER_ONLY hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); void ppc_gdb_gen_spr_feature(PowerPCCPU *cpu); diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index f67751d5b7..46b06b1962 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -421,8 +421,10 @@ int riscv_cpu_write_elf64_note(WriteCoreDumpFunction f= , CPUState *cs, int cpuid, DumpState *s); int riscv_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, DumpState *s); -int riscv_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int riscv_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int riscv_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int riscv_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); int riscv_cpu_hviprio_index2irq(int index, int *out_irq, int *out_rdzero); uint8_t riscv_cpu_default_priority(int irq); uint64_t riscv_cpu_all_pending(CPURISCVState *env); diff --git a/target/rx/cpu.h b/target/rx/cpu.h index 7f03ffcfed..d1a099cf72 100644 --- a/target/rx/cpu.h +++ b/target/rx/cpu.h @@ -126,8 +126,10 @@ bool rx_cpu_exec_interrupt(CPUState *cpu, int int_req); hwaddr rx_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); #endif /* !CONFIG_USER_ONLY */ void rx_cpu_dump_state(CPUState *cpu, FILE *f, int flags); -int rx_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int rx_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int rx_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int rx_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); =20 void rx_translate_init(void); void rx_cpu_list(void); diff --git a/target/s390x/s390x-internal.h b/target/s390x/s390x-internal.h index 825252d728..4c2bb30358 100644 --- a/target/s390x/s390x-internal.h +++ b/target/s390x/s390x-internal.h @@ -316,8 +316,10 @@ uint16_t float128_dcmask(CPUS390XState *env, float128 = f1); =20 =20 /* gdbstub.c */ -int s390_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int s390_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int s390_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int s390_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); void s390_cpu_gdb_init(CPUState *cs); =20 =20 diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index 1399d3840f..74c8f0f574 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -214,8 +214,10 @@ struct ArchCPU { =20 =20 void superh_cpu_dump_state(CPUState *cpu, FILE *f, int flags); -int superh_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int superh_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int superh_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int superh_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); G_NORETURN void superh_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, = int mmu_idx, uintptr_t retaddr); diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index 98044572f2..b03174938c 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -573,8 +573,10 @@ hwaddr sparc_cpu_get_phys_page_debug(CPUState *cpu, va= ddr addr); #endif =20 void sparc_cpu_do_interrupt(CPUState *cpu); -int sparc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int sparc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int sparc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int sparc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); G_NORETURN void sparc_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, int mmu_idx, diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h index 3708405be8..7da6c88a15 100644 --- a/target/tricore/cpu.h +++ b/target/tricore/cpu.h @@ -361,8 +361,10 @@ enum { =20 uint32_t psw_read(CPUTriCoreState *env); void psw_write(CPUTriCoreState *env, uint32_t val); -int tricore_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n= ); -int tricore_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n); +int tricore_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml); +int tricore_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml); =20 void fpu_set_state(CPUTriCoreState *env); =20 diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 87fe992ba6..093593eb0c 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -581,8 +581,10 @@ hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, v= addr addr); void xtensa_cpu_dump_state(CPUState *cpu, FILE *f, int flags); void xtensa_count_regs(const XtensaConfig *config, unsigned *n_regs, unsigned *n_core_regs); -int xtensa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); -int xtensa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); +int xtensa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, + bool has_xml); +int xtensa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg, + bool has_xml); G_NORETURN void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, = int mmu_idx, uintptr_t retaddr); diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index e5bb2c89ba..caef6aabab 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -423,7 +423,7 @@ static int gdb_read_register(CPUState *cpu, GByteArray = *buf, int reg) GDBRegisterState *r; =20 if (reg < cc->gdb_num_core_regs) { - return cc->gdb_read_register(cpu, buf, reg); + return cc->gdb_read_register(cpu, buf, reg, gdb_has_xml); } =20 for (r =3D cpu->gdb_regs; r; r =3D r->next) { @@ -441,7 +441,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *m= em_buf, int reg) GDBRegisterState *r; =20 if (reg < cc->gdb_num_core_regs) { - return cc->gdb_write_register(cpu, mem_buf, reg); + return cc->gdb_write_register(cpu, mem_buf, reg, gdb_has_xml); } =20 for (r =3D cpu->gdb_regs; r; r =3D r->next) { diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index ced66c2b34..549f52f46f 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -89,12 +89,14 @@ void cpu_exit(CPUState *cpu) qatomic_set(&cpu->icount_decr_ptr->u16.high, -1); } =20 -static int cpu_common_gdb_read_register(CPUState *cpu, GByteArray *buf, in= t reg) +static int cpu_common_gdb_read_register(CPUState *cpu, GByteArray *buf, in= t reg, + bool has_xml) { return 0; } =20 -static int cpu_common_gdb_write_register(CPUState *cpu, uint8_t *buf, int = reg) +static int cpu_common_gdb_write_register(CPUState *cpu, uint8_t *buf, int = reg, + bool has_xml) { return 0; } diff --git a/target/alpha/gdbstub.c b/target/alpha/gdbstub.c index 0f8fa150f8..c5b4a190f3 100644 --- a/target/alpha/gdbstub.c +++ b/target/alpha/gdbstub.c @@ -21,7 +21,8 @@ #include "cpu.h" #include "gdbstub/helpers.h" =20 -int alpha_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int alpha_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { AlphaCPU *cpu =3D ALPHA_CPU(cs); CPUAlphaState *env =3D &cpu->env; @@ -57,7 +58,8 @@ int alpha_cpu_gdb_read_register(CPUState *cs, GByteArray = *mem_buf, int n) return gdb_get_regl(mem_buf, val); } =20 -int alpha_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int alpha_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { AlphaCPU *cpu =3D ALPHA_CPU(cs); CPUAlphaState *env =3D &cpu->env; diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 56d24028f6..f941186b58 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -37,7 +37,8 @@ typedef struct RegisterSysregFeatureParam { We hack round this by giving the FPA regs zero size when talking to a newer gdb. */ =20 -int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; @@ -48,7 +49,7 @@ int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *m= em_buf, int n) } if (n < 24) { /* FPA registers. */ - if (gdb_has_xml) { + if (has_xml) { return 0; } return gdb_get_zeroes(mem_buf, 12); @@ -56,7 +57,7 @@ int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *m= em_buf, int n) switch (n) { case 24: /* FPA status register. */ - if (gdb_has_xml) { + if (has_xml) { return 0; } return gdb_get_reg32(mem_buf, 0); @@ -72,7 +73,8 @@ int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *m= em_buf, int n) return 0; } =20 -int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; @@ -102,7 +104,7 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *m= em_buf, int n) } if (n < 24) { /* 16-23 */ /* FPA registers (ignored). */ - if (gdb_has_xml) { + if (has_xml) { return 0; } return 12; @@ -110,7 +112,7 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *m= em_buf, int n) switch (n) { case 24: /* FPA status register (ignored). */ - if (gdb_has_xml) { + if (has_xml) { return 0; } return 4; diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index c5ed7c0aa3..aff3836037 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -22,7 +22,8 @@ #include "internals.h" #include "gdbstub/helpers.h" =20 -int aarch64_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int aarch64_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; @@ -43,7 +44,8 @@ int aarch64_cpu_gdb_read_register(CPUState *cs, GByteArra= y *mem_buf, int n) return 0; } =20 -int aarch64_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int aarch64_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; diff --git a/target/avr/gdbstub.c b/target/avr/gdbstub.c index 150344d8b9..c40f4ecd4b 100644 --- a/target/avr/gdbstub.c +++ b/target/avr/gdbstub.c @@ -21,7 +21,8 @@ #include "qemu/osdep.h" #include "gdbstub/helpers.h" =20 -int avr_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int avr_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { AVRCPU *cpu =3D AVR_CPU(cs); CPUAVRState *env =3D &cpu->env; @@ -51,7 +52,8 @@ int avr_cpu_gdb_read_register(CPUState *cs, GByteArray *m= em_buf, int n) return 0; } =20 -int avr_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int avr_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { AVRCPU *cpu =3D AVR_CPU(cs); CPUAVRState *env =3D &cpu->env; diff --git a/target/cris/gdbstub.c b/target/cris/gdbstub.c index 25c0ca33a5..2b5c0d5f14 100644 --- a/target/cris/gdbstub.c +++ b/target/cris/gdbstub.c @@ -21,7 +21,8 @@ #include "cpu.h" #include "gdbstub/helpers.h" =20 -int crisv10_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int crisv10_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { CRISCPU *cpu =3D CRIS_CPU(cs); CPUCRISState *env =3D &cpu->env; @@ -53,7 +54,8 @@ int crisv10_cpu_gdb_read_register(CPUState *cs, GByteArra= y *mem_buf, int n) return 0; } =20 -int cris_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int cris_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { CRISCPU *cpu =3D CRIS_CPU(cs); CPUCRISState *env =3D &cpu->env; @@ -88,7 +90,8 @@ int cris_cpu_gdb_read_register(CPUState *cs, GByteArray *= mem_buf, int n) return 0; } =20 -int cris_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int cris_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { CRISCPU *cpu =3D CRIS_CPU(cs); CPUCRISState *env =3D &cpu->env; diff --git a/target/hexagon/gdbstub.c b/target/hexagon/gdbstub.c index 54d37e006e..42fa563fc4 100644 --- a/target/hexagon/gdbstub.c +++ b/target/hexagon/gdbstub.c @@ -20,7 +20,8 @@ #include "cpu.h" #include "internal.h" =20 -int hexagon_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int hexagon_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { HexagonCPU *cpu =3D HEXAGON_CPU(cs); CPUHexagonState *env =3D &cpu->env; @@ -40,7 +41,8 @@ int hexagon_gdb_read_register(CPUState *cs, GByteArray *m= em_buf, int n) g_assert_not_reached(); } =20 -int hexagon_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int hexagon_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { HexagonCPU *cpu =3D HEXAGON_CPU(cs); CPUHexagonState *env =3D &cpu->env; diff --git a/target/hppa/gdbstub.c b/target/hppa/gdbstub.c index 48a514384f..44a1869d54 100644 --- a/target/hppa/gdbstub.c +++ b/target/hppa/gdbstub.c @@ -21,7 +21,8 @@ #include "cpu.h" #include "gdbstub/helpers.h" =20 -int hppa_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int hppa_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { HPPACPU *cpu =3D HPPA_CPU(cs); CPUHPPAState *env =3D &cpu->env; @@ -146,7 +147,8 @@ int hppa_cpu_gdb_read_register(CPUState *cs, GByteArray= *mem_buf, int n) } } =20 -int hppa_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int hppa_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { HPPACPU *cpu =3D HPPA_CPU(cs); CPUHPPAState *env =3D &cpu->env; diff --git a/target/i386/gdbstub.c b/target/i386/gdbstub.c index ebb000df6a..56c9aedd6b 100644 --- a/target/i386/gdbstub.c +++ b/target/i386/gdbstub.c @@ -32,9 +32,7 @@ static const int gpr_map[16] =3D { static const int gpr_map32[8] =3D { 0, 1, 2, 3, 4, 5, 6, 7 }; =20 /* - * Keep these in sync with assignment to - * gdb_num_core_regs in target/i386/cpu.c - * and with the machine description + * Keep these in sync with the machine description */ =20 /* @@ -96,7 +94,8 @@ static int gdb_write_reg_cs64(uint32_t hflags, uint8_t *b= uf, target_ulong *val) return 4; } =20 -int x86_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int x86_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; @@ -248,7 +247,8 @@ static int x86_cpu_gdb_load_seg(X86CPU *cpu, X86Seg sre= g, uint8_t *mem_buf) return 4; } =20 -int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c index 2886b106bb..6b14f73084 100644 --- a/target/loongarch/gdbstub.c +++ b/target/loongarch/gdbstub.c @@ -30,7 +30,8 @@ void write_fcc(CPULoongArchState *env, uint64_t val) } } =20 -int loongarch_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int= n) +int loongarch_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int= n, + bool has_xml) { LoongArchCPU *cpu =3D LOONGARCH_CPU(cs); CPULoongArchState *env =3D &cpu->env; @@ -48,7 +49,8 @@ int loongarch_cpu_gdb_read_register(CPUState *cs, GByteAr= ray *mem_buf, int n) return 0; } =20 -int loongarch_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int loongarch_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { LoongArchCPU *cpu =3D LOONGARCH_CPU(cs); CPULoongArchState *env =3D &cpu->env; diff --git a/target/m68k/gdbstub.c b/target/m68k/gdbstub.c index 1e5f033a12..24e636cddc 100644 --- a/target/m68k/gdbstub.c +++ b/target/m68k/gdbstub.c @@ -21,7 +21,8 @@ #include "cpu.h" #include "gdbstub/helpers.h" =20 -int m68k_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int m68k_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { M68kCPU *cpu =3D M68K_CPU(cs); CPUM68KState *env =3D &cpu->env; @@ -48,7 +49,8 @@ int m68k_cpu_gdb_read_register(CPUState *cs, GByteArray *= mem_buf, int n) return 0; } =20 -int m68k_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int m68k_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { M68kCPU *cpu =3D M68K_CPU(cs); CPUM68KState *env =3D &cpu->env; diff --git a/target/microblaze/gdbstub.c b/target/microblaze/gdbstub.c index 29ac6e9c0f..71962b98de 100644 --- a/target/microblaze/gdbstub.c +++ b/target/microblaze/gdbstub.c @@ -46,7 +46,8 @@ enum { GDB_SP_SHR, }; =20 -int mb_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int mb_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { MicroBlazeCPU *cpu =3D MICROBLAZE_CPU(cs); CPUClass *cc =3D CPU_GET_CLASS(cs); @@ -111,7 +112,8 @@ int mb_cpu_gdb_read_stack_protect(CPUMBState *env, GByt= eArray *mem_buf, int n) return gdb_get_reg32(mem_buf, val); } =20 -int mb_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int mb_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { MicroBlazeCPU *cpu =3D MICROBLAZE_CPU(cs); CPUClass *cc =3D CPU_GET_CLASS(cs); diff --git a/target/mips/gdbstub.c b/target/mips/gdbstub.c index 62d7b72407..9022fc5375 100644 --- a/target/mips/gdbstub.c +++ b/target/mips/gdbstub.c @@ -23,7 +23,8 @@ #include "gdbstub/helpers.h" #include "fpu_helper.h" =20 -int mips_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int mips_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { MIPSCPU *cpu =3D MIPS_CPU(cs); CPUMIPSState *env =3D &cpu->env; @@ -76,7 +77,8 @@ int mips_cpu_gdb_read_register(CPUState *cs, GByteArray *= mem_buf, int n) return 0; } =20 -int mips_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int mips_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { MIPSCPU *cpu =3D MIPS_CPU(cs); CPUMIPSState *env =3D &cpu->env; diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index bc5cbf81c2..5015866b4d 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -280,7 +280,8 @@ static void nios2_cpu_disas_set_info(CPUState *cpu, dis= assemble_info *info) info->print_insn =3D print_insn_nios2; } =20 -static int nios2_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, = int n) +static int nios2_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, = int n, + bool has_xml) { Nios2CPU *cpu =3D NIOS2_CPU(cs); CPUNios2State *env =3D &cpu->env; @@ -305,7 +306,8 @@ static int nios2_cpu_gdb_read_register(CPUState *cs, GB= yteArray *mem_buf, int n) return gdb_get_reg32(mem_buf, val); } =20 -static int nios2_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, in= t n) +static int nios2_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, in= t n, + bool has_xml) { Nios2CPU *cpu =3D NIOS2_CPU(cs); CPUClass *cc =3D CPU_GET_CLASS(cs); diff --git a/target/openrisc/gdbstub.c b/target/openrisc/gdbstub.c index d1074a0581..5ac841e52a 100644 --- a/target/openrisc/gdbstub.c +++ b/target/openrisc/gdbstub.c @@ -21,7 +21,8 @@ #include "cpu.h" #include "gdbstub/helpers.h" =20 -int openrisc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int = n) +int openrisc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int = n, + bool has_xml) { OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); CPUOpenRISCState *env =3D &cpu->env; @@ -46,7 +47,8 @@ int openrisc_cpu_gdb_read_register(CPUState *cs, GByteArr= ay *mem_buf, int n) return 0; } =20 -int openrisc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int openrisc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); CPUClass *cc =3D CPU_GET_CLASS(cs); diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index ac4ed12371..fba4b9a2fa 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -48,7 +48,7 @@ static int ppc_gdb_register_len_apple(int n) } } =20 -static int ppc_gdb_register_len(int n) +static int ppc_gdb_register_len(int n, bool has_xml) { switch (n) { case 0 ... 31: @@ -56,7 +56,7 @@ static int ppc_gdb_register_len(int n) return sizeof(target_ulong); case 32 ... 63: /* fprs */ - if (gdb_has_xml) { + if (has_xml) { return 0; } return 8; @@ -76,7 +76,7 @@ static int ppc_gdb_register_len(int n) return sizeof(target_ulong); case 70: /* fpscr */ - if (gdb_has_xml) { + if (has_xml) { return 0; } return sizeof(target_ulong); @@ -118,12 +118,13 @@ void ppc_maybe_bswap_register(CPUPPCState *env, uint8= _t *mem_buf, int len) * the FP regs zero size when talking to a newer gdb. */ =20 -int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray *buf, int n) +int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray *buf, int n, + bool has_xml) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *env =3D &cpu->env; uint8_t *mem_buf; - int r =3D ppc_gdb_register_len(n); + int r =3D ppc_gdb_register_len(n, has_xml); =20 if (!r) { return r; @@ -168,7 +169,8 @@ int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray = *buf, int n) return r; } =20 -int ppc_cpu_gdb_read_register_apple(CPUState *cs, GByteArray *buf, int n) +int ppc_cpu_gdb_read_register_apple(CPUState *cs, GByteArray *buf, int n, + bool has_xml) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *env =3D &cpu->env; @@ -222,11 +224,12 @@ int ppc_cpu_gdb_read_register_apple(CPUState *cs, GBy= teArray *buf, int n) return r; } =20 -int ppc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int ppc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *env =3D &cpu->env; - int r =3D ppc_gdb_register_len(n); + int r =3D ppc_gdb_register_len(n, has_xml); =20 if (!r) { return r; @@ -269,7 +272,8 @@ int ppc_cpu_gdb_write_register(CPUState *cs, uint8_t *m= em_buf, int n) } return r; } -int ppc_cpu_gdb_write_register_apple(CPUState *cs, uint8_t *mem_buf, int n) +int ppc_cpu_gdb_write_register_apple(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *env =3D &cpu->env; diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index b3d4d4de3e..060bfa4317 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -47,7 +47,8 @@ static const struct TypeSize vec_lanes[] =3D { { "uint8", "bytes", 8, 'b' }, }; =20 -int riscv_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int riscv_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; @@ -73,7 +74,8 @@ int riscv_cpu_gdb_read_register(CPUState *cs, GByteArray = *mem_buf, int n) return 0; } =20 -int riscv_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int riscv_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; diff --git a/target/rx/gdbstub.c b/target/rx/gdbstub.c index d7e0e6689b..57d5ed11eb 100644 --- a/target/rx/gdbstub.c +++ b/target/rx/gdbstub.c @@ -19,7 +19,8 @@ #include "cpu.h" #include "gdbstub/helpers.h" =20 -int rx_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int rx_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { RXCPU *cpu =3D RX_CPU(cs); CPURXState *env =3D &cpu->env; @@ -51,7 +52,8 @@ int rx_cpu_gdb_read_register(CPUState *cs, GByteArray *me= m_buf, int n) return 0; } =20 -int rx_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int rx_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { RXCPU *cpu =3D RX_CPU(cs); CPURXState *env =3D &cpu->env; diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c index 02c388dc32..57871e3b24 100644 --- a/target/s390x/gdbstub.c +++ b/target/s390x/gdbstub.c @@ -28,7 +28,8 @@ #include "sysemu/hw_accel.h" #include "sysemu/tcg.h" =20 -int s390_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int s390_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { S390CPU *cpu =3D S390_CPU(cs); CPUS390XState *env =3D &cpu->env; @@ -44,7 +45,8 @@ int s390_cpu_gdb_read_register(CPUState *cs, GByteArray *= mem_buf, int n) return 0; } =20 -int s390_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int s390_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { S390CPU *cpu =3D S390_CPU(cs); CPUS390XState *env =3D &cpu->env; diff --git a/target/sh4/gdbstub.c b/target/sh4/gdbstub.c index d8e199fc06..9afe6fc116 100644 --- a/target/sh4/gdbstub.c +++ b/target/sh4/gdbstub.c @@ -24,7 +24,8 @@ /* Hint: Use "set architecture sh4" in GDB to see fpu registers */ /* FIXME: We should use XML for this. */ =20 -int superh_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int superh_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { SuperHCPU *cpu =3D SUPERH_CPU(cs); CPUSH4State *env =3D &cpu->env; @@ -74,7 +75,8 @@ int superh_cpu_gdb_read_register(CPUState *cs, GByteArray= *mem_buf, int n) return 0; } =20 -int superh_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int superh_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { SuperHCPU *cpu =3D SUPERH_CPU(cs); CPUSH4State *env =3D &cpu->env; diff --git a/target/sparc/gdbstub.c b/target/sparc/gdbstub.c index a1c8fdc4d5..288cf7d6f7 100644 --- a/target/sparc/gdbstub.c +++ b/target/sparc/gdbstub.c @@ -27,7 +27,8 @@ #define gdb_get_rega(buf, val) gdb_get_regl(buf, val) #endif =20 -int sparc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int sparc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { SPARCCPU *cpu =3D SPARC_CPU(cs); CPUSPARCState *env =3D &cpu->env; @@ -104,7 +105,8 @@ int sparc_cpu_gdb_read_register(CPUState *cs, GByteArra= y *mem_buf, int n) return 0; } =20 -int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { SPARCCPU *cpu =3D SPARC_CPU(cs); CPUSPARCState *env =3D &cpu->env; diff --git a/target/tricore/gdbstub.c b/target/tricore/gdbstub.c index e8f8e5e6ea..a06e590344 100644 --- a/target/tricore/gdbstub.c +++ b/target/tricore/gdbstub.c @@ -104,7 +104,8 @@ static void tricore_cpu_gdb_write_csfr(CPUTriCoreState = *env, int n, } =20 =20 -int tricore_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int tricore_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { TriCoreCPU *cpu =3D TRICORE_CPU(cs); CPUTriCoreState *env =3D &cpu->env; @@ -119,7 +120,8 @@ int tricore_cpu_gdb_read_register(CPUState *cs, GByteAr= ray *mem_buf, int n) return 0; } =20 -int tricore_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int tricore_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { TriCoreCPU *cpu =3D TRICORE_CPU(cs); CPUTriCoreState *env =3D &cpu->env; diff --git a/target/xtensa/gdbstub.c b/target/xtensa/gdbstub.c index 4b3bfb7e59..81d97b51b8 100644 --- a/target/xtensa/gdbstub.c +++ b/target/xtensa/gdbstub.c @@ -63,7 +63,8 @@ void xtensa_count_regs(const XtensaConfig *config, } } =20 -int xtensa_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) +int xtensa_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n, + bool has_xml) { XtensaCPU *cpu =3D XTENSA_CPU(cs); CPUXtensaState *env =3D &cpu->env; @@ -118,7 +119,8 @@ int xtensa_cpu_gdb_read_register(CPUState *cs, GByteArr= ay *mem_buf, int n) } } =20 -int xtensa_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) +int xtensa_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n, + bool has_xml) { XtensaCPU *cpu =3D XTENSA_CPU(cs); CPUXtensaState *env =3D &cpu->env; --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793316; cv=none; d=zohomail.com; s=zohoarc; b=iKPGc55elEmDpw1WTQUGbuxk7vgME5vhDM66q48DPE4xlzv+7Bczn/PiLal73OMeh0i9tolm5p3GEe5JAeOIeg9pN5ToIk1iL00xvP/UijRG/7xDZqd5xvJiZq43qtuIqkjuxsczZZ+QZMy17iS7CkwOgEnOp2bHzrkCJq7ooFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793316; 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; bh=gMFQkURIt+B7Z40RIh76WBFgtW+t214r6i/VW2pjKYA=; b=FGnbtKkiIqUJm3lPDvp+IntNzK36bTgQMwIt/JyBbT9cSPxNgfuJ9W3lVKHwxgIjtRXILqp8Fwo6sKZcZ0b7zCZa9zjkPJHaglCAlk1Xu6q//bwOG2PwTa4ti7qgBfzomjLn+I2Jyjq1mIQE5S3mBAOT+lQ0hQZvgGlP7PJ3HUo= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793316446155.67518225895515; Mon, 31 Jul 2023 01:48:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOYw-0006dI-Iq; Mon, 31 Jul 2023 04:47:34 -0400 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 1qQOYa-0005oc-3V for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:47:14 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOYX-0005BU-6D for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:47:11 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-686b879f605so2741782b3a.1 for ; Mon, 31 Jul 2023 01:47:08 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.46.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:47:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793227; x=1691398027; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gMFQkURIt+B7Z40RIh76WBFgtW+t214r6i/VW2pjKYA=; b=vX/uDG/V67JjXpDvQqFGigdALwh1rnSEaO1QjrZ7QnWYxlqXVmSZ0LNzPcE5tGKE4/ egmnWAbx6wYRGX0WCDys8rgaNNl+Uh6EVJg5f95JZj5mCnhNFbc008LR3wCWun7tc62i xAvy5By5M6rwEUYKcy6a1CwzY2Ett2phfKrfgfe/E+NELvHN1ru6jRsnP3JvFM6BYIFH rEhBcpGIOaou2icpefra6aqyafhvXCoST5PDaB6jGR/ncn4LzlonIjjFqVzNENCK/QDY 7kOl2aPIz6nMKuCXpY6vlUspbYVQd250gdRzXUwYdcf62L2Xs+ehH/HsbMG4lvYAggkB 71Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793227; x=1691398027; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gMFQkURIt+B7Z40RIh76WBFgtW+t214r6i/VW2pjKYA=; b=fPR3ysX9K0pYoZPcberNALY5k4q+5pGNy6aj5nzMyMSgw9AFrxydUuY2fYyRvAtzDK 0hw7s9IOg4gsd1OruN3WRxIH5+/0A2qKtoeUhpUSt1MAUi/efGnhflm4Bh26L5ocFI5J PBWSCzno6fZAXMSkkGGVJKLVYAr4z9x+vFsXpJXw75eesFDeoBxWUen8whGtiPrMAUCN UTOiZDNCnoRBI2mC39UVosyclPUAx3/HjNyz0wwLl2wvO+CVBm97Y1r4gNNtsIf1Jty8 9p+JW+ySJcdxF1T3lePtsJkDrXaR52hkBUy2bABX7BqQjroeaQXt6lHNvAmrX0RmFjIt 4/Qw== X-Gm-Message-State: ABy/qLYRsq1va10FW8Qxl/vPkpdsjuLHndf2P2cIPBFzGpxEy21z8iXg bcT5VtM69/lTPlpLTwxEZOEJzw== X-Google-Smtp-Source: APBJJlGkUW1RnGS9ESWmYImJ9GrE7QDrALMk8lbobcLMurlu7CrDj8O8WvZLmQUWPdukfH3AvivBNA== X-Received: by 2002:a05:6a00:174a:b0:66c:6766:7373 with SMTP id j10-20020a056a00174a00b0066c67667373mr10776209pfc.23.1690793227302; Mon, 31 Jul 2023 01:47:07 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 19/24] gdbstub: Hide gdb_has_xml Date: Mon, 31 Jul 2023 17:43:46 +0900 Message-ID: <20230731084354.115015-20-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::431; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x431.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793317604100001 Content-Type: text/plain; charset="utf-8" gdb_has_xml is no longer referenced by the other components. Signed-off-by: Akihiko Odaki --- gdbstub/internals.h | 8 ++++++++ include/exec/gdbstub.h | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index f2b46cce41..92f5ce8cbb 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -234,4 +234,12 @@ void gdb_breakpoint_remove_all(CPUState *cs); int gdb_target_memory_rw_debug(CPUState *cs, hwaddr addr, uint8_t *buf, int len, bool is_write); =20 +/** + * gdb_has_xml: + * This is an ugly hack to cope with both new and old gdb. + * If gdb sends qXfer:features:read then assume we're talking to a newish + * gdb that understands target descriptions. + */ +extern bool gdb_has_xml; + #endif /* GDBSTUB_INTERNALS_H */ diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 6da4af9612..cbd1e6ead4 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -40,14 +40,6 @@ const GDBFeature *gdb_find_static_feature(const char *xm= lname); =20 void gdb_set_stop_cpu(CPUState *cpu); =20 -/** - * gdb_has_xml: - * This is an ugly hack to cope with both new and old gdb. - * If gdb sends qXfer:features:read then assume we're talking to a newish - * gdb that understands target descriptions. - */ -extern bool gdb_has_xml; - /* in gdbstub-xml.c, generated by scripts/feature_to_c.py */ extern const GDBFeature gdb_features[]; =20 --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793391; cv=none; d=zohomail.com; s=zohoarc; b=isFF3fKz29HpPa7kVaU0xiwdUptH3fdbCf0yzxfNY3c+r4ULFl5IS+O0yA7sI1pyebE+zwJLP8+3Fau6fAG7MYfSmGMjFFLFRteYovsavQI0hDGtUqP6TntVDdWal9TQRx8D4DguNGvTr1DajIvEkvVg1saqB3YFA+hP4C/Epao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793391; 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; bh=VKGqRmFHlLElcyIKfmdM6E/OloMqOiQP/Nmx8ezyg2c=; b=BSCVzxpHVYZryf/m+H/oAmYl9l+hLOZnPv3E4TdpnaDpxTxEZXHsJKnml9H01WynIohk4+gboom7fIZwKjO+oFrUhWjjyEF1f+DEeUnZZauJmlraP6WYXud1ADjJAcvzYKRxocPuzf3a/EC4Nybef/LS9JCsJ1tt1aKjClzP1pA= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793391091177.56824803341635; Mon, 31 Jul 2023 01:49:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOYy-0006uj-DZ; Mon, 31 Jul 2023 04:47:36 -0400 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 1qQOYj-00062x-1e for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:47:24 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOYf-0005E8-HX for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:47:20 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-68706b39c4cso2208879b3a.2 for ; Mon, 31 Jul 2023 01:47:17 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793236; x=1691398036; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VKGqRmFHlLElcyIKfmdM6E/OloMqOiQP/Nmx8ezyg2c=; b=gJ5S9Cw9jZyUlNakHoWVELex9gRK+d9tCD1vu1ejgda3LVVYxWLBdHtGKcopy7xkFa CPt4Rjc01FhgSxN2hkw6PsUBYMaC8RH8vxkqT0VncAn+w7iDkbcXeBkF5A7rmy/k/TGz QdRH3uaZq1s0U8sg4TFNTNLb7jFK9VEobJf8KZLsXv2lxSVGxwCZbH7JrPuJyZG6FOXJ Pp8U0mtvOKEkuEE2BAuUI2wFk2d5Edcreca5BzyJsVKqXNbviiIcxDEUoZ5l2uKulUrp pvPeeFgdLvfD6z86v03XZPDFtge3hulTbu52Et1S4V9dFAvnbCtqmkHArDXGQsM9jNae ZacA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793236; x=1691398036; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VKGqRmFHlLElcyIKfmdM6E/OloMqOiQP/Nmx8ezyg2c=; b=eRwIpP5qqoF94Fift2vC1X7EzFWWxJW1+fD4hWuIu/C/sc9Zs0EDt3HrowePNNd72f Ks8jftDHTlz9GaPuIB0SuLc+vYQGTYq0mon5XEfQ0VQ1H3so2Fk+K3D+fXhHo1Tq1n5H AEfbN9ftmRAIpD9jhINahqKjN681tFWOCdkOHRg6dFmSIiwZFsUwP4Qxn0Yru1+cALk/ RbnXlw2r1lc9Za0wnRuLXkUcgYil603h6ziutCj+HRCEjOBZ3XlnR8DKI8sj5UxQBeZx YYTAT8h0gaNyElOKktIlPFkkzG4GkDjvtz8H2YmkON86coyMyVTVv5j0gmwOMjCfFqjl sqZw== X-Gm-Message-State: ABy/qLbJAEF+cwPoSWlzSRmNJ9BieO/QXgYERUMuj6SOd+B0UDs/HAbt ZmFa44WTclnjEzc02PY6VaHkTw== X-Google-Smtp-Source: APBJJlGpgUS7fCkfqnBEJVFzmloEcHFe98LXemCdllwcT3LxUf+wXFN8nI8bEETPZId/zh5Dk9KKzw== X-Received: by 2002:a05:6a00:1302:b0:686:bd88:605e with SMTP id j2-20020a056a00130200b00686bd88605emr10960922pfu.11.1690793236352; Mon, 31 Jul 2023 01:47:16 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 20/24] gdbstub: Expose functions to read registers Date: Mon, 31 Jul 2023 17:43:47 +0900 Message-ID: <20230731084354.115015-21-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::429; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x429.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793391800100001 Content-Type: text/plain; charset="utf-8" gdb_foreach_feature() enumerates features that are useful to identify registers. gdb_read_register() actually reads registers. Signed-off-by: Akihiko Odaki --- include/exec/gdbstub.h | 6 ++++++ gdbstub/gdbstub.c | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index cbd1e6ead4..5e5789f7bb 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -38,6 +38,12 @@ int gdbserver_start(const char *port_or_device); =20 const GDBFeature *gdb_find_static_feature(const char *xmlname); =20 +void gdb_foreach_feature(CPUState *cpu, + void (* callback)(void *, const GDBFeature *, int= ), + void *opaque); + +int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, bool has_xm= l); + void gdb_set_stop_cpu(CPUState *cpu); =20 /* in gdbstub-xml.c, generated by scripts/feature_to_c.py */ diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index caef6aabab..5f76ff7271 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -416,14 +416,32 @@ const GDBFeature *gdb_find_static_feature(const char = *xmlname) return NULL; } =20 -static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) +void gdb_foreach_feature(CPUState *cpu, + void (* callback)(void *, const GDBFeature *, int= ), + void *opaque) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + GDBRegisterState *r; + + if (!cc->gdb_core_feature) { + return; + } + + callback(opaque, cc->gdb_core_feature, 0); + + for (r =3D cpu->gdb_regs; r; r =3D r->next) { + callback(opaque, r->feature, r->base_reg); + } +} + +int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg, bool has_xm= l) { CPUClass *cc =3D CPU_GET_CLASS(cpu); CPUArchState *env =3D cpu->env_ptr; GDBRegisterState *r; =20 if (reg < cc->gdb_num_core_regs) { - return cc->gdb_read_register(cpu, buf, reg, gdb_has_xml); + return cc->gdb_read_register(cpu, buf, reg, has_xml); } =20 for (r =3D cpu->gdb_regs; r; r =3D r->next) { @@ -434,14 +452,15 @@ static int gdb_read_register(CPUState *cpu, GByteArra= y *buf, int reg) return 0; } =20 -static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg) +static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg, + bool has_xml) { CPUClass *cc =3D CPU_GET_CLASS(cpu); CPUArchState *env =3D cpu->env_ptr; GDBRegisterState *r; =20 if (reg < cc->gdb_num_core_regs) { - return cc->gdb_write_register(cpu, mem_buf, reg, gdb_has_xml); + return cc->gdb_write_register(cpu, mem_buf, reg, has_xml); } =20 for (r =3D cpu->gdb_regs; r; r =3D r->next) { @@ -1067,7 +1086,7 @@ static void handle_set_reg(GArray *params, void *user= _ctx) reg_size =3D strlen(get_param(params, 1)->data) / 2; gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 1)->data, reg_= size); gdb_write_register(gdbserver_state.g_cpu, gdbserver_state.mem_buf->dat= a, - get_param(params, 0)->val_ull); + get_param(params, 0)->val_ull, gdb_has_xml); gdb_put_packet("OK"); } =20 @@ -1087,7 +1106,8 @@ static void handle_get_reg(GArray *params, void *user= _ctx) =20 reg_size =3D gdb_read_register(gdbserver_state.g_cpu, gdbserver_state.mem_buf, - get_param(params, 0)->val_ull); + get_param(params, 0)->val_ull, + gdb_has_xml); if (!reg_size) { gdb_put_packet("E14"); return; @@ -1174,7 +1194,8 @@ static void handle_write_all_regs(GArray *params, voi= d *user_ctx) for (reg_id =3D 0; reg_id < gdbserver_state.g_cpu->gdb_num_g_regs && len > 0; reg_id++) { - reg_size =3D gdb_write_register(gdbserver_state.g_cpu, registers, = reg_id); + reg_size =3D gdb_write_register(gdbserver_state.g_cpu, registers, = reg_id, + gdb_has_xml); len -=3D reg_size; registers +=3D reg_size; } @@ -1192,7 +1213,8 @@ static void handle_read_all_regs(GArray *params, void= *user_ctx) for (reg_id =3D 0; reg_id < gdbserver_state.g_cpu->gdb_num_g_regs; reg= _id++) { len +=3D gdb_read_register(gdbserver_state.g_cpu, gdbserver_state.mem_buf, - reg_id); + reg_id, + gdb_has_xml); } g_assert(len =3D=3D gdbserver_state.mem_buf->len); =20 --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793306; cv=none; d=zohomail.com; s=zohoarc; b=IhwaFKtCgf2DYcLht0O6mczKXqcwh/dc4R5tapXRlv5vr+CX2dkrOpHyUupsNmKP+bom+50z2U+5v8e1YvGUVANXxPWMX7x6OK03XznNtcozydOokZkVl3YQCvPJJgu7PB07nkRsQKR/BOC6U7HUr4Oi7uei47lzPmTXdcm9tmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793306; 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; bh=pkAMXzWLpRkH5krv4cGVkpHiNU1YTqojQ0YjYT7VOO8=; b=UF4yG/eZph44jnj2uvkjo1siCERll/pF2J73QcmsF3mEb/Aus5KOYP/SYLavakeOeJOUZCbt1W4w4Ata3YyqnFYzloKG4tnucZqnw42cgl8HfjHoOvQwaEMwpy6q+SrCVZvUnoAPXf69yzYUDbgIiBl42w4UntBGFuRJ9Wlx+1k= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793306111344.33239506755933; Mon, 31 Jul 2023 01:48:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOZE-0007bB-Tt; Mon, 31 Jul 2023 04:47:52 -0400 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 1qQOYw-0006gE-MD for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:47:34 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOYs-0005Hd-FF for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:47:34 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-686daaa5f1fso2870445b3a.3 for ; Mon, 31 Jul 2023 01:47:29 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.47.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793245; x=1691398045; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pkAMXzWLpRkH5krv4cGVkpHiNU1YTqojQ0YjYT7VOO8=; b=5VI/8DDyL+Dq2u6mipsb7KpcrPPw7wzvVzIhOZjCRlnzLxQxlOCpk3uKPEGt/Vse3E llz11VoJTYVaMoD98xgVmXsGKNkEWz/gP0m49BECa1qBwSh92UZ6cKFrW6KrFlOCaVxX ywAYIsvSzWeSHerxo+8zLyS8+1LP/dNeW9yk+8pRRPB38FGFgCxZ2OlpY5qJxO8P2W9d uyd2RfAthgTZuVrDg8YkodLv7dqDuqr7VEo9EftBxUD2/rV3LU0jrEs/hmtggbO9gZxx A/xwXOVwQtBP6knVESb7mm4orqJNewvTIY9UHTSZ4uD/6vXKddWwVozEQ1DzYTwvbTZW NQvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793245; x=1691398045; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pkAMXzWLpRkH5krv4cGVkpHiNU1YTqojQ0YjYT7VOO8=; b=Z9SZpEOVvxhOyyGXO3/d3waiHi0yXaK5KiqcE28W+hLvWGE39TXkmICOyB+q+hvkAU Hs/Rgqm7UuslW+c8qG9mX2EDRctWXQoVtG4CkciV4nRLlBQ+xzCwuSEu2tWQbiMkXZ/T 5hhUWHOIaYum2Pji3Z+QJvyvGElC9sTdvtr7KO5SS1luhRbbIuRSzfV7ORleA048TTHM 7CMzdMvoDXaIrEtXX48mGVcgMFRURwEkzXYxSA8B2zL7ac6avN6xCApyisdex3n+p4T0 ykG2kB690rCU2w126lU/DP/h62JTxaY5p250gf7RObcKDteN9kQjHobmmljzhazDnePh GsfA== X-Gm-Message-State: ABy/qLZkce2TlAmqQ6B2Vv0Rz2S7foQhke2vkyYwqiWjE4PySNMtLsM4 uDlNqOU0QbzLG0B437PH3k/qzg== X-Google-Smtp-Source: APBJJlGU5LwqEBb0O9rbYYygkPxT10/cuYLhGKDiZiLetwr+kj+8R/Z5G3z2u8VZwh3KKgJ2AkMusw== X-Received: by 2002:a05:6a00:88e:b0:681:3ed2:b493 with SMTP id q14-20020a056a00088e00b006813ed2b493mr10319253pfj.26.1690793245616; Mon, 31 Jul 2023 01:47:25 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 21/24] plugins: Allow to read registers Date: Mon, 31 Jul 2023 17:43:48 +0900 Message-ID: <20230731084354.115015-22-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::42f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793307818100003 Content-Type: text/plain; charset="utf-8" It is based on GDB protocol to ensure interface stability. The timing of the vcpu init hook is also changed so that the hook will get called after GDB features are initialized. Signed-off-by: Akihiko Odaki --- include/qemu/qemu-plugin.h | 65 ++++++++++++++++++++++++++++++++++-- cpu.c | 11 ------ hw/core/cpu-common.c | 10 ++++++ plugins/api.c | 40 ++++++++++++++++++++++ plugins/qemu-plugins.symbols | 2 ++ 5 files changed, 114 insertions(+), 14 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 50a9957279..214b12bfd6 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -11,6 +11,7 @@ #ifndef QEMU_QEMU_PLUGIN_H #define QEMU_QEMU_PLUGIN_H =20 +#include #include #include #include @@ -51,7 +52,7 @@ typedef uint64_t qemu_plugin_id_t; =20 extern QEMU_PLUGIN_EXPORT int qemu_plugin_version; =20 -#define QEMU_PLUGIN_VERSION 1 +#define QEMU_PLUGIN_VERSION 2 =20 /** * struct qemu_info_t - system information for plugins @@ -218,8 +219,8 @@ struct qemu_plugin_insn; * @QEMU_PLUGIN_CB_R_REGS: callback reads the CPU's regs * @QEMU_PLUGIN_CB_RW_REGS: callback reads and writes the CPU's regs * - * Note: currently unused, plugins cannot read or change system - * register state. + * Note: currently QEMU_PLUGIN_CB_RW_REGS is unused, plugins cannot change + * system register state. */ enum qemu_plugin_cb_flags { QEMU_PLUGIN_CB_NO_REGS, @@ -664,4 +665,62 @@ uint64_t qemu_plugin_end_code(void); */ uint64_t qemu_plugin_entry_code(void); =20 +/** + * struct qemu_plugin_register_file_t - register information + * + * This structure identifies registers. The identifiers included in this + * structure are identical with names used in GDB's standard target featur= es + * with some extensions. For details, see: + * https://sourceware.org/gdb/onlinedocs/gdb/Standard-Target-Features.html + * + * A register is uniquely identified with the combination of a feature name + * and a register name or a register number. It is recommended to derive + * register numbers from feature names and register names each time a new = vcpu + * starts. + * + * To derive the register number from a feature name and a register name, + * first look up qemu_plugin_register_file_t with the feature name, and th= en + * look up the register name in its @regs. The sum of the @base_reg and the + * index in the @reg is the register number. + * + * Note that @regs may have holes; some elements of @regs may be NULL. + */ +typedef struct qemu_plugin_register_file_t { + /** @name: feature name */ + const char *name; + /** @regs: register names */ + const char * const *regs; + /** @base_reg: the base identified number */ + int base_reg; + /** @num_regs: the number of elements in @regs */ + int num_regs; +} qemu_plugin_register_file_t; + +/** + * qemu_plugin_get_register_files() - returns register information + * + * @vcpu_index: the index of the vcpu context + * @size: the pointer to the variable to hold the number of returned eleme= nts + * + * Returns an array of qemu_plugin_register_file_t. The user should g_free= () + * the array once no longer needed. + */ +qemu_plugin_register_file_t * +qemu_plugin_get_register_files(unsigned int vcpu_index, int *size); + +/** + * qemu_plugin_read_register() - read register + * + * @buf: the byte array to append the read register content to. + * @reg: the register identifier determined with + * qemu_plugin_get_register_files(). + * + * This function is only available in a context that register read access = is + * explicitly requested. + * + * Returns the size of the read register. The content of @buf is in target= byte + * order. + */ +int qemu_plugin_read_register(GByteArray *buf, int reg); + #endif /* QEMU_QEMU_PLUGIN_H */ diff --git a/cpu.c b/cpu.c index 1c948d1161..2552c85249 100644 --- a/cpu.c +++ b/cpu.c @@ -42,7 +42,6 @@ #include "hw/core/accel-cpu.h" #include "trace/trace-root.h" #include "qemu/accel.h" -#include "qemu/plugin.h" =20 uintptr_t qemu_host_page_size; intptr_t qemu_host_page_mask; @@ -148,11 +147,6 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) /* Wait until cpu initialization complete before exposing cpu. */ cpu_list_add(cpu); =20 - /* Plugin initialization must wait until cpu_index assigned. */ - if (tcg_enabled()) { - qemu_plugin_vcpu_init_hook(cpu); - } - #ifdef CONFIG_USER_ONLY assert(qdev_get_vmsd(DEVICE(cpu)) =3D=3D NULL || qdev_get_vmsd(DEVICE(cpu))->unmigratable); @@ -179,11 +173,6 @@ void cpu_exec_unrealizefn(CPUState *cpu) } #endif =20 - /* Call the plugin hook before clearing cpu->cpu_index in cpu_list_rem= ove */ - if (tcg_enabled()) { - qemu_plugin_vcpu_exit_hook(cpu); - } - cpu_list_remove(cpu); /* * Now that the vCPU has been removed from the RCU list, we can call diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 549f52f46f..e06a70007a 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -211,6 +211,11 @@ static void cpu_common_realizefn(DeviceState *dev, Err= or **errp) cpu_resume(cpu); } =20 + /* Plugin initialization must wait until the cpu is fully realized. */ + if (tcg_enabled()) { + qemu_plugin_vcpu_init_hook(cpu); + } + /* NOTE: latest generic point where the cpu is fully realized */ } =20 @@ -218,6 +223,11 @@ static void cpu_common_unrealizefn(DeviceState *dev) { CPUState *cpu =3D CPU(dev); =20 + /* Call the plugin hook before clearing the cpu is fully unrealized */ + if (tcg_enabled()) { + qemu_plugin_vcpu_exit_hook(cpu); + } + /* NOTE: latest generic point before the cpu is fully unrealized */ cpu_exec_unrealizefn(cpu); } diff --git a/plugins/api.c b/plugins/api.c index 2078b16edb..dd7ff5067b 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -35,6 +35,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/main-loop.h" #include "qemu/plugin.h" #include "qemu/log.h" #include "tcg/tcg.h" @@ -442,3 +443,42 @@ uint64_t qemu_plugin_entry_code(void) #endif return entry; } + +static void count_gdb_feature(void *opaque, const GDBFeature *feature, + int base_reg) +{ + (*(int *)opaque)++; +} + +static void map_gdb_feature(void *opaque, const GDBFeature *feature, + int base_reg) +{ + qemu_plugin_register_file_t **cursor =3D opaque; + (*cursor)->name =3D feature->name; + (*cursor)->regs =3D feature->regs; + (*cursor)->base_reg =3D base_reg; + (*cursor)->num_regs =3D feature->num_regs; + (*cursor)++; +} + +qemu_plugin_register_file_t * +qemu_plugin_get_register_files(unsigned int vcpu_index, int *size) +{ + QEMU_IOTHREAD_LOCK_GUARD(); + + *size =3D 0; + gdb_foreach_feature(qemu_get_cpu(vcpu_index), count_gdb_feature, size); + + qemu_plugin_register_file_t *files =3D + g_new(qemu_plugin_register_file_t, *size); + + qemu_plugin_register_file_t *cursor =3D files; + gdb_foreach_feature(qemu_get_cpu(vcpu_index), map_gdb_feature, &cursor= ); + + return files; +} + +int qemu_plugin_read_register(GByteArray *buf, int reg) +{ + return gdb_read_register(current_cpu, buf, reg, true); +} diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 71f6c90549..4ed9e70e47 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -42,4 +42,6 @@ qemu_plugin_tb_vaddr; qemu_plugin_uninstall; qemu_plugin_vcpu_for_each; + qemu_plugin_get_register_files; + qemu_plugin_read_register; }; --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793328; cv=none; d=zohomail.com; s=zohoarc; b=Svk4QIfMSKIu1Ra5P1ufT84LnuRTV5fXyZEp48Wm00Wc1ZQ25rDQIjfMh4gwnEgJbkLQzAr3fZvqfI2Y6PevnJSrMErWYf8nn4mLaA4xrp/SZf66bDCpk9uaZjWZtq50QVoa1Sg/bEl4U2UiaWPbEnzak+C8fo7pe4GAR1MwQu8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793328; 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; bh=TPZLL2BQqlmuIWxUEHn0Sk9lpGxDteaJZxDIDmp8UqM=; b=ci1xcubdkKGMr/4blecI9VRzpgoPbdywJwqarUekxHpghsnwK9HGJDT7wMju5tUyICv5db6nB9GBaMEKyhd9HIeyaQ2kp6nQT7d8tKFrxF4zA5iPfJBelLoWlcROYlAnbJcvEDeMOgMXpUi/qxau2XWp+1BiuJLuYGK6WKCJf7w= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793328708599.5090061656966; Mon, 31 Jul 2023 01:48:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOZE-0007bD-UG; Mon, 31 Jul 2023 04:47:53 -0400 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 1qQOZ0-0007Fx-EU for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:47:39 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOYx-0005Kh-WB for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:47:38 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-68706d67ed9so2353435b3a.2 for ; Mon, 31 Jul 2023 01:47:35 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:47:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793255; x=1691398055; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TPZLL2BQqlmuIWxUEHn0Sk9lpGxDteaJZxDIDmp8UqM=; b=Ntzl3L+Ycidt4E2sO5Qc+c7zR4Dphu4IUHgX7FrwOK8K/wXakETfwScShXAZfHuEuv UFtCEebyPjkdPA1SHJRqpP3gszGb/x5iZly137X5e47BUvHM5reb16bLn/05qimMfa4M C3/vCek/onHA+9m/wEKJuPikSKb7U4bLLgeGqYTPd8w8iSbfYdZQH1q2OQjxMSPiHGk1 Ja2qVpiPPIrjuDFBG3NO+iYhHmAhAh4qCwj8UNnWZUFQ9ZBi2DtL2eI2oNCL94Kij21D WYQIW1nAlh+mXSisl3r8GhbRvVr6H9BTpcy2SX/Wjgcl7oigFEn5+mhBY3/VDUk/6ENn 3epQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793255; x=1691398055; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TPZLL2BQqlmuIWxUEHn0Sk9lpGxDteaJZxDIDmp8UqM=; b=jEICsUWcq5E5dppRWmFH4n0KOxsf4IadT2l4d+60s6+SVaXlzVGOfDZOUSbq23BH3h SlGDZULL4ft7QVlJR0gnWIr7s4MohGggXQFP3VEfsyXJpPZRmj7KSJqxMq6NRlhqRMag 7g3dC1A9C3Wwxg9hdSo5ASjWRBjPUNPc+6BSMu9oqL6h+aBCP0LTScn8rzWXqo8BZdwQ QpghDaKSxECjRzIMYNMrD1VoxtDT7OTwDnAnSlvsmgMuw0Xd3EjdAjugBgHSeKHdYtBB YvpPa/BEsjMf9nUsiro1t4SrBMcLvtuNKligo5otvgWt/tKPtF3hVWBihbxlUtMNUzhR nVOw== X-Gm-Message-State: ABy/qLa7F4qbLWQRDcwnF8GYBSPxwTJV4ws311ufs+Q6jp69Sg/k88U/ vK/92LRRbl2SZodTSO+MLE/DXg== X-Google-Smtp-Source: APBJJlFcxshJrqA9zCwgmiIX33aC0EjZT2Dp52t6StvzwN1DIW87O7vpMOwB6ZtLuvZowEya52+lxA== X-Received: by 2002:a05:6a00:15d4:b0:677:bdc:cd6b with SMTP id o20-20020a056a0015d400b006770bdccd6bmr11677189pfu.19.1690793254686; Mon, 31 Jul 2023 01:47:34 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 22/24] contrib/plugins: Allow to log registers Date: Mon, 31 Jul 2023 17:43:49 +0900 Message-ID: <20230731084354.115015-23-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::432; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x432.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793330378100003 Content-Type: text/plain; charset="utf-8" This demonstrates how a register can be read from a plugin. Signed-off-by: Akihiko Odaki --- docs/devel/tcg-plugins.rst | 10 ++- contrib/plugins/execlog.c | 130 ++++++++++++++++++++++++++++--------- 2 files changed, 108 insertions(+), 32 deletions(-) diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst index 81dcd43a61..c9f8b27590 100644 --- a/docs/devel/tcg-plugins.rst +++ b/docs/devel/tcg-plugins.rst @@ -497,6 +497,15 @@ arguments if required:: $ qemu-system-arm $(QEMU_ARGS) \ -plugin ./contrib/plugins/libexeclog.so,ifilter=3Dst1w,afilter=3D0x400= 01808 -d plugin =20 +This plugin can also dump a specified register. The specification of regis= ter +follows `GDB standard target features `__. + +Specify the name of the feature that contains the register and the name of= the +register with ``rfile`` and ``reg`` options, respectively:: + + $ qemu-system-arm $(QEMU_ARGS) \ + -plugin ./contrib/plugins/libexeclog.so,rfile=3Dorg.gnu.gdb.arm.core,r= eg=3Dsp -d plugin + - contrib/plugins/cache.c =20 Cache modelling plugin that measures the performance of a given L1 cache @@ -583,4 +592,3 @@ The following API is generated from the inline document= ation in include the full kernel-doc annotations. =20 .. kernel-doc:: include/qemu/qemu-plugin.h - diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c index ce67acf145..031ad67fbb 100644 --- a/contrib/plugins/execlog.c +++ b/contrib/plugins/execlog.c @@ -15,27 +15,42 @@ =20 #include =20 +typedef struct CPU { + /* Store last executed instruction on each vCPU as a GString */ + GString *last_exec; + GByteArray *reg_buf; + + int reg; +} CPU; + QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; =20 -/* Store last executed instruction on each vCPU as a GString */ -static GPtrArray *last_exec; +static CPU *cpus; +static int num_cpus; static GRWLock expand_array_lock; =20 static GPtrArray *imatches; static GArray *amatches; =20 +static char *rfile_name; +static char *reg_name; + /* - * Expand last_exec array. + * Expand cpu array. * * As we could have multiple threads trying to do this we need to * serialise the expansion under a lock. */ -static void expand_last_exec(int cpu_index) +static void expand_cpu(int cpu_index) { - g_rw_lock_writer_unlock(&expand_array_lock); - while (cpu_index >=3D last_exec->len) { - GString *s =3D g_string_new(NULL); - g_ptr_array_add(last_exec, s); + g_rw_lock_writer_lock(&expand_array_lock); + if (cpu_index >=3D num_cpus) { + cpus =3D g_realloc_n(cpus, cpu_index + 1, sizeof(*cpus)); + while (cpu_index >=3D num_cpus) { + cpus[num_cpus].last_exec =3D g_string_new(NULL); + cpus[num_cpus].reg_buf =3D g_byte_array_new(); + num_cpus++; + } } g_rw_lock_writer_unlock(&expand_array_lock); } @@ -50,8 +65,8 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin_= meminfo_t info, =20 /* Find vCPU in array */ g_rw_lock_reader_lock(&expand_array_lock); - g_assert(cpu_index < last_exec->len); - s =3D g_ptr_array_index(last_exec, cpu_index); + g_assert(cpu_index < num_cpus); + s =3D cpus[cpu_index].last_exec; g_rw_lock_reader_unlock(&expand_array_lock); =20 /* Indicate type of memory access */ @@ -77,28 +92,35 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugi= n_meminfo_t info, */ static void vcpu_insn_exec(unsigned int cpu_index, void *udata) { - GString *s; + CPU cpu; + int n; + int i; =20 /* Find or create vCPU in array */ g_rw_lock_reader_lock(&expand_array_lock); - if (cpu_index >=3D last_exec->len) { - g_rw_lock_reader_unlock(&expand_array_lock); - expand_last_exec(cpu_index); - g_rw_lock_reader_lock(&expand_array_lock); - } - s =3D g_ptr_array_index(last_exec, cpu_index); + cpu =3D cpus[cpu_index]; g_rw_lock_reader_unlock(&expand_array_lock); =20 /* Print previous instruction in cache */ - if (s->len) { - qemu_plugin_outs(s->str); + if (cpu.last_exec->len) { + qemu_plugin_outs(cpu.last_exec->str); qemu_plugin_outs("\n"); } =20 /* Store new instruction in cache */ /* vcpu_mem will add memory access information to last_exec */ - g_string_printf(s, "%u, ", cpu_index); - g_string_append(s, (char *)udata); + g_string_printf(cpu.last_exec, "%u, ", cpu_index); + g_string_append(cpu.last_exec, (char *)udata); + + if (cpu.reg >=3D 0) { + g_string_append(cpu.last_exec, ", reg,"); + n =3D qemu_plugin_read_register(cpu.reg_buf, cpu.reg); + for (i =3D 0; i < n; i++) { + g_string_append_printf(cpu.last_exec, " 0x%02X", + cpu.reg_buf->data[i]); + } + g_byte_array_set_size(cpu.reg_buf, 0); + } } =20 /** @@ -167,8 +189,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct = qemu_plugin_tb *tb) QEMU_PLUGIN_MEM_RW, NULL); =20 /* Register callback on instruction */ - qemu_plugin_register_vcpu_insn_exec_cb(insn, vcpu_insn_exec, - QEMU_PLUGIN_CB_NO_REGS,= output); + qemu_plugin_register_vcpu_insn_exec_cb( + insn, vcpu_insn_exec, + rfile_name ? QEMU_PLUGIN_CB_R_REGS : QEMU_PLUGIN_CB_NO_REG= S, + output); =20 /* reset skip */ skip =3D (imatches || amatches); @@ -177,17 +201,53 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct= qemu_plugin_tb *tb) } } =20 +static void vcpu_init(qemu_plugin_id_t id, unsigned int vcpu_index) +{ + int reg =3D 0; + bool found =3D false; + + expand_cpu(vcpu_index); + + if (rfile_name) { + int i; + int j; + int n; + + qemu_plugin_register_file_t *rfiles =3D + qemu_plugin_get_register_files(vcpu_index, &n); + + for (i =3D 0; i < n; i++) { + if (g_strcmp0(rfiles[i].name, rfile_name) =3D=3D 0) { + for (j =3D 0; j < rfiles[i].num_regs; j++) { + if (g_strcmp0(rfiles[i].regs[j], reg_name) =3D=3D 0) { + reg +=3D j; + found =3D true; + break; + } + } + break; + } + + reg +=3D rfiles[i].num_regs; + } + + g_free(rfiles); + } + + g_rw_lock_writer_lock(&expand_array_lock); + cpus[vcpu_index].reg =3D found ? reg : -1; + g_rw_lock_writer_unlock(&expand_array_lock); +} + /** * On plugin exit, print last instruction in cache */ static void plugin_exit(qemu_plugin_id_t id, void *p) { guint i; - GString *s; - for (i =3D 0; i < last_exec->len; i++) { - s =3D g_ptr_array_index(last_exec, i); - if (s->str) { - qemu_plugin_outs(s->str); + for (i =3D 0; i < num_cpus; i++) { + if (cpus[i].last_exec->str) { + qemu_plugin_outs(cpus[i].last_exec->str); qemu_plugin_outs("\n"); } } @@ -224,9 +284,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_= id_t id, * we don't know the size before emulation. */ if (info->system_emulation) { - last_exec =3D g_ptr_array_sized_new(info->system.max_vcpus); - } else { - last_exec =3D g_ptr_array_new(); + cpus =3D g_new(CPU, info->system.max_vcpus); } =20 for (int i =3D 0; i < argc; i++) { @@ -236,13 +294,23 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugi= n_id_t id, parse_insn_match(tokens[1]); } else if (g_strcmp0(tokens[0], "afilter") =3D=3D 0) { parse_vaddr_match(tokens[1]); + } else if (g_strcmp0(tokens[0], "rfile") =3D=3D 0) { + rfile_name =3D g_strdup(tokens[1]); + } else if (g_strcmp0(tokens[0], "reg") =3D=3D 0) { + reg_name =3D g_strdup(tokens[1]); } else { fprintf(stderr, "option parsing failed: %s\n", opt); return -1; } } =20 + if ((!rfile_name) !=3D (!reg_name)) { + fputs("file and reg need to be set at the same time\n", stderr); + return -1; + } + /* Register translation block and exit callbacks */ + qemu_plugin_register_vcpu_init_cb(id, vcpu_init); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); =20 --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793341; cv=none; d=zohomail.com; s=zohoarc; b=EG/Ew0LlvVgIJFjYN9AKg9TDMbTCDElWxb+/QzgdHnxnCoSqePHHnPFItgbvBr7GB1VBnFyzvabkPkTR1Y78tRqSrXSbReYbnsQBnt1zEhdCeDXpu0bg1q2m3vdVFRI0c38hOtq8xytdxpC97G10qPj8LO9hIMfYMkRJb1TiK+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793341; 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; bh=3o76KcQlFp/MuUPscQNwseGhYtySE7hW349U50r8SMs=; b=Ts+Nr4cFPh2NPCoTfdXRZ4mh6cj1RRaiPhPNYI8VxVG+/vgXadfdw64Ywpz6Peyb8gPMsLw8uW6AIYy5U3kFM8jYynWjbZzYF6HLS1SWGtj3kRUthljIAnsChPjEpp6FP6CwWhgH+MF6DfH7wxnMcJ8VSnAJnu3jViCOIUCODZ8= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793341816924.6173752101329; Mon, 31 Jul 2023 01:49:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOZH-0007kC-Jo; Mon, 31 Jul 2023 04:47:55 -0400 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 1qQOZA-0007U7-L1 for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:47:51 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOZ7-0005MC-UB for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:47:48 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-686b9964ae2so2804997b3a.3 for ; Mon, 31 Jul 2023 01:47:44 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.47.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:47:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793263; x=1691398063; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3o76KcQlFp/MuUPscQNwseGhYtySE7hW349U50r8SMs=; b=y7u6jP89IRQwFYemyUCc7xG0gnAOc6UdmwLMYKHPqhVV64B/3hHVL4MPPDtz7wqlA7 10yZVU9H/4k+HA54IqVn54qBfdzJZBgZDG5Q/xylLQlBEQ067qih3SvSuJYzKTvcJmjc mrxi2zEuDLRUQdx80/tkyCb3ED+1QiEZws52SCZBk3yaVyIh5T5NQ5bhTTEAlGyGOrf3 SGfvTJF9Cc5V3n7kDlhmbTcHZ1oApB3rUp6rNP919WOivk9EBpEDr9HJlAfw+sYJk0gm PDRE4rN7kgwMyNEgJFvdeJUd1lyD/ncCVmGusDXssoXlqcBDaRtCpwHb6+7lOCRKVef5 hdHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793263; x=1691398063; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3o76KcQlFp/MuUPscQNwseGhYtySE7hW349U50r8SMs=; b=Hq6mzbC7LJgXm7XVT4sJ3ewHdub6wqOzsOlZhO8fbKcIzPxWTixgBra/XXUsKrbLDo XmW7nAZhLsmPFsoe+PXFJ+oETBcRpzWQmcnwBmgQsG6RC2JIwqv7an4lyCfmg1b4TFTt s/vqRKzbsfDvsiD7zy4lzUiv+RLbKgnyyakK9tw7G8xf4RJ2wjQ2aVCIhve/ACNnIsX9 KXBUY1fvgc73zpH7gkmpT2pTItJftZQDvb+54psdy3GFacPCkITGd9R+ebcnvpeHzjRV F8HNgbh0ispIDt/a+M1mhWHCNm0M3HyhEFRJNi3KyZebPBC+YW8lr6E+vv5qiUwxjePf dqhA== X-Gm-Message-State: ABy/qLZqOc/iX4G5Tmvk89yTaGPlnlUNMM9pPVpxGwPBRX9fTQUhfXB+ HZCvzKoEip1Qh8xsEswUKjlE4A== X-Google-Smtp-Source: APBJJlEaUUZeLz9nI9U553gFiXbqNs1uGKfoHWk0vvfK5zSNsIuJ4De3cguOxUIvGNrmixpzNVrxxA== X-Received: by 2002:a05:6a20:8e2a:b0:137:4bff:7c92 with SMTP id y42-20020a056a208e2a00b001374bff7c92mr9475935pzj.0.1690793263643; Mon, 31 Jul 2023 01:47:43 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 23/24] plugins: Support C++ Date: Mon, 31 Jul 2023 17:43:50 +0900 Message-ID: <20230731084354.115015-24-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::436; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x436.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793342579100001 Content-Type: text/plain; charset="utf-8" Make qemu-plugin.h consumable for C++ platform. Signed-off-by: Akihiko Odaki --- include/qemu/qemu-plugin.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 214b12bfd6..8637e3d8cf 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -16,6 +16,8 @@ #include #include =20 +G_BEGIN_DECLS + /* * For best performance, build the plugin with -fvisibility=3Dhidden so th= at * QEMU_PLUGIN_LOCAL is implicit. Then, just mark qemu_plugin_install with @@ -723,4 +725,6 @@ qemu_plugin_get_register_files(unsigned int vcpu_index,= int *size); */ int qemu_plugin_read_register(GByteArray *buf, int reg); =20 +G_END_DECLS + #endif /* QEMU_QEMU_PLUGIN_H */ --=20 2.41.0 From nobody Fri May 17 02:41:56 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1690793341; cv=none; d=zohomail.com; s=zohoarc; b=D/f2+CxgiBODFmElreQdSrwb4bLeYDPhL4z9rGfztyW02patlck70jrTbf4laAtlwA1skEOokYYlfUmQnZNhCCnKZaZWajxu05Z2x/OmHox1TJiQNZTNUFUt14RHSTK0+JxBlamfn0/v+kpt7VYlzRwfYQM8hSOeZpv1STKcGbY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690793341; 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; bh=q/ljaudOPf1jdz+9rwGQeEP3d6AMU+42VcuNs3f2VA4=; b=mEHue9flR/tmKS9UeYo02Ar4BILpSMWobw4fHXGdV4X1jj6OK1ZsC/L7IdW40xKpB8XrVPntun2PtblmsJ6+HTm2ssgqOKtvEv6GQrvibEsSQnwB4Nxx1eEH5if2AlNAyrDV32bo+14RxDcxT1rIRSduPqO8ME1gBKdFJnvOioE= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690793341935155.53559438410502; Mon, 31 Jul 2023 01:49:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOZJ-0007uY-KH; Mon, 31 Jul 2023 04:47:57 -0400 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 1qQOZH-0007kY-Q0 for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:47:55 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOZF-0005Pw-PM for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:47:55 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-686b9920362so2903177b3a.1 for ; Mon, 31 Jul 2023 01:47:53 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.47.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793272; x=1691398072; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q/ljaudOPf1jdz+9rwGQeEP3d6AMU+42VcuNs3f2VA4=; b=nZhLxAvp/2C33LdlnpYPZp34/slMDnUUx4cwF5RmfJ6JeoUf5Oi+vYGGAws4eolnvo 2p5xh7PGxwvPK9vYczLlb8vbfKvW52MbYRaJIksHnowC93XbrL1fFRT25YQ8WC0Rrz6F PC0gA8Kdbt7LQt3g4kInIfJoo7rNRMyFX+6gfgaBGM3I07rFaJ3mhwWvRoZWc7EetuP0 BqxYXoWRuWFmNIFZNo+GGzzLxRt4cnE/JYJQIQnlW+QMJf2pV2Z1MUwCdWv4lWHbZrsb v+W8T+m46sHcD8t7A4+qH+/9I1s4/ARsPTqGWdSUkzW+eiweuBa00AtSVTH1S9HYcLaE TxWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793272; x=1691398072; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q/ljaudOPf1jdz+9rwGQeEP3d6AMU+42VcuNs3f2VA4=; b=ATvkEti9XWgNBrsYvwBA3TGegQRJTCFcv3FcYyBHFWS7Y5sCGF1Jt4Xy9/oXbVZXl+ s43uc+g5JJAz35aYFwzZGh3BwrDJGa9dnj6Rd9ZMqwtud3afV626jTOhtWyx/Nky4XKs ibh/8LVPANEFI67BJVwwRHh3uJenlD0Q0JBApo4E97jK1i3nIf2dNkZ6ZynNgvmu8zSz n8N+SnRdZYLkEM0RvUh3rLM4yLytcvat44pkEWtzHllkWvbe+NiEsu2vPwFqzisdVpjn mpSxtJrTbb4PgEl7khV4noNRMcDXWZ1JCSLdrryl1hWS6VKdrdvcxFAShM3lY50QPQh0 +SGQ== X-Gm-Message-State: ABy/qLbv7GQWnFgN2y2KOixmuFzEwub1YtAaxNAulwdmQOkiKFcdljZt p5649ymcw7SmhniC/7xDWlxKbw== X-Google-Smtp-Source: APBJJlEsp426D/hJ2qOs56A+RF7uySuqd1KXfb7I+eDTnz00qZVW1bhYr8MFZbAJbWbLrTQhqBDOpA== X-Received: by 2002:a05:6a00:c95:b0:686:6fa8:2b0d with SMTP id a21-20020a056a000c9500b006866fa82b0dmr11250632pfv.4.1690793272620; Mon, 31 Jul 2023 01:47:52 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Richard Henderson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Cleber Rosa , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Xiaojuan Yang , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Greg Kurz , Nicholas Piggin , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , David Hildenbrand , Ilya Leoshkevich , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Akihiko Odaki Subject: [RFC PATCH 24/24] contrib/plugins: Add cc plugin Date: Mon, 31 Jul 2023 17:43:51 +0900 Message-ID: <20230731084354.115015-25-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.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: none client-ip=2607:f8b0:4864:20::42f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1690793343516100007 Content-Type: text/plain; charset="utf-8" This demonstrates how to write a plugin in C++. Signed-off-by: Akihiko Odaki --- docs/devel/tcg-plugins.rst | 8 ++++++++ configure | 15 ++++++++++++--- contrib/plugins/Makefile | 5 +++++ contrib/plugins/cc.cc | 15 +++++++++++++++ tests/tcg/Makefile.target | 3 +++ 5 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 contrib/plugins/cc.cc diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst index c9f8b27590..0a11f8036c 100644 --- a/docs/devel/tcg-plugins.rst +++ b/docs/devel/tcg-plugins.rst @@ -584,6 +584,14 @@ The plugin has a number of arguments, all of them are = optional: configuration arguments implies ``l2=3Don``. (default: N =3D 2097152 (2MB), B =3D 64, A =3D 16) =20 +- contrib/plugins/cc.cc + +cc plugin demonstrates how to write a plugin in C++. It simply outputs +"hello, world" to the plugin log:: + + $ qemu-system-arm $(QEMU_ARGS) \ + -plugin ./contrib/plugins/libcc.so -d plugin + API --- =20 diff --git a/configure b/configure index 26ec5e4f54..0065b0dfe0 100755 --- a/configure +++ b/configure @@ -293,10 +293,18 @@ else cc=3D"${CC-${cross_prefix}gcc}" fi =20 -if test -z "${CXX}${cross_prefix}"; then - cxx=3D"c++" +if test -n "${CXX+x}"; then + cxx=3D"$CXX" else - cxx=3D"${CXX-${cross_prefix}g++}" + if test -n "${cross_prefix}"; then + cxx=3D"${cross_prefix}g++" + else + cxx=3D"c++" + fi + + if ! has "$cxx"; then + cxx=3D + fi fi =20 # Preferred ObjC compiler: @@ -1702,6 +1710,7 @@ echo "MESON=3D$meson" >> $config_host_mak echo "NINJA=3D$ninja" >> $config_host_mak echo "PKG_CONFIG=3D${pkg_config}" >> $config_host_mak echo "CC=3D$cc" >> $config_host_mak +echo "CXX=3D$cxx" >> $config_host_mak echo "EXESUF=3D$EXESUF" >> $config_host_mak =20 # use included Linux headers diff --git a/contrib/plugins/Makefile b/contrib/plugins/Makefile index b2b9db9f51..93d86b3d07 100644 --- a/contrib/plugins/Makefile +++ b/contrib/plugins/Makefile @@ -21,6 +21,9 @@ NAMES +=3D lockstep NAMES +=3D hwprofile NAMES +=3D cache NAMES +=3D drcov +ifneq ($(CXX),) +NAMES +=3D cc +endif =20 SONAMES :=3D $(addsuffix .so,$(addprefix lib,$(NAMES))) =20 @@ -31,6 +34,8 @@ CFLAGS +=3D -fPIC -Wall CFLAGS +=3D $(if $(CONFIG_DEBUG_TCG), -ggdb -O0) CFLAGS +=3D -I$(SRC_PATH)/include/qemu =20 +CXXFLAGS :=3D $(CFLAGS) + all: $(SONAMES) =20 %.o: %.c diff --git a/contrib/plugins/cc.cc b/contrib/plugins/cc.cc new file mode 100644 index 0000000000..e7270d7adc --- /dev/null +++ b/contrib/plugins/cc.cc @@ -0,0 +1,15 @@ +#include + +extern "C" { + +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, int ar= gc, + char **argv) +{ + qemu_plugin_outs("hello, world\n"); + return 0; +} + +}; diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index 462289f47c..3d7837d3b8 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -149,6 +149,9 @@ PLUGIN_SRC=3D$(SRC_PATH)/tests/plugin PLUGIN_LIB=3D../../plugin VPATH+=3D$(PLUGIN_LIB) PLUGINS=3D$(patsubst %.c, lib%.so, $(notdir $(wildcard $(PLUGIN_SRC)/*.c))) +ifneq ($(CXX),) +PLUGINS+=3D$(patsubst %.cc, lib%.so, $(notdir $(wildcard $(PLUGIN_SRC)/*.c= c))) +endif =20 # We need to ensure expand the run-plugin-TEST-with-PLUGIN # pre-requistes manually here as we can't use stems to handle it. We --=20 2.41.0