From nobody Wed May 15 18:43:50 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=1690966150; cv=none; d=zohomail.com; s=zohoarc; b=VWb2EzgSOaUb7zAxDbws/kvUvorb1O9z8z6d5qgUt5X3avwbxfwNhgrvXL1lrlXao4uH+Xzdr5CphuNRdFB7AUq38ljz1UzTnaedqA91fWJICiVapCCXhwSFAeT5ys1g3YaHW6A/tSPQBQrYiwbTHviysYmM1Ub9lYcAlIBMbUY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966150; 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=HMn5e/fQ/4gWJzXGDDVMR3j+/XN/ALHZ+mZq/ju8W1FR70YONGt5TYY/MMiNV9RyHgXi594ygQgQjnMFSMOYbdmjM/6TOcd75py+udmnVqSN3tAkrY7P4bIz1cpPUYs2JdJlVchUVnPY42TdTkz69RiS4+kojXS50fyrkbNjsfI= 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 1690966150074985.6259302260232; Wed, 2 Aug 2023 01:49:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7VM-0005oh-9O; Wed, 02 Aug 2023 04:46: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 1qR7VL-0005oB-7a for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:46:51 -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 1qR7VI-0005P5-Gd for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:46:50 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-687087d8ddaso5276336b3a.1 for ; Wed, 02 Aug 2023 01:46:48 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966007; x=1691570807; 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=z9wjAVBDpHMbkG6eQ1r3e9ny+mLCXFsCxQQo9SYfOOWYUY/RQPMbUkymHZVAcfvvUD 3OofNVeHGqhCahnR+/UW17yxhH8ot8q5p/iXgKmsmiPiopZQMEmehFUtMHFDUpXUMfVk mXofmBj+JmzrPOTqZG7I6XcZup+9uM4oJXNVeEmv30/qd/keO32a3USFQhIgSLQ2PZ7u ELBSV6eteUtIFtJwqeXRW0rEr6R0QCQZsTsBYZ7fYa+dC1y5OXxZ9DtIg3tGbuy/IG6J j6FW/Ud5yeigEy+TXBLOTHiZEH8VDLmJMNPu7hi/EtSV7v2v92EAuOQt7Ymv2pxyXYKY Q0Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966007; x=1691570807; 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=fErJw3PFTMiU2CrwuFsIhaUMS92VH25adV10Bvav0MA27nWhEOb8MJpI9kxWzey3y/ POB3bLUfxywfLgzzt85QwGXwaVBjEAuTguDKdRnuPNOIoDE+9d25Wl4VsyFKf3/wW1Fg UicW/FMJTMAHQ6cIr0P5RbI4sadkL/DxQY1ROeboMWI5qjg9NIpkLUZff21SFVklE8PA S3Ned7p5OaoEI61eDmK2nvTXFYVBlLmOSEAsRU+yIluMHbSDGsV1c7OjyExZo2bFMlO8 dsumlGiMFCHvWuAKLsV8iscCZK2G3UOAqyKdOt16BDRUQFU0xabgx1RUMWlf47PvTa/U SItQ== X-Gm-Message-State: ABy/qLakR0kLXyxm3HGYzpyIeNUpr/A8dToCIFOAY5mqZxFyOrId2j8v 7JDyYUu9yFOyTUDQPY0H4cYXog== X-Google-Smtp-Source: APBJJlFbT3djjGa3AhGETEN9Ly5DOGsyt62WPoYE4syhoesTaxfMJ77VjnntAWiN77OHXldGylrOGA== X-Received: by 2002:a05:6a20:7355:b0:116:d935:f742 with SMTP id v21-20020a056a20735500b00116d935f742mr16115776pzc.20.1690966007186; Wed, 02 Aug 2023 01:46:47 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 01/24] contrib/plugins: Use GRWLock in execlog Date: Wed, 2 Aug 2023 17:45:49 +0900 Message-ID: <20230802084614.23619-2-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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: 1690966152117100001 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 --- 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 Wed May 15 18:43:50 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=1690966098; cv=none; d=zohomail.com; s=zohoarc; b=YDd4Qtt4WoqW3JRnJo/35LYzfrHJXD+KQbwAfTBtu6yi7vadDHaTl6zICCuDjWpuVMpW7mitjvKDcW31YbueRM/IoKhtMxG7GMdexvyb3D8HVvsBwJEL+7GLzp9bCKfg4rPErTamosRJxRkWNarNubODwGrCBWQlGgzZKNtxsW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966098; h=Content-Type: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=QuvIopVSRamRsD9Z/MQeiUn7QSNXQD4RaEJM/8PCMOs=; b=XOHRm4RpLU2BNLyQY84t+G5WuYuLjl1WSvqidpYSJPNdqL3/jpk3Ozu99HfCVj8sNUfjfZKexmBgriPKFwx42GSM7Dz5MzKb85fxMT3aPCi74sGtKjE3CHPn0zxn5RD7iGRFxZ3Jsajp7pFhs3CLilO/G3Oy6m/ap3izoau3REY= 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 1690966098725477.0866311435334; Wed, 2 Aug 2023 01:48:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7VU-0005uK-I2; Wed, 02 Aug 2023 04:47:00 -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 1qR7VT-0005u2-OA for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:46:59 -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 1qR7VR-0005QU-Mp for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:46:59 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-686e29b058cso4775562b3a.1 for ; Wed, 02 Aug 2023 01:46:57 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.46.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:46:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966016; x=1691570816; 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=QuvIopVSRamRsD9Z/MQeiUn7QSNXQD4RaEJM/8PCMOs=; b=fp352XUsvsmveGrjKC+PsFtVGzB0OOeJB6ERYbFkC+uP1WrY9e0GHL4KkmU7oULsEP bW/9YvNJKUjbVIgDbd14LexbJsY6aqAu9Lcyq+SjOi7H/AddROhnbUH7L0yUcHYWyqBr gjJ8N7MS8nw+WtJzPFDQGcLpD6Z/EFve5xfxMEQ6QGu0n0aPV+b2X/RQOJ+0wGKyYNbe z2FB2rpoD+GwjSiDVawBVSNDwPKENiMMUMavxiMKIpcuyxiUBKHWrjUq6dXkG0TSPIqV P38WB49hjrMcf1X+opb7K44ubaFDr+zoXoaBJvuys2NKMuH6ZAp/OLP0CXvo7UWZCg5x gsVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966016; x=1691570816; 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=QuvIopVSRamRsD9Z/MQeiUn7QSNXQD4RaEJM/8PCMOs=; b=HcRHUAuNNNu2m9pqx5ZOst071oXTs3lQUKfcdZ51TCguAV7HfNPuJRdFLMLgHufYV9 mYVAmV5BhHtVdaMXaJUsHUqUNQ/AH/ClPkynqq83A29vnfVwlrlygSCIxGNFzFFZw44b EmrBZkHujW+Ik1659sNcySygyqOUqTk813VO9l/unWwPPhkOeoKXFH7p+M0VCH5A4Msu tGhBHTGiMYV488AfEdq+/sxxWG5NlZUYA4wNQE4ISF6lQDHktekdGl1/oZyKrnjp/rNR XV5cGeZfHKJSwqa9qXkc48vTa2M5JPdJFXvpacA1bVATqsI91gyqlG2OOrmY91YlRoME 7xpQ== X-Gm-Message-State: ABy/qLaGGWWODoksj8uW9Q1SsQeyEx/+kwv0O7pzGlTqNRyhM0wKMpEh CmijbLUnK13oaZDhe04U6i3zLw== X-Google-Smtp-Source: APBJJlHdBZqk+dowMe+vVY1XcuubzsPWW+8fBRGudLXVSYK2ofRFWifSZd4GbL66ZsqQDbnmoH0Ztw== X-Received: by 2002:a05:6a00:80e:b0:687:2e0b:228 with SMTP id m14-20020a056a00080e00b006872e0b0228mr10793551pfk.11.1690966016521; Wed, 02 Aug 2023 01:46:56 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 02/24] gdbstub: Introduce GDBFeature structure Date: Wed, 2 Aug 2023 17:45:50 +0900 Message-ID: <20230802084614.23619-3-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: 1690966099954100001 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: 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 | 48 ++++++++++++++++++++++++++++ scripts/feature_to_c.sh | 69 ----------------------------------------- 7 files changed, 62 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..3f08093321 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_static_features[]; =20 #endif diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 6911b73c07..2772f07bbe 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_static_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_static_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..580e20702b 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_static_features */ =20 -const char *const xml_builtin[][2] =3D { - { NULL, NULL } +const GDBFeature gdb_static_features[] =3D { + { NULL } }; diff --git a/scripts/feature_to_c.py b/scripts/feature_to_c.py new file mode 100755 index 0000000000..bcbcb83beb --- /dev/null +++ b/scripts/feature_to_c.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-later + +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' \ + '\n' + 'const GDBFeature gdb_static_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 Wed May 15 18:43:50 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=1690966083; cv=none; d=zohomail.com; s=zohoarc; b=NM/4oMoKBI96EWOLRAfX7aOeBHp3okDlc45BM2RSV6HHOtPCgMHg6C4FYXMkAmbIIloPYbDlt0j73EO2mTYK1nBPMOaaQilJPEj7axEGg93v6nllzelTnjDpuj3sLU3s9mT8POgXZeiqjrOoIrfHAwLHHoKGPhy+w89otcgvWas= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966083; h=Content-Type: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=zTBgY964k8VXNYb9VGNlkEmpxpnjsuPBBlVtKq+L/Io=; b=JChGo0uS/dqSRhuAkSqeIn+HrPmZRt8YVazTG7X8FdI+esPk9OASEU+jH47exiiId1jyC7unp7AwMrScj3Qqzyf7gHxxIhSvjqcpFvSq/2i5XdD2Px0qQ/OPfSngqFZ6aaWwamccuQmPCbX8ffEeNmpuWk7+rfv7/9bgqZ+JKV8= 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 1690966083470524.6391136753197; Wed, 2 Aug 2023 01:48:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7Vd-0005zM-OT; Wed, 02 Aug 2023 04:47:09 -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 1qR7Vd-0005z4-06 for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:47:09 -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 1qR7Vb-0005SQ-2a for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:47:08 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-686efa1804eso4728367b3a.3 for ; Wed, 02 Aug 2023 01:47:06 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.46.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:47:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966026; x=1691570826; 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=zTBgY964k8VXNYb9VGNlkEmpxpnjsuPBBlVtKq+L/Io=; b=OttrSR8JUkKtPBGuD39KMjovIn2JEUobFUctPa7T057KBsa8zgy79KRbVLHcGQ7N6G v72bcYIn1+OPkUNshy9kOO3cth2+oFfJilRmuJBq87HbDuv0rcfzOxNXnQLbk6Xw5Dpr CV7JBygGE4g+qyQfUUQWZ00rh/5Kb1GY+ulKEFBv0RnValT/uYmKUVthd88zzV5EfKFw 6wOej+rXHteFRbmGqPkMS8+f6/6b1Hv+WVYE0YDIsAw1Pxw5V6sLnqutdAwv443Mm588 SR1SVPUFk0Tq3l9EowXJUwmrxAKRiK/x150u/cQNWN1HKzrSojZk1vmjr3X7u37RuHq/ jknw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966026; x=1691570826; 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=zTBgY964k8VXNYb9VGNlkEmpxpnjsuPBBlVtKq+L/Io=; b=Nk3iDCUb58jBuuz0BqEcQmAP3b21/oIEKP9dj9EtiWLddpGV2YfFg+p7yts4Sx8ctg aJpTfmY7BUwik0CjCjOD5JfdEtXT0pdSfgTGuzQftsjJ/ci17A3MjRrtlpefd7y/dbft fgBsExx24awSoWkDvyqA7xRQFSv8IZ1mIA8bsz8DZaS9cc07JHqeVvh5QeC3GEWlLAHo hg01OL5ZOpw067INhl4q/61QUYgXetJeX4611Edl9/j1gyIWo0ttb4o4XtGepxbSgddJ f4EVVIWVxBwoM8KUTby31W+qg4wPOOXJM8yZKgqPO6kDNWVtaw7mG4hg8ANssyhXkBOZ h1AQ== X-Gm-Message-State: ABy/qLbXoFUWTrx2qlEuBwUmaQNJHcI9rUkHEroIZ3kQrQYnLVFJFZsw /ojYTGqjIOyU9IMo+zFZeIsGbQ== X-Google-Smtp-Source: APBJJlEgaOGw2+VVq4s38WdeLGvh03plnA1wEWOz2wnFmKGpUcZfXL103bjvunVpryZsoWEVwyfy7w== X-Received: by 2002:a05:6a00:15d6:b0:682:a62a:ec36 with SMTP id o22-20020a056a0015d600b00682a62aec36mr19141012pfu.15.1690966025894; Wed, 02 Aug 2023 01:47:05 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 03/24] gdbstub: Add num_regs member to GDBFeature Date: Wed, 2 Aug 2023 17:45:51 +0900 Message-ID: <20230802084614.23619-4-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=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: 1690966084225100001 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: 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 3f08093321..9b484d7eef 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 bcbcb83beb..e04d6b2df7 100755 --- a/scripts/feature_to_c.py +++ b/scripts/feature_to_c.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0-or-later =20 -import os, sys +import os, sys, xml.etree.ElementTree =20 def writeliteral(indent, bytes): sys.stdout.write(' ' * indent) @@ -39,10 +39,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 Wed May 15 18:43:50 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=1690966173; cv=none; d=zohomail.com; s=zohoarc; b=LxxQ6Bf0bD0Mm/utDOyyh1RtPj1Z8kHuB0FX1eT4kuACpPgyqPi8LM3rZxQsxjO0Kps4vCVHsftblvGRgWp+yUNLzi3UcyX9MO60cUdvmmrpJ4E8bJKYly83KX2P7/dmm2soHOwql4riYfxxa3ODLfJbMv5YbkblRhvQ0PklFME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966173; h=Content-Type: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=FznljfH/+zYGuRietSNCgMOr89IrbQo5GMLU/BnGdrE=; b=XoH4XH8A7ucxDADy5kD1ZOm4UYcJGTSwG/5/ej3w08JhIna5ZQuaMbv2AyTHGmysSIWFmomIjjyJrfXXAzbgxM4AfrKVz1gglYX49TwzybjPxK+pTOQoCTQlmQVarpNB67Pik/NKGSTKmp+NiQgZCjPkeJy7kFlvrcChkGsyBs0= 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 1690966172993627.3178013415956; Wed, 2 Aug 2023 01:49:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7Vs-0006BQ-1c; Wed, 02 Aug 2023 04:47:24 -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 1qR7Vn-00067i-5F for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:47:19 -0400 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qR7Vk-0005V9-Bs for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:47:18 -0400 Received: by mail-oi1-x232.google.com with SMTP id 5614622812f47-3a3efebcc24so5072196b6e.1 for ; Wed, 02 Aug 2023 01:47:16 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.47.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966035; x=1691570835; 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=FznljfH/+zYGuRietSNCgMOr89IrbQo5GMLU/BnGdrE=; b=0xZJvJvsA2joPzm67xxpk70vUtVP652nx7gZn9vSjD7ZCv1vG7IcGlIXp25iUO0zQD RTXNirSsSK9ekJ1S8009vhSlO1iN+D0xXrB78byq7rAHpkMfoQC083ARr2VnJIWzl9+w lK/uicf8YHrkagejO2WJjAvchXjBkGqnRW/Jv3cYmzPov8/zio88wPFUQ05HjIV2BCUu EMLLopps07g67H7nXg3OVRGsQmy7Gc7smYvzV0mw5w4yrZ8MP1jupTnyU5oivN+5HbSE cxWTKCtzq7Dv4uY7HzboXm0/e8yFnFTMcZ1k7JIYQrXVM/OQ7zwmqMiW+UH/YDcNA6rT 05gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966035; x=1691570835; 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=FznljfH/+zYGuRietSNCgMOr89IrbQo5GMLU/BnGdrE=; b=KhwOOHYc0ISMoBzvPs+OobMkjfO0SkjrQXDvc3wHBdVp3hNODZ4gNjkWYVQIRakxfD rmf05VNWEGTxVvG0xyL4ow30MdJUlODNh4JHuxzL2KY1ub5j0Vk82dgjhZklmNkZ+RKR 89WTC9t5XEpOzgxpnTqWOlMGVb3FmqtXgEKGFs+lLGc4yK+JBihAqWjpTKj9LdBN9Iwc pCOJ5QilX9+0InizcFlJp7mF172iHznm4PhcuKNnYLOcg+Mmz3k08NAyfA9i9a9KXIGp BiQkfixqaCY/zjuD4lfPtPmjyL4omSm5/QieT+yyBzb/Oe0CYRaLmIgdiSOmBIXu7lWk PgSw== X-Gm-Message-State: ABy/qLbCrrTPONY91kIIp4qYe9sawPMKJjFWTdRt5X/TkqTKxTY5fz7C sYxEItpLqHvrjjkj/aAV7bBKDA== X-Google-Smtp-Source: APBJJlEUGZXJI8Kr1i0JYa2fWmNRk4YlR7ELX33qcgUfelTxcAQEILGkknZDhw1Sb6+BnXLG1V4TZQ== X-Received: by 2002:a05:6808:ece:b0:3a1:d1d9:d59c with SMTP id q14-20020a0568080ece00b003a1d1d9d59cmr19156761oiv.33.1690966035334; Wed, 02 Aug 2023 01:47:15 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 04/24] gdbstub: Introduce gdb_find_static_feature() Date: Wed, 2 Aug 2023 17:45:52 +0900 Message-ID: <20230802084614.23619-5-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::232; envelope-from=akihiko.odaki@daynix.com; helo=mail-oi1-x232.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: 1690966173840100001 This function is useful to determine the number of registers exposed to GDB from the XML name. Signed-off-by: Akihiko Odaki 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 9b484d7eef..d0dcc99ed4 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 2772f07bbe..48fb43a6e0 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_static_features[i].xml : NULL; } =20 +const GDBFeature *gdb_find_static_feature(const char *xmlname) +{ + const GDBFeature *feature; + + for (feature =3D gdb_static_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 Wed May 15 18:43:50 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=1690966137; cv=none; d=zohomail.com; s=zohoarc; b=HkEow+PUyEeD06VcQr3EYeXyTXN6H9vbm3LApjqSBJ9C5ZcJgh7yrAY17J/pFUr7ek+P9PedXldwmFIWaRAYjRMjeUOCLhPP4RafohbxOM0ZsSBSBqBHJE3pxshsOWcu/f1/tGXVQxvFxn9sBd/HbYIKIfYu0T9XStpU7gIbZqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966137; 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=bFRFEKxCalTLsJ4MDriFr+A76Gu07MoO7Vj0wefGHXDQQJftB7g6CKxVZ6SriPRhdoRDndpYpJxhLbcXhR4WN1Hk7lqtz0/p9/YxsZ4cuWbvEmse6c+UoViD1NNfErxwS2t50kYDwifP5g0DY6m9l581GH+0Nwi4Ewa4HYvYlaA= 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 1690966137742377.67822286078876; Wed, 2 Aug 2023 01:48:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7Vz-0006IX-2w; Wed, 02 Aug 2023 04:47:31 -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 1qR7Vx-0006Gu-7C for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:47:29 -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 1qR7Vu-0005Xs-4o for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:47:28 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-686c06b806cso4711990b3a.2 for ; Wed, 02 Aug 2023 01:47:25 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.47.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966045; x=1691570845; 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=FMdOtL/tD7myXj/IdXUWwv0OhCLMI76GrQgmfKiVNmlzOagEusQ18knV0LFpznwcXC DyzZFhhDmlo/cxyYG0CVFRJi+IEbg5FlaFj730D+neuNjDSl9hY0CbQTrQKuAao857DQ uh1fNvG2wijrfjxMjFMmu8Ogq5VtZzrLzMl9B5hiRqst5aB9iPuQm8WDveR9UwwQNPbf CGksAi83FeUTBJG3DG2kJ4PNKVrqsDIKvJn5QIXEjzuG7UcnOZ4J7dbMb0pBR/ply01i q1qG0KOEG8bxi+0tybLTkqjvOAL/yctjfcX5aYjfxpAmwZ70Qrj17bwL+u8q2n/0tFNo /5Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966045; x=1691570845; 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=FfJbNsXdawe8wJMD2KdltravVfV3HSsNb4dehO7F2yuHHxxkWOt37ABE92x1t1fFFD 0oVH6/+DBy6nh1E7beJQctY9E8Icqj+Vmh//WIB9zVF9xOY3+ry3nQ3LogHZrzCjpjvx pUOWqvh15g/9/0OWUcey9doQuKD3WzJPeBuNJ+i/u2Ux9RGgvLJrrUXTPJ9Pbc6nAJ/R bG0FtGAGlzc+rA02h04hEc800sxFeVbOGiYzazUQO86WDp9XZ0HukrwdbtrAjLuP9bDd AMTNMOtft7Ra3DZuvEQKRnDsanA5m4vXQV9CCdcYriEAdo5TqRh9BHOAUFcCHK99PwJl 9XtQ== X-Gm-Message-State: ABy/qLbeaOABq2PeYzLjgu/WYfuLrUg0GXuoxG8Vt/oWKgNr1LxzCPEK dJU/TgJFL1ntmhxND94yfKBluw== X-Google-Smtp-Source: APBJJlEnnRto9xXYMTw1Q9C6BrUErHR1qtyByJ2JLC0h5olSPzr/TyKXwrhsJo9ViZgu/OvWOjAe9g== X-Received: by 2002:a05:6a00:1947:b0:680:6d16:8f8c with SMTP id s7-20020a056a00194700b006806d168f8cmr14888398pfk.32.1690966044899; Wed, 02 Aug 2023 01:47:24 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 05/24] target/arm: Move the reference to arm-core.xml Date: Wed, 2 Aug 2023 17:45:53 +0900 Message-ID: <20230802084614.23619-6-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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: 1690966139961100007 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 Wed May 15 18:43:50 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=1690966115; cv=none; d=zohomail.com; s=zohoarc; b=VvPCysEwHeN1ogAYGkkit6goKYSn7L4bRywTlFHs/T/9QW3+wUwJhXSVrUGVo7u0m//abHnEEqEBO/e4ykpGr5q0wR45nIfhJzvnCY2K98JC5Q8E++xeGect9vBf08NDdYBt90hnl8s1RKPWbT/InoG1zn1E84S1ja+5OGww6dU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966115; 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=ZOFypdkRAT6LYERBJdEUmMDv2WZ8Vo9XOmm/3AtZVVs=; b=PpFC7I/HRLZasWBch8jOAwACGuBEA1rAJChvYb5s9F79nJX1HU5df21fZ8cYRV55zov/L+tJMmtmvTqDI7c/UPlJA32VPWZvocjcj9rIdM6lLVKRNrGA1dkVsMMvIAnFH9/XbR/Z9jvK971QT+7+JDBSAZwBhVVNeAaPIUpbqb8= 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 1690966115718949.8208051364518; Wed, 2 Aug 2023 01:48:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7WF-0006yN-Nz; Wed, 02 Aug 2023 04:47:47 -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 1qR7WC-0006mU-0R for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:47:44 -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 1qR7W8-0005dZ-Fd for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:47:43 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-686efdeabaeso4413879b3a.3 for ; Wed, 02 Aug 2023 01:47:35 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966054; x=1691570854; 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=ZOFypdkRAT6LYERBJdEUmMDv2WZ8Vo9XOmm/3AtZVVs=; b=Aji9QXsSvrw3+G8DabhsbuhqjPxrAiflFDsAjRfHLLSLACElbQUH+PUeD4GFOSXY1n 1Ayzq60YD31v9anZlBYjyMvYiBZeg/JVaL+RhrQFPGrb+Ykjl+Kc4ft3GNlbu3JeI7Lm ESYvb++N9wz6cetOzped0BBGb26CHTNuGdADWG4nskX6p72D866cSxYjECj+FMlWIApo uHZ7TkEoStO93+5GOVFjVzYLOZaeUVyOSWHzLR8WICN5lunkoqcdwMfulJqSnpMHbRNv jdT9Gj66cozOGwXTP480fTo53GuO/m/j1i/AzL/Lt1KjsQWXQrpdoQF69xQDnb7RMoTi xhwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966054; x=1691570854; 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=ZOFypdkRAT6LYERBJdEUmMDv2WZ8Vo9XOmm/3AtZVVs=; b=L0klKPvybsvGswYUuX9KRilanS8to/CGl9HR1R+Q3emOvkONxG5P/q3TDnexveXYpp snrzDRXBRcTPaPwU9dgh7irphHznNCxdV6tAVGBCxEG5lkunwW5R/RfCdb+Dt4wwZTcW 4ysTq0Ne0bOMsvicKaJC2UZ341YgVTwCe8fs9cz8K/LdJ9v2bcLY3h6a/eUnEiv2IRy6 CR18Jb0vVQaJcYq+d+V5L+fmulDC49pmmLBb7y06TvUZ4eH/tN1j3RzVV+7Gkd8gV1Dj 8UWbiVPPNND5K2MmEjAPZHm5ONqLACKo2OzaEHv87qj1ISj9BZ/ZaiBlkqDE33vZWb3W SpzA== X-Gm-Message-State: ABy/qLb/LoEoCXGpMqwg5ZKkSt/uqYxsmroFk7GKNgvh8ywbwwjNRmbC Lvkgtbrnhg+30GJLmEOj1sqz9A== X-Google-Smtp-Source: APBJJlGNj3/4SCpTsJCU3xfP2Btw8HyyJzI9Dsetuuaa+TbhRjrLa+RzxHXYeZGIGMxHD+/FBtk7Tg== X-Received: by 2002:a05:6a00:15d6:b0:668:73f5:dce0 with SMTP id o22-20020a056a0015d600b0066873f5dce0mr17853334pfu.29.1690966054512; Wed, 02 Aug 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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 06/24] hw/core/cpu: Replace gdb_core_xml_file with gdb_core_feature Date: Wed, 2 Aug 2023 17:45:54 +0900 Message-ID: <20230802084614.23619-7-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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: 1690966116850100003 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 48fb43a6e0..0a4bc2be72 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 Wed May 15 18:43:50 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=1690966154; cv=none; d=zohomail.com; s=zohoarc; b=cKss5VlPIhEu2lN2KoHni7FNUc4UUEc3gc5eY6bM4YQg9cNbT6IaNpmFQ6PkJ2vv4NsRlJBNY66gITeSwW4G8KK6dGUjbEQ9oG5rKBeGMQhdDQsAzod0U1U6swPoXFTI/z5RAe9zhTJNCVSSk2yQQvEeusgmXOoAAt9RlmltYzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966154; h=Content-Type: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=8f63ib9JJpmtDwfqHTeNpttYdeUJZ0jujL0l8UUZXLo=; b=JEGj4N6pyV5PksR5AZE0TMwisd5LPS6uSjgYWI17KPpAXTS15TaqQlvBYU7LzHxq5EPICadzWmWClxSF1oQsAdkXG1usT21ImlmPYxJqPQKyfn7ET5zHlVM1l0HufPUc1vZmedqolrpgu4v8kAuveTvASQGQc3wPW39CgPB63tA= 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 1690966154683398.3016090824375; Wed, 2 Aug 2023 01:49:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7WJ-0007VI-Hg; Wed, 02 Aug 2023 04:47: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 1qR7WG-00077S-CL for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:47:48 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qR7WD-0005fm-KU for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:47:48 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-686ba97e4feso6385273b3a.0 for ; Wed, 02 Aug 2023 01:47:45 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.47.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 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=1690966064; x=1691570864; 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=8f63ib9JJpmtDwfqHTeNpttYdeUJZ0jujL0l8UUZXLo=; b=fwoQv2RMvfk/GQV42KIJXb0OMDfgcuvgl+TrjN+4fOZPAnjb3FJCcHTMmKLR7VaNcm lr6UADOmQNcli+7z5accaCSH4O3M0QjsKze9GkZqiKZ50V7jFsMk0LMg9tJDPjljDtNt Gr/x5BAGdJJa51Druk4VSNRQkK/J1TIi96IZ+M0HVKWl4S9I1eQMDMOFqzCcwaN7W6FI c6ivkIZ7DPUy0ZmDcmt6BTXiFiVKQwQ+GGQ91EJ9YGI7850jBKkn+fCoUG/L8LuM58Z3 8TkPIKIU3YjFYuyhpSS8GBZFmIIQD6R77/A2qgF30Kjl18C1MSUpjvdvSfRUfDj2iQ7b TUfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966064; x=1691570864; 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=8f63ib9JJpmtDwfqHTeNpttYdeUJZ0jujL0l8UUZXLo=; b=hi7Iw3bTr0TzH080WxxKRwpZhfmVS32tv212s726x5PGULMTu3FBsF0ODMWlRVGqaG 0oOege/UvqoMpFloEWoI0FfJLr6A/42gqhX3byVPI6pPH7Rnb9r5udbh7f4YA5HMrg3f PQVGkYEdtDsR0smCQ1AWE4br9CFBNRr6d1R58pWzOl+CNtcPcjBNliJlsM4Fc8UTMpey /jTKjqHktuwzhKSx2wt9y+wsmKGUH6+pN8z4mM9xMRJEJv+KiSaYqlKzbaFcgk6yohgi enLqA9Q2PCICiegwsYqytl6binjc43gEINs7eiAEHSphFRePBAmHNNXljBSh8gDPdbMT A9KA== X-Gm-Message-State: ABy/qLYrgXDqWC7hu14ZXYIIMxcHAJt84dUugxRC0+8ag8225c2M2eCb MndAwjfgln5AIX5egTs1DT2L2g== X-Google-Smtp-Source: APBJJlETkxoDxTZWrkkmY0/jiqqcRhfmqaYPfzCc5RZvPIQTt3cmhJeyRz44IIEHMQKP53rxK0r6Lg== X-Received: by 2002:a05:6a21:329f:b0:131:47f7:e811 with SMTP id yt31-20020a056a21329f00b0013147f7e811mr19660432pzb.22.1690966064021; Wed, 02 Aug 2023 01:47:44 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 07/24] target/arm: Use GDBFeature for dynamic XML Date: Wed, 2 Aug 2023 17:45:55 +0900 Message-ID: <20230802084614.23619-8-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::42c; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42c.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: 1690966156918100011 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/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 Wed May 15 18:43:50 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=1690966158; cv=none; d=zohomail.com; s=zohoarc; b=PnkRHzrc3QptlvAWpEseVoBFXa9vUSkY/7M2gdr17phSweOma4KqG9DIgK1/a8x+CYCQTYpbNQAS9djyrAHK6G2AniubHGTQ4CKk8FtYSTlpV4wL5ZJ+8Sckw8WUwOPdW3Kup6TCYblADU4cdiBFyz98VhANCbbcHZONDTpdBts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966158; h=Content-Type: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=FfSLUm35sjJsoTcaq+das4MWgsMnUid5n089D7b/Mw4=; b=FX9OAo7y8TVZA6bjCVei50tQl5cHFmSmytekR3flJyVs1ii6osEZzO7XndYGfbveQJExslSEMe185lChr5N18Ele8OzsFkVqgQTWshjnoEoAzsujw1i3SYdyACQjl5/SlFYdT9Y/zNH4FI3FrnmqcJc9TcgjGzhOB9yqD6Ztd5A= 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 1690966158896165.77925307026703; Wed, 2 Aug 2023 01:49:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7WR-00087W-1p; Wed, 02 Aug 2023 04:47:59 -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 1qR7WP-00084e-Rg for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:47:57 -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 1qR7WM-0005ht-RT for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:47:57 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6873a30d02eso2241069b3a.3 for ; Wed, 02 Aug 2023 01:47:54 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.47.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:47:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966073; x=1691570873; 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=FfSLUm35sjJsoTcaq+das4MWgsMnUid5n089D7b/Mw4=; b=LbemMOCpA59+4SX3Vw5YM4Hrn90s38FAys9idCA11uRYhyXfXGj8DIFj8y3U1AKxKG lLWA/D5ny862rglbLVPPRZw/1Ao56oKPzhrQTISGzFmmQR+cvjJT6kCgiquGBQoIrs4g 6Tz8AkPKbeq6ehbUTBNj/FCf+Q4nySlngDkPyWCsVY2/+5gE+aTJTNJhF4w9ZhaS/luT 6Zjd1+dfLraJK8q8L3tdcJgAj1tZ5/QtvIt37lIAXZ4k7LWgPceRZ6+gag2KZkqFW2Hr F2IJWC8WtKNMeEf91I8Rqq2KBfiiWIG2aQI0paDtVCMhPlSs9svUGIfjy0wm7qWw0M54 IaIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966073; x=1691570873; 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=FfSLUm35sjJsoTcaq+das4MWgsMnUid5n089D7b/Mw4=; b=g2/LGT2hgBjvm/PQX6gmf2waazTPqlfbkcReaX5EAYgVTCdYhoGQ52eQj+5mqXIKWS P7cHs3HRaH3Cczqk4zHq4RropdQfSr2CmCVroOqKbST7klex9ymvOqswaPGASWb431+I c1KpwLV5tBS4W+erCR07D684BiKBLP6H2ytHaMpIJQjEYlSSZdiqNlP0j5GbS7dwiYKo 2RcdIKErSLil15lV6qHZBJYrp5tn+netGmLvNIr+d0nyaFnH6xS06irFpG40Fb/pHOTD CCV9VQs2EWBt+fI0PBwbGvwupTI6HWoEMY8eHK5ozDW/H7umJ3EW9NcrbZJTmr58MskC NuxQ== X-Gm-Message-State: ABy/qLajezZROvm5Oslh4DqFMmh3EWqib8rKRVtAt9AfSy+H2c6KjBOa 6+MVKmU9iOi69UU1wJ8M81kO6g== X-Google-Smtp-Source: APBJJlFhFy6f1OBgGKEWBPpueI+nYG1EJAkDB7LgjnmraVDggWbfuovQNJK5km1/39tHxk+3HTcQDA== X-Received: by 2002:a05:6a00:1947:b0:680:6d16:8f8c with SMTP id s7-20020a056a00194700b006806d168f8cmr14889190pfk.32.1690966073436; Wed, 02 Aug 2023 01:47:53 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 08/24] target/ppc: Use GDBFeature for dynamic XML Date: Wed, 2 Aug 2023 17:45:56 +0900 Message-ID: <20230802084614.23619-9-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: 1690966160168100021 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 Wed May 15 18:43:50 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=1690966157; cv=none; d=zohomail.com; s=zohoarc; b=QU+2zZiSX5LPZC/kuoQ/ATGux0BP0tKki216jrZYiKA8M5fWRCDAXWsapn7nm1NjR8Tdi+FGAA3Lfwzt7i7+RXPMjp2EjyU5SaOCb7Cj2l0rBFhxBtX89d2RUKo9Y8/awU/h4w7d/qLbIjOMEV/ZBG9wyhtFIF9Dt9xvBPYF2UQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966157; h=Content-Type: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=Pq57Uwa7dhS1yah39mA3LMQjW22Opa3qbj+NxrN5x90=; b=FaBCwoLMjDsAVgqij6CPJgMDDT2x8i2hbY70rSVyk89jNGfkbDOrWQQyCjP0DwjDfNffFhfMkCa8RA70tAEcwIGQNqXNJzhcnHYHAlK6vS82cQjh4grtES/tcSXNkm9iy0OjLS/VVPck6fxt1Wf4RvJw3u5IMf9y/bx65HbQE+Y= 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 1690966157473740.1623310290265; Wed, 2 Aug 2023 01:49:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7Wa-000067-2R; Wed, 02 Aug 2023 04:48:08 -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 1qR7WY-0008PN-SN for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:48:06 -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 1qR7WW-0005jp-22 for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:48:06 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-686f38692b3so6329593b3a.2 for ; Wed, 02 Aug 2023 01:48:03 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:48:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966083; x=1691570883; 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=Pq57Uwa7dhS1yah39mA3LMQjW22Opa3qbj+NxrN5x90=; b=4znDbBz6dIiW1VW2ERZ5N671RxvfR2niT81CdTbsjZ2f0UeUIuBqmgOgoVy9m5nJYk 8WDqdCMszED50KukaStQUAnY91CcBcK6+EX+Gtn7EM5agVYJbZuVHnz+NxyATyeNrOHa IPxcM6KrMWjBcwso3CUdTX3ejnzxa2fREIhA3PpeogE2N246RCsqkNrpKNPAyLaT1yUE 1baAejwRDwC26tZJscMEclsurDmdVOKEzjrR4jPzyCZIETdKCZdeDbuczEaLl3oxUx5w OZVuT5JtFeT+J68E+8MinTsn7fbaDujkWB1g87LlcutaA1YjqyX7hjL+DACKArXdnqoQ GLog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966083; x=1691570883; 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=Pq57Uwa7dhS1yah39mA3LMQjW22Opa3qbj+NxrN5x90=; b=W+gueq1PLjpcqW/WGMSEDSAZepW1LCkZTnCBNaNZoFivTmUVZFTjbIXCK9j23AMu+U lq+2SV0ZMRX8gkkm0WQVdKgF+d/2btNIunjVjABV85EL6Gu3EeJaunJ8a5zpoTjCnEE1 gHpHjRmAfqALQZOw4czJmdYsnwnK8SgNH9nJpZLiTCSo9tARbYA40aBSnRPxIjhD5GmB 2joIMpKkXjuTr2TBBwLMak9M5N+sUt6xqfCZZlO+SrJ0P7xxCc4330XS0u8q/UqBXnwn JN/Vd+cEcPCW+7tRmNTA9qTBEc/7HrvvcoPhIZtgUxnIYA2Vjaj0tACnTh5/s9woo0yX m5nA== X-Gm-Message-State: ABy/qLYgEB1mPeCzIGOhpXfwiu/Fk+6fWBujRdn9N7ZkNTRvFKXSqfDV L1AdIwhwaV3yzcjHWXgSpmrqyQ== X-Google-Smtp-Source: APBJJlFMRrpUhrrO4SHd4nCouhxInOUR/e1nvQUtmnw6oZkEvYyek1ma0delv8dR+RSGch9NfFdhCA== X-Received: by 2002:a05:6300:8002:b0:137:293b:f9c0 with SMTP id an2-20020a056300800200b00137293bf9c0mr13735849pzc.33.1690966082899; Wed, 02 Aug 2023 01:48:02 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 09/24] target/riscv: Use GDBFeature for dynamic XML Date: Wed, 2 Aug 2023 17:45:57 +0900 Message-ID: <20230802084614.23619-10-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: 1690966158897100019 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 Wed May 15 18:43:50 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=1690966121; cv=none; d=zohomail.com; s=zohoarc; b=Jx2SXPf03wMcTRHwvz0Rs8kBatpPglHYD1Y+pNh1IrI/1s9eiScqnSD/0b/sHfxH0IRVWBF1YdFR73PWHOTNKTtHbcLMTskZVBugUug7TZEGe3lCN3b3bM/K/4VbTQiNxbBhoHU+1WOW/c/dRqw+cMYk6UI8v+ESS014NY8UFWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966121; 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=Mq+uuSiUrolYReCRF5+Obq1ib0ofOaZM2qYGWvYvmjc=; b=N3wbszB78gQpQPLSuM8TL82Dx+ke+1ZoTdVi3FIW+ba/rkCtLIzaoTsYQ/aLlnKYB/cYFAFJNC3+/ttzgS4X6Es2YzkTXurt1sbDtLGBiAPv5Pqiq2unYnqJlVYionV0HMLH9l+oULj7wiz6vgthaZWbX4pI22lPAlE6V7f/N/Y= 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 1690966121594410.2699037137213; Wed, 2 Aug 2023 01:48:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7Wj-0000sg-Qv; Wed, 02 Aug 2023 04:48:17 -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 1qR7Wh-0000qZ-Ub for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:48:15 -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 1qR7Wf-0005n2-Gb for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:48:15 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-686ba29ccb1so477886b3a.1 for ; Wed, 02 Aug 2023 01:48:13 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.48.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966092; x=1691570892; 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=Mq+uuSiUrolYReCRF5+Obq1ib0ofOaZM2qYGWvYvmjc=; b=wu5j05sjwgcXLnfcne2R/DB6MaBVW4uopUJST4w+8OolmU67Ra4z/2ppgEY25vbK2o dqDh0+DdW+fqjhk9yH+9JppyNC4VQZhrQDEBdMbfeV/n8cx5vsh2Jb1Q8/ngQcKCDrI1 VQVOvhrk5ejgLz27bwH0kyGD0LGtRyZGz8RSdgctUD2Zw9eq6/TvoL/mVfoTlQ/avVjh XTxb3qf89MXh4iN+tqirdmPlbDKIV+Y5HXcrnIv3t/DKi2gFWl4+cI/lSUVY523p4yBe kj605oRlBu0hAKu8Z7WttVDqTatrdGy72cfUKkT6/kVw9EqM4yu65//imLk6aFfHuLjM UKtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966092; x=1691570892; 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=Mq+uuSiUrolYReCRF5+Obq1ib0ofOaZM2qYGWvYvmjc=; b=UrPBHFhBgaZg8PHACVXwBIzn1BXgmdRoB/p1D0wE5vI9KG4PFUM/1FU8jeaP/UCMst goz67mbQwd2rXGSHe+om5ofEncuTSiIcrNi0MeGWu3MIHaXWkgUMxY6sHt+5yYe89F3c NcpjAqkdKFVp61E4dlBp3UW8wXN0pEB5JMp+B0mvU/QysS2nBOh603b5sWPZtZND10JR HUGrh2tk7rJMFVHGYOGYGJ1EKZ4qJeYDpfXoOEb4Lu7Yl65NS80RHlXcf1iMcPrHF82D YRHaJFp5U9edG3lKZbnALLTK0uBosiElfplsL7BhJx/pZuB1EsKZ3rsI/965pj3ziwnG bPyg== X-Gm-Message-State: ABy/qLaRWyldoLdb0mNBX9Lc0m/4MErqS0WrzxlZLcD/0UpxsGenVtqb vt6Vf+RnEHHS6vqlcqatZtUDMw== X-Google-Smtp-Source: APBJJlE82pARSVvN4QCmrtysKoShZHDBqmGoqR0AvVbNxr4BSNtDc0GNMfAKDUmA2dvCnWF0zlV6JQ== X-Received: by 2002:a05:6a00:2d16:b0:687:427c:1ac8 with SMTP id fa22-20020a056a002d1600b00687427c1ac8mr9248490pfb.8.1690966092259; Wed, 02 Aug 2023 01:48:12 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 10/24] gdbstub: Use GDBFeature for gdb_register_coprocessor Date: Wed, 2 Aug 2023 17:45:58 +0900 Message-ID: <20230802084614.23619-11-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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=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: 1690966123333100001 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 --- 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 d0dcc99ed4..d6d1c1d5c9 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 0a4bc2be72..e84364e97c 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 Wed May 15 18:43:50 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=1690966153; cv=none; d=zohomail.com; s=zohoarc; b=Lky8NO+UgchqVhBENp7q7y0135q84N8Ry3Unbp2NJt8vjP5eQUfHfpBcpxtzdKM4sSL5LQttIjuB+QKTIJSp7VbZEtqff/XFmDNGrhCg9eoHlnQDtRz0M5YxR49EbRsE2Pjr0uZsoMeqcSjVQ6X6b73qqj2lrE3hL29jDyf5YwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966153; 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=ruJ8d/vSVZrm7sThl9nP3ObIEeEirGTreGnkmjoxCvs=; b=nO0DwjIBJVDNNcN9AxZVQ6uMzNmLdVtWafDxtIVE3orcR+H0/ONjlZoxJoG1/nHavnG2bzQdI4CeOdLcawF78hnCkXuKFroajEm2aSDV29IO+6lhbuKRIg8WMZXYhCOk39Sjscwu2Cy5RRJKiaZflYjNI5p02pe7iLitALTPX3U= 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 1690966153537585.6346008407816; Wed, 2 Aug 2023 01:49:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7Ws-0001US-6f; Wed, 02 Aug 2023 04:48:26 -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 1qR7Wq-0001Eh-GT for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:48:24 -0400 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qR7Wo-0005p0-Sq for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:48:24 -0400 Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3a5a7ebdd9fso4929960b6e.0 for ; Wed, 02 Aug 2023 01:48:22 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:48:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966102; x=1691570902; 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=ruJ8d/vSVZrm7sThl9nP3ObIEeEirGTreGnkmjoxCvs=; b=myF+MsNulhFlcFL/pZTfIFTUemYarjMi9vYPVfJt7laosn9DLrGWrSxinaN9ZP7u/+ V3Dfyk+jinhb8PJual3MGLlzXi5tDj4lLmLD4YvQmNUfXk0hCyYTaCGe0i80HVmqwISZ mnnl4+VJWGJjICUzQWkIksXIdfFQU2xj5wgxDDSRAg2rkIv7yIX7nmYXaKqpiVzvaLn9 iTz20kDzh+dyrUCRFsDEhGo5LLj4w9cxobKrLq6jkgz5UNUWMcRTPeAIN/1Dn63mZC7l ro8tWDUJK1QnLdP3I/ipI4ikx1v3evK8B5L4/S+TsKkfqCwZBhjV9DXeBQyfOkWFtR0Z tPMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966102; x=1691570902; 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=ruJ8d/vSVZrm7sThl9nP3ObIEeEirGTreGnkmjoxCvs=; b=IPNkTH2TPGwgO4XWTSqOmX8Xvsd6EonL62GCgLzbl7rtBwU+ZCRr3w5f7cNLVlwbl8 6YJZQxUfQySAwK5qNdqm5n7WkeSZ1ddebfrzioloLO5zrjjPOJ7Od4BjJcS6GI56fLgp WqQC7d+wIYrhexTRyRBHKE4mboEvOGMZX1I1wHG5HbULJhX4T/ljPGavxH4f0omrL2b/ S9IDh9s/FevMCWrxrxwjfvfk2MY3vb813FDac2e+OoIYk7PbYrrKvYqkguQS1Y7/3O0P O5eyUL1Xmjw5JQWAzRcDyg1APL7/Ec4if7ZZv2eVlAKoY0+i1FWsPNZyMGtMVeCRvjkY QiRw== X-Gm-Message-State: ABy/qLaxNqY0tK64KEdgOOsQgFsGHeo2sB4YkoeL33CZTOgEBjlEfhFy BRoxDmDKIuoEvjzUTqZeHKXKzQ== X-Google-Smtp-Source: APBJJlHVDqS0XAai+VQcv+DxOoG+LOTZT+DhNpQbZTqaU6vEQVV/Kyk6xdh5C8J+c/zX1mm2xFUP6Q== X-Received: by 2002:a05:6808:2111:b0:3a7:aa1:f883 with SMTP id r17-20020a056808211100b003a70aa1f883mr14880724oiw.29.1690966101830; Wed, 02 Aug 2023 01:48: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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 11/24] gdbstub: Use GDBFeature for GDBRegisterState Date: Wed, 2 Aug 2023 17:45:59 +0900 Message-ID: <20230802084614.23619-12-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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::233; envelope-from=akihiko.odaki@daynix.com; helo=mail-oi1-x233.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: 1690966155493100001 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 e84364e97c..e49bb06a6d 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 Wed May 15 18:43:50 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=1690966172; cv=none; d=zohomail.com; s=zohoarc; b=fUnLfESsa+O3h0ci5elW2W2bkVkeff4kcKaHqOJy4JLF/7nZXbA7u+9d2e/0YEjZOexik28+N9tkXq5jSX7jWgD9p+Mo7eerD1+SVaXTUyfxomF/kYqFGSBG4OJIbTSa26OQhf4R6RH7HBgOw2wMzdnsAHMivJxwrPBONyrqYac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966172; 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=gCc1m+1u4UvLkSCROs1ORKKsW+fn0ilT0PSDkSbe4xs=; b=Zc9GsV1dIexwH1Xpnd/A3Z0KiYqSmr5byvG99HjIauU7WSEWz/jRTvopXYZPD5h+o2+sEb3vlPpEsHWr4IqFd/bnjQ074WlMfd+xtRJRthfcOuqrBGKW3VUZTXBEX0Q3VqN0ePpnkamRAKNnjAopA9IWSM4UbwV+01MZhpXHEa4= 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 1690966172119602.6771729944624; Wed, 2 Aug 2023 01:49:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7X4-0002e3-Um; Wed, 02 Aug 2023 04:48: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 1qR7Wz-0002F7-UP for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:48:35 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qR7Wy-0005x9-9Q for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:48:33 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-68336d06620so6375045b3a.1 for ; Wed, 02 Aug 2023 01:48:31 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966111; x=1691570911; 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=gCc1m+1u4UvLkSCROs1ORKKsW+fn0ilT0PSDkSbe4xs=; b=IUJEbhsalejJ+OztBTcBeuyom3Qm+km+ogMM/ZU0/9+THAZ4ViAw7G9MQDwbqBq90k ECvezMafzc1zNyix/cBaeDfzYELcQmj6PMZ5GTWxnhRsjzEQugcTbo6Qqf1Rd+d/xnIl xwFVGtUJgunpCz6Uc6r3C3HhkjnEfdM00G4XpRUFQOSmibfKMRGagbiuBVtw2blcXccg uAQqSzCL4/5q83eeT/21yBMe1ZClEn+wTdW9E0kBq/clJlYL3gJGZIb050BZH14lVqFw HfHOqv3ESbzM9nw7WdwWaNv7XSPqgCD+udX+TeE+RL5RnmHRS20f2dgJsNlRgj5o4++b 4Ofg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966111; x=1691570911; 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=gCc1m+1u4UvLkSCROs1ORKKsW+fn0ilT0PSDkSbe4xs=; b=bS5/OO3rwLxu59ClsX8r41t53R46rnJ/t6o6coIoJG/EMetZpE/cZJ85UOo24Pl0rE ICpgSafYWb1hk0k5Wdsbt9LcJxOQOVx4Nq6+xiPmLmZCKzGQuLzfR2ghxtTrI0tSQSg0 VqjJ3jj/0Pqy5/5xVyAMymqjAYX07yK+aqsk+DpSU/3OZKE33ejK/1YEX0njr06OL7DU hEVcleqmwE7qPW2ocBq5TVt2mC0+x07AdGu6pvd0OZdictYRfuDf8fGVtYxO95bFTTSI xamn2ShqcpZWgRs8ghHhCnIS/gthGSY347/AhlpruoLnX98MlPvAUoYt26uVp6HI5Azn 514w== X-Gm-Message-State: ABy/qLbtm09SmJ4Aw343G7gmCG1M3jFf0IfaFQJy7Yad5d1T5GmF2HlL 2kjVa550nby9vbhLWym+jNgE+w== X-Google-Smtp-Source: APBJJlGA0cDNIJlNalBTL8lVjVOL7XXK7R6kLlA4eqXCofDi2IWymFHyEGup9YgQ3I+FvOG+jmnmzA== X-Received: by 2002:a05:6a00:1351:b0:675:8f71:290a with SMTP id k17-20020a056a00135100b006758f71290amr20461967pfu.34.1690966111142; Wed, 02 Aug 2023 01:48:31 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 12/24] gdbstub: Simplify XML lookup Date: Wed, 2 Aug 2023 17:46:00 +0900 Message-ID: <20230802084614.23619-13-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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::435; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x435.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: 1690966174177100003 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 e49bb06a6d..9955f996ac 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_static_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_static_features[i].xml : NULL; + return NULL; } =20 const GDBFeature *gdb_find_static_feature(const char *xmlname) --=20 2.41.0 From nobody Wed May 15 18:43:50 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=1690966157; cv=none; d=zohomail.com; s=zohoarc; b=C5vJjPNa4x0p5lM9d/Q/Eh+K+0eE8mIrJZN2HmwwYdJD6LIqxUM6vEK8KShlesj+z6XHFDisbg/ji9oVkghg3/slmxxew031ms0EzayytParmlAIEEc42nDCgBwuedMdkDM/YNPA/fnF/ZAvnGctNALxpSdYDd30fmPwr6MSCs8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966157; 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=hy5oI9+dl1+12MKL9mz9CEXFHWXaKn69OuSLYj+BTHxjUZmXgIWD2osNgu4DLzvUZ5ZCvZgcCMjAwgYPMpiROKYWsLsXNgSySY9eya/iE63McFsUj91+qhRPZT9WBzLdcIs6iPaVyonO2l5zX9frM9QCLjAYsi1z94F16Xc+Dxs= 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 1690966157335804.0734314607724; Wed, 2 Aug 2023 01:49:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7XC-0003qx-1F; Wed, 02 Aug 2023 04:48:46 -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 1qR7XB-0003eF-1f for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:48:45 -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 1qR7X7-0006Lo-NQ for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:48:44 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-686f19b6dd2so4445372b3a.2 for ; Wed, 02 Aug 2023 01:48:41 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.48.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:48:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966120; x=1691570920; 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=Cm/e8UzVT4KQAvI1ClENJSpR7OStDxbcQFHAvzP3SZuujIUSc2S4TfzsKDsPmzDmKw oyPsaoZsDQrMo7fwomUrKOVXKGgsxGuQlmqYrxYLyqLrIf6YMxtpUFoVQQbnIGDqDZ6W TDmpyF1jNBur55RXwMQZwKWPulign6VqnosfwJjBWSj+8pICdNwUf80DrI7rjGQjNehW M9WW9niM7CtGQgvCioZ/85BNdrZP0a7eqgZh3OC3UGP+R8B0FxePpkq1BNFxxV+fxcwv +RFru6zgx1d0BLbPThod6tzCgFu4eYhYwb/7ryhQ1PNY7sgjjNNgR5CO9IJX7KwUcoCf UBtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966120; x=1691570920; 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=g4hGvx2L26hmaBdMZbE1yeAAVEiGMowHiL480mtwICHMuySLvj6gKw2UTLf6LtIr+t nAAi3vE2fqxSLmmXXOs3CwIAUs6VI17NMiUyAtOLL/IMBkDze7SdJHwlfhy6FVxUtQod jiyT9wK3Bmdb5WGKdC5kdNLCUZGn/faFkMz/9ZI2O7pazWZx1FqCQlchDh0+N9XAOOSF lrQxxIlnUcjWUcSLWpQkQRv1ZBAVEipCGjdbpnpIbiFCGREDv8mMVpHNSZkqXKHSwD+c PfenI6Gltrne+KQLeVapAhRLReHNNifMbA6EXW4b0MjhqISilrgnOmAxrVQzJxGlkdbU AzoQ== X-Gm-Message-State: ABy/qLYS7qyp3UsSz5LcJeQ4qroBkrqURi9b5twEu5X9UuH+ww6G2BIz OQgCap1weibshn/R8PoxgCa6Tw== X-Google-Smtp-Source: APBJJlFW5lRrYMo6eqYUlAKH/hFLl/XeWlhWtsFZT/iD29oAZLgxphTIeIQiMMYq/A/hVwH3t4AjWw== X-Received: by 2002:a05:6a20:7348:b0:12f:eb74:72b6 with SMTP id v8-20020a056a20734800b0012feb7472b6mr14923427pzc.60.1690966120560; Wed, 02 Aug 2023 01:48:40 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 13/24] hw/core/cpu: Remove gdb_get_dynamic_xml member Date: Wed, 2 Aug 2023 17:46:01 +0900 Message-ID: <20230802084614.23619-14-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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=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: 1690966158177100013 Content-Type: text/plain; charset="utf-8" This function is no longer used. Signed-off-by: Akihiko Odaki --- 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 Wed May 15 18:43:50 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=1690966137; cv=none; d=zohomail.com; s=zohoarc; b=nuzze47fStvzFvxlqfEZ0aDC9prdTq1Wl/qzOJ4WC5gPcq9EzRO8OKF+G0Gwm/LIWEMu2AraZw9f7/RZMhIzUHsf7FabqlnJCfeBN44bHYPyHJCzlES6Ir+Z7gYQeZP4tePYaY63RuPfLJlYViV/HV7WLrZFvoo51ORF7RFpQxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966137; 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=3mXpG7RfRm8JlpAYSZCkqg1BzSErUQp+Pq7CWqY/JwI=; b=O96UaCLGtrD2HqCqe5W6H6lECTirXNSj1QPTB/OM11GlGnexKDngHO6V+IU8xFVS6NgBV6gb4p013yv6t2xX562VZRLm23mpBV7a+m5K4YWvlXuzL6sxXn6aUyxuxMko4k335M1ZDj3lIi6VA/VsVw6j3B6XcmcioDdLvKT4/R8= 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 1690966137598183.6987479894359; Wed, 2 Aug 2023 01:48:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7XK-0004cD-8f; Wed, 02 Aug 2023 04:48:54 -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 1qR7XJ-0004SE-1W for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:48:53 -0400 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qR7XH-0006d0-Cp for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:48:52 -0400 Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-3a751d2e6ecso1084330b6e.0 for ; Wed, 02 Aug 2023 01:48:51 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966130; x=1691570930; 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=3mXpG7RfRm8JlpAYSZCkqg1BzSErUQp+Pq7CWqY/JwI=; b=CrhfxksF1NFb0q2nze9v1c26xeVhGQQ7irYxosnuSWwpGACUwn+ENg9cUk7h5knF2Q +reg8hFWf8jzXgTzWoUi7QDnxmx1ktcUWQBBoKGGRuu5dGBUb5/fGVRkkJSTTqMH7yQr i/j1JQSY+hAzf9/cks/CVHHdqGyBfvhE9kJNZeHsczMigBf/mrudwbBG3YPmJOLd1VkJ PszOFPiqrCdexxBb2lWsu8sUfeVSXSryU/j4PdQ8Y6JFz6VghghuMGwQCliwxK1LJjv+ 4J5mGX9Aee12hdwLHLOipxjGAUxCiksDVhnbgPkMvAI09N756FiIRGNVDDGohQ2Uoids yiLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966130; x=1691570930; 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=3mXpG7RfRm8JlpAYSZCkqg1BzSErUQp+Pq7CWqY/JwI=; b=GZpmpSG1bj66c6gB7s3DXuyRGTASV6eNBFP/FgnzRb4b7RQitptZ8KwpIRxk70z3gS wkZH7CXBI7hWBAj9LafbGjN2dTdOHwzdPTcdg0jwnXbsyUqycnhLSLLCTARYawSC4PW/ 4XwbBGCv0leov7fYpLzhP98+brkEupB9q8WsvWcAdfBmHoD896unjS5uun9LLLxkF1N9 2oJSqbzOWxpLEWxLXw4UUosSOFpjn1oq5hJioJ/W+n6WmqNutOenLhquAhxsfkQ/Q9Oy yUFzkbAIB4M7Yl8UhIjvWOElc1mISmnAsP9ZxWue07FmWnYn/tu/vK8SrfsnHraqxz1I OMGw== X-Gm-Message-State: ABy/qLakl8IUrHoGQQ4DGBz0TeOO6d8W2JE9D5Rd6A7P00sI3d+cXpge Nf5VypaAvxPcPnm4xk6fdQ+U5w== X-Google-Smtp-Source: APBJJlER6reQfJykuZwjPtzbzzona963n6JmU7xtwhUp5XPbBq9g91pdWRQFRo9OIB6cc9JjfzMZDg== X-Received: by 2002:aca:f14:0:b0:3a7:8f7:62ee with SMTP id 20-20020aca0f14000000b003a708f762eemr12789666oip.12.1690966129957; Wed, 02 Aug 2023 01:48:49 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 14/24] gdbstub: Add members to identify registers to GDBFeature Date: Wed, 2 Aug 2023 17:46:02 +0900 Message-ID: <20230802084614.23619-15-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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::229; envelope-from=akihiko.odaki@daynix.com; helo=mail-oi1-x229.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: 1690966138022100002 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 d6d1c1d5c9..da4b9173a9 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 e04d6b2df7..807af0e685 100755 --- a/scripts/feature_to_c.py +++ b/scripts/feature_to_c.py @@ -50,7 +50,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: @@ -67,6 +69,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 @@ -85,6 +88,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 Wed May 15 18:43:50 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=1690966155; cv=none; d=zohomail.com; s=zohoarc; b=jt3UgHeMC1kp6ngRHpG/TCBqQNyCsgkLWc5IWc1D+EfTuotWsDV/ZnOe58RRIDAWVIojXLJnufzSzhHJseKGIZlDSX10hlLOu+JztEM4zP84KdJm38hzB10Mvy5wapBi49pMWr3RLeB09WctU0F3wkvP7ls7bh6E2mLwbIhxewE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966155; 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=GQjbuIu6eC+Bc1GFtVu1ZMTIlDnO0WlkwYXe/N3RZibYBMAjjD2MKNVw3P0zmAPKUvuylUmNJfGdTW9fyAklowrj2RpMD+0xibUaHbmWgjzdyxUlETgj1D/TX4smjf4E038304zfD+lU/r300MByIn0Pa3cJjeCn2DRMUxpxRXM= 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 1690966155155136.46538475219756; Wed, 2 Aug 2023 01:49:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7XU-0005U2-KG; Wed, 02 Aug 2023 04:49:04 -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 1qR7XT-0005NO-2u for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:49:03 -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 1qR7XR-0007BI-3J for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:49:02 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-686f1240a22so6002108b3a.0 for ; Wed, 02 Aug 2023 01:49:00 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966140; x=1691570940; 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=I9d6y7L17EfUytj96v5S19LRy/CQ6SU7inX25mzQgjzhAp3moNUahFdWKqDTfyCdyy 43GZoxBHpqNnOIXlM7HwGjkd0OU1vhETOpiODnPgGPH2nkPYJ6T26MvEv6C4RO/vsqNc 5cZnK+USTMsY378w3rI6O9vS83dagBxbUAuE8a2xbEUt1fIZ5lwPtsACFg5d6O1sM/em BswCKAhGOGYnxijAapdXIcH2m9CGemD0JyaXMzL49YY9rlFNrq7FLPO795hpPZ9nKE47 IGSkEguuouMLkg7NcrgC621AMvlm6CxrUvM5wChmVk8EKxdW+MswD34au3Vf/j8VSCj4 9kiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966140; x=1691570940; 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=HDqn/meb7NXzPWN+CSnYIxf8pFkMar4mK7+UvaFZfbT1hIpJYVAWXN6hSp+eaPsut+ xoCsc4LYSfJZwRlwyqjIWBbxJwFaCQJydhjK9alUUdFXgxIpeExVGtPvdNQYDrVpcIMO nVyz6dHvAPS/FvCg0ps0JE29Jr9MOp6brof9gvRxMFMUqGgBb9WClVsDBaY5MvfcAZaW azskzEk0a+pcx3hBffdkE4ejCxkAnCw7ZumLzFeJuNcImRhMSJ7Cjxr5AHY54KRf7OuV nD+IW2JjvqBDNPgsncXseNPYC5is/pP8tzKpYof9r0NsM49wfTXAz+6y3FgYYs3lyu0b bE/g== X-Gm-Message-State: ABy/qLZF7zhSMUMjcpt7e0YQ7ql0STy8TY5nJNY5u4n9zFGAVXedxAgG NmS1ekblBES4aonb88DItt9RGg== X-Google-Smtp-Source: APBJJlHA8kBTXnSW5YBX55gXyLrdeEM777duI6lt/h359/3N7WEXi+2k5C8a3eQTg+fSHu3N0eflgA== X-Received: by 2002:a05:6a21:3b4a:b0:135:4527:efe4 with SMTP id zy10-20020a056a213b4a00b001354527efe4mr16329600pzb.10.1690966140004; Wed, 02 Aug 2023 01:49:00 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 15/24] target/arm: Fill new members of GDBFeature Date: Wed, 2 Aug 2023 17:46:03 +0900 Message-ID: <20230802084614.23619-16-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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: 1690966156073100005 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 Wed May 15 18:43:50 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=1690966196; cv=none; d=zohomail.com; s=zohoarc; b=GWIrCbipu8Mt4sueZtx1p75cOigblWFia8QwTYf/lsKu5S0Zhd0GaNNnh0OLIV+0SonPzVWYDgAzkNWTfa4zNlk0ao5fh22C77vTeI8OZSpylpZWuW4NFC243VuovBfzxYIR4prRkbEM9XDNR4DDXcmUTnfud6iFiKYZm6Vgaos= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966196; 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=ShuKEKRZhVBD+lwuPB3GUSV0qga6QoxeKkhRvF/a03CVYLpvwF5dtx3aniOvtqPc3iQ2vw51WpTSaq5EX+4IqzlRMdff2RWbS9VRIhXFij//ouWc9aiQ58a+ArUUhOJz7jc8tX5DHvUtCcCaaHwpT1J4rca280hzgTfQgG2o6+Y= 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 1690966196189672.3000516724069; Wed, 2 Aug 2023 01:49:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7Xg-0006PC-4D; Wed, 02 Aug 2023 04:49:16 -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 1qR7Xd-0006CQ-9O for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:49:13 -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 1qR7Xa-0007Vm-FC for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:49:12 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-686f94328a4so487807b3a.0 for ; Wed, 02 Aug 2023 01:49:10 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.49.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:49:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966149; x=1691570949; 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=32iKauRLm81dMdupNHGvMeT0jcPCTs2ygcH6qGMBFC/EttM1MJZitTxUaJtFLsCECS nDjDMQ9PhulSU3lH/qEOj+I7DcwiunIKOlu5ogkiUbJYpBRy5Vn1B8LIINuz5Wdt51+r N9f/c++u7xCtFn2Z8aOZASMRn1+LaEttNIb/CVT2lg3jSpmuKvYMDW6a55ILoh4JYXda tOxozn4pLEwGIk71uMj2x9YC3KuDsdOAOe92R5uwwMybzGZgQoz3BMIFzooYwPbTX+Qn 0vAY8AazAOtizEqZsEfOlefKV8N+Ucs6taGYeOvY+Ue+A0R2oCo3/IOT4OHbAlso2A7u TUzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966149; x=1691570949; 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=cDjsz76udDezOfgRSXD1jQ7JVYSrdZjKdcQ4ZgdA/FjbvDtt8GJcZnh9K4cjnyCu84 56R2yAx0DwNvWLFRhz5T/2j/qDCeqilgtdHKcQjyj8DTQMzKtD+1D1C6sHph4pPjeYh+ 78wRTSwjAuk8ntvgn+WFRMGF7IV4ebhS9gRQTM8Cix1prW3hJXCaQIeu6CgkPDXG3Pbn T5Q9bh4KC6K3FeOGK6tkxKlnUbcgGxLFhTfWBNnLCRl/LR9d/65M7y85OyZoFbAIEVs0 wOa+QkhMGgvNz9sdL9TjtmqSThSr0tIgoA6VY9gFceADqYUr8vyxU/m6L6KdL75ydHwI HPPA== X-Gm-Message-State: ABy/qLYrEm9QslmI8QR2JAEPZq0qblJ9pBepAfQeqEqajP2u1rqt2/t6 a9JeS36xbU7jrrSvExc/CY8rvA== X-Google-Smtp-Source: APBJJlHOTYRm37ZBlokXGWWoGIFh/LaeDtcj+HzwoToZ0gPsZdSfjpIdmRQWrLaDADrsY5eJUpsINA== X-Received: by 2002:a05:6a00:1f0f:b0:67a:72d5:3365 with SMTP id be15-20020a056a001f0f00b0067a72d53365mr16066677pfb.6.1690966149354; Wed, 02 Aug 2023 01:49:09 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 16/24] target/ppc: Fill new members of GDBFeature Date: Wed, 2 Aug 2023 17:46:04 +0900 Message-ID: <20230802084614.23619-17-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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: 1690966198323100003 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 Wed May 15 18:43:50 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=1690966278; cv=none; d=zohomail.com; s=zohoarc; b=g1nl5dthHlHcG/e/30n6nDqRFcb4mgFjcq8r7Ny7ynmvL4dk8IoE5tubvFiJnGeJWVIAYvdN1NzaGx3D31RbYGMjHXr2Gt1vs2l96sIr5sU08WmAV9DTxjDRwUBNLfR83yCicmPtA2k8pgO8XlFbNB9iGEMIvCeATVaQGCFOkqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966278; 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=K/vJtPtrV0yDepP+qsXS4NKN0HZ9eaXTlY4W5kcrXuj46JjWh7YjiEl7lfcdxVqmRAcCp/+G+G4a/pzoJ82XG+yymnG6I/WwEX8ZpNtAjf07Xyq6Rwd/F/3pnDgJDu+b6GwsZPKmc+Hr7dONisjFDGiAGpN9EhFgfTFSODEWeFg= 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 1690966278479337.95489061073783; Wed, 2 Aug 2023 01:51:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7Xv-0007Nw-8g; Wed, 02 Aug 2023 04:49:31 -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 1qR7Xm-000714-TE for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:49:23 -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 1qR7Xk-0008C9-02 for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:49:22 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-686b9920362so4713820b3a.1 for ; Wed, 02 Aug 2023 01:49:19 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:49:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966159; x=1691570959; 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=zPbHPJIK6FiXB+zkQYrl1p4vc47YNlZwx4dsVHkLtpH8gEsibkyaoAcPHCP7E+T81T L3p3hXRqqnwTNsn2Pugvt7W/sFitJomOKLBDXYmmtHA/HiLTWRUO7efyYkY0+vOV9Swl l5emdPACZeKr4XDUOKY8Ez3rFXfKMMR7GMj+GgyFI1cWRk0u2qfBMlNbSE144AyGWYaY r8tS0Bmi0IopraG2dAQ0/jYX4fF+aWFo+vnbVkI665YKC/B9eZhuDFZ2IwpWN4PdpgdT V1EoHZcEvKsL/thbLXSUVr7N+8vvXvmuTGaLrFpKVQe5P01KiI0RnDlY8YE7hlI6L4qg r4fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966159; x=1691570959; 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=Im0a8N5ta8h4pzH8iW5nEvgoTyTTwkyGXXf26dq/VXHmae1jVoNHi/w0rKA3sVw1Kx T4HbG6MN31vUu7CE3C+6R6dvRbEk37NIseLgWr9+w2QZFRGIQwqMQZ1ppm9wSZbYS8bj PHpB52wsmE/QVMMnzpSBkjmBzhSYfjhEXuv0g0ziSvQPwmR94Byc8Pa8nRYcDajh9UwS 7Mg0uKrJM8wsJaQs1nQ7M9mQuihIB7aT71KzDu4+dCsSfh7X7br9WqZtOGhU7xsm0h0j sq93+I9H+j8FGrl3OsYavdkTQ+1Yu4RwWZA0gVmyffbj7t3crTtdKYWJ8p8tGIjII2Qd clsQ== X-Gm-Message-State: ABy/qLaqDtrkvkULa8Ppqc6rx8ybNV2Ts28LMisgb+qviOnHs4dLKPUT E9jPCV7L23V2aZITkR1KacpS6A== X-Google-Smtp-Source: APBJJlFs/0Lyyo2poP1hVg2sI/C2SNqfz80TTITgo28IlbyxFxJl+qWlt1UT3L35LNW+0usyWMJOJA== X-Received: by 2002:a05:6a20:5526:b0:137:3803:33c with SMTP id ko38-20020a056a20552600b001373803033cmr13298373pzb.54.1690966158768; Wed, 02 Aug 2023 01:49:18 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 17/24] target/riscv: Fill new members of GDBFeature Date: Wed, 2 Aug 2023 17:46:05 +0900 Message-ID: <20230802084614.23619-18-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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: 1690966280058100005 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 Wed May 15 18:43:50 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=1690966200; cv=none; d=zohomail.com; s=zohoarc; b=mQha+V//A2pxAYpbRKh9pUQUQPuALa/cKi5hCn77p1Q5DKoA8P8/0K4tmikF/RIA7lzVtAAfiW02ZxkIiBBOBZNBscoR8MmFQLWZIgKxGjqPcWKXpG+p+SvJ+wNaFmVVCv6bOWZK/7DhRj8wnaijE8BJ8Z2Y3KY2lwVSYcT38NY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966200; 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=yjvQDe2b+YgBASgDnFbtEHw5GS6qkoh6PD3E7sO/27M=; b=eKfsxA+1kHITh6jxUtMMai6A6LKPUKh9cT15OELWti3GVPLRKT0yAQ6d1P25+UBhh+yDUdQ2DRbQh8Fm0AV3upIFbaicFItRgVXRp75qAClb+niPKLuECwxmcxBHZKmPd3seQj/3sS6gTFoyNmgKu0Fgd8M40dx3OMd0ymJbGj8= 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 1690966199986436.0085762945462; Wed, 2 Aug 2023 01:49:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7Y5-0000YT-1S; Wed, 02 Aug 2023 04:49:41 -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 1qR7Y2-0000H8-V2 for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:49:38 -0400 Received: from mail-oo1-xc35.google.com ([2607:f8b0:4864:20::c35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qR7Xu-0000Ap-Mx for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:49:38 -0400 Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-56ca9a337caso2052449eaf.1 for ; Wed, 02 Aug 2023 01:49:29 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.49.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:49:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966168; x=1691570968; 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=yjvQDe2b+YgBASgDnFbtEHw5GS6qkoh6PD3E7sO/27M=; b=IbMBUT1hX3yJoM+MVTBXLAisKFdsPH2XOlflYVD7CFpuA/bJzfcbg0b0OHBgYFNbER hgJ0w4NWJ1dQ4aNkDr58zgM3FyhzVUz7MQq79WA25b/7hvTEqSPX7fl+xW/baH+mmQte hOi1SNnNiDMSZimRi2zIvMmkv7tpDoSqBNvXNC97JqaVPe7veL0QW6LwMgdlJiZxcht2 v63/4RzGBFPEOWcxu5phhTJuFLv75UtN5jF0MxzDbXTzfmCFaevYPmdKFRh5mKOYvsnN cC0HROJNmbtUjiBXFSsHVqWflbuFUEj8oOBhaFWsw3UaKvGyhRtYho7of/en2mFV/jaq XS7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966168; x=1691570968; 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=yjvQDe2b+YgBASgDnFbtEHw5GS6qkoh6PD3E7sO/27M=; b=hHcvHIASOHs/HJd+aIx/HbZa8D1jlR5g7slKzo5SoIAAXCoBTpmQ0mo4wQ0i1HBxRD 2jhcJ64fqyciqvr+pRjV5Lpm65XMAPilwHcMLwXd3cS4JOhNIzWazCZaA/CDKxL4ybLO 6OTQCbxHPgq2h575xiD9c6MH6xOtCVxN7ZP8cs1DWbpvOO+b9f0xtKvZ0xrXPMk9gStO jS6oROGn8LyJnlWe4ojaHB9ncb2VnOLctryF3AQYxiUMrkCiwvONVHvwCRMQCyJ8WjY7 K7Xiw/jGn75Tpb7NnP/EmOfZ+ltUMdnlbr3nn0vSV6PMzG1mFDSaJEh9UvhaLdceUpi+ kN8A== X-Gm-Message-State: ABy/qLaC51VFunBy4XfeEmnySOgJmazSmTD9I4aIHw52TKkHlNQtv6vH xq9auUPp5r29LBfXzvbNeVIdAQ== X-Google-Smtp-Source: APBJJlH+3IlZocuW1L0dWvAcqtjNLM67z8T/WtUvRCzwWrJeAFXA+Sy+o1+QNVwfj2iR7N5WD8dErA== X-Received: by 2002:a05:6808:2a7b:b0:3a7:55b3:85ee with SMTP id fu27-20020a0568082a7b00b003a755b385eemr1659073oib.6.1690966168444; Wed, 02 Aug 2023 01:49:28 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 18/24] hw/core/cpu: Add a parameter to gdb_read_register/gdb_write_register Date: Wed, 2 Aug 2023 17:46:06 +0900 Message-ID: <20230802084614.23619-19-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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::c35; envelope-from=akihiko.odaki@daynix.com; helo=mail-oo1-xc35.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: 1690966201642100003 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 9955f996ac..8e0c85d7b0 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 Wed May 15 18:43:50 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=1690966270; cv=none; d=zohomail.com; s=zohoarc; b=nWvTnynih7+sxNwRynGXdCR+wPC1bH6c+19fvif4ON/Fv4Ml6wDgutsId12gcEyQMMNWCQu7Jm5BjVEQJ+g4pSnB16eFAfiqYtma2srUJQw+VMf2a/N8FG6AMKdWcSdkeOiLiNVNdX4+gCGKRbJkRJX7pbQBWp/3BJXgC7cKgEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966270; 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=+UF5S4BAA/eK+ZwqrbbvWnZLqcwv53M7+DITdN+nup4=; b=cecu4p689MAm6SAKfd4Liuj2fX2VkMTjfwCLdesKZdylpZAEGQggmM6PneTyRJzVuWqlPlXow8eBG/8Bz6xL6HLJLfFtpSIIRGWmUO7GA3IlDIh70vAC8GOiGdVd/mLf9xKCKzlkOS1NsXv3ThQ+SARi8XYWYG78CO9aSpsXRAE= 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 1690966270673359.6051691464462; Wed, 2 Aug 2023 01:51:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7Y7-0000zW-9h; Wed, 02 Aug 2023 04:49: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 1qR7Y5-0000i8-Pw for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:49:41 -0400 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qR7Y2-0000DC-TO for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:49:41 -0400 Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3a751d2e6ecso1084838b6e.0 for ; Wed, 02 Aug 2023 01:49:38 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:49:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966178; x=1691570978; 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=+UF5S4BAA/eK+ZwqrbbvWnZLqcwv53M7+DITdN+nup4=; b=YYYPirH24uWg7w/+2GQEt8PnEr6ndcrCwToWcTIylCL9ZOFMATdIBokhxiHySCpdnN u4FKHg02k6fsXM1xvYzyW9kPI4tS8AXV0dw8h37LBZnNzZ5EeHBoIf3YMdXFBcaTMS6r tgikHOvTAQFlc52x/SL3B3Ls6SHknMjm9wSkrvJS2oX51+lXJtOMzZ1sAyR92LpSac9a wXyh5Bj+rvYyHHW2sH7ZzsrT8gvzb066JznuyiSRGkzFz6WcJDkzgEtGkWEjuv74MTO5 IVFJGu9tP6PjsjmuQPAtqGmZIPJ7zO7MtZHaOI3D8TzyqYEQLgdmfiVf3W3U217k4US9 qS/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966178; x=1691570978; 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=+UF5S4BAA/eK+ZwqrbbvWnZLqcwv53M7+DITdN+nup4=; b=VntyStjRYttp5RLX0LdO3LKP8+TQd/GCZS/EaMUwj7DDIa55AetgyhNufKukRyU8og YDb+mZKWiDAkqqShnFlliKnv8caxk+zLC8H6332BMgFE2NiGReOVxI0XJ4gPZNToPrtf JL8bMoexSAC2Xrzp8/BpI7lBoYW0z1QmkFGwn6aKyTrzphIdFbUXUpJMtLGNyxM4miXZ b8nbVPhKiXPeqiNacG+Xo24bNiY+9gVyrmPYvOpFw5/hSgFrvBjlcerA4BywHS2AVEUA bsW8yvfgR/YCedC/16sdyeZ+Tb+qch56qQspT9QgEQqCmxRwD1nVl7rwSXv3uvcXQu+o KgVw== X-Gm-Message-State: ABy/qLb8Nv9/QgZDWnMUg4Jo+wCNiV0jywV0UsRGHNlzSZMPuG5I49wp FDuA31FR0YC6F4zo3y3Cts6sDQ== X-Google-Smtp-Source: APBJJlFrQBDzH2I3mg74KwFQ0Q8QnXZRyBTfiWFR68SVT7RXFCg1IlIPcfLorCZvXM+RBFRLS3jDnQ== X-Received: by 2002:a05:6808:148e:b0:3a3:613b:2787 with SMTP id e14-20020a056808148e00b003a3613b2787mr19582390oiw.32.1690966177903; Wed, 02 Aug 2023 01:49:37 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 19/24] gdbstub: Hide gdb_has_xml Date: Wed, 2 Aug 2023 17:46:07 +0900 Message-ID: <20230802084614.23619-20-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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::22a; envelope-from=akihiko.odaki@daynix.com; helo=mail-oi1-x22a.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: 1690966272953100007 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 da4b9173a9..aafbea78ab 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_static_features[]; =20 --=20 2.41.0 From nobody Wed May 15 18:43:50 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=1690966216; cv=none; d=zohomail.com; s=zohoarc; b=kn3wqSdXpr9qhaRy7z3OiDAQ0ji0RDluuxWAmZQqLGNXglqqXb316EywW5M+E0o99I1FWUOq4VFlAxjNmO6dZgpca5bg0VqYgOUqvmHpgcNMrPob9GzlY1gNmQMO/DAjkLbUDEkcGoYzfFwVKHn+8j7AVNbZ3bYD3bAkTKql9Yc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966216; 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=b1wI6pbT+UOvNduKCMCkfq23k895sVylyUMgvMoltAI=; b=DZxTuU9zxall8louhVM/pLpLRxWmRFjfOn7gdgECTaOHabnvFGuh7bhyPIHtaCjNEcWXU628Zye0Z4Khb+QrXXo1Oz3mVnhJ3HfcogEHa1/rgK4dQ5dK8jAKVl+o9KS2zsgEB1kaa4n2gwSro+OFleWZIh03Xg2NvigsgG5xhSY= 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 1690966216926524.4745709726683; Wed, 2 Aug 2023 01:50:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7YH-0001kE-NZ; Wed, 02 Aug 2023 04:49: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 1qR7YF-0001dm-RS for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:49:51 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qR7YC-0000FP-My for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:49:51 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-686efdeabaeso4415060b3a.3 for ; Wed, 02 Aug 2023 01:49:48 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966187; x=1691570987; 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=b1wI6pbT+UOvNduKCMCkfq23k895sVylyUMgvMoltAI=; b=i7IvH2YNE7Fbek3+xcRbwdyMf+UMhgDfWnFXIqDtHy9An+D9BuS6csAdsYfmvZMovp s3CZsvzqvZtMGUxO3MooQ3U8oiwe7IyIlAIS0rxInvVxc38L6tmYwRAurNPUA2cetf0N spcomepRsHP7/5mIi+CQxxra5sBZjMbvCl+EyfJA5Qk4kfn8VUQYlFVS3YLpk3MB2AqG 8eAj1zUHNkPZ/glsl5+nT5n5P0m804GfhEk2scyRZK6xLByYl1whMJIwmBW5WhbX2SpY Ggc8jajpPLrZV+rOvwJ/mmYX+aXIMqWx+zS93qwB+QFpdXrrLQvIoys5KzbRa/ky5uSm sOyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966187; x=1691570987; 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=b1wI6pbT+UOvNduKCMCkfq23k895sVylyUMgvMoltAI=; b=D2RctCJbVfrV9u8D7mAUOh9zGTtiHigKXpDi+oAZXj0aMaDGrHzVDb2mRVqFnw0Nit vRXhOLYd0Iiy/BkPYa6dNKNAnSKSOXlfoFBJVtxPhs5V4KX5O4bFwxVJytBfHhiPhFTg aIP+JKx/jSaEKdTnFSg3uJbr7Vv8lHHihZB4QFPIbkqWIbYG00BXxmeT47Hu5hUULDJA vtUemF/vyeMhssFti5Ry1uqjI79PclI089kkF80k/Vq8tMSDVCKzAWVdLNe3avxdBKiP GJ6X3Te5/AlZ+YnNeiOh46CmJYa1O1cWPBnI9mF3yoiHmd+46Ad/8IPem8fB+tmwcX5f +lXg== X-Gm-Message-State: ABy/qLbfeHdQpOUoCDAQDN3fAQGXQQN7cOHY8KWCIGI5WtKJL6zP2ZmS xCuYl6KAAQxuBSS1ZTuKNSFvmg== X-Google-Smtp-Source: APBJJlHs2gxFhAzibAywGj6CvASC/9SoxfmpCfsJv3DymHVWtTmAN7gtXGM6Bwq8kInKr4phCH8C8Q== X-Received: by 2002:a05:6a00:390f:b0:682:4de1:adcc with SMTP id fh15-20020a056a00390f00b006824de1adccmr15775059pfb.12.1690966187524; Wed, 02 Aug 2023 01:49:47 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 20/24] gdbstub: Expose functions to read registers Date: Wed, 2 Aug 2023 17:46:08 +0900 Message-ID: <20230802084614.23619-21-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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::42e; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42e.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: 1690966217704100001 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 aafbea78ab..86fc0c46f4 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 8e0c85d7b0..aa165111db 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 Wed May 15 18:43:50 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=1690966282; cv=none; d=zohomail.com; s=zohoarc; b=XA/YdtO0wFG7oxbkvkbPaEDUMWTpM0es1h3pt9PQ1mvH9GKsjxMksSZREM6iDfk11zcQcXWddb5LPRT/gu+jcL8IZNjITdOOU4cYp+yPbcJSTWL4E1lLJIucippwHHbce/7EadO5K4KUlCT5duTOq9LOHlMe+1rJNtjCiJZCGdo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966282; 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=mfIfeQaWJxnPxlVo3FqUH9rpNdT3zJyqvDQZ+p6vZ28=; b=QxVOM669nRNCWA5EsQWrII8Nc7mXfchFYLYTiynU0FNx0t+DHacx4ihmQXqZzJ7nfnF3AkAKtTVELPMy+ry7BUni7jL6V8utNQT9RGyfFKkbfnUJfTae5NcC1PnsmFb49Gpmt1xKtYo0tabSvFd61D8t611Iitng1SOF7hBw/aQ= 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 1690966282892588.5502132542758; Wed, 2 Aug 2023 01:51:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7YS-0002lC-PZ; Wed, 02 Aug 2023 04:50:04 -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 1qR7YQ-0002Sg-LY for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:50:02 -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 1qR7YM-0000HY-8Y for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:50:02 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-686efb9ee0cso6345707b3a.3 for ; Wed, 02 Aug 2023 01:49:57 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.49.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:49:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966197; x=1691570997; 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=mfIfeQaWJxnPxlVo3FqUH9rpNdT3zJyqvDQZ+p6vZ28=; b=oxIsKd3b0mKv/An/9BI/xVIplHD4gnHI9aDAI3Sv9qeRG4zDDcHmuoQO0Q5HOP2fVz P/mrjpwWwyXyAMrxgSx6fzxRhJNOeqe6cM77A72pDvc5mZHRCj6PV0QzKQ0QNNCVuxvL bN1yfOPwXQXZZNirYivOmTTlD2J5FCicF0ZQZSvBOEWWhxbuf9kMf/IrI4jowgT291Vp +NUT7bNR9lI9KTOXrDeLl8K9yKCnDtRA60E9LrhHuSsJjHhs3bEeqoR10mJuMxULyc1W uiCnyGUozyF1EQ5ytelUc2d6Phk54nHXs0WXuRFMYJoLu3/nyMosFTs6Z4e2uBWGJWD4 7XvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966197; x=1691570997; 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=mfIfeQaWJxnPxlVo3FqUH9rpNdT3zJyqvDQZ+p6vZ28=; b=fkopIDbcCtG+1RTtg/9NnuKS9/ZFkeiHGAEPjKyILS5pedjcmGFXCSiRDR5zHuw031 JTDlijltGJs8AVsDUY06/BPBjgWLvW0EvI2YPhxuhlIaBJl+untFvI5WAeeTwhlxMr4u EVZ7NWeB0AyyZRQi20/uA1GbU6rwybjQ7hecIgT82vi0ta3Rdpxqg/AqwWBtZCWZ7woQ B2gW3ttrcXCfX+zuZHIT/5Buwdkcs4c/U8wwZqWU6ci+oeomuo/RXsfe6aj6czwtbzRj euBa5ZM3TWohsZUPFQqOycAFm0J7sk/B4yW1C6oxHX+h2s/sAN9+MLtOoqf0/qBrwgOH 9pIQ== X-Gm-Message-State: ABy/qLZ7Ww1+aIo3SZZnE/BxZtgxcE+vMfzEo3SZdr/B+LWW3+xMLaOM WGDak3wQUf2+X0dxqqz7MYEzvw== X-Google-Smtp-Source: APBJJlHy8SEY12BHWlQDHfGBH7m0AWrju65mWCO8TNxFTeolKNPjwm8lznyCbrEMQYCdPOryP5UuSQ== X-Received: by 2002:a05:6a00:1795:b0:64d:46b2:9a58 with SMTP id s21-20020a056a00179500b0064d46b29a58mr18867563pfg.26.1690966197043; Wed, 02 Aug 2023 01:49:57 -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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 21/24] plugins: Allow to read registers Date: Wed, 2 Aug 2023 17:46:09 +0900 Message-ID: <20230802084614.23619-22-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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: 1690966284877100003 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. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1706 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 Wed May 15 18:43:50 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=1690966285; cv=none; d=zohomail.com; s=zohoarc; b=GitX8KISS/V0ECxoHGagAPRRmk1fX4xVmGFhCxCxHY72M+nd7nXiHSFzO0VSNRjt9zl3cgSo51/2g9HdHfYZNwdo7gabaSlTgOayB0cpjP+ifpTJXSG5WnsaIsxPgmiSMQLMejnGNNjnlb57pOox+lOia4x9LjoSjNKMfNOqta4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966285; 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=igHnC3fClfV2pCR6TDNyHrB3Amz8lQCymrvjNa1q8SdXHSI/2tvYtEdUJ+e6ZyTnIIuwB3UvYzzu9nf6lOnzuk6LXplzGuTRE3jaIKpBLc6pCN0bZ7UfvdIE54mlAX78GgSkGxMhq4xAvSLWx2w2xO+KN1NyJbdvs40zmWtFjAQ= 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 1690966285446769.3491389552137; Wed, 2 Aug 2023 01:51:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7Yd-00040I-Pp; Wed, 02 Aug 2023 04:50:15 -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 1qR7Yb-0003n5-NX for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:50:13 -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 1qR7YX-0000Z9-Cy for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:50:13 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-686ba29ccb1so478966b3a.1 for ; Wed, 02 Aug 2023 01:50:08 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966207; x=1691571007; 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=EsBUBuCR0S4RhEpI2lo1HRKWkjsztQCFEY2V0Zi2etZuY9bE8UqSuf9FKb3JfK0RH3 fdP6AofXO8C4X4rEC/af1ZN2MEniRKql5q7cfVVIObHwmPU452I+23vzvsKWXI+l3Pmb eHWSo8i80v/ur5RupSrxk2zBxtI9y8qArjKfSpzyLXCy+0GzIljOlrXRfQjg+uQ7rvkj 0vgy2B6ndvBtlK/Nwpw8+v6lL4v0xRG2rnlNrAgG0GNj7UEzbK10fV+jCEWTd74YE8hf v+JBH0JQ0ntaY4Ke7+rrrFhfDMjjLpqtfoHpJ5O9DZvmMYaMvx3PmJJdv7aVCQ/7cqKB PBIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966207; x=1691571007; 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=Lzg/6BEGA2xy5L3bRQWum8VUQhCORBLSf9ZxhYCzKiy8d5N2GPNlfXVqBwsc83WmeM MfdiJnV9149SXqyjXKdrqmSPwTm+M1fBURqEnIyFjjfTdwVjpTZ2J7u4YPMQOLbzDFLb dDowFKe/D4RBJahphhiSZ7Uk2WOkE1LFVof+1ly1SsiKo9X0LG/LyulOAvEp+/bVrRRX Iqh4kVzZfMIxeiSoZRlm+e44o4oA2/6mJXf+dBVGIv7FXXAw1CkxTnIcu95SlNECN/n8 j0vghkoRzFkyxYN7f2mH3DLHH3My96Wa0+RA4opjIen2EYZzPik190NuNrJfVRfryVe+ vHbA== X-Gm-Message-State: ABy/qLYgOvsvSyAPPfycVJajo1u+iyIifqm0J0W6Ij2a6ieUC8skv2Ad ZGUcCCHcLLCTt31YSj1gnfw+1A== X-Google-Smtp-Source: APBJJlEGoPx4uVJ2v8p8ALkAYuDoR6HCD2Gx0IPmrd1EGhSec+muAQP1Q8gGudB5AwHAIy/XtvygnQ== X-Received: by 2002:a05:6a21:6da5:b0:134:73f6:5832 with SMTP id wl37-20020a056a216da500b0013473f65832mr20217917pzb.16.1690966207669; Wed, 02 Aug 2023 01:50: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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 22/24] contrib/plugins: Allow to log registers Date: Wed, 2 Aug 2023 17:46:10 +0900 Message-ID: <20230802084614.23619-23-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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: 1690966287076100001 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 Wed May 15 18:43:50 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=1690966264; cv=none; d=zohomail.com; s=zohoarc; b=NZ+Ps5vNh+oRPwcoMk38v/42Z1RlRG8yOjuFVH83tyoKkieEy2LfHFVC5YUdy7ZIIfDeyAxnE6UZrGDJAs1ThMr3Du9obyDOO+v5QzaEu6/hLIFGoIkxa6vVJqFRy5g2sNVnVcx4akaCeloWEokOyJEfLaayE86zrVOGuz3YZJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966264; 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=Clu1frJeQylRuZDcRNFaPeH7OEh0wp2JdFxM9dTBVuC7LGahffaoxWS4AXyKfaodi4ZifjYkvgBxNEXGjdZeZOtkPMNpZbHAx0q289Snmqv10T6J/qIGLmrqu6BSG4fqOD4cvI9Xeh/5lAzfKMNNHagQ7y96KsZ4H0+/jqGDN0s= 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 1690966264231709.8245338794741; Wed, 2 Aug 2023 01:51:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7Yq-0004uq-G2; Wed, 02 Aug 2023 04:50:28 -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 1qR7Yj-0004kc-74 for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:50:22 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qR7Yg-0000dG-C3 for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:50:20 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-686b9920362so4714452b3a.1 for ; Wed, 02 Aug 2023 01:50:17 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.50.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966217; x=1691571017; 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=n64321uiEYqMxpwq+YPMHlejbTIDDAtsGHUU9HQt/tRzKERlAQH5pAl3jyaN9mBtxo NZpbwZr5VzWAk+NOAsFMWztzHWEcqh6omALyQrV/a2PIzPQM6yS5vADVB6tbr7LrPWj8 gdPuiDzSODq7YCzU/Tzi2aydzbnUKWWidoPGNBx+U5kGC+5aE9NtNB6KUQ9470TCLUan vRhdz18glsozpm3n6zS+1lAAM/m9Zc/z7+nDcSmQGSLCvdfHIUSXCwR2WD5gws7GH8KX 266iQ6ybkPE9LPUJNNWKRojbPN7oZguGzooZYUYsiwZjmw0CzGSepZFEZAcseNqCwexB MQyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966217; x=1691571017; 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=CZOerlS8XDN1VD7NW7rViddpCoLCGaMNVdqed/oDDbM0h0ZSgDXY6OAKhZlE335C4E FlHWeqlbUwygv7tfRH4OFzkQDN1JU0Dv+OaJrFbUb9VuR/hNrPUhVEL3Y/QwTn4mOsB2 Sk0nTb9aEPfe3MHun1I4wtNqoqG1LSwML3TZDVg2jY0OpjD9kOy9P2OE0A2XlvR7MqeT DaMsr0LFEMs80FKskL4Xx0pzfH+45FIGdsLhVZCHauRu+sqPBuIeslhZVB1kpWKOI1HY ed/JF19nCpcWt2ayp5t++jXrZLfXvLpdmjOH7i8SXuLJvdOYeHX9xJWTc0o99ZaaVQpY I/Og== X-Gm-Message-State: ABy/qLYkBSStCb2QrsLBLCqnpsdGsfbApjJYN6/M4839jWnnSKOMaBYL ScSYOTYMtP9D3C/Ul7p+lAkuEw== X-Google-Smtp-Source: APBJJlEvPSLRRm2xJjIsvRMcJDpt21CYiEG6/gmSf1umI+nX8s8y9EC2IUL3JXw3sPALcyMOgzSphQ== X-Received: by 2002:a05:6a21:7185:b0:137:2f8c:fab0 with SMTP id wq5-20020a056a21718500b001372f8cfab0mr14147444pzb.49.1690966217220; Wed, 02 Aug 2023 01:50: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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 23/24] plugins: Support C++ Date: Wed, 2 Aug 2023 17:46:11 +0900 Message-ID: <20230802084614.23619-24-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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::435; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x435.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: 1690966264570100001 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 Wed May 15 18:43:50 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=1690966270; cv=none; d=zohomail.com; s=zohoarc; b=P+ICI16qU8AE52JfiTm4tfoaSKoria00iDziz56yA7wgo5f4bb76DZ7dfh8h/wYmSgDy9l00e0KOgSQSQhHqU1uv+gSlSozQuFVGQio9QXIpGGhZii2q6NCw3N/DPxrCMu2m21Zm44aH5Y6mWp/pqe/IPlBWxqBoZvqhWlIQHpA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690966270; 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=kNR+2DDMQySc8psqEDhnZbBav2KTV36MZCBGyLQQO2o=; b=R1amL2BwnnQjrSKryjRBBuqRBy2zIiaeipvS9AWOLZMb15yL8VfBtabVf3kT3NVzgbGlkSreNyI8qzpoIfMdRMWlfaFiHTd+8CFXb8NvfQhUbggfOQTQ8Ws3TAp0x17axZcbp+qdFmFO+Nl23s9tFdzINM466xxAtpTieAQv+lc= 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 1690966270185586.3059446308699; Wed, 2 Aug 2023 01:51:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qR7Yx-0005EQ-0Q; Wed, 02 Aug 2023 04:50: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 1qR7Yu-00057E-JP for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:50:32 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qR7Yq-0000jS-17 for qemu-devel@nongnu.org; Wed, 02 Aug 2023 04:50:31 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-686b9964ae2so4595411b3a.3 for ; Wed, 02 Aug 2023 01:50:27 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b00659b8313d08sm10592860pfa.78.2023.08.02.01.50.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 01:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690966227; x=1691571027; 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=kNR+2DDMQySc8psqEDhnZbBav2KTV36MZCBGyLQQO2o=; b=K3R00I0tgQEZb0otU0GHIAVYlvmecLUiB5W39EKRq4ECqfoqWkNTjCmG4zKtIpZoZh VfsG4KPhxENtsIe86jub6NeeRolk5LB9TLjyihIYhW2P65+56Ba8/TwltgAnhLzyA9P9 xGPX7FvX9WUGwemYyrLWJhYPYDCKVkw0qSWaTesj1zHl1Pj4HFb3cgPWnF7Pgwpl5s8K NpyqMiYzhBMrobxSmC6uVYD4aF/1h/joNnykcji0hmsweV4k7Fz+ZeyYelN6HWkAxkC+ 9ZegLOJACRjnrPK/TVG0NmwyITi3ttLvQ3relVP1Erynux1YurQ01HCinx6WEZzUfsF5 +MtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690966227; x=1691571027; 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=kNR+2DDMQySc8psqEDhnZbBav2KTV36MZCBGyLQQO2o=; b=YKiUE+RgZYYBTbsH6ANAUgGYiOZkYkeLkPlKBY9JIW9uHxg2e3W6gCSSwoLq4PaEER Im5uLorHEavLrrieRSHFxJW4y/eE3CJ4WUHGer0ued+wfA+aitXZYYkFLmN9/0ekR0K5 E29SRHseJQzVJzdnyM+TBkuv+z3E0QmMwG0EwgwEyF1WRfHtdvqijsEAR2Ddu384129H JX8PfF43C07elOxf1J3BJovyvnKBZAvKAiupkPUWf5CbvqWiGMw91GHUp+AfhvIkUf0o DV9E8RzHwbTrvfuFA6X1HBL76FCMyPAX1A6KwJViWax4/EFgDv+ybvZlMtX00GVDR9zv Ed/w== X-Gm-Message-State: ABy/qLbVwl6Cyxl5w6wgc8pI/HcJk0uZQs+Bl1L1OpQ1tmPUZ4jC7zSm mH0sjMZba69zMI9LhnMJYiq3Rg== X-Google-Smtp-Source: APBJJlFGHdzb68i9hkzSc4thw9evgdTiFF4LBhOLeZ9K59RBAH4Gv68G5UXefQweRnrCHWCvkNy+Sw== X-Received: by 2002:a05:6a20:840b:b0:137:514a:9835 with SMTP id c11-20020a056a20840b00b00137514a9835mr18011045pzd.9.1690966226760; Wed, 02 Aug 2023 01:50: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=20=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, Anton Kochkov , Akihiko Odaki Subject: [PATCH v2 24/24] contrib/plugins: Add cc plugin Date: Wed, 2 Aug 2023 17:46:12 +0900 Message-ID: <20230802084614.23619-25-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802084614.23619-1-akihiko.odaki@daynix.com> References: <20230802084614.23619-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::42c; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42c.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: 1690966272008100003 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 | 17 +++++++++++++++++ tests/tcg/Makefile.target | 3 +++ 5 files changed, 45 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..83a5528db0 --- /dev/null +++ b/contrib/plugins/cc.cc @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#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