From nobody Tue Feb 10 07:57:37 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=1702449872; cv=none; d=zohomail.com; s=zohoarc; b=gtyoWWJ9iNzCtOQAsi/5wSFNF2BiIHdxPU1IAKqUcpnmSV6+WeqUTTjVEbX492xiXBov4MBG1Z4zwJPVGlDT/WmwPnanAu1qrRi+lPEi6T5Hl5VAQxGjTiG8kCYzIQeIYuCEGFvOWQaEQMabLv3RfjQhbhUYAu12zAcm6sElT60= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702449872; 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=OAupFqc1JBzPkUxJAR+qiP/3aZYcWF4MicDMF8EiQdU=; b=EaAK+Bn3BQ/15z39EhbVXMQaul1Oe2DZC+ZcPJC7v85pMtb5QWUr4TzkSgOEUxnviEcfAmdGJMKnxKzwTLEdXrf/DHXSYqqduCzaKBdxsnKzwbj5PHSWGFE6UfvBKlIM3GhyyJNycd/3wB7b2IjsjouFKr4h5uDN7r7akIcLyQ8= 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 1702449872102535.2573709366849; Tue, 12 Dec 2023 22:44:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rDIwi-000874-21; Wed, 13 Dec 2023 01:42:16 -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 1rDIwd-000830-TA for qemu-devel@nongnu.org; Wed, 13 Dec 2023 01:42:11 -0500 Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rDIwY-0005Lq-Jy for qemu-devel@nongnu.org; Wed, 13 Dec 2023 01:42:08 -0500 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-5d8a772157fso57804457b3.3 for ; Tue, 12 Dec 2023 22:42:06 -0800 (PST) Received: from localhost ([157.82.205.15]) by smtp.gmail.com with UTF8SMTPSA id k9-20020a170902c40900b001bc676df6a9sm9716213plk.132.2023.12.12.22.41.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Dec 2023 22:42:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1702449726; x=1703054526; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=OAupFqc1JBzPkUxJAR+qiP/3aZYcWF4MicDMF8EiQdU=; b=zijNywKKVdyDwolS5b3pfIGIDmsDzYB9fP3MU/c9cAuRnTCT4CCuHgeKQqwUPRkuP9 uyC3llzffZbsTG8jJdhO2N/hpD6KN6x19k84o1nIxbzX0oPY4YRSfN61d4UAjhiaAkEz Z/zbGW/yEr07xaj3W8DZRgwyEVorLrovTLnnG1K8Byb17HOVJ7h/47ai9Tx4Spouy745 QKjjTLa2iuCs/24evMlQF2cu60ChYV7fpRwzAo4hV+QivInPla9nArV0Hd7oF3F6C/Vo gkS/wlQ/ztie+BXIWq/sInpSiylOTtA1BwlfCu+s8cDyw4JctS01rj3AopL+ev0So2Vp qZJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702449726; x=1703054526; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OAupFqc1JBzPkUxJAR+qiP/3aZYcWF4MicDMF8EiQdU=; b=iCpNn9qai7a9+7+Vs/BTfxyOY0RiJ2j92aMXPUJu5ZYSs9nTUIlZD16Zol2galgIiT VB9Ei2UWaW1WK03tRxKO3apN44RbzbAk3kmFNVb5aRnQZF1cv81xIXLdneQxil33aqEK LDmxCyf1dHiC7RmjqkvnHqvNutCaOT/QK6kHnZYP+6QjHk9BQlI0gkB8dB0nME1juUFb kYP7kWAdTnzK0ijuBFTPCEsM4E3kG/aiNcNL6DT9Tdx4HGyRUJp/frofQwQaxZr1ETG1 86Hdjvk9LFofzlO2/B8QFhUc+QJU26rO8gruVdt2Gko1HbxxvvwgyCMWbBNW/6c6KidK tqIA== X-Gm-Message-State: AOJu0YyU+GPIi1+XqYUPROF9lewO0TP4+7VvLvmqndlPOACEp8ziVicr zc66CazosL+tt+Lv/Nk7s12I9A== X-Google-Smtp-Source: AGHT+IESOLNQJniqWJf1VGq3fudMOlCr1Vuv7DttmgTkagjY5mkXu8fPIIWNTeun9E/fBkSKtKAowg== X-Received: by 2002:a81:8487:0:b0:5e2:6005:4d4 with SMTP id u129-20020a818487000000b005e2600504d4mr1251523ywf.8.1702449725699; Tue, 12 Dec 2023 22:42:05 -0800 (PST) From: Akihiko Odaki Date: Wed, 13 Dec 2023 15:41:04 +0900 Subject: [PATCH v17 05/14] gdbstub: Use GDBFeature for GDBRegisterState MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231213-gdb-v17-5-777047380591@daynix.com> References: <20231213-gdb-v17-0-777047380591@daynix.com> In-Reply-To: <20231213-gdb-v17-0-777047380591@daynix.com> To: Peter Maydell , Nicholas Piggin , Daniel Henrique Barboza , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Brian Cain , Song Gao , Laurent Vivier , "Edgar E. Iglesias" , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Eduardo Habkost , Marcel Apfelbaum , Yanan Wang , Michael Rolnik , Paolo Bonzini , Yoshinori Sato , John Snow , Cleber Rosa , Alexandre Iooss , Mahmoud Mandour , Mikhail Tyutin , Aleksandr Anenkov Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, 20231213-riscv-v7-0-a760156a337f@daynix.com, Akihiko Odaki X-Mailer: b4 0.12.4 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::112b; envelope-from=akihiko.odaki@daynix.com; helo=mail-yw1-x112b.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=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: 1702449873578100003 Simplify GDBRegisterState by replacing num_regs and xml members with one member that points to GDBFeature. Signed-off-by: Akihiko Odaki Reviewed-by: Alex Benn=C3=A9e --- gdbstub/gdbstub.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 068180c83c76..a80729436b66 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -47,10 +47,9 @@ =20 typedef struct GDBRegisterState { int base_reg; - int num_regs; gdb_get_reg_cb get_reg; gdb_set_reg_cb set_reg; - const char *xml; + const GDBFeature *feature; } GDBRegisterState; =20 GDBState gdbserver_state; @@ -391,7 +390,7 @@ static const char *get_feature_xml(const char *p, const= char **newp, g_ptr_array_add( xml, g_markup_printf_escaped("", - r->xml)); + r->feature->xmlname)); } } g_ptr_array_add(xml, g_strdup("")); @@ -513,7 +512,7 @@ static int gdb_read_register(CPUState *cpu, GByteArray = *buf, int reg) if (cpu->gdb_regs) { for (guint i =3D 0; i < cpu->gdb_regs->len; i++) { r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (r->base_reg <=3D reg && reg < r->base_reg + r->num_regs) { + if (r->base_reg <=3D reg && reg < r->base_reg + r->feature->nu= m_regs) { return r->get_reg(env, buf, reg - r->base_reg); } } @@ -534,7 +533,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *m= em_buf, int reg) if (cpu->gdb_regs) { for (guint i =3D 0; i < cpu->gdb_regs->len; i++) { r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (r->base_reg <=3D reg && reg < r->base_reg + r->num_regs) { + if (r->base_reg <=3D reg && reg < r->base_reg + r->feature->nu= m_regs) { return r->set_reg(env, mem_buf, reg - r->base_reg); } } @@ -553,7 +552,7 @@ void gdb_register_coprocessor(CPUState *cpu, for (i =3D 0; i < cpu->gdb_regs->len; i++) { /* Check for duplicates. */ s =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (strcmp(s->xml, feature->xmlname) =3D=3D 0) { + if (s->feature =3D=3D feature) { return; } } @@ -565,10 +564,9 @@ void gdb_register_coprocessor(CPUState *cpu, g_array_set_size(cpu->gdb_regs, i + 1); s =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); s->base_reg =3D cpu->gdb_num_regs; - s->num_regs =3D feature->num_regs; s->get_reg =3D get_reg; s->set_reg =3D set_reg; - s->xml =3D feature->xml; + s->feature =3D feature; =20 /* Add to end of list. */ cpu->gdb_num_regs +=3D feature->num_regs; --=20 2.43.0