From nobody Wed Feb 11 01:08:57 2026 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=1697089879; cv=none; d=zohomail.com; s=zohoarc; b=B0CvZ6pgr83p/p+YNV+RIrLIBkOZ4v/usf4DcdNtnt5otLQoWSKqP/rlHhZOHvjFkgsZKyhDzvs1QkCVMTgqegUcdQPvy1kLsi0vYyMuZ/TD8gFQrAXMU9GO9nC5B1cskI2JFebuNSSxZbv13YtWPaCDChpFTaExlNhjQr13tM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697089879; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:Message-Id:Reply-To:To; bh=gFOcxaxE00qEUA7xLO6eamS+KcZmytC9bsalAK3gbi0=; b=ZAe3gpaRnuNCVF9izYNbKBm0jlM3VwqgUuSfX2R2KreTmSMeSatQhIEu1Tr9KS2cFb6hPuy0BnVG15gonFQYT2GIktGmXv9PyQF6uJHSH8NUob6Cs6bsC2S0UGbtmAvoVabeBRVe9NtIPTl7FYzO7gZ4zJ7UOpzZIOLFh4UnbW8= 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 169708987927060.886870506205355; Wed, 11 Oct 2023 22:51:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qqoZz-0001pX-59; Thu, 12 Oct 2023 01:49: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 1qqoZs-0001kz-Fd for qemu-devel@nongnu.org; Thu, 12 Oct 2023 01:49:46 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qqoZq-00073e-FS for qemu-devel@nongnu.org; Thu, 12 Oct 2023 01:49:44 -0400 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-578b407045bso481292a12.0 for ; Wed, 11 Oct 2023 22:49:42 -0700 (PDT) Received: from localhost ([157.82.206.10]) by smtp.gmail.com with UTF8SMTPSA id ik26-20020a170902ab1a00b001bdc3768ca5sm942690plb.254.2023.10.11.22.49.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 11 Oct 2023 22:49:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1697089781; x=1697694581; darn=nongnu.org; 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=gFOcxaxE00qEUA7xLO6eamS+KcZmytC9bsalAK3gbi0=; b=j7euIgroM8plFnE77UrTESV+p5ILvAr799LqeFrzQiyOPr6tleeI6g0L8xbJngpeNb +iv8C0Ce5oOWAd1IxrpNCbP1XOvyOYXlusV5iiTWJroSm/ItY+UqJtzX9Ft9QX02xr8P ZoslcXkR72Rk5wClTsLY4BEz9OCt8/0Nfp35dhx3GPkjLa0QGti7GeGOJe6wg/w4x464 AVigEX9SCbRE1kOowXnU/SeGLBCxor7FffPUuKS6R0BqIPkADR23Hyh2VTK+516sKaUE D87ruasSdZsxUJ/HRzivJUKpvzGRcG5WJrV2j8Ri+hBfXE1qqnnnIMa958dADuruy/mO 7krQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697089781; x=1697694581; 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=gFOcxaxE00qEUA7xLO6eamS+KcZmytC9bsalAK3gbi0=; b=iDig5PMtLpFMwJE9EMXGyQgsPn1wKrmjjBWnIAL7wiTUJJ9FQ+HDBUBDBvdC+P2e13 Ae3G5XFTSez/u68O95WLGbVHgI55f+Nb+radNoPtQ9zrsv32sTLZbpEFSaCiLMQCTi5i fNmE1kasCXk0+3AtHs6YwpzL55lTnp3QZGDzeclrUdFFxQRzGmX7ExJy0qdznDzcsf9c ulJn/0p+Y/MKdSf5miyBHu3TZFt5tirVkL8ktgKpiopAES1aUEzddIR9yBnKqtXL+Clx IyMh+BFwDmP+EVPjTs1giXvOXK3PO28A5+GcRQMspxElNHNIXNDoY+I5P8lPUXxnTMzN 4ibg== X-Gm-Message-State: AOJu0YzBtCLF0qwPdadWC4EEjL4ONnJ0wvsX1aYXofZhPOOH0CPcd2b7 XuIWRiYigPYxVHiqDMoNXxrxug== X-Google-Smtp-Source: AGHT+IEHGZ6uj25Ek+oiqeP1L7+JLVig64pmfwpT1Jhrtn8QuhAJjEoKgGTf3ch/u0cRIDRTPDaGpQ== X-Received: by 2002:a05:6a21:8199:b0:174:af85:96a2 with SMTP id pd25-20020a056a21819900b00174af8596a2mr1455732pzb.35.1697089781268; Wed, 11 Oct 2023 22:49:41 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs) Subject: [PATCH v10 06/18] target/riscv: Use GDBFeature for dynamic XML Date: Thu, 12 Oct 2023 14:48:45 +0900 Message-ID: <20231012054902.38447-7-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231012054902.38447-1-akihiko.odaki@daynix.com> References: <20231012054902.38447-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::532; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x532.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 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.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1697089879974100001 Content-Type: text/plain; charset="utf-8" In preparation for a change to use GDBFeature as a parameter of gdb_register_coprocessor(), convert the internal representation of dynamic feature from plain XML to GDBFeature. Signed-off-by: Akihiko Odaki --- target/riscv/cpu.h | 5 +-- target/riscv/cpu.c | 4 +-- target/riscv/gdbstub.c | 77 ++++++++++++++++++------------------------ 3 files changed, 38 insertions(+), 48 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 83f48f9e7e..42f9bd0de4 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -23,6 +23,7 @@ #include "hw/core/cpu.h" #include "hw/registerfields.h" #include "exec/cpu-defs.h" +#include "exec/gdbstub.h" #include "qemu/cpu-float.h" #include "qom/object.h" #include "qemu/int128.h" @@ -390,8 +391,8 @@ struct ArchCPU { =20 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 02c85bf1ac..9417a5d897 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1989,9 +1989,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 b9528cef5b..b7159f1db8 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -214,13 +214,14 @@ static int riscv_gdb_set_virtual(CPURISCVState *cs, u= int8_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) { RISCVCPUClass *mcc =3D RISCV_CPU_GET_CLASS(cs); RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; - GString *s =3D g_string_new(NULL); + GDBFeatureBuilder builder; riscv_csr_predicate_fn predicate; + const char *name; int bitsize =3D 16 << mcc->misa_mxl_max; int i; =20 @@ -233,9 +234,8 @@ static int riscv_gen_dynamic_csr_xml(CPUState *cs, int = base_reg) bitsize =3D 64; } =20 - g_string_printf(s, ""); - g_string_append_printf(s, ""); - g_string_append_printf(s, ""= ); + gdb_feature_builder_init(&builder, &cpu->dyn_csr_feature, + "org.gnu.gdb.riscv.csr", "riscv-csr.xml"); =20 for (i =3D 0; i < CSR_TABLE_SIZE; i++) { if (env->priv_ver < csr_ops[i].min_priv_ver) { @@ -243,72 +243,63 @@ static int riscv_gen_dynamic_csr_xml(CPUState *cs, in= t 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); + + gdb_feature_builder_append_reg(&builder, name, bitsize, + "int", NULL); } } =20 - g_string_append_printf(s, ""); - - cpu->dyn_csr_xml =3D g_string_free(s, false); + gdb_feature_builder_end(&builder); =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) { RISCVCPU *cpu =3D RISCV_CPU(cs); - GString *s =3D g_string_new(NULL); - g_autoptr(GString) ts =3D g_string_new(""); + GDBFeatureBuilder builder; int reg_width =3D cpu->cfg.vlen; - int num_regs =3D 0; int i; =20 - g_string_printf(s, ""); - g_string_append_printf(s, "= "); - g_string_append_printf(s, ""); + gdb_feature_builder_init(&builder, &cpu->dyn_vreg_feature, + "org.gnu.gdb.riscv.vector", "riscv-vector.xml= "); =20 /* First define types and totals in a whole VL */ for (i =3D 0; i < ARRAY_SIZE(vec_lanes); i++) { int count =3D reg_width / vec_lanes[i].size; - g_string_printf(ts, "%s", vec_lanes[i].id); - g_string_append_printf(s, - "", - ts->str, vec_lanes[i].gdb_type, count); + gdb_feature_builder_append_tag( + &builder, "", + vec_lanes[i].id, vec_lanes[i].gdb_type, count); } =20 /* Define unions */ - g_string_append_printf(s, ""); + gdb_feature_builder_append_tag(&builder, ""); for (i =3D 0; i < ARRAY_SIZE(vec_lanes); i++) { - g_string_append_printf(s, "", - vec_lanes[i].suffix, - vec_lanes[i].id); + gdb_feature_builder_append_tag(&builder, + "", + vec_lanes[i].suffix, vec_lanes[i].i= d); } - g_string_append(s, ""); + gdb_feature_builder_append_tag(&builder, ""); =20 /* Define vector registers */ for (i =3D 0; i < 32; i++) { - g_string_append_printf(s, - "", - i, reg_width, base_reg++); - num_regs++; + gdb_feature_builder_append_reg(&builder, g_strdup_printf("v%d", i), + reg_width, "riscv_vector", "vector"= ); } =20 - g_string_append_printf(s, ""); + gdb_feature_builder_end(&builder); =20 - cpu->dyn_vreg_xml =3D g_string_free(s, false); - return num_regs; + return &cpu->dyn_vreg_feature; } =20 void riscv_cpu_register_gdb_regs_for_features(CPUState *cs) @@ -324,10 +315,9 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState= *cs) 32, "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_xml(cs, base_reg= ), + ricsv_gen_dynamic_vector_feature(cs)->num= _regs, "riscv-vector.xml", 0); } switch (mcc->misa_mxl_max) { @@ -347,9 +337,8 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState = *cs) } =20 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)->num_re= gs, "riscv-csr.xml", 0); } } --=20 2.42.0