From patchwork Mon Jul 31 08:43:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1814868 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20221208.gappssmtp.com header.i=@daynix-com.20221208.gappssmtp.com header.a=rsa-sha256 header.s=20221208 header.b=fn5aOlNO; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RDsNh2CWxz1yfG for ; Mon, 31 Jul 2023 18:49:08 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQOY3-0004Av-EC; Mon, 31 Jul 2023 04:46:39 -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 1qQOXy-0003T5-Nv for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:46:35 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQOXw-00055y-DO for qemu-devel@nongnu.org; Mon, 31 Jul 2023 04:46:34 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-55fcc15e109so2437478a12.3 for ; Mon, 31 Jul 2023 01:46:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1690793191; x=1691397991; 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=fn5aOlNO+lR//hLYr/z6yhrEcLcazpFsajIq8hrQtcABL2+xx6wQf5HmRUtwkvATGc nlMl3PoSnBFv9Bv8Apnw1NbGb4hD0TWtBvaWtbQgpRq5B/E77yI+TSE/sfezYcG1eovo DCfO8Hmk1QpLMT71KkkSxt+l+itkmieHKyASAayWNBQWSr0AL7tgjk3TJw6bvSTnj/vY UGmSsCVqayq0faB13EP95bSFRM6ZWXFqPwZQCM9ZobT+QeD58jWyKeaZy1stF52DgHcy ERAtGbeDojQuXj0OpvqlSHC3CRZlUhinNsyHXJgD0S7NLPmF96MSbUpo7KUk2JB1KhLx JA0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690793191; x=1691397991; 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=cZDfsyJzeZipGGy7Ut4gwrVMSlEBlapuaOKapfLR0V68TTCUIlyTNa8AeZz4nLN2om FBxn1i53HhSCJj4I5VGZ2y+k2aEZD841Sg39smRSys7bKKdLfjSoSvpR70+S3c2ykZnj pkUgaWnWJJdwBaE9gMHjx79LkZykaYOCY0Cgn/ej6LFVw2M8OJiU4KqFP29nJHC+IT2P 19ClF2QV5zBHpt9o4/xxYsCRZNc7qb7buw9P/kZKeGtpZ/GvU6wRfgvTos2AjBbHcMId j7HDR0K57KBMcVolSLPclljOrM2PJToHVoIKUfrVl70isJjKFhT+XuK1k8q7Dm/p6Tv2 KPrg== X-Gm-Message-State: ABy/qLbLXk6ZzokFmHt90ZY/jEX604MbneyBxurrRn4da5iaBrvXouRv Wtj4GtiA9WP/ycxq9/s5PwEYlw== X-Google-Smtp-Source: APBJJlHGvpNsETGTwq0mtROsBUroG4nrkYSkJD40PaBshN9RoFr5aQ6bmrVDPKT3K7UzrGU//pWsCA== X-Received: by 2002:a05:6a20:8f0c:b0:137:a9d7:de12 with SMTP id b12-20020a056a208f0c00b00137a9d7de12mr10330974pzk.59.1690793190951; Mon, 31 Jul 2023 01:46:30 -0700 (PDT) Received: from alarm.. ([157.82.204.253]) by smtp.gmail.com with ESMTPSA id u19-20020aa78493000000b00666e649ca46sm7075563pfn.101.2023.07.31.01.46.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 01:46:30 -0700 (PDT) From: Akihiko Odaki To: Cc: Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Alexandre Iooss , Mahmoud Mandour , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Richard Henderson , =?utf-8?q?Marc-Andr=C3=A9?= =?utf-8?q?_Lureau?= , =?utf-8?q?Daniel_P=2E_Be?= =?utf-8?q?rrang=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_Le_G?= =?utf-8?q?oater?= , 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, Akihiko Odaki Subject: [RFC PATCH 15/24] target/arm: Fill new members of GDBFeature Date: Mon, 31 Jul 2023 17:43:42 +0900 Message-ID: <20230731084354.115015-16-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230731084354.115015-1-akihiko.odaki@daynix.com> References: <20230731084354.115015-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::52d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x52d.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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=\"%d\"", regnum); g_string_append_printf(s, " group=\"cp_regs\"/>"); dyn_feature->data.cpregs.keys[dyn_feature->desc.num_regs] = ri_key; + ((const char **)dyn_feature->desc.regs)[dyn_feature->desc.num_regs] = ri->name; dyn_feature->desc.num_regs++; } @@ -316,6 +317,8 @@ static GDBFeature *arm_gen_dynamic_sysreg_feature(CPUState *cs, int base_reg) DynamicGDBFeatureInfo *dyn_feature = &cpu->dyn_sysreg_feature; gsize num_regs = g_hash_table_size(cpu->cp_regs); + dyn_feature->desc.name = "org.qemu.gdb.arm.sys.regs"; + dyn_feature->desc.regs = g_new(const char *, num_regs); dyn_feature->desc.num_regs = 0; dyn_feature->data.cpregs.keys = 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) } static GDBFeature *arm_gen_dynamic_m_systemreg_feature(CPUState *cs, - int orig_base_reg) + int base_reg) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; GString *s = g_string_new(NULL); - int base_reg = orig_base_reg; - int i; + const char **regs = g_new(const char *, ARRAY_SIZE(m_sysreg_def)); + int i = 0; + int j; g_string_printf(s, ""); g_string_append_printf(s, ""); g_string_append_printf(s, "\n"); - for (i = 0; i < ARRAY_SIZE(m_sysreg_def); i++) { - if (arm_feature(env, m_sysreg_def[i].feature)) { + for (j = 0; j < ARRAY_SIZE(m_sysreg_def); j++) { + if (arm_feature(env, m_sysreg_def[j].feature)) { + regs[i] = 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++); } } g_string_append_printf(s, ""); + cpu->dyn_m_systemreg_feature.desc.name = "org.gnu.gdb.arm.m-system"; cpu->dyn_m_systemreg_feature.desc.xmlname = "arm-m-system.xml"; cpu->dyn_m_systemreg_feature.desc.xml = g_string_free(s, false); - cpu->dyn_m_systemreg_feature.desc.num_regs = base_reg - orig_base_reg; + cpu->dyn_m_systemreg_feature.desc.regs = regs; + cpu->dyn_m_systemreg_feature.desc.num_regs = i; 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) } static GDBFeature *arm_gen_dynamic_m_secextreg_feature(CPUState *cs, - int orig_base_reg) + int base_reg) { ARMCPU *cpu = ARM_CPU(cs); GString *s = g_string_new(NULL); - int base_reg = orig_base_reg; - int i; + const char **regs = g_new(const char *, ARRAY_SIZE(m_sysreg_def) * 2); + int i = 0; + int j; g_string_printf(s, ""); g_string_append_printf(s, ""); g_string_append_printf(s, "\n"); - for (i = 0; i < ARRAY_SIZE(m_sysreg_def); i++) { + for (j = 0; j < ARRAY_SIZE(m_sysreg_def); j++) { + regs[i] = 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] = 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++; } g_string_append_printf(s, ""); + cpu->dyn_m_secextreg_feature.desc.name = "org.gnu.gdb.arm.secext"; cpu->dyn_m_secextreg_feature.desc.xmlname = "arm-m-secext.xml"; cpu->dyn_m_secextreg_feature.desc.xml = g_string_free(s, false); - cpu->dyn_m_secextreg_feature.desc.num_regs = base_reg - orig_base_reg; + cpu->dyn_m_secextreg_feature.desc.regs = regs; + cpu->dyn_m_secextreg_feature.desc.num_regs = i; 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, ""); } -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 = ARM_CPU(cs); GString *s = g_string_new(NULL); DynamicGDBFeatureInfo *info = &cpu->dyn_svereg_feature; + const char **regs; int reg_width = cpu->sve_max_vq * 128; int pred_width = cpu->sve_max_vq * 16; - int base_reg = orig_base_reg; - int i; + int i = 0; + int j; + + info->desc.name = "org.gnu.gdb.aarch64.sve"; + info->desc.num_regs = 32 + 16 + 4; + regs = g_new(const char *, info->desc.num_regs); + info->desc.regs = regs; 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); /* Define the vector registers. */ - for (i = 0; i < 32; i++) { + for (j = 0; j < 32; j++) { + regs[i] = g_strdup_printf("z%d", j); g_string_append_printf(s, - "", - i, reg_width, base_reg++); + regs[i], reg_width, base_reg + i); + i++; } /* fpscr & status registers */ + regs[i] = "fpsr"; g_string_append_printf(s, "", base_reg++); + " type=\"int\"/>", base_reg + i++); + regs[i] = "fpcr"; g_string_append_printf(s, "", base_reg++); + " type=\"int\"/>", base_reg + i++); /* Define the predicate registers. */ - for (i = 0; i < 16; i++) { + for (j = 0; j < 16; j++) { + regs[i] = 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] = "ffr"; g_string_append_printf(s, "", - pred_width, base_reg++); + pred_width, base_reg + i++); /* Define the vector length pseudo-register. */ + regs[i] = "vg"; g_string_append_printf(s, "", - base_reg++); + base_reg + i++); g_string_append_printf(s, ""); info->desc.xmlname = "sve-registers.xml"; info->desc.xml = g_string_free(s, false); - info->desc.num_regs = base_reg - orig_base_reg; + assert(info->desc.num_regs == i); return &info->desc; }