From patchwork Fri Feb 23 16:21:42 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: 775148 Delivered-To: patch@linaro.org Received: by 2002:adf:a356:0:b0:33b:4db1:f5b3 with SMTP id d22csp437603wrb; Fri, 23 Feb 2024 08:43:37 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX4CoexVUpKv/LbO5r6ZEClh+9BqyFRGxtbatrRH2KhS3qivvWPrCDaBHHsdZT9xqMI4ggBKHjvcw4cE2K6Kw4O X-Google-Smtp-Source: AGHT+IH7ibbRV3iBN7XbVTxSOfGEtvr3KLInq+TO4DmbJRo81CpxLwVqqQeryGb9krTjcgdZchCw X-Received: by 2002:a05:6214:27e5:b0:68f:9ce7:e6a with SMTP id jt5-20020a05621427e500b0068f9ce70e6amr360703qvb.57.1708706617146; Fri, 23 Feb 2024 08:43:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708706617; cv=none; d=google.com; s=arc-20160816; b=F132o8RVuCJrLJjMpWyusbcyb4FRuas5KR5ILPNWUBw6B0Rs5Nk5v9UxTrrp/JfK9S 5g4RZWCqsgZa7q8YFSe7TvmAJYdM+DMMErGf7wblYdMyWKMC83kcr+POnRp9iNEFwR2b cZz0VLTP00lg/2w6Wf1hWModeo7lL/LL8IQlaRWlIQJBNosjRx/uUssX7DOsktKpnHPg SDBiu1R5eAl//9AhoLzPUTw0MGIVJYLQAUQGJAfhg7/0c5rOxKy9kEMoEYYLm+Xl9FeS zYUcW8QfjL+Y7nVCTW3/eEER5Eu4xo32gody6KUROp5pFHSDo+bBKxoOV4nvRmwIQW/I +9Hg== 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=sYddgSiv4TdBqJm1PnHuh0lKMNJczxN97MFaER3IoIY=; fh=2IXDtwkhE3u9iDHwRQ543d03t9X1toYDqf9u6DZTCZM=; b=p3pA16qGNgb8mPwkslRsH/ksLt5gWsUgoEAI6lSvsN3MR6K61vGiYs9bxMjW+O+g4q 3J8q1fOmdr/SYu6HUJHg6tpRVWYiItuVkdjbMZF/hp352OrN/sAyF8c/DfbDeIxt3UHp DMzgr/VMikoaDVu1RhSbdh04D/UfAHD0x8S1mrSgP9IPLwmTmP0UI7E0iM2uIyul5ha4 wGZz3KQPl7CVN8PP+JhfJz7sUhfHYzYuheUg+GTwThv5aA94i9OhsXOwBTKI600ifCSU wiA0610eE2mDizlboc4pU9TyezkpCoFy/nQv7lFlcEh5UxjOF0DKLmrVwkn3j894hqT6 RN6Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fUwSd61t; 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 t5-20020ad45bc5000000b0068f2b1d42d6si15381856qvt.92.2024.02.23.08.43.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Feb 2024 08:43:37 -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=fUwSd61t; 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 1rdYdK-0003iF-8I; Fri, 23 Feb 2024 11:42:46 -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 1rdYJd-00043S-AD for qemu-devel@nongnu.org; Fri, 23 Feb 2024 11:22:26 -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 1rdYJO-00064d-7J for qemu-devel@nongnu.org; Fri, 23 Feb 2024 11:22:24 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-33d8739ddd4so779670f8f.2 for ; Fri, 23 Feb 2024 08:22:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708705327; x=1709310127; 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=fUwSd61tPQp+0MbvQ1LcI8CObUsTNzw4ixTZqy8jabKWAGwR2SworRZO22jdT7yYu+ WkoGZ8bGS8oYHqmASQdv8AAmra9V2y/aGtEVug+SwTpfINxZyh4nO2YE/YEzb+e2+trV GlfK9TFS2sNYwxmoNY2B0RiUanYJzUCzlegV3EL1jz4ISBGZ12zXLMHd5R4kKxIbgQLY zO+zekMscZwX8PA9prUD8+5IavVOBIPi3vkOOVso8SfOvv+fvV8Q5OQ9hMxivfX1X4bl v7SR72HKxkVLaAkmrAC8cmRF/bv9GmFnkWbzYZakSq5OH2LlWF9mDTr8Ou/BdSt+AJPt LZ2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708705327; x=1709310127; 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=RR51SXkRPBmX0CBaDZWW1po9TbCPf1bq+E7EVZWOP+nVbTxDPiRNDJ8Fd1yqkrR4uv BxTgB07bIxn9LqCKGR2S0ravT/h+Teo1Gz8eoHD4FyEziLyyz52JJjYkUH1CD/nNOT7O v8WZihYt1CPCwlO5pcPIuYaUR3qlUrk0p8twg9D0Emdi77WBDUMOsMM0S82pd1P/DrCV EFDtHddqN1wqpUL99rvUsci49I/MfGBLN8upisIuij3YDZq2FsBKmwz3mRXkqj6RwxSv MD7rSmaOJF+eAfdkgk3UuP+LeMJOwUKAQKUAS3NRfByfuc+WueW90F5/qwfx+kArXJWh Xenw== X-Gm-Message-State: AOJu0YwIgDU8Kqyshe4gFcljUxrSie3+s5jYNVYCjMgqDGcRpFjZTXM6 Q5o0JWgRux8nmsKBP0xTnnV85HDNDV36xmha9T8IwxpaA/BlTbE3PU1s+Q/YkAA= X-Received: by 2002:a5d:4a06:0:b0:33d:2885:ce58 with SMTP id m6-20020a5d4a06000000b0033d2885ce58mr210596wrq.5.1708705327369; Fri, 23 Feb 2024 08:22:07 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id q25-20020a056000137900b0033ce06c303csm3262428wrz.40.2024.02.23.08.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 08:22:06 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 22CF65F92B; Fri, 23 Feb 2024 16:22:03 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Song Gao , qemu-s390x@nongnu.org, Liu Zhiwei , Pierrick Bouvier , Thomas Huth , Daniel Henrique Barboza , Bin Meng , Yanan Wang , Laurent Vivier , qemu-ppc@nongnu.org, David Hildenbrand , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Ilya Leoshkevich , Cleber Rosa , Nicholas Piggin , Marcel Apfelbaum , Eduardo Habkost , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Alexandre Iooss , Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= , Daniel Henrique Barboza , qemu-arm@nongnu.org, qemu-riscv@nongnu.org, Palmer Dabbelt , Mahmoud Mandour , John Snow , Weiwei Li , Alistair Francis , Yoshinori Sato , Brian Cain , Paolo Bonzini , "Edgar E. Iglesias" , Michael Rolnik , Akihiko Odaki Subject: [PATCH v2 07/27] gdbstub: Use GDBFeature for GDBRegisterState Date: Fri, 23 Feb 2024 16:21:42 +0000 Message-Id: <20240223162202.1936541-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223162202.1936541-1-alex.bennee@linaro.org> References: <20240223162202.1936541-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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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+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 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;