From nobody Fri Nov 1 07:18:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708101119; cv=none; d=zohomail.com; s=zohoarc; b=RD7sbJTY68RQz1kKWPrqMBkd5ieUYE1Jjkbz5TPeUuwXYAHxlWyi2QCRq/NN6Ekned8tLVGjQo5MV+Jx7sds6rqPGFXFi/aNwZxdbjBTyqlhec89yWREPCwETNTROtuyth2+8NHlMmxUD4Ru3HXAlYy8kc7TH3FKwsbhsbyELGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708101119; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sYddgSiv4TdBqJm1PnHuh0lKMNJczxN97MFaER3IoIY=; b=HOmD9aIdPHtpQoCpOrfALw59t9+p8T+Ebk9a8wU7btfLKvMX7Ts+pLl30X33XP1m1o+b6MJSwHtykIbM+A7a76PFOr+SuNnmYxcXuV1ZmxMhJ1LnCK1TCIVB3vZURq+TODQeNsBmCt0PMEoBR6Fn4vioPYCNcvkqq3zBtsq0wq4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708101119726557.050409735024; Fri, 16 Feb 2024 08:31:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb16n-0004Y5-Ou; Fri, 16 Feb 2024 11:30:41 -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 1rb16m-0004WY-I4 for qemu-devel@nongnu.org; Fri, 16 Feb 2024 11:30:40 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rb16d-0002AZ-Up for qemu-devel@nongnu.org; Fri, 16 Feb 2024 11:30:40 -0500 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3394bec856fso2007320f8f.0 for ; Fri, 16 Feb 2024 08:30:31 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id u7-20020a05600c00c700b0040fb783ad93sm2701787wmm.48.2024.02.16.08.30.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 08:30:27 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A8DA55F9D4; Fri, 16 Feb 2024 16:30:26 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708101030; x=1708705830; 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=NPjz0KIkUTDHtLThIgxxbAOkeM6anrOCASER3dpVo7EQJmlLYh+ySCio9S82G7ZBc1 K1tv965z3WKkscsxTFcOgrVFYFuJWLQhCM9nxyjuNWpEepuWBOS4T8IvCYbq124Z49sH p5w4zLCMi3h7Ml/I2NsrGkyNcUgrsQ1L8ZbNLrHAPvggGldY7bCKvg1t+NrxNWWRdGkC Mn6uWomy0wvrYH3wnq0YsdQUp1fIayqUhhrqk9zSxErU36D1PqCzXP/Uc0FZEG7uVn+q tgt5fkEBqUN0zXMFPfNVdiPgJGp+ETZufnZsWOWBn5qBcKTfwfKaOUWKEdczeORaqAfb LPnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708101030; x=1708705830; 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=d8TH/RbWtXrR+/RxrBt/1WXI/lqhJMc+e59UXAfLlmeHh5ySr9JPl0h9bJQOr7H1ZS d6+oaNaELzi08be3IUqnienJU60/AiJ4qebGp+lC7BrSkk6OspiXQ0aILpw3RbLVZHC1 ++/TL4pmVKL4wH74M8ny0D/SgwMyfx1Qe61+Z2ec+/c50aGv3EtvgReij35HNmUi4Lqi Im+aw7uQjnaiMoDHAUicxgi1ln99PwnlHfNNUIE3t2tZfiGX7/iMLzxwZ8lJfTSVa7na QrryW8v/RQd6BtKkki/X22+siJupdRrGic8Fw6SRYIMrtuCE/eXlKwZr+RfR3wpneflZ 6bHA== X-Gm-Message-State: AOJu0Yw/8lrp08zZr9TiiHMRh0B0YEmk8Yc4ZvQy7ccuzJhLP+ZZNm7T 6BK7dBIsK0G4dnPt2s59bpFu46dqKvjnVz81Imn7hG8Yd/+H4xInEaJx3RRSnl0= X-Google-Smtp-Source: AGHT+IH6jBG62yhhC23uU9Oaa6e7Fr21M61N/MOtjfTUrHt1W7xHepcanxFyWjp2v+ED36BfoIiVhQ== X-Received: by 2002:adf:f9c6:0:b0:33a:d28c:222c with SMTP id w6-20020adff9c6000000b0033ad28c222cmr7733487wrr.11.1708101029794; Fri, 16 Feb 2024 08:30:29 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Yoshinori Sato , David Hildenbrand , Weiwei Li , Richard Henderson , Michael Rolnik , Ilya Leoshkevich , Peter Maydell , qemu-ppc@nongnu.org, Paolo Bonzini , qemu-riscv@nongnu.org, Cleber Rosa , Thomas Huth , Song Gao , qemu-arm@nongnu.org, Pierrick Bouvier , John Snow , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Nicholas Piggin , qemu-s390x@nongnu.org, Laurent Vivier , "Edgar E. Iglesias" , Daniel Henrique Barboza , Yanan Wang , Palmer Dabbelt , Marcel Apfelbaum , Brian Cain , Mahmoud Mandour , Alexandre Iooss , Bin Meng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Daniel Henrique Barboza , Eduardo Habkost , Alistair Francis , Liu Zhiwei , Akihiko Odaki Subject: [PATCH 06/23] gdbstub: Use GDBFeature for GDBRegisterState Date: Fri, 16 Feb 2024 16:30:08 +0000 Message-Id: <20240216163025.424857-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216163025.424857-1-alex.bennee@linaro.org> References: <20240216163025.424857-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708101120410100005 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=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20240103173349.398526-31-alex.bennee@linaro.org> Message-Id: <20231213-gdb-v17-5-777047380591@daynix.com> Signed-off-by: Alex Benn=C3=A9e --- 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 @@ =20 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; =20 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 =3D 0; i < cpu->gdb_regs->len; i++) { r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (r->base_reg <=3D reg && reg < r->base_reg + r->num_regs) { + if (r->base_reg <=3D reg && reg < r->base_reg + r->feature->nu= m_regs) { return r->get_reg(env, buf, reg - r->base_reg); } } @@ -534,7 +533,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *m= em_buf, int reg) if (cpu->gdb_regs) { for (guint i =3D 0; i < cpu->gdb_regs->len; i++) { r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (r->base_reg <=3D reg && reg < r->base_reg + r->num_regs) { + if (r->base_reg <=3D reg && reg < r->base_reg + r->feature->nu= m_regs) { return r->set_reg(env, mem_buf, reg - r->base_reg); } } @@ -553,7 +552,7 @@ void gdb_register_coprocessor(CPUState *cpu, for (i =3D 0; i < cpu->gdb_regs->len; i++) { /* Check for duplicates. */ s =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (strcmp(s->xml, feature->xmlname) =3D=3D 0) { + if (s->feature =3D=3D feature) { return; } } @@ -565,10 +564,9 @@ void gdb_register_coprocessor(CPUState *cpu, g_array_set_size(cpu->gdb_regs, i + 1); s =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); s->base_reg =3D cpu->gdb_num_regs; - s->num_regs =3D feature->num_regs; s->get_reg =3D get_reg; s->set_reg =3D set_reg; - s->xml =3D feature->xml; + s->feature =3D feature; =20 /* Add to end of list. */ cpu->gdb_num_regs +=3D feature->num_regs; --=20 2.39.2