From patchwork Mon Jan 22 14:55:58 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: 764661 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:10c4:b0:337:62d3:c6d5 with SMTP id b4csp1145066wrx; Mon, 22 Jan 2024 07:04:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFL7bofupHuZ3lYGN1tOb8IWdzO8dwr4da4ygDNWKxarMfUpAciaqvN/1DPJmoPSeaHnbJC X-Received: by 2002:a05:6830:1e10:b0:6e0:ed26:c9fc with SMTP id s16-20020a0568301e1000b006e0ed26c9fcmr1786630otr.13.1705935895604; Mon, 22 Jan 2024 07:04:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705935895; cv=none; d=google.com; s=arc-20160816; b=OxKml6V3tVAvJ5fhm/8rTOHv9pJFS8Wp9VXlR/DebxehaomQ2gL60JWJns8WiSgZ/P YB3PVrxBO6QC98KkcTkfUsMnm9O9ZldXGofWIVKZNNYNwnP8xz7XcOVFC59UTJ/t7xrN 85s2YBLr6+4rJeAa6J7Kj/ftbVxdXicY0f5oYxGRM0KtMMirEsE8nVvDhKRKDaScVOnw 5qOGJL6VzgVgk+utaVMftf7sdI6ESrgOEqzyUDXtYktY/YmdnPIceVKfIUgKyjyMaY79 ThzGcdq3G+PEhFYBaCPsWJ/rROpgGK68MvFobv+bnD98Ld8ewYcr8E8noSL/vzeJwr3i MhoA== 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=vrHtFk8FqRL+779o45NQf1FCvJE8oH7F88C4kJtsxq8=; fh=mGQIuaf4A7RZOxcauYqguCwKMqzWt70hd4nAkQm0M6A=; b=GdEWOJu/MDG5cheSHRG2sKkRaw09M6IXi5LKotHX24b5brkuz5LwJAIPWLSvhs+z7H /jL/r/jdfOLYAT1aRSr+isUdhkXrQqimIpQIUfOxTwA4hchbWU9un5s2xIG+7A37KYbz yl0GSZq21J3tELa9eJkTu2UfzHZeqXnUKjzZd0JF01KayMtoP2u6oXn9o1efUVGmDXon XlMjpzCUO9Hbk6QCzZittmdFjsF8mdtIP80/f+wUBR7sHb+ozhlHBVn28cnaNB0PsAYW ZA2Y7DKZZMVzqEW5zei4AgXU6evuuqXgr4Ca247ZWumSx7mT0Lt+NtURRG1J7UwnDJVD a4pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NhkOtwcc; 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 r21-20020a05610204b500b00466e7cd7db1si524263vsa.427.2024.01.22.07.04.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jan 2024 07:04:55 -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=NhkOtwcc; 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 1rRvjE-0007K8-Df; Mon, 22 Jan 2024 09:56:48 -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 1rRvj1-00078q-Qk for qemu-devel@nongnu.org; Mon, 22 Jan 2024 09:56:36 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rRvin-0008NX-G2 for qemu-devel@nongnu.org; Mon, 22 Jan 2024 09:56:35 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40eacb6067dso13428465e9.1 for ; Mon, 22 Jan 2024 06:56:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705935380; x=1706540180; 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=vrHtFk8FqRL+779o45NQf1FCvJE8oH7F88C4kJtsxq8=; b=NhkOtwccMNYLvvjbUFcASIuS18B0b9rkgcCT1RDMFR5sJKHOWzb/F2KwDpq5lBvRze Nad09VqhDgWQNXzSoclcIxmI0ZxmApidlSHMR5vrABaSWzGeJOvk+DWisb2v6U8MAvzp sVberuz04Tag9sT/zdomTy2rbqhTSlDgyHYaZlhGGjgXfuKhtmdWxhaylDnqaQSmYuW0 ky4VZgJW2uDIxQWSmWrlKp3HgC3F2AGuIrhJBa00Fh9iT4n2Jz9m/YS6IpfEqFvUjbQ2 G41e6FQ6Cq/4TIC3qfbBpY/p1ymgzDj4heOCq2Dsv8kO4jz7wpC3dKQ0yYQ3hRBhpVM7 8zCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705935380; x=1706540180; 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=vrHtFk8FqRL+779o45NQf1FCvJE8oH7F88C4kJtsxq8=; b=jkiVMhIxAOGB0gVXFeaCJGL6HVu/z9OgD5Vv1Gvm7fCejuqXYhek+bqBZ3+S1gBv26 jUGVumoc/WJK26PKlvwSd5sCoxVhUJO8nyC6DU8p3SsnZt/MbXtFCWM05WkkaaWtCA9V nivF39PE1giFUtqdJhKhlj4RZE6uC1/HwywNhNrstxxmBXQUhpKqFGDBDlUEvCVQ8Guu JYjocuKzcv0tSWzSPciGRxfUydnC2bV9dn7n9PgS/cl4/IJ04zh0wRyM7m8NfOhe/oFZ fc7AIW/LbTD3USB8mrhjLVvItqBv28Msmb/3REeeOMKs6fiaklF2X7YaVOQQ6b4+ulzy Qytg== X-Gm-Message-State: AOJu0Yx83x2NGYnMe59ReJf21vu6GmKCj1xjoNvd9Rc31mO9kxhA3dXp v4gbuX/1dCsbvanS4dGhl5g4AqYHu6Bmzp0uIzafq+VlrE144g/Cxv1AJV8fkyE= X-Received: by 2002:a05:600c:1906:b0:40e:a7d2:5a5a with SMTP id j6-20020a05600c190600b0040ea7d25a5amr918637wmq.71.1705935379780; Mon, 22 Jan 2024 06:56:19 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id x8-20020a5d4448000000b0033925e94c89sm7018246wrr.12.2024.01.22.06.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 06:56:14 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C81A55F90B; Mon, 22 Jan 2024 14:56:11 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Michael Rolnik , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Laurent Vivier , kvm@vger.kernel.org, Yoshinori Sato , Pierrick Bouvier , Palmer Dabbelt , Liu Zhiwei , Laurent Vivier , Yanan Wang , qemu-ppc@nongnu.org, Weiwei Li , qemu-s390x@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Peter Maydell , Alexandre Iooss , John Snow , Mahmoud Mandour , Wainer dos Santos Moschetta , Richard Henderson , Ilya Leoshkevich , Alistair Francis , David Woodhouse , Cleber Rosa , Beraldo Leal , Bin Meng , Nicholas Piggin , Aurelien Jarno , Daniel Henrique Barboza , Daniel Henrique Barboza , Thomas Huth , David Hildenbrand , qemu-riscv@nongnu.org, qemu-arm@nongnu.org, Paolo Bonzini , Song Gao , Eduardo Habkost , Brian Cain , Paul Durrant , Akihiko Odaki Subject: [PATCH v3 09/21] gdbstub: Use GDBFeature for GDBRegisterState Date: Mon, 22 Jan 2024 14:55:58 +0000 Message-Id: <20240122145610.413836-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240122145610.413836-1-alex.bennee@linaro.org> References: <20240122145610.413836-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.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 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 068180c83c7..a80729436b6 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;