From nobody Fri Nov 1 07:34:04 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=1708101308; cv=none; d=zohomail.com; s=zohoarc; b=NJtMPkQUpfMmGpjGn0jF1ATmf8CuPqh3ToTqG87Xv1Nojlxk8MV4wjKRZw2irXbdx1uzZJ2ZoqEZ5mEusv+UtIIzz61QLLAzozsAc7PLQGt5OWtmZZqMCbQTkuwL7v+1v0zcz06wji55ufxf1MIRtdEV9GXmaigU4cNk/8k5RaU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708101308; 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=dq5FWPM4VHMj0x6UG1qqCtiR6uckkFEr60gNfPoOVWsYgX8xfgJE3rrmapOhv0hv3D58vW+aHoTt0OxR1vERiS/Y5ySij8x85JewTis5T3kXx1j6rWmgyxrzsNSYOfDeO0hA1wG2OZRpV1DIr/2TPF4uB/XhSJ5AlfYoW3bH3hI= 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 1708101308131993.651430176589; Fri, 16 Feb 2024 08:35:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb16h-0004Rr-G3; Fri, 16 Feb 2024 11:30:35 -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 1rb16g-0004Qb-7S for qemu-devel@nongnu.org; Fri, 16 Feb 2024 11:30:34 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rb16b-00029P-Ro for qemu-devel@nongnu.org; Fri, 16 Feb 2024 11:30:33 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-41242d2f73cso5658135e9.0 for ; Fri, 16 Feb 2024 08:30:29 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id t3-20020a1c7703000000b0041238df09fesm2734111wmi.41.2024.02.16.08.30.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 08:30:26 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3B2225F91D; Fri, 16 Feb 2024 16:30:26 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708101027; x=1708705827; 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=nneB591eBB7bJ26pOH+0MQ/4Yi36dQbxLjNKUXMwfWEcwxk4X6+8DfzVXiAcQqvss+ wwAHjXscnkAE2ru1XWa2NWn/TJ30rMkBdQjZjChC8FqCPUi0Z4JC1TwKJ6FJwVwDnff3 KaV+3evyk6YAzLKBB5t4Nn66YcMzTOHB6imDpzIqqIeb46Z/hrx6fPPpkSJSMUi8sUAj Y+BeimPMiEdDH2Da+11LhqYK9cQ3QKnZwOAzrEcXTOxOr1H2K+6vcHw8jTKqdVm/edks +029CrW3YuvVwcVzVQfGLNQyLhYZXMppfyFqLbTvYk2HHmBSefhA1dAvwIH82sOehqdu aXbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708101027; x=1708705827; 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=qDgWEWrJZ7RmD3Nb9vIoi+uxZJaErH7l2hkO4fHNXYWEAqN55GKbeIKHw7tQg0fDPY 5u/Nhmqwiw8od0dfqEun7foyZVpHDtE5ZxjDfIUNGi9VnmtwMdEyM6+kSsG3MJycygxJ e/RPsj6B46fDIMwrJAxGuF/y6OUA/goYG3rbt4B/W7xQZYabe6Yt1o28scgHJ93KD5Tj o3yLzxk1+wmXXhHi5/Qh5vBdj68Zc2WzVudS64V4wHzCxVIObLhKvqs2t0fZfvje08iD H+tjUPcYsJBKBYfNUsXqSepKWptguhcYolzvpoZ57pfFfKxt6Jtl3UqvNItUul7OGyfB zmDg== X-Gm-Message-State: AOJu0YxD8JEcSDoMAh3j9YKd140+js3OpolQEvA0cEEMnNlcNxUgBNAa Ztb6aLUdiMQy5vN4MDqUhMp2bFYakQlgTyq7OMwIiqjbhI7igolmmzAodAAHdFg= X-Google-Smtp-Source: AGHT+IGATiKEfOoPt9UxwAm1yaA4JO7yxc5l4wGSjjWDIlvSb5gf2xJeUcLt3XoWVSi7EXbDIUGc7A== X-Received: by 2002:a05:600c:1ca1:b0:40e:f9df:3531 with SMTP id k33-20020a05600c1ca100b0040ef9df3531mr4038837wms.8.1708101027190; Fri, 16 Feb 2024 08:30:27 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Yoshinori Sato , David Hildenbrand , Weiwei Li , Richard Henderson , Michael Rolnik , Ilya Leoshkevich , Peter Maydell , qemu-ppc@nongnu.org, Paolo Bonzini , qemu-riscv@nongnu.org, Cleber Rosa , Thomas Huth , Song Gao , qemu-arm@nongnu.org, Pierrick Bouvier , John Snow , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Nicholas Piggin , qemu-s390x@nongnu.org, Laurent Vivier , "Edgar E. Iglesias" , Daniel Henrique Barboza , Yanan Wang , Palmer Dabbelt , Marcel Apfelbaum , Brian Cain , Mahmoud Mandour , Alexandre Iooss , Bin Meng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Daniel Henrique Barboza , Eduardo Habkost , Alistair Francis , Liu Zhiwei , Akihiko Odaki Subject: [PATCH 02/23] target/arm: Use GDBFeature for dynamic XML Date: Fri, 16 Feb 2024 16:30:04 +0000 Message-Id: <20240216163025.424857-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216163025.424857-1-alex.bennee@linaro.org> References: <20240216163025.424857-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::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.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=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 @linaro.org) X-ZM-MESSAGEID: 1708101309217100001 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