From nobody Fri Dec 26 04:11:47 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1705935897; cv=none; d=zohomail.com; s=zohoarc; b=gUL2O+5CQKwb3FIIJIYAA9ZV5AX2I5gnMQw4AfhQYuvwxtx2X9fGqcNQP262jpOjt51+63/E1Ku9qjZw4I2L89XEzrndOVMqKZ+c7k2Kh/TDDyXy3pSx9y+Fs0HQa4tI8LaInfCyS2cRfilFCsgiH/UTT7YlCxuci5S/jrrYjYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705935897; h=Content-Type: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:To:To:Message-Id:Reply-To; bh=L7VOplgsBBAgAtEJeAgTFkF54S4NCVefHHQnrnHK8t0=; b=WSBj35/u/Ak1/3llOL3H+FA6dDt4iJXW81mffCbH157nOZEzUgUkcqsawLKHHSs6MCsZcGai83fA14k+dT/cuffXXcnuQPPUYmNDnnwTqSN4Wa0BE6WXG+JHoJir8XC0jM5/IFtg8E+37FWHMG2Kp7TzLC051X2SBTKK/JUjce4= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705935897827280.6747031306754; Mon, 22 Jan 2024 07:04:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rRvo2-00087Z-CA; Mon, 22 Jan 2024 10:01:46 -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 1rRvnv-0007jF-Ab for qemu-devel@nongnu.org; Mon, 22 Jan 2024 10:01:39 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rRvnn-0001lx-4Y for qemu-devel@nongnu.org; Mon, 22 Jan 2024 10:01:38 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40eaf3528c8so7312885e9.2 for ; Mon, 22 Jan 2024 07:01:30 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id s15-20020a5d6a8f000000b00336898daceasm11699962wru.96.2024.01.22.07.01.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 07:01:28 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id AC7E75F936; Mon, 22 Jan 2024 14:56:12 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705935689; x=1706540489; 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=L7VOplgsBBAgAtEJeAgTFkF54S4NCVefHHQnrnHK8t0=; b=AeXivKSIoxzxKpSA5sDZUPsObI+mOKI6PtGCp/2+NCKKUp6/qasomAmjU47aa7LGwR rV/MqzpdLGHcEQk4bm67pbfE2Ca7EKP3EOrT+akQnEsOvR6t5huLkfPhSV3Ll87uTjJP cBzift88zp7T7Og8YUvkFyHROsvUIYzjLOMma6MxoGyu5MacDBwp09hgVleVe1tN31Pf cocfTKjFfSGYW3rM/tdf0oOPGOA4XWfY04r2B0EnoVczTbxz5RSMrZdef/algMQqoKhn o14wNHaYls1Z02ZgXTp0rXegaTap90mnZyWJ999oi1vZZNeEo804Ql/O9KfH7UNgA7UE wVtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705935689; x=1706540489; 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=L7VOplgsBBAgAtEJeAgTFkF54S4NCVefHHQnrnHK8t0=; b=WyQ3iRxzIxKscXJpFQkvplMn2q4ji6VWOiBgXB2xjjKanu/f6fbabWTEdqYBb93HpA dpxSzZIhwfVxO8KMHmkrmLs/PnZ+I+bdX21v+XYB8TUTiUaYLFbblbMJ4WCQVBxdx3OO VyLLNQWYEI5ECrFWfg2BPmzbkLyGIYQw7kgcqewDFjJfwZ18ntWEJQc6ICs3g/aRQVp2 JMC8e0IIrsErLOhFPw+EgUdKPhGqzPlVY8G1Y1etqD8RWDJsVoEuCEMr2dpd5L/tPdRK 5AUqUH9HQ4VPkR8DnPbhXC0n8NpHGj3wLmuiHbQEb32imf9kj7FPB49w9ECMz9mUED4n fJcA== X-Gm-Message-State: AOJu0YzM/lKvav4obueg0oBDNHiS4zmkLJ1XP+Mm/x9S+Toj7O6Sgkpz dJsi6+22E8VUqSkGG5obQPKCelUyYEYwpLDAZ4TBZMqtZxldQ2gTZoHpS4tdkc0= X-Google-Smtp-Source: AGHT+IFxNTPr8NUI2fFrYkNhQafasrORn8JAkp9EvucZOYRV+FHSy9wjv9TICupAQqM47gPf+Jni/Q== X-Received: by 2002:a05:600c:154c:b0:40d:7f19:40b1 with SMTP id f12-20020a05600c154c00b0040d7f1940b1mr2366763wmg.169.1705935688882; Mon, 22 Jan 2024 07:01:28 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , "Edgar E. Iglesias" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Michael Rolnik , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , 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=20Benn=C3=A9e?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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 16/21] gdbstub: expose api to find registers Date: Mon, 22 Jan 2024 14:56:05 +0000 Message-Id: <20240122145610.413836-17-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2a00:1450:4864:20::334; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x334.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705935898246100004 Expose an internal API to QEMU to return all the registers for a vCPU. The list containing the details required to called gdb_read_register(). Based-on: <20231025093128.33116-15-akihiko.odaki@daynix.com> Cc: Akihiko Odaki Message-Id: <20240103173349.398526-38-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- v3 - rm unused api functions left over --- include/exec/gdbstub.h | 28 ++++++++++++++++++++++++++++ gdbstub/gdbstub.c | 27 ++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index da9ddfe54c5..eb14b91139b 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -111,6 +111,34 @@ void gdb_feature_builder_end(const GDBFeatureBuilder *= builder); */ const GDBFeature *gdb_find_static_feature(const char *xmlname); =20 +/** + * gdb_read_register() - Read a register associated with a CPU. + * @cpu: The CPU associated with the register. + * @buf: The buffer that the read register will be appended to. + * @reg: The register's number returned by gdb_find_feature_register(). + * + * Return: The number of read bytes. + */ +int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); + +/** + * typedef GDBRegDesc - a register description from gdbstub + */ +typedef struct { + int gdb_reg; + const char *name; + const char *feature_name; +} GDBRegDesc; + +/** + * gdb_get_register_list() - Return list of all registers for CPU + * @cpu: The CPU being searched + * + * Returns a GArray of GDBRegDesc, caller frees array but not the + * const strings. + */ +GArray *gdb_get_register_list(CPUState *cpu); + void gdb_set_stop_cpu(CPUState *cpu); =20 /* in gdbstub-xml.c, generated by scripts/feature_to_c.py */ diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 420ab2a3766..14f2f32e63f 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -490,7 +490,32 @@ const GDBFeature *gdb_find_static_feature(const char *= xmlname) g_assert_not_reached(); } =20 -static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) +GArray *gdb_get_register_list(CPUState *cpu) +{ + GArray *results =3D g_array_new(true, true, sizeof(GDBRegDesc)); + + /* registers are only available once the CPU is initialised */ + if (!cpu->gdb_regs) { + return results; + } + + for (int f =3D 0; f < cpu->gdb_regs->len; f++) { + GDBRegisterState *r =3D &g_array_index(cpu->gdb_regs, GDBRegisterS= tate, f); + for (int i =3D 0; i < r->feature->num_regs; i++) { + const char *name =3D r->feature->regs[i]; + GDBRegDesc desc =3D { + r->base_reg + i, + name, + r->feature->name + }; + g_array_append_val(results, desc); + } + } + + return results; +} + +int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { CPUClass *cc =3D CPU_GET_CLASS(cpu); GDBRegisterState *r; --=20 2.39.2