Return-Path: Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id c3-20020adfe703000000b0033d6fe3f6absm10874714wrm.62.2024.02.27.02.08.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 02:08:33 -0800 (PST) Received: from draig (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id EB8925F78A; Tue, 27 Feb 2024 10:08:32 +0000 (GMT) From: =?utf-8?Q?Alex_Benn=C3=A9e?= To: Akihiko Odaki Cc: qemu-devel@nongnu.org, Nicholas Piggin , Liu Zhiwei , =?utf-8?Q?C=C3=A9dric?= Le Goater , Peter Maydell , qemu-riscv@nongnu.org, Michael Rolnik , Song Gao , Alexandre Iooss , Marcel Apfelbaum , David Hildenbrand , Pierrick Bouvier , John Snow , Eduardo Habkost , Mahmoud Mandour , qemu-arm@nongnu.org, Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Paolo Bonzini , Cleber Rosa , qemu-ppc@nongnu.org, Richard Henderson , qemu-s390x@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Yoshinori Sato , Yanan Wang , Brian Cain , Ilya Leoshkevich , Weiwei Li , "Edgar E. Iglesias" , Bin Meng , Laurent Vivier , Palmer Dabbelt , Daniel Henrique Barboza , Alistair Francis Subject: Re: [PATCH v3 21/27] plugins: add an API to read registers In-Reply-To: (Akihiko Odaki's message of "Tue, 27 Feb 2024 16:47:26 +0900") References: <20240226165646.425600-1-alex.bennee@linaro.org> <20240226165646.425600-22-alex.bennee@linaro.org> User-Agent: mu4e 1.12.0; emacs 29.1 Date: Tue, 27 Feb 2024 10:08:32 +0000 Message-ID: <878r36dxsv.fsf@draig.linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-TUID: yebej4TzH9eP Akihiko Odaki writes: > On 2024/02/27 1:56, Alex Benn=C3=A9e wrote: >> We can only request a list of registers once the vCPU has been >> initialised so the user needs to use either call the get function on >> vCPU initialisation or during the translation phase. >> We don't expose the reg number to the plugin instead hiding it >> behind >> an opaque handle. For now this is just the gdb_regnum encapsulated in >> an anonymous GPOINTER but in future as we add more state for plugins >> to track we can expand it. >> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1706 >> Cc: Akihiko Odaki >> Message-Id: <20240103173349.398526-39-alex.bennee@linaro.org> >> Based-on: <20231025093128.33116-18-akihiko.odaki@daynix.com> >> Signed-off-by: Alex Benn=C3=A9e >> Reviewed-by: Pierrick Bouvier > > Hi, > > Mostly looks good. I have a few trivial comments so please have a look > at them. Done >> + g_array_append_val(find_data, desc); >> + } >> + >> + return find_data; >> +} >> + >> +GArray *qemu_plugin_get_registers(void) >> +{ >> + g_assert(current_cpu); >> + >> + g_autoptr(GArray) regs =3D gdb_get_register_list(current_cpu); >> + return regs->len ? create_register_handles(current_cpu, regs) : NUL= L; > > Why do you need regs->len check? Not all guests expose register to gdb so we need to catch that: TEST catch-syscalls-with-libinsn.so on alpha ** ERROR:../../plugins/api.c:459:qemu_plugin_get_registers: assertion failed: = (regs->len) Aborted --=20 Alex Benn=C3=A9e Virtualisation Tech Lead @ Linaro