From nobody Fri Nov 1 07:23:31 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=1708101258; cv=none; d=zohomail.com; s=zohoarc; b=RjtqV/x4wMNyuKgGgccWFZSIoksMDn6Y8JQdtxNY4JSxkMo839WNY9umdoACgGX02jnOTeA0CrW67ULcgBnkDMz6dYmA05cczY/BPk5hjuCc/UWMpf6pwyaXLb6Sew5vSvdwJcZr0ncYA6erqr3DRFAD5tddLabxH2rqg04n4ec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708101258; 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=E8QhIidXtm1KWUMz6R6/HNvg/qk4Sel77EmOGwDTHnU=; b=R6IUNhQ4p5hxAp735yOdoxqxPJeVwAEKkUjT3B1LgRcoHM/w070cTaoF+AzZbH4MqgjvCxFSj26lSMH9CWeyRcPYMzB1EjJ0h3nSzlf8yguHX599ixVIUd6YeqfCFPJK/1VXTFxkVm2BVQmFENtsGyf3b3ijt3MAe2BGRZST8Uo= 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 17081012585801012.100322131781; Fri, 16 Feb 2024 08:34:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb16p-0004a3-MU; Fri, 16 Feb 2024 11:30:43 -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 1rb16m-0004Wb-L1 for qemu-devel@nongnu.org; Fri, 16 Feb 2024 11:30:40 -0500 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rb16d-0002Al-V4 for qemu-devel@nongnu.org; Fri, 16 Feb 2024 11:30:40 -0500 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2d0a4e1789cso26225211fa.3 for ; Fri, 16 Feb 2024 08:30:31 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id e25-20020a05600c219900b0040fe4b733f4sm2752985wme.26.2024.02.16.08.30.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 08:30:27 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 564055F9CF; 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=1708101030; x=1708705830; 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=E8QhIidXtm1KWUMz6R6/HNvg/qk4Sel77EmOGwDTHnU=; b=dgr9S6daOqP5CXmvIQtjeWlB1YwoIIEYSvRow5lY3q1S86w9WTSlr2QC/7vWzX+e0q F8/TBxc+ki6TaYe3q4WmgB2EriqH8BaZYtMGrBvBvOVnGOirQ/j8lypYMC5TiTMtuNHB QxXq3vIp/1+r3EOK8NuRsMtamRSJl1garfJBsDgXYMPZT/2gHu7G16GaozuR4Mevz3L8 3vjTJZbEmqrAZUSo+d9K+viPGYGnW0D1z43nN8gaPnXBqLOcQiROXcyJ1O+6HYyXPjlv cr+FlV5E4nIfQ+DrDyLGpi2YaX9oMvqHKzzZqkHKz54qjVmKP4dSmpho8S5SeeJLyPQ8 aKWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708101030; x=1708705830; 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=E8QhIidXtm1KWUMz6R6/HNvg/qk4Sel77EmOGwDTHnU=; b=McR0dBY3tXe6LnSKamgOxqEAlMtdpiHio7uyahTAL+KJPF6ojWqqg3e+9NRA7GEqly PBUhy8NSMvEzJpWnw9DKiXk0sJfWHMH2RTTUrhj10owpGKSnSqXPCKUZci4Pzwco7w/9 2qlOw/CgvvPK4plyMo3X6hunIXfouV7KV2csFmBjyYJI20CrKsEZkZEqXmYl/EfrKuGD /ooCZhHDRzIGxsZINIZS3nqkt6hK3tK/Pf7IJhqBaU9UuZaggGtb7bm5dxnBCJarJWjX MmAqaQ7/9QnGXvMyOHDcSZAqM+5OJwusBz0ICJmuNWNsZPB8xQWsx28Yes6gdsU11Yhf poZw== X-Gm-Message-State: AOJu0YwODrcdrt19ghQB0AdvnJgQ6KtAHiRrTVyOl/rowozrekDXyJNs oaYQKnKIOVZM7sKM1LR2qCuPIQnVuiEHyxQi2GlJMOAkAV2Xjxv/xaS3onDpYxQ= X-Google-Smtp-Source: AGHT+IEZb/UwB10mJDW7fzrmYtk43wYQsAjrEo4Z5yqrY2hjQBoFL2V66DwsUa27+WZRkBKVQZ9ItQ== X-Received: by 2002:a2e:8919:0:b0:2d0:bc40:2aa1 with SMTP id d25-20020a2e8919000000b002d0bc402aa1mr3949706lji.10.1708101030008; Fri, 16 Feb 2024 08:30:30 -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 03/23] target/ppc: Use GDBFeature for dynamic XML Date: Fri, 16 Feb 2024 16:30:05 +0000 Message-Id: <20240216163025.424857-4-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::22b; envelope-from=alex.bennee@linaro.org; helo=mail-lj1-x22b.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: 1708101258901100001 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 Reviewed-by: Richard Henderson Message-Id: <20240103173349.398526-28-alex.bennee@linaro.org> Message-Id: <20231213-gdb-v17-2-777047380591@daynix.com> Signed-off-by: Alex Benn=C3=A9e --- target/ppc/cpu-qom.h | 1 + target/ppc/cpu.h | 4 +--- target/ppc/cpu_init.c | 4 ---- target/ppc/gdbstub.c | 51 ++++++++++++++++--------------------------- 4 files changed, 21 insertions(+), 39 deletions(-) diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index 0241609efef..8247fa23367 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -20,6 +20,7 @@ #ifndef QEMU_PPC_CPU_QOM_H #define QEMU_PPC_CPU_QOM_H =20 +#include "exec/gdbstub.h" #include "hw/core/cpu.h" =20 #ifdef TARGET_PPC64 diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index a44de22ca4a..200652e2c87 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1471,8 +1471,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; @@ -1525,7 +1524,6 @@ 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); 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 9931372a08a..4f6903d3f16 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -6682,10 +6682,6 @@ static void init_ppc_proc(PowerPCCPU *cpu) /* PowerPC implementation specific initialisations (SPRs, timers, ...)= */ (*pcc->init_proc)(env); =20 -#if !defined(CONFIG_USER_ONLY) - ppc_gdb_gen_spr_xml(cpu); -#endif - /* MSR bits & flags consistency checks */ if (env->msr_mask & (1 << 25)) { switch (env->flags & (POWERPC_FLAG_SPE | POWERPC_FLAG_VRE)) { diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index ec5731e5d67..e3be3dbd109 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -300,15 +300,23 @@ int ppc_cpu_gdb_write_register_apple(CPUState *cs, ui= nt8_t *mem_buf, int n) } =20 #ifndef CONFIG_USER_ONLY -void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu) +static void gdb_gen_spr_feature(CPUState *cs) { - PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); + PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cs); + PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *env =3D &cpu->env; - GString *xml; - char *spr_name; + GDBFeatureBuilder builder; unsigned int num_regs =3D 0; int i; =20 + if (pcc->gdb_spr.xml) { + return; + } + + gdb_feature_builder_init(&builder, &pcc->gdb_spr, + "org.qemu.power.spr", "power-spr.xml", + cs->gdb_num_regs); + for (i =3D 0; i < ARRAY_SIZE(env->spr_cb); i++) { ppc_spr_t *spr =3D &env->spr_cb[i]; =20 @@ -326,35 +334,13 @@ void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu) */ spr->gdb_id =3D num_regs; num_regs++; - } - - if (pcc->gdb_spr_xml) { - return; - } =20 - xml =3D g_string_new(""); - g_string_append(xml, ""); - g_string_append(xml, ""); - - for (i =3D 0; i < ARRAY_SIZE(env->spr_cb); i++) { - ppc_spr_t *spr =3D &env->spr_cb[i]; - - if (!spr->name) { - continue; - } - - spr_name =3D g_ascii_strdown(spr->name, -1); - g_string_append_printf(xml, ""); + gdb_feature_builder_append_reg(&builder, g_ascii_strdown(spr->name= , -1), + TARGET_LONG_BITS, num_regs, + "int", "spr"); } =20 - g_string_append(xml, ""); - - pcc->gdb_num_sprs =3D num_regs; - pcc->gdb_spr_xml =3D g_string_free(xml, false); + gdb_feature_builder_end(&builder); } =20 const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name) @@ -362,7 +348,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; } @@ -599,7 +585,8 @@ void ppc_gdb_init(CPUState *cs, PowerPCCPUClass *pcc) 32, "power-vsx.xml", 0); } #ifndef CONFIG_USER_ONLY + gdb_gen_spr_feature(cs); 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.39.2