qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH] plugins: filter out the PC from the register list


From: Alex Bennée
Subject: [RFC PATCH] plugins: filter out the PC from the register list
Date: Tue, 5 Mar 2024 17:12:18 +0000

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]