From nobody Wed Feb 11 02:12:11 2026 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 ARC-Seal: i=1; a=rsa-sha256; t=1697007883; cv=none; d=zohomail.com; s=zohoarc; b=ZRuPoSDINi82ef85EHh6FXXyL8flUy47QjHHqspJL9DmIYvKjU8M5/O851DKP8lfE/nGin2yt41fA61fIE2PaWJSVp31ijvoBOE6e4rx9UcU3fCVQh5VG8d0DQrcAhWiqVPDRl29cUlzpQGiDRwdpbHQsxPlJb94uAmAO5mgo0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697007883; h=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:Message-Id:Reply-To:To; bh=HlYmSExF9OA8PmNERjADq51WxQfZ83JfKJQYueZPenE=; b=jeOzTNztiU4xdQr06sZtvJiXeNwVWgTScERy9FD9BDUVFwJkpiYQO0xVYU0KNfvPxS2PNy1PbOQ1BMnl1607EVfdbtJoLAF/8p2/J8KBiZFCpUvfha37LpufJ4k3sMbOGQSThu+DhD3+MFXATTGiUikd7j9mEQhJjqrhTVi0hbw= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697007883942687.3630949169617; Wed, 11 Oct 2023 00:04:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qqTGn-00080X-TR; Wed, 11 Oct 2023 03:04:37 -0400 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 1qqTGl-0007wE-7b for qemu-devel@nongnu.org; Wed, 11 Oct 2023 03:04:35 -0400 Received: from mail-oo1-xc36.google.com ([2607:f8b0:4864:20::c36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qqTGj-0005qO-1U for qemu-devel@nongnu.org; Wed, 11 Oct 2023 03:04:34 -0400 Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-57bca5b9b0aso3606484eaf.3 for ; Wed, 11 Oct 2023 00:04:31 -0700 (PDT) Received: from localhost ([157.82.206.10]) by smtp.gmail.com with UTF8SMTPSA id q15-20020a62ae0f000000b00690c4577101sm9673982pff.140.2023.10.11.00.04.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 11 Oct 2023 00:04:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1697007871; x=1697612671; 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=HlYmSExF9OA8PmNERjADq51WxQfZ83JfKJQYueZPenE=; b=qdsUTn/+vA04aQ6Xk8yfRTLQIj/tG/XgfT5dnClRckLzQZC3aLwiM6lnMTwwhMGpS+ MwGJRGgNdYyx8bGfwUz26yzbdWttQTrey3qwzjSx8f35snjf095LCyex4/kpkq9DZ6G+ I3Oi/qudS55UY7ATXiLg3Dcr82+bosOW1cffSCFNjtxQZhXBuNkO2TMdc7ek+yEoCJKt gwO0KRtxKn+wdecNEfPzdAzGNfL8oqqH5j4Z/65Cezcna9C6NWrYKU+6kKyswAmXAITL gIHAOVHrcm+u8qxfSvvbiNwYULGmtj0pTcbNk87OYhK8CVViMuib4zJoWofE+GdzoByH uCjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697007871; x=1697612671; 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=HlYmSExF9OA8PmNERjADq51WxQfZ83JfKJQYueZPenE=; b=Ez6NxmH7ByuIMMntCcmM4QmOFsG+bDR7vFKyjzQPzBtumhzLPVbmSYJAy0lzDmhQg0 6aqzQmc/1X9/WorlJM+qmZUVp5DuA1tqTZLG5JgYkz/kDAbLgVgjWJL8cJ0jJAf/1Zee D63wWigwa5c3W3zkKbKONJCfBYpRKQqeVbE0BO2d0VZeWUL5YrQCIfcVXR7vvdIOFCHl z1Sv44An7FwMVPKfzQ8fiKUzMw7lyZCNWMm7TjqEhMVr8XLrG9muOaV4zLC6hz8GNHQk PyHYfyXqpiQx7BWdDNz3cVAQJOf7bCsoCB67xICqR4tYUwzpTBLdP/NyUsjhMrK1CKHz ETAg== X-Gm-Message-State: AOJu0Ywa3gv/5Ot44DxKH7+hB50vcA5UIpQDAerKe9NVFGQZQJOMOzmL 64aESnJhIziaYVD3jkWj3/VZBJdbc/095YRzTRQ= X-Google-Smtp-Source: AGHT+IHtZqxJcQ5Q0j1W/dIdHSz/CtIG6SOhfYQTuIT78ZmLscGJnKefJwrVoMLj2ovASToQM0Vgsg== X-Received: by 2002:a05:6358:7e07:b0:134:c650:cc0a with SMTP id o7-20020a0563587e0700b00134c650cc0amr24131232rwm.15.1697007870741; Wed, 11 Oct 2023 00:04:30 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PATCH v9 11/23] gdbstub: Use GDBFeature for GDBRegisterState Date: Wed, 11 Oct 2023 16:02:57 +0900 Message-ID: <20231011070335.14398-12-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231011070335.14398-1-akihiko.odaki@daynix.com> References: <20231011070335.14398-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 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: none client-ip=2607:f8b0:4864:20::c36; envelope-from=akihiko.odaki@daynix.com; helo=mail-oo1-xc36.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1697007885566100003 Content-Type: text/plain; charset="utf-8" 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 --- gdbstub/gdbstub.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 20586e0b6a..9a4124afc4 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; @@ -390,7 +389,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("")); g_ptr_array_add(xml, NULL); @@ -504,7 +503,7 @@ static int gdb_read_register(CPUState *cpu, GByteArray = *buf, int reg) =20 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->num_re= gs) { return r->get_reg(env, buf, reg - r->base_reg); } } @@ -523,7 +522,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *m= em_buf, int reg) =20 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->num_re= gs) { return r->set_reg(env, mem_buf, reg - r->base_reg); } } @@ -541,7 +540,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; } } @@ -553,10 +552,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.42.0