summaryrefslogtreecommitdiffstats
path: root/debug/risc-v-gsp-rm-vm/plugins/example_plugin.py
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-10-02 08:36:35 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-10-02 08:36:35 -0400
commit31e27d455969d33190d28917ef98f034888d217b (patch)
treec0c4dc18e78e6a1702fcda43bc2806e7cfb7c931 /debug/risc-v-gsp-rm-vm/plugins/example_plugin.py
parentc155ee8de5b642cbd407bf2231041f17ebe43734 (diff)
downloadopen-iov-31e27d455969d33190d28917ef98f034888d217b.tar.gz
open-iov-31e27d455969d33190d28917ef98f034888d217b.zip
debug: add green-eye GSP/uproc RISC-V VM runtime analysis tooling
Adds open-iov/debug/risc-v-gsp-rm-vm: a GDB-free instrumentation stack that boots uproc/GSP firmware in qemu-system-riscv64 and provides Frida-like hooks, breakpoints, watchpoints, memory dumps, structure decoding, snapshot diffs, recorded sessions, declarative probes, a plugin API and a Ghidra symbol/hit bridge. Verified: 25 tests green (including a live QEMU smoke test); the demo uproc boots with correct hook/leave/watch/schema/snapshot/fault evidence; the optional TCG trace plugin builds and recorded 15M trace lines in 3 s; the TU104 570.144 fwimage probe reports its first exception (load access fault at firmware vaddr 0x4009014 reading 0x2000000000000A00). Documentation: lean tool docs under debug/risc-v-gsp-rm-vm/docs/00-10, a new docs/05-operations/03-risc-v-gsp-rm-vm.md debugging document, and '# TOOL IN DEVELOPMENT - NOT READY YET!' markers in docs/README.md, the onboarding tooling table and the debugging workflows doc. Vendors qemu-plugin.h from QEMU v8.2.2 (GPL-2.0-or-later), with its license header intact, so the optional TCG plugin builds without a QEMU source tree.
Diffstat (limited to 'debug/risc-v-gsp-rm-vm/plugins/example_plugin.py')
-rw-r--r--debug/risc-v-gsp-rm-vm/plugins/example_plugin.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/debug/risc-v-gsp-rm-vm/plugins/example_plugin.py b/debug/risc-v-gsp-rm-vm/plugins/example_plugin.py
new file mode 100644
index 0000000..0bd382e
--- /dev/null
+++ b/debug/risc-v-gsp-rm-vm/plugins/example_plugin.py
@@ -0,0 +1,45 @@
+"""Example green-eye plugin.
+
+Load it explicitly with ``--plugin plugins/example_plugin.py`` (the bundled
+``plugins/`` directory is discovered automatically), or set
+``GREENEYE_PLUGINS=/path/to/plugins``.
+
+It demonstrates the three plugin extension points:
+ * a CLI command (``gehits``),
+ * runtime instrumentation (a hook on ``rpc_state`` logging transitions),
+ * session notes / event stream contributions.
+"""
+from __future__ import annotations
+
+
+def register(ge):
+ ge.log("example plugin loaded")
+
+ state_seen: list[int] = []
+
+ def on_state(hit):
+ state_seen.append(hit.retval or 0)
+ ge.recorder.event(
+ "plugin_state_transition",
+ plugin="example",
+ step=len(state_seen),
+ result=hit.retval,
+ a0=hit.arg(0),
+ )
+
+ sym = ge.symbols.get("rpc_state")
+ if sym is not None:
+ ge.hook("rpc_state", on_leave=on_state)
+ ge.log("hooked rpc_state for transition logging")
+ else:
+ ge.log("rpc_state not in symbol DB; hook skipped")
+
+ def cmd_gehits(session, args):
+ """gehits -- print plugin-observed state transitions."""
+ print(f" observed {len(state_seen)} rpc_state transitions: {state_seen}")
+ directory = getattr(session.recorder, "dir", None)
+ if directory:
+ print(f" session: {directory}")
+ return 0
+
+ ge.add_command("gehits", cmd_gehits, help="print plugin-observed rpc_state transitions")