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: 13525586 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77E9947A6B for ; Mon, 22 Jan 2024 14:56:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705935383; cv=none; b=A/xMzD9sI10vGSgDZvKLMsQGF+8f/egQ5SQ4BK0Obu65yye8Pyp+9qV/Y3IpOHp4+OLWQ3g1aik9YHDZSPgf2KMjg0lRaFtxI5X4fM8xHb4q5I9k2XdG19HiWdxcuD1cv9Da/0EA7iI0Z3Wjlt4mFczUwnoeiVOjk+pQZe07+3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705935383; c=relaxed/simple; bh=uOag9YiVhHjgAc4PSGF9mhIRbvghllC3fCxvBHokFrw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=BNMRDkXMz+vXWqSuzIG0ebC5JkPaUl69xvS33dFWBzIIEloXANqI4fdrFgThGtzGjNbbk5pjH9Ny0y5lbeKS0Gu66rS12Mb4/B8eKo0sVlUgTAMPTB5p+tWTq86xQ1+wVKpQyKmEHThdAhLB9EJBG5TopUN0FPYkkAwx7C/5ItI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=OvB2KzDC; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OvB2KzDC" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-40eb28271f8so2199115e9.2 for ; Mon, 22 Jan 2024 06:56:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705935380; x=1706540180; darn=vger.kernel.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=OvB2KzDCaKU8Y9BoYhl4tXKDbOCn9ShIIsV4Ie7DDuEjqjst4P8ZNcrl6184BJV8cM aCXD26GIiHVaiN2nbvbFJl/oVVU7m21QP7cOXF02R7LEwMZLJqSR11jUucTJGbPBqTZW qR5F4/Jt5Aetsn1sJMgcf+FJkrYwMwcZzLK7hQ5GZJign447gWYzKAe2zn+oeNIfr6/b T926I3ZkXtm84RsbGDIK+nr5obE2xOQ0VDaqmCdWSLRdi1zS4yw3awcO12U9Zyq3N3xF lrGe0FWs2IGb2syUjoNOE8gqAkzuwnP3vlDqswAH3WG4e0JkO/dvwiidsjCjnZyKLocj eD6A== 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=dUHk4ojb9sHwsnItEmrHIHzAH34lp2q1/npmKpL0UcEW0Iqt0Aj64rinLH+JAG24eF 9KG6iMjmq1vEQKWIxWcg7E13BiF8lHKeGPXSC2cP8diX02HFblnCnhCFt5sTsG9ev5PV aTEbycQNI+SYmJLmuCaRS/GYyj98j6JlH8AnT0x3ZHBbJrIn7VsGkALZKYDhkP9RUAk7 Ap0mUVNIxJPGh8WTUUsg7VA5yXD1rb8L8lHXSeIO2u4avcacu+1PLvX6o9dlnXdKBwBp IDZI4VJsJoLBrTZF4dSxyUhXwEbRmHu0NdG6AgzgrJTbD6Bjmnjs/yC70f7vyi+mJ114 YNeA== X-Gm-Message-State: AOJu0YxqrVMvREEUy6H6R6dktzXqTAK1gTxRPhxkEBziALcxXryUFIjp dYBqvG6CtT+Jo/f84hluC5Beg2L6bU0RzuhMDo/gwiK4g0+JOYUn84txVwYPYDs= X-Google-Smtp-Source: AGHT+IGO7+SVpVCty+QMuZ5XWMkD2R7LdfBxaB5kk1TI4ToS3w8RJ5QwV5ZQrYH9LHANHW13J9fUYA== 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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;