From patchwork Thu Dec 21 10:38:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 757019 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp819982wrw; Thu, 21 Dec 2023 02:55:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5kwBoxgSMzgqMXnXUi08/pOClayaVybDO3ttIyGXOJXgKShsn/Iz5DyAlQrdTHPxLGUJ7 X-Received: by 2002:a05:6214:21cb:b0:67f:1290:4ff0 with SMTP id d11-20020a05621421cb00b0067f12904ff0mr17450589qvh.76.1703156101053; Thu, 21 Dec 2023 02:55:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703156101; cv=none; d=google.com; s=arc-20160816; b=s8NTzut6kuzmzU9DNbDS8oipyU8i6E3SzpriDHoKNnIUORCbveSUMHwZej+u6v52VQ ZLg7tmNiq5emb1wM7cF0Y2f7FU7JZvKLQqL3Z+G415lhUX5ZIOX9EnDlbYnDoPg6jXSR QC3+yX8rZNaj3add5gBiSCGAiSCSY7uzvFSjHAoVT5x8AMif6b9DRd+aoVgRMtFQU882 vs9Z3Nc5xKN+uIFZWyILykd+jyyZ07z4RuEdzrSBX5WDUBzClo64Elm7FxzOEb1Vo9V1 hstGsE0Q0CNY3SLdppp0r9CLYawR83cp3vdbNxg6OnMOl/Xmihw/A8o6NmRxhkUTmEFM dfzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TgDW5VAJqq7zKC6xI7H/BZAKg5Ps7sHcrddcH+tFs60=; fh=h+iJ7wyXFF+2j8Jm0Vjg9zb3yTkBquA+YJjBn+/tlFs=; b=a4PZryeyF7Y+BAGkG7X5VB4PMLkGcWR6s+xDTLDiEKd+rQx3TgqPjkFjH5beRN8QWm JYaT7O00IFyxiNdxU1I7FifwdnjV4FO7XUNd+aecT2FjgpuiAuQ8NPA1PJpLbP08kJ1C LfdbYB+crhBV4xb9Uqn/UOg6iaVS8lGAYVV48TGahcU/MVMleGsk1AxjV9JtBHeQW2ba m2W6IARaUjOFOjMs16JyzKBxLX61XDIGRlMN3am5wAPKSBNQ3Fc90Ilsq2OElsYUPhC5 GHrI8/nMj5bSBX+zy/muYKZdwR+ZBeN3gB/9CrJKJy0Hm6NocVd6sLLIfqalEG/29E+7 +sBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tWzWuXE3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z5-20020a0cda85000000b0067ae55821adsi1910240qvj.243.2023.12.21.02.55.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Dec 2023 02:55:01 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tWzWuXE3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGGay-000531-Uo; Thu, 21 Dec 2023 05:48:05 -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 1rGGam-0004jw-2T for qemu-devel@nongnu.org; Thu, 21 Dec 2023 05:47:52 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGGa9-0007OX-7H for qemu-devel@nongnu.org; Thu, 21 Dec 2023 05:47:51 -0500 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3363aa1b7d2so585851f8f.0 for ; Thu, 21 Dec 2023 02:47:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703155629; x=1703760429; 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=TgDW5VAJqq7zKC6xI7H/BZAKg5Ps7sHcrddcH+tFs60=; b=tWzWuXE3NNRMWFAmm2IOHwXebLdLFP2lttjf8TaBpnDQRxvvWZiUSQ+QGae7y0/k3z F3ipisvPYXUKIiwCVSZwmGBw3a7Q6Ix42R1vypns+45qamM+WOXJpx0wzFjXNVFYdz5z bJDNKo1Z6TNLrkYA96Z7Qq2k+cuA85JnbZ/wQUIZgdIFzde4Z7WSmx7rdPCk0XuL6PtU Csw4Wpy5LC6Z7aUDKAi6fqnbF8OCAu8Rh/lBLSzcHHR1IFunr6AktNKZVpKk96MV0I3D iYprXqnwa1Uq4IpGFjNUHlqKKgk7yb/W48hcW7u9ZZdr5XjNT1yaCnc6h9HLn+mi/Cpu KWWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703155629; x=1703760429; 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=TgDW5VAJqq7zKC6xI7H/BZAKg5Ps7sHcrddcH+tFs60=; b=gFyHSEG5gv50QLPXP1fNG/JNb5gtVwMRThaa24QG+gjRJPty/YKWnmXn06r2UOXrZ6 spfXPt9gEvhqC6e1td0MkLhwNt1DfexztdVknC+cLK8rUKTG5HRVuF+eizGgOKLBHSk9 d+BqWnOzlG9OoF6HpMfFPYPzNfJ3VBxEyZUqjGlPcVgTwAAOLDL+cBy5gGs8laZ2TDST Y2UO/wc3sDf73V5zuZaWkLzZh85UFA8JAikfhBAj81Gc5f4wE+uusv9iJl1qdoKeQ3VP vtXSIwNYmvZbbDIHfVZeldg/5QujGtRR7Lnuy3VgBpXoq6du5qNtUiIXNgqK2QjmxKr/ Iyyg== X-Gm-Message-State: AOJu0YxnD+dBpTCi50nYKhJXUsKLQ0SFyfiGQGqaDgxhRhRXVFvz/o5c whOLZw5iB7AqMtmgxuVubSWwcA== X-Received: by 2002:adf:f151:0:b0:336:6058:8fd3 with SMTP id y17-20020adff151000000b0033660588fd3mr461380wro.211.1703155629359; Thu, 21 Dec 2023 02:47:09 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id z11-20020a5d640b000000b003364e437577sm1724035wru.84.2023.12.21.02.47.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 02:47:06 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C866C5F8F7; Thu, 21 Dec 2023 10:38:21 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Edgar E. Iglesias" , John Snow , Aurelien Jarno , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Yanan Wang , Eduardo Habkost , Brian Cain , Laurent Vivier , Palmer Dabbelt , Cleber Rosa , David Hildenbrand , Beraldo Leal , Pierrick Bouvier , Weiwei Li , =?utf-8?q?Alex_Benn=C3=A9e?= , Paul Durrant , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , Ilya Leoshkevich , Wainer dos Santos Moschetta , Michael Rolnik , Alistair Francis , Daniel Henrique Barboza , Laurent Vivier , kvm@vger.kernel.org, =?utf-8?q?Marc-An?= =?utf-8?q?dr=C3=A9_Lureau?= , Alexandre Iooss , Thomas Huth , Peter Maydell , qemu-ppc@nongnu.org, Paolo Bonzini , Marcel Apfelbaum , Nicholas Piggin , qemu-riscv@nongnu.org, qemu-arm@nongnu.org, Song Gao , Yoshinori Sato , Richard Henderson , Daniel Henrique Barboza , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Mahmoud Mandour , Bin Meng , Akihiko Odaki Subject: [PATCH 29/40] gdbstub: Use GDBFeature for GDBRegisterState Date: Thu, 21 Dec 2023 10:38:07 +0000 Message-Id: <20231221103818.1633766-30-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221103818.1633766-1-alex.bennee@linaro.org> References: <20231221103818.1633766-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42f.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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 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 068180c83c7..a80729436b6 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;