From patchwork Fri Nov 3 19:59:42 2023 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: 740728 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp11830wrr; Fri, 3 Nov 2023 13:09:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgJQpk15C/oEU3MnSbq5JfCJvkAEZRAvvj7qp+jTWDU1do4BTt9jgUczA6oDa4dslY5/q1 X-Received: by 2002:ad4:5946:0:b0:672:2989:589c with SMTP id eo6-20020ad45946000000b006722989589cmr19187987qvb.27.1699042176422; Fri, 03 Nov 2023 13:09:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699042176; cv=none; d=google.com; s=arc-20160816; b=HUT7jg8j0qtzYDBJW4FiDVUKjLVF1EQ9IPLoTBAelpXFoAQ8qeDVq/5OXoMF2boVSe fELv1FQWrBfX5Q5nWi9FCbEpdSLZVB5B5I8Zv2KBrhsM58bZGJUQUFrr5Gn5EYhkuQAN LJ+Rcvll7utc/opjDascyFj4BueAN2xEuwrJV+uzf44c6S9+pDJUVUq8ZmWp8698CRo7 xcz7naE43M5YanY5vJ7EXXyifoIe3opOu0PzeDUw1oWCXApjagfnXQa5SycxzJECJCsu ctBurMNK/Qg7rKTJobck1ocEPtY5IDtObGIFyzbhj+B/VD1NeMRHTiKhn3gt3zUgwhdK vqiw== 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=SOAWWpjiiwaZDA84JjbEaSKaXBc7LOkqYDSzl30vo8w=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=RQ/c0JSyQ2fa48neA+HZ186nKBtrMW/CG7eL+GndA8tcGDvp0kXVi7q4rapExlhjA0 K0Uoc06Zo+iVReqiLs3Ralbq2nYdHE9TxP3pkaBsw0tcZMGepo4RGkQwk6m3rGcPdFkK 1Qt4YMTh1V22b4sd6ixqYqPGqxhFUOorfy+SH+qbqX3whC0gQP7iBx4KssdUnyyTZ1Pr j0LNSdy75UqQfc2ycTnNJHZ9vKAOxvqgwJTo/5yC5L+PbcNoEwXCnEbus6GYK4NOt+my OQD3I9/giXphXNpHtqfWNrIQiHAUD6BYQ0O+kHRmHEXQp3H+GnM6/w13o+bNb76+jS45 GFlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c2RRyGuk; 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 ev18-20020a0562140a9200b0066cf12ca208si1986440qvb.309.2023.11.03.13.09.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:09:36 -0700 (PDT) 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=c2RRyGuk; 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 1qz0Qp-0003WX-36; Fri, 03 Nov 2023 16:06:15 -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 1qz0Qm-0003Mw-Nw for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:12 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Qh-0006vc-GF for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:12 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-32f7c44f6a7so1429268f8f.1 for ; Fri, 03 Nov 2023 13:06:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041965; x=1699646765; 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=SOAWWpjiiwaZDA84JjbEaSKaXBc7LOkqYDSzl30vo8w=; b=c2RRyGuksi3vjxs6sO6a2MSZjoRkbwG66rbPUWTutEYqQH0IQRTJ3y5orvgU/Eb9K+ TYqzB/+mUZCGunTWpIdqX2XNX8gFtEqr5TFslLMFCwI5u3xLqXE1NxJnEPrtwERsyruX 6nPPq2ECa+lLJ2Ve4pGSG6a8WT2eira5mFGhPmKo6gx1tDAIXvQxZu2EbPp8xbaXsnOp +pGylLlQqy6g+jBC4YV5LDBRIDQpmr9h7oqmGPvIBZcXyD8WQ9i30Wl684n71uC1SIsr bQNKSnF/CVvoXHpedcIlg8oiWmYjuWViiE7jRAllL6USm4ssUjUyqeocz9kqIzGsHhff D0fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041965; x=1699646765; 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=SOAWWpjiiwaZDA84JjbEaSKaXBc7LOkqYDSzl30vo8w=; b=XuQi6a+qNMMyg35cI9PJEgK7KhCNGMcvG11zMGfX9Lr+MIG2J443uq9rsfEb++sli3 CYVn0TL2zX9hqIHR89ORX0dtJSi7CDlreNVwNEj7qUFuhpZoXyHg/qqyHHCldtx2dUnq 1o8HngHcPocxP0NWHoPPoiMlgc2CcE+Kw+etUH1Xle8xgjjr736SoWMpz0AJul8jE9Ge oHJ+1wZiH2i5xDqaT7N2mXsvaf4lGDPNALxVE9BzYADpdh2vDFineepz1bWM2kwAToCU LeMbMsKaBYwk/CuwT2irIXKONOBPZ+zHMPIbHFfBO1etqmjsRJWp//ZbpIWxJLB2yRKD og8A== X-Gm-Message-State: AOJu0YyjsVlvAbPRnQuHuJSnCYm6F3z/FmsMMuHFUx9YpuajMZsC1hC7 G03hYlQ9dVCipit44DANZ4RNFA== X-Received: by 2002:a05:6000:b8d:b0:32d:9395:dec6 with SMTP id dl13-20020a0560000b8d00b0032d9395dec6mr17341981wrb.67.1699041965381; Fri, 03 Nov 2023 13:06:05 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id h3-20020a5d5043000000b0032dba85ea1bsm2636714wrt.75.2023.11.03.13.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:06:05 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 407AC6574B; Fri, 3 Nov 2023 19:59:58 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 15/29] gdbstub: Use GDBFeature for GDBRegisterState Date: Fri, 3 Nov 2023 19:59:42 +0000 Message-Id: <20231103195956.1998255-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x432.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+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: <20231025093128.33116-9-akihiko.odaki@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 67c6fd2609..ebabbc00f6 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;