From nobody Fri Nov 1 07:31:22 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709045290; cv=none; d=zohomail.com; s=zohoarc; b=DTq3c/kHFwNyKgGPOZAKHf5vs2WaBYuXZ/JXkTWODK2d+KtsfadIlrK1TeEckiGo3QNqNjIvZRrh+1Lsk0ymQsfxPvyUuuQ6Pbl/AauWubN5ovFhkzNZFOkuvib0YSDFAoYuwydQGo6wo6lMptg81ORKWVJ9DoEaFXSrooCJwIY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709045290; h=Content-Type: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:To:To:Message-Id:Reply-To; bh=hEkB87vjsQGzSl3E7O7wQIu148BX3ny3/hCUqbep6mw=; b=HtE9U64vJqxXUo7Lf43VNjfxlayveYGSXd/GFvGZ6nul4OMgqHUVwr6KXC1BHdjLRMaQQc5McKM8ElqTMU/BnC/pxgSoyC/7OlAom92v7RloEP+GaStgMZDRILfjzt/eaQWW+Yg1N7VswYJGzqRaG5ZOuH4s/bXN1UdyUUzS2h4= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709045290161763.0061571457269; Tue, 27 Feb 2024 06:48:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1reygy-00061Z-VL; Tue, 27 Feb 2024 09:44:24 -0500 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 1reygx-00060E-FJ for qemu-devel@nongnu.org; Tue, 27 Feb 2024 09:44:23 -0500 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1reygM-000225-DF for qemu-devel@nongnu.org; Tue, 27 Feb 2024 09:44:23 -0500 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2d29111272eso22071841fa.0 for ; Tue, 27 Feb 2024 06:43:45 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id w15-20020a05600c474f00b004129860d532sm11612767wmo.2.2024.02.27.06.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 06:43:40 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id DC70B5F8FE; Tue, 27 Feb 2024 14:43:35 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709045024; x=1709649824; 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=hEkB87vjsQGzSl3E7O7wQIu148BX3ny3/hCUqbep6mw=; b=VrlQ8/mJhrBnqCjNT8ZhJCoXeHBj2Y9rLsGthrCxBPsjMUGHje7ELIB5wULG58KicI 0e413uHYTSDlkhJNLKQ5A8y2DNvWh1VeMEDNa9g7NvB/aJTuCBxGSTVT6Od3+jwYIGmU XWLD2KAKWls8aYYQkspskYfp/kp8ncwIn7cWXS3KWuwz0v/S04VcMoJU2dJxZjZIEhdJ sCwEXBztFgbyoY6DhQuU2ttuwoLvrib4SQCsy4TDD4LzORpJM3f+jMV2J0jypGMNSNAP 6NPp32iY2HOurNwQBssF8XRRnkTZ40oWB5ZgL/fO8qVcUTENpMdhA0LZ5TrkvnV5/VMz PrpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709045024; x=1709649824; 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=hEkB87vjsQGzSl3E7O7wQIu148BX3ny3/hCUqbep6mw=; b=jQXATJcBeK0zKUUOlL/1Y0mWd3dq5gNCYSYccQ+gauZauY1nY0YQ1xXwCHSKy0OP2G NCKhvaIUNKzdEadQlG6IdTJv3ssl/2vFN4RkcIhL+4b2158/YUPIrn77yRYKPT79HUPO nSlEW0IK618AsnHwqoFQC2udBOQjWqGkLDP1+e5DA18L4RcKO8lrs1LNBo+gDZd0gYT0 uuEz7h1cuoiLvWIr8W+tpyJZZHl0f3iYe2U1JcBPGSLMc/e0Cv3O3fQbZPlwNBLpMpn8 g5DQjND5mTk6Jj/crHHdBnNTjVMMsp8/4Xs1GIVn36HDqtoJxNVEPA13UA9nIyw7EC8b 6IvQ== X-Gm-Message-State: AOJu0YzAxDQtSQMtaC2Ps1ZrTsruOHy0X4uRcLFbHHOzVLMsiE9lCYke eoJUo2j2h9jX5J9K6M8Mocu4cGZc0L4F4MK+G2sJzJQ4SmbtzQsvLD9L7MckPMU= X-Google-Smtp-Source: AGHT+IFETPpP6IKVGROjZ80HoeQNKA/D8ZB6fkZOqMjJ5qKcpIJrxG2/VcOzhosV2eOTfU0SAtxACg== X-Received: by 2002:a05:651c:220a:b0:2d2:4374:b71 with SMTP id y10-20020a05651c220a00b002d243740b71mr8103548ljq.11.1709045024490; Tue, 27 Feb 2024 06:43:44 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, Yoshinori Sato , qemu-arm@nongnu.org, Liu Zhiwei , Michael Rolnik , Yanan Wang , Eduardo Habkost , Wainer dos Santos Moschetta , Beraldo Leal , Cleber Rosa , David Hildenbrand , Paolo Bonzini , Peter Maydell , Song Gao , Daniel Henrique Barboza , Laurent Vivier , Warner Losh , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Ilya Leoshkevich , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-s390x@nongnu.org, Kyle Evans , Brad Smith , Nicholas Piggin , "Edgar E. Iglesias" , Pierrick Bouvier , John Snow , Alistair Francis , Richard Henderson , Brian Cain , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-riscv@nongnu.org, Bin Meng , Daniel Henrique Barboza , Weiwei Li , Marcel Apfelbaum , Palmer Dabbelt , Mahmoud Mandour , Akihiko Odaki Subject: [PATCH v4 05/29] target/arm: Use GDBFeature for dynamic XML Date: Tue, 27 Feb 2024 14:43:11 +0000 Message-Id: <20240227144335.1196131-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240227144335.1196131-1-alex.bennee@linaro.org> References: <20240227144335.1196131-1-alex.bennee@linaro.org> 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: pass client-ip=2a00:1450:4864:20::234; envelope-from=alex.bennee@linaro.org; helo=mail-lj1-x234.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, 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 @linaro.org) X-ZM-MESSAGEID: 1709045292356100002 From: Akihiko Odaki In preparation for a change to use GDBFeature as a parameter of gdb_register_coprocessor(), convert the internal representation of dynamic feature from plain XML to GDBFeature. Signed-off-by: Akihiko Odaki Acked-by: Richard Henderson Message-Id: <20240103173349.398526-27-alex.bennee@linaro.org> Message-Id: <20231213-gdb-v17-1-777047380591@daynix.com> Signed-off-by: Alex Benn=C3=A9e --- target/arm/cpu.h | 21 +++--- target/arm/internals.h | 2 +- target/arm/gdbstub.c | 142 ++++++++++++++++++++--------------------- target/arm/gdbstub64.c | 95 +++++++++++++-------------- 4 files changed, 123 insertions(+), 137 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 63f31e0d984..508a9c1e0d6 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -25,6 +25,7 @@ #include "hw/registerfields.h" #include "cpu-qom.h" #include "exec/cpu-defs.h" +#include "exec/gdbstub.h" #include "qapi/qapi-types-common.h" #include "target/arm/multiprocessing.h" #include "target/arm/gtimer.h" @@ -117,23 +118,21 @@ */ =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 { @@ -855,10 +854,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 50bff445494..05eb9daac7d 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1451,7 +1451,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 28f546a5ff9..5949adfb31a 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -26,11 +26,11 @@ #include "cpu-features.h" #include "cpregs.h" =20 -typedef struct RegisterSysregXmlParam { +typedef struct RegisterSysregFeatureParam { CPUState *cs; - GString *s; + GDBFeatureBuilder builder; 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 @@ -216,7 +216,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)) { @@ -233,34 +233,32 @@ 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(GDBFeatureBuilder *builder, + DynamicGDBFeatureInfo *dyn_feature, ARMCPRegInfo *ri, uint32_t ri_key, - int bitsize, int regnum) + int bitsize, int n) { - g_string_append_printf(s, "name); - 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++; + gdb_feature_builder_append_reg(builder, ri->name, bitsize, n, + "int", "cp_regs"); + + dyn_feature->data.cpregs.keys[n] =3D ri_key; } =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; - GString *s =3D param->s; + RegisterSysregFeatureParam *param =3D p; 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, - param->n++); + arm_gen_one_feature_sysreg(¶m->builder, dyn_feature, + ri, ri_key, 64, param->n++); } } else { if (ri->state =3D=3D ARM_CP_STATE_AA32) { @@ -269,32 +267,32 @@ 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, - param->n++); + arm_gen_one_feature_sysreg(¶m->builder, dyn_featur= e, + ri, ri_key, 64, param->n++); } else { - arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 32, - param->n++); + arm_gen_one_feature_sysreg(¶m->builder, dyn_featur= e, + ri, ri_key, 32, param->n++); } } } } } =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}; - - 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)); - 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_string_append_printf(s, ""); - cpu->dyn_sysreg_xml.desc =3D g_string_free(s, false); - return cpu->dyn_sysreg_xml.num; + RegisterSysregFeatureParam param =3D {cs}; + gsize num_regs =3D g_hash_table_size(cpu->cp_regs); + + gdb_feature_builder_init(¶m.builder, + &cpu->dyn_sysreg_feature.desc, + "org.qemu.gdb.arm.sys.regs", + "system-registers.xml", + base_reg); + cpu->dyn_sysreg_feature.data.cpregs.keys =3D g_new(uint32_t, num_regs); + g_hash_table_foreach(cpu->cp_regs, arm_register_sysreg_for_feature, &p= aram); + gdb_feature_builder_end(¶m.builder); + return &cpu->dyn_sysreg_feature.desc; } =20 #ifdef CONFIG_TCG @@ -386,31 +384,29 @@ static int arm_gdb_set_m_systemreg(CPUARMState *env, = uint8_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 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; + GDBFeatureBuilder builder; + int reg =3D 0; int i; =20 - g_string_printf(s, ""); - g_string_append_printf(s, "= "); - g_string_append_printf(s, "\n"); + gdb_feature_builder_init(&builder, &cpu->dyn_m_systemreg_feature.desc, + "org.gnu.gdb.arm.m-system", "arm-m-system.xml= ", + base_reg); =20 for (i =3D 0; i < ARRAY_SIZE(m_sysreg_def); i++) { if (arm_feature(env, m_sysreg_def[i].feature)) { - g_string_append_printf(s, - "\n", - m_sysreg_def[i].name, base_reg++); + gdb_feature_builder_append_reg(&builder, m_sysreg_def[i].name,= 32, + reg++, "int", NULL); } } =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; + gdb_feature_builder_end(&builder); =20 - return cpu->dyn_m_systemreg_xml.num; + return &cpu->dyn_m_systemreg_feature.desc; } =20 #ifndef CONFIG_USER_ONLY @@ -428,31 +424,31 @@ static int arm_gdb_set_m_secextreg(CPUARMState *env, = uint8_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 base_reg) { ARMCPU *cpu =3D ARM_CPU(cs); - GString *s =3D g_string_new(NULL); - int base_reg =3D orig_base_reg; + GDBFeatureBuilder builder; + char *name; + int reg =3D 0; int i; =20 - g_string_printf(s, ""); - g_string_append_printf(s, "= "); - g_string_append_printf(s, "= \n"); + gdb_feature_builder_init(&builder, &cpu->dyn_m_secextreg_feature.desc, + "org.gnu.gdb.arm.secext", "arm-m-secext.xml", + base_reg); =20 for (i =3D 0; i < ARRAY_SIZE(m_sysreg_def); i++) { - g_string_append_printf(s, - "\n", - m_sysreg_def[i].name, base_reg++); - g_string_append_printf(s, - "\n", - m_sysreg_def[i].name, base_reg++); + name =3D g_strconcat(m_sysreg_def[i].name, "_ns", NULL); + gdb_feature_builder_append_reg(&builder, name, 32, reg++, + "int", NULL); + name =3D g_strconcat(m_sysreg_def[i].name, "_s", NULL); + gdb_feature_builder_append_reg(&builder, name, 32, reg++, + "int", NULL); } =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; + gdb_feature_builder_end(&builder); =20 - return cpu->dyn_m_secextreg_xml.num; + return &cpu->dyn_m_secextreg_feature.desc; } #endif #endif /* CONFIG_TCG */ @@ -462,14 +458,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; @@ -487,7 +483,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); @@ -533,20 +529,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 d7b79a6589b..5286d5c6043 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -247,7 +247,7 @@ int aarch64_gdb_set_pauth_reg(CPUARMState *env, uint8_t= *buf, int reg) return 0; } =20 -static void output_vector_union_type(GString *s, int reg_width, +static void output_vector_union_type(GDBFeatureBuilder *builder, int reg_w= idth, const char *name) { struct TypeSize { @@ -282,10 +282,10 @@ static void output_vector_union_type(GString *s, int = reg_width, =20 /* First define types and totals in a whole VL */ for (i =3D 0; i < ARRAY_SIZE(vec_lanes); i++) { - g_string_append_printf(s, - "", - name, vec_lanes[i].sz, vec_lanes[i].suffix, - vec_lanes[i].gdb_type, reg_width / vec_lane= s[i].size); + gdb_feature_builder_append_tag( + builder, "", + name, vec_lanes[i].sz, vec_lanes[i].suffix, + vec_lanes[i].gdb_type, reg_width / vec_lanes[i].size); } =20 /* @@ -296,86 +296,77 @@ static void output_vector_union_type(GString *s, int = reg_width, for (i =3D 0; i < ARRAY_SIZE(suf); i++) { int bits =3D 8 << i; =20 - g_string_append_printf(s, "", name, suf[i]); + gdb_feature_builder_append_tag(builder, "", + name, suf[i]); for (j =3D 0; j < ARRAY_SIZE(vec_lanes); j++) { if (vec_lanes[j].size =3D=3D bits) { - g_string_append_printf(s, "", - vec_lanes[j].suffix, name, - vec_lanes[j].sz, vec_lanes[j].suffi= x); + gdb_feature_builder_append_tag( + builder, "", + vec_lanes[j].suffix, name, + vec_lanes[j].sz, vec_lanes[j].suffix); } } - g_string_append(s, ""); + gdb_feature_builder_append_tag(builder, ""); } =20 /* And now the final union of unions */ - g_string_append_printf(s, "", name); + gdb_feature_builder_append_tag(builder, "", name); for (i =3D ARRAY_SIZE(suf) - 1; i >=3D 0; i--) { - g_string_append_printf(s, "= ", - suf[i], name, suf[i]); + gdb_feature_builder_append_tag(builder, + "", + suf[i], name, suf[i]); } - g_string_append(s, ""); + gdb_feature_builder_append_tag(builder, ""); } =20 -int arm_gen_dynamic_svereg_xml(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); - DynamicGDBXMLInfo *info =3D &cpu->dyn_svereg_xml; 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; + GDBFeatureBuilder builder; + char *name; + int reg =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_svereg_feature.desc, + "org.gnu.gdb.aarch64.sve", "sve-registers.xml= ", + base_reg); =20 /* Create the vector union type. */ - output_vector_union_type(s, reg_width, "svev"); + output_vector_union_type(&builder, reg_width, "svev"); =20 /* Create the predicate vector type. */ - g_string_append_printf(s, - "", - pred_width / 8); + gdb_feature_builder_append_tag( + &builder, "= ", + pred_width / 8); =20 /* Define the vector registers. */ for (i =3D 0; i < 32; i++) { - g_string_append_printf(s, - "", - i, reg_width, base_reg++); + name =3D g_strdup_printf("z%d", i); + gdb_feature_builder_append_reg(&builder, name, reg_width, reg++, + "svev", NULL); } =20 /* fpscr & status registers */ - g_string_append_printf(s, "", base_reg++); - g_string_append_printf(s, "", base_reg++); + gdb_feature_builder_append_reg(&builder, "fpsr", 32, reg++, + "int", "float"); + gdb_feature_builder_append_reg(&builder, "fpcr", 32, reg++, + "int", "float"); =20 /* Define the predicate registers. */ for (i =3D 0; i < 16; i++) { - g_string_append_printf(s, - "", - i, pred_width, base_reg++); + name =3D g_strdup_printf("p%d", i); + gdb_feature_builder_append_reg(&builder, name, pred_width, reg++, + "svep", NULL); } - g_string_append_printf(s, - "", - pred_width, base_reg++); + gdb_feature_builder_append_reg(&builder, "ffr", pred_width, reg++, + "svep", "vector"); =20 /* Define the vector length pseudo-register. */ - g_string_append_printf(s, - "", - base_reg++); + gdb_feature_builder_append_reg(&builder, "vg", 64, reg++, "int", NULL); =20 - g_string_append_printf(s, ""); + gdb_feature_builder_end(&builder); =20 - info->desc =3D g_string_free(s, false); - info->num =3D base_reg - orig_base_reg; - return info->num; + return &cpu->dyn_svereg_feature.desc; } --=20 2.39.2