From patchwork Wed Dec 13 06:41:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1875485 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=zijNywKK; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 4SqmDc5mdKz20LT for ; Wed, 13 Dec 2023 17:44:32 +1100 (AEDT) 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) 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) 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) 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 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_?= =?utf-8?q?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_M?= =?utf-8?q?athieu-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: 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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ée --- 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 @@ 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; 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 = 0; i < cpu->gdb_regs->len; i++) { r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) { + if (r->base_reg <= reg && reg < r->base_reg + r->feature->num_regs) { return r->get_reg(env, buf, reg - r->base_reg); } } @@ -534,7 +533,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg) if (cpu->gdb_regs) { for (guint i = 0; i < cpu->gdb_regs->len; i++) { r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) { + if (r->base_reg <= reg && reg < r->base_reg + r->feature->num_regs) { return r->set_reg(env, mem_buf, reg - r->base_reg); } } @@ -553,7 +552,7 @@ void gdb_register_coprocessor(CPUState *cpu, for (i = 0; i < cpu->gdb_regs->len; i++) { /* Check for duplicates. */ s = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (strcmp(s->xml, feature->xmlname) == 0) { + if (s->feature == feature) { return; } } @@ -565,10 +564,9 @@ void gdb_register_coprocessor(CPUState *cpu, g_array_set_size(cpu->gdb_regs, i + 1); s = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); s->base_reg = cpu->gdb_num_regs; - s->num_regs = feature->num_regs; s->get_reg = get_reg; s->set_reg = set_reg; - s->xml = feature->xml; + s->feature = feature; /* Add to end of list. */ cpu->gdb_num_regs += feature->num_regs;