From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF139C54E4A for ; Mon, 26 Feb 2024 17:01:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1reeIS-0006H8-Ag; Mon, 26 Feb 2024 11:57:44 -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 1reeI5-0005j6-5x for qemu-devel@nongnu.org; Mon, 26 Feb 2024 11:57:26 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1reeHl-0007dT-6L for qemu-devel@nongnu.org; Mon, 26 Feb 2024 11:57:20 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-412a9ea61adso1146105e9.0 for ; Mon, 26 Feb 2024 08:56:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708966613; x=1709571413; 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=sYddgSiv4TdBqJm1PnHuh0lKMNJczxN97MFaER3IoIY=; b=Dgk5iUk2BDMljYerivm3CcAoB6/L8l/Kc3uMX8Xigwp+SIlRCjUMLAhShyC3EhtOOF vWo4zIXNG3blrjZNiVbaSdzs+yT7/JVYdiPM9GFEs2h0EszmCgaVVEE1l8gZKiCwEuNi VOvSKlD8paS6J0RtKZPt4ribhNYyN+9eAp8hn9kIWEqMYdbXGrlSlUH7q2JnHD5cDb1L ix31azRI0aZjWcQ+mRG9GsLD32JerJMkd887VPTW43sZon7pjnn58qvbIsPB1rETOWLr wXEiBptM47QNiHC1ASfYBk7mOrWG42EP/PTfWK6KxuVfADc84aHDyaWKBfRsPDH/1v9q ImkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708966613; x=1709571413; 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=sYddgSiv4TdBqJm1PnHuh0lKMNJczxN97MFaER3IoIY=; b=o4qQ5z7gE/z82EQLOqJqdMx6947DOF+oKuljTlFBz/KvaMbIoUuJxkAh8UJSqn2jLt GcAKGua+IaULJ4yJodCZ7wU86kZe7/G6hZs+NQfiJlx9t/Cx5KQnfs1WPmgjiSgYplBb oSHcDQiH0djxal+BDiNn+MSqWAEftMyp7YAkYWfcbCd2fuKQAm90F5F6h6Asfx6xe/i3 heued63fVI7KDkN2xvpX7H1v12yHE6xHbRYf8ejEi/VWv2qcGh3oX/NqYzi8gtJWAtKE bndYZW1Q/Y7VmJUYLyihoP2K3W1XbWNiRXLZphZR66mDv3zcm+ETi+7fM3iIcXT6u5Or FBbA== X-Gm-Message-State: AOJu0Yw46w/JicVHWaPJ8C+vbINV3pwHWb6F5fbe6w+/oFe2bJfU4PZn xCuNQkXX4fnRrUud3tM4RPuoIy8S7vmNGToqB/vmwJCqIcdRfQ5c0UVyYz5RDv0= X-Google-Smtp-Source: AGHT+IF4Kzq2+aaetRXNsGrKPIJjub2/ifnXaEdfPS5tH9Uw3PDc5YKG/1jaZ06zcJk84SR8HECcGg== X-Received: by 2002:a05:600c:c17:b0:412:a482:cd75 with SMTP id fm23-20020a05600c0c1700b00412a482cd75mr2722211wmb.7.1708966613463; Mon, 26 Feb 2024 08:56:53 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id be13-20020a05600c1e8d00b004129ed6f9cbsm8101711wmb.4.2024.02.26.08.56.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:56:50 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 5F59E5F90D; Mon, 26 Feb 2024 16:56:47 +0000 (GMT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Nicholas Piggin , Liu Zhiwei , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-riscv@nongnu.org, Michael Rolnik , Song Gao , Alexandre Iooss , Marcel Apfelbaum , David Hildenbrand , Pierrick Bouvier , John Snow , Eduardo Habkost , Mahmoud Mandour , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Cleber Rosa , qemu-ppc@nongnu.org, Richard Henderson , qemu-s390x@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Yoshinori Sato , Yanan Wang , Brian Cain , Ilya Leoshkevich , Weiwei Li , "Edgar E. Iglesias" , Bin Meng , Laurent Vivier , Palmer Dabbelt , Daniel Henrique Barboza , Alistair Francis , Akihiko Odaki Subject: [PATCH v3 07/27] gdbstub: Use GDBFeature for GDBRegisterState Date: Mon, 26 Feb 2024 16:56:26 +0000 Message-Id: <20240226165646.425600-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240226165646.425600-1-alex.bennee@linaro.org> References: <20240226165646.425600-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Akihiko Odaki 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 Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20240103173349.398526-31-alex.bennee@linaro.org> Message-Id: <20231213-gdb-v17-5-777047380591@daynix.com> Signed-off-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 256599c8dfb..0ea417b2c9a 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; -- 2.39.2