From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Alexandre Iooss" <erdnaxe@crans.org>,
"Mahmoud Mandour" <ma.mandourr@gmail.com>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [RFC PATCH] plugins: filter out the PC from the register list
Date: Tue, 5 Mar 2024 17:12:18 +0000 [thread overview]
Message-ID: <20240305171218.3621274-1-alex.bennee@linaro.org> (raw)
QEMU's handling of the program counter is special in so far as the
translator avoids setting it whenever possible. As the PC is available
at translation time lets avoid confusion by just filtering the program
counter from the list of available registers.
Update the documentation with some notes about the register access and
calling out the behaviour of the PC.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2208
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
docs/devel/tcg-plugins.rst | 15 +++++++++++++++
plugins/api.c | 5 +++++
2 files changed, 20 insertions(+)
diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst
index 9cc09d8c3da..656df012e77 100644
--- a/docs/devel/tcg-plugins.rst
+++ b/docs/devel/tcg-plugins.rst
@@ -151,6 +151,21 @@ Unsuccessful operations (i.e. faults) will not be visible to memory
instrumentation although the execution side effects can be observed
(e.g. entering a exception handler).
+Register Values
++++++++++++++++
+
+Callbacks registered with the ``QEMU_PLUGIN_CB_R_REGS`` flags can read
+the current register values of the system. The plugin need to request
+the list of available registers after a vcpu has initialised by
+calling ``qemu_plugin_get_registers`` and using the supplied handle to
+query the values when executing the callback.
+
+.. Note:: the program counter (PC) is not available through this
+ interface but can be queried at translation time by using
+ the ``qemu_plugin_insn_vaddr`` and
+ ``qemu_plugin_insn_haddr`` on the instruction handle.
+
+
System Idle and Resume States
+++++++++++++++++++++++++++++
diff --git a/plugins/api.c b/plugins/api.c
index 8fa5a600ac3..fc3477acf2d 100644
--- a/plugins/api.c
+++ b/plugins/api.c
@@ -448,6 +448,11 @@ static GArray *create_register_handles(GArray *gdbstub_regs)
continue;
}
+ /* skip the program counter */
+ if (g_ascii_strncasecmp(grd->name, "pc", 2) == 0) {
+ continue;
+ }
+
/* Create a record for the plugin */
desc.handle = GINT_TO_POINTER(grd->gdb_reg);
desc.name = g_intern_string(grd->name);
--
2.39.2
next reply other threads:[~2024-03-05 17:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-05 17:12 Alex Bennée [this message]
2024-03-05 17:28 ` [RFC PATCH] plugins: filter out the PC from the register list Peter Maydell
2024-03-05 17:36 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240305171218.3621274-1-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=erdnaxe@crans.org \
--cc=ma.mandourr@gmail.com \
--cc=pbonzini@redhat.com \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).