From patchwork Wed Jan 3 17:33:36 2024 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: 759647 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp6615262wrw; Wed, 3 Jan 2024 09:48:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IE18nKVea1c+4LaBCbCTTGsWCWCFACt2wPrr1Y/bbqRXKlDLqtf9Rra30srlhmM/ogbKCWj X-Received: by 2002:a05:6808:2105:b0:3bc:1584:308a with SMTP id r5-20020a056808210500b003bc1584308amr3443427oiw.104.1704304111590; Wed, 03 Jan 2024 09:48:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704304111; cv=none; d=google.com; s=arc-20160816; b=t+zpLOzR3S4xAoPDvdoUdG1rERQNwzzxxYkS5myU1GGea0KJblIMmN7LNKt7VbSrvZ NT2v8ZQTZClcrLITjZpiL74UZdK/S36ZI5QqI5SND+LR4CP/t6V0/SK1QybQBl5zdafW jJg59YQzIR5G4Sa/NHU33KgzVmtyjF+t6psbkhLUuXwJahtKlrwSLdrZ5q2aagnQSmsY U4JfHzguQZpYXfjAs0K3ZwkXoPK03h/4eW2mU93/vtTwCURdCkpCrQbp39fFL7LtH8jh nrF6k826B7JQ1DR5qKQcpZefC3P+eBQK3249ARw+dNfuXxmk4+CZmo5YDJlpVs3WkWPy bXhw== 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=MptfaR+7adpcaME/63X0fm8Oaab8Ri8YJu2OQMap89k=; b=hl5ZpEAaLEug2L5nsOweMWzjKkyPDf163B8uzVB56EvFUDCrXLbkdEqcVABLw5pKZ3 1hFcL2SGBg6NTXPX6tzP2utoBteZtP1KFH9nXKFeCjCsTIBCsLFmIw48zW7XCbu/drA0 XggeE2b7BXgIXfZyDWXel5qZZwFMX9D7j8r8nNgfVw7iBsgxmTK6qyFQ/fE3n1NteFX3 lBwc7aWRRJEbPmlaXS88sYBYErM1XgVHryWDOETIag2He3zHxNzKkBkKg8zpc9kWsHrI msmfUGpncA6uF8BRAvIcVtqO7oDpkf3W0ktRvUGRxGMwpVYoNgCVSTUhp/f5mUeCSSD7 N2KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xaybZ25a; 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 g29-20020a0caadd000000b00680d46d3a88si339873qvb.587.2024.01.03.09.48.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jan 2024 09:48:31 -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=xaybZ25a; 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 1rL5De-0008Ia-Me; Wed, 03 Jan 2024 12:39:54 -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 1rL5DU-0007rK-SZ for qemu-devel@nongnu.org; Wed, 03 Jan 2024 12:39:44 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rL5D0-0000hp-8p for qemu-devel@nongnu.org; Wed, 03 Jan 2024 12:39:44 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-33723ad790cso4120253f8f.1 for ; Wed, 03 Jan 2024 09:39:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704303552; x=1704908352; 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=xaybZ25a5sbfByqKrUUH63hT/sTyYWYwrttHo61ZwQo4PPwaR4ll/kzCnNlkgPesI8 cY2xWyMFk5CHnjvreTqP2D0N04lcFUHcsR4nmhs/L3k2X9RltTkyUm2i2oXJTR8iftc+ WJAOwKhrTzVn+5hQB3wEv5OoZnn4cX1Y2Nmaz4eI5DUfPV0drqZ3FTLzdYPxR7L3/Wz9 1mFk+tAEH2uCiovbpaMZ4QWzuMgsPjX3nNmKTufR0MiufHm20Zyt/rVyRldzn0MIbvKi xq0FZ0oLRlH3RJ/CFh/zNwIWB18v4NEhyOLu9UsrVG0i4mbAdZEomEZV52grQQOCYEi7 4TyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704303552; x=1704908352; 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=HeZ8Cu2ES13LB4AYxb2Qmnbcp2fOT3yp6Xm8BebpMiO5xVlPsUNxW3gcqoDutqM83m pllXKxAp/L9xMJvei+FJe9EiQwgeikirMNUnYbAlHVssBiQWajkkf8imuji7QIwLgrMy NfCgwDrKsK4QLdm02DjfMjyEa2F58A4hOK3GqU7Cb4YKftk8GP8tBqo5oRbdscB72ddi +Kc/HMzVIHrBrm7KO5V/ZX2iiYv8wmwMCiPtVrt8p9WtDBswcTl1j9jtlsDOlmqhXNZC b0qWMJ5jDIchV2w9OSPhHYEjqzoNXvy+WBQSE7iA2MBa/IKaq5Qe25lUjDkb247jkAJf l2NQ== X-Gm-Message-State: AOJu0YzzS0kmhmkHfwy88pPTENg6iXEbm3XI4JeU6QkFo4NEKOsj9YWQ AJeKncaPquBDbe4tcmkI62+m2u143PNM1Q== X-Received: by 2002:a5d:6789:0:b0:336:566e:ffdc with SMTP id v9-20020a5d6789000000b00336566effdcmr6879484wru.101.1704303552300; Wed, 03 Jan 2024 09:39:12 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id m12-20020adffe4c000000b0033677aae2e2sm30939987wrs.107.2024.01.03.09.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 09:39:08 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 383255F9CC; Wed, 3 Jan 2024 17:33:52 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Richard Henderson , Song Gao , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , David Hildenbrand , Aurelien Jarno , Yoshinori Sato , Yanan Wang , Bin Meng , Laurent Vivier , Michael Rolnik , Alexandre Iooss , David Woodhouse , Laurent Vivier , Paolo Bonzini , Brian Cain , Daniel Henrique Barboza , Beraldo Leal , Paul Durrant , Mahmoud Mandour , Thomas Huth , Liu Zhiwei , Cleber Rosa , kvm@vger.kernel.org, Peter Maydell , Wainer dos Santos Moschetta , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , qemu-arm@nongnu.org, Weiwei Li , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , John Snow , Daniel Henrique Barboza , Nicholas Piggin , Palmer Dabbelt , Marcel Apfelbaum , Ilya Leoshkevich , =?utf-8?q?C=C3=A9dric_Le_Goater?= , "Edgar E. Iglesias" , Eduardo Habkost , Pierrick Bouvier , qemu-riscv@nongnu.org, Alistair Francis , Akihiko Odaki Subject: [PATCH v2 30/43] gdbstub: Use GDBFeature for GDBRegisterState Date: Wed, 3 Jan 2024 17:33:36 +0000 Message-Id: <20240103173349.398526-31-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240103173349.398526-1-alex.bennee@linaro.org> References: <20240103173349.398526-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42a.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, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=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 Reviewed-by: Philippe Mathieu-Daudé --- 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;