From patchwork Tue Oct 17 19:09:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1850409 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=ZcbDGhp2; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S93Wl2gdqz20Pd for ; Wed, 18 Oct 2023 06:12:19 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qspSp-00068d-Bo; Tue, 17 Oct 2023 15:10:47 -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 1qspSO-0005iZ-KX for qemu-devel@nongnu.org; Tue, 17 Oct 2023 15:10:25 -0400 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qspSK-0001rw-8L for qemu-devel@nongnu.org; Tue, 17 Oct 2023 15:10:20 -0400 Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-3575c10421aso23026135ab.3 for ; Tue, 17 Oct 2023 12:10:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1697569815; x=1698174615; 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=DWdQ6aLWe6UH15pXNv0GlBymb4HpIAegdj+DNQlxeF0=; b=ZcbDGhp2sl+h+YEt3oHFMTjFJlSwLNt77j8ivi1AyPTB07nwVaMKrWGn4Iw9gORh+T eHEOlTmWuizElk8VQJ6EQglQVKOGHnEvVhS+lMwgNdFugJQPzoh8Dslui0SCKBxkwX0v i3pLiRb2PzPLJoUQNraYz0RM0Nyu4xkvW8ZHgGJdDJ7XabWcH9tY6TETiEd6Y4+5lA+H qXJOOJEf+mBfIES7EOFvuUtlSQZWpwD/UQG1IuJoihD21jur5GtHbKpJ9Fmnech+9Sit gZQ0qGP3MZXsJ+4eDnLQSCTePJDusVXKmy6a3xIv788TJ4NGVVbfguhVXT6e7NOXzQUq MAVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697569815; x=1698174615; 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=DWdQ6aLWe6UH15pXNv0GlBymb4HpIAegdj+DNQlxeF0=; b=V+5LIcEBV8tBLAFZlHyh2KSpawSoT5PJa/b5NQVDxuKTFH7TW8lUZqePiaYgjZ9IJC KsnHs2Yyr78SLE8nZyawoS6AZopKguo5/2pZEqXlbNcZebIDS+Y1UFpe3HH6JoowJYW/ SURnxXUOaoSBa3LasCQpPRlYx2QEqjUYSchODLgSARFhd5foFa1G5egFAmi9/PnaLaC9 5N6Cz2a3xp9AnToCmks6Y0Xd5MWngMjucZTp46nDJCQC2GmKnu2L7zwmbW029BnmHJs+ DBRfCWAwCYYRYz6148mJa7DX82LZ5PFeMIZqT7EqT8TU0kPPO23PLGpN8tIb6MnhyKd9 zMpA== X-Gm-Message-State: AOJu0YzlkfsFzkjBuUvOjO61bKzOZh8bKVWBKkCrF6LOPBKPczuVb5is uASHJIbaZ7obbQ+dWaMt0gcrn2zYX1efgkRhVJkJOg== X-Google-Smtp-Source: AGHT+IFT0oKUHzKSsj24krKgq8nvSNtS46E18VQTWF1lYy7sPZuhaXZ+iFghG/c3NQhM+1GFUwBvdQ== X-Received: by 2002:a05:6e02:164f:b0:34f:68fe:630 with SMTP id v15-20020a056e02164f00b0034f68fe0630mr4191004ilu.25.1697569814948; Tue, 17 Oct 2023 12:10:14 -0700 (PDT) Received: from localhost ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with UTF8SMTPSA id e10-20020aa7980a000000b00690c52267easm1821258pfl.40.2023.10.17.12.10.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Oct 2023 12:10:14 -0700 (PDT) From: Akihiko Odaki To: Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PATCH v13 08/18] gdbstub: Use GDBFeature for GDBRegisterState Date: Wed, 18 Oct 2023 04:09:18 +0900 Message-ID: <20231017190931.16211-9-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231017190931.16211-1-akihiko.odaki@daynix.com> References: <20231017190931.16211-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::135; envelope-from=akihiko.odaki@daynix.com; helo=mail-il1-x135.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- gdbstub/gdbstub.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index fd945822cf..556391cbf3 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("")); @@ -507,7 +506,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); } } @@ -528,7 +527,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); } } @@ -547,7 +546,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; } } @@ -559,10 +558,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;