Skip to content

plugins: Allow to read registers

Akihiko Odaki qemu-arm qemu-devel qemu-riscv 18 versions – In review

Get series with b4
b4 am [email protected] change-id 20231213-gdb-349db0da93f2

Versions newest first · linked by author and title

  1. v17 Latest14 patches 5 repliesIn review
  2. v1618 patches 2 repliesSuperseded
  3. v1519 patches 0 repliesSuperseded
Earlier versions · 15
VersionPostedPatchesRepliesStatus
v1418 patches11 repliesSuperseded
v1318 patches1 replySuperseded
v1218 patches0 repliesSuperseded
v1118 patches5 repliesSuperseded
v1018 patches0 repliesSuperseded
v923 patches12 repliesSuperseded
v819 patches0 repliesSuperseded
v718 patches2 repliesSuperseded
v618 patches0 repliesSuperseded
v5 posting 2/226 patches11 repliesSuperseded
v5 posting 1/23 of 26 patches2 repliesSuperseded
v425 patches10 repliesSuperseded
v325 patches0 repliesSuperseded
v224 patches0 repliesSuperseded
v1 RFC24 patches36 repliesSuperseded

Changes in v17 from the cover letter

Rebased.

Patches in v17 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14target/arm: Use GDBFeature for dynamic XMLtarget/arm/cpu.h target/arm/gdbstub.c target/arm/gdbstub64.c +1 more+123 -1370 replies
2/14target/ppc: Use GDBFeature for dynamic XMLtarget/ppc/cpu-qom.h target/ppc/cpu.h target/ppc/cpu_init.c +1 more+21 -390 replies
3/14target/riscv: Use GDBFeature for dynamic XMLtarget/riscv/cpu.c target/riscv/cpu.h target/riscv/gdbstub.c+40 -481 reply
4/14gdbstub: Use GDBFeature for gdb_register_coprocessorgdbstub/gdbstub.c include/exec/gdbstub.h target/arm/gdbstub.c +7 more+60 -651 reply
5/14gdbstub: Use GDBFeature for GDBRegisterStategdbstub/gdbstub.c+6 -80 replies
6/14gdbstub: Change gdb_get_reg_cb and gdb_set_reg_cbgdbstub/gdbstub.c include/exec/gdbstub.h target/arm/gdbstub.c +11 more+236 -911 reply
7/14gdbstub: Simplify XML lookupgdbstub/gdbstub.c hw/core/cpu-common.c include/exec/gdbstub.h+69 -600 replies
8/14gdbstub: Infer number of core registers from XMLgdbstub/gdbstub.c include/hw/core/cpu.h target/arm/cpu.c +11 more+6 -171 reply
9/14hw/core/cpu: Remove gdb_get_dynamic_xml memberinclude/hw/core/cpu.h target/arm/cpu.c target/arm/cpu.h +5 more+0 -571 reply
10/14gdbstub: Add members to identify registers to GDBFeaturegdbstub/gdbstub.c include/exec/gdbstub.h scripts/feature_to_c.py +1 more+26 -70 replies
11/14gdbstub: Expose functions to read registersgdbstub/gdbstub.c include/exec/gdbstub.h+59 -10 replies
12/14plugins: Use different helpers when reading registersaccel/tcg/plugin-gen.c accel/tcg/plugin-helpers.h include/qemu/plugin.h +1 more+52 -70 replies
13/14plugins: Allow to read registersinclude/qemu/qemu-plugin.h plugins/api.c plugins/qemu-plugins.symbols+71 -20 replies
14/14contrib/plugins: Allow to log registerscontrib/plugins/execlog.c docs/devel/tcg-plugins.rst+97 -330 replies

Reviews trailers per patch

9 of 14 patches have a Reviewed-by or Acked-by.

PatchRichard HendersonAlex BennéeAlistair Francis
1/14A-b
2/14R-b
3/14A-b
4/14A-b A-b
5/14R-b
6/14R-b A-b
7/14R-b
8/14A-b
9/14R-b A-b
10/14
11/14
12/14
13/14
14/14

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v17 thread

Cover letter [PATCH v17 00/14] plugins: Allow to read registers

Based-on: <[email protected]> ("[PATCH v7 0/4] gdbstub and TCG plugin improvements")

I and other people in the University of Tokyo, where I research processor design, found TCG plugins are very useful for processor design exploration.

The feature we find missing is the capability to read registers from plugins. In this series, I propose to add such a capability by reusing gdbstub code.

The reuse of gdbstub code ensures the long-term stability of the TCG plugin interface for register access without incurring a burden to maintain yet another interface for register access.

This process to add TCG plugin involves four major changes. The first one is to add members to GDBFeature necessary for register identification.

The second one is to make gdb_read_register/gdb_write_register usable outside of gdbstub context.

The third one is to actually make registers readable for plugins.

The execlog plugin will have new options to demonstrate the new feature. I also have a plugin that uses this new feature to generate execution traces for Sniper processor simulator, which is available at:
https://github.com/shioya-lab/sniper/tree/akihikodaki/bb

The below is a summary of patches:
Patch [01, 09] changes to use GDBFeature for dynamic XMLs. Patch 10 adds members useful to identify registers to GDBFeature. Patch 11 makes registers readable outside of gdbstub context. Patch [12, 14] add the feature to read registers from plugins.

V16 -> V17:
Rebased.

V15 -> V16:
Added new plugin_dyn_cb_subtype and plugin_gen_cb to remove the global translator state change.

V14 -> V15:
Added kdoc comments to include/exec/gdbstub.h. Changed to use g_array_append_val() in gdb_register_feature(). Separated the CPU flags from event bitmap.

V13 -> V14:
Fixed RISC-V CSR register numbers.

V12 -> V13:
Rebased to "[PATCH v4 0/5] gdbstub and TCG plugin improvements".

V11 -> V12:
Rebased to "[PATCH v2 0/3] gdbstub and TCG plugin improvements".

V10 -> V11:
Fixed QEMU_PLUGIN_CB_RW_REGS.

V9 -> V10:
Rebased to "[PATCH 0/4] gdbstub and TCG plugin improvements". Dropped patch "plugins: Support C++".
Removed the unnecessary QEMU_PLUGIN_VERSION change.

V8 -> V9:
Rebased to "[PATCH 00/25] October maintainer omnibus pre-PR (tests, gdbstub, plugins)".
Added patch "target/riscv: Move MISA limits to class". Added patch "target/riscv: Remove misa_mxl validation". Added patch "target/riscv: Validate misa_mxl_max only once". Added patch "plugins: Use different helpers when reading". Moved contrib/plugins/cc.cc to tests/plugin/cc.cc.

V7 -> V8:
Rebased to "[PATCH v3 00/12] gdbstub and TCG plugin improvements". Clarified that initialization and exit hooks affect TCG state. Simplified by adding the core feature to gdb_regs.

V6 -> V7:
Rebased to "[PATCH v2 00/11] gdbstub and TCG plugin improvements". Replaced functions to get register identifiers.

V5 -> V6:
Rebased to "[PATCH 0/8] gdbstub and TCG plugin improvements".

V4 -> V5:
Corrected g_rw_lock_writer_lock() call. (Richard Henderson) Replaced abort() with g_assert_not_reached(). (Richard Henderson) Fixed CSR name leak in target/riscv. (Richard Henderson) Removed gdb_has_xml variable.

V3 -> V4:
Added execlog changes I forgot to include in the last version.

V2 -> V3:
Added patch "hw/core/cpu: Return static value with gdb_arch_name()". Added patch "gdbstub: Dynamically allocate target.xml buffer". (Alex Bennée)
Added patch "gdbstub: Introduce GDBFeatureBuilder". (Alex Bennée) Dropped Reviewed-by tags for "target/*: Use GDBFeature for dynamic XML". Changed gdb_find_static_feature() to abort on failure. (Alex Bennée) Changed the execlog plugin to log the register value only when changed. (Alex Bennée)
Dropped 0x prefixes for register value logs for conciseness.

V1 -> V2:
Added SPDX-License-Identifier: GPL-2.0-or-later. (Philippe Mathieu-Daudé) Split long lines. (Philippe Mathieu-Daudé)
Renamed gdb_features to gdb_static_features (Philippe Mathieu-Daudé) Dropped RFC.

---
Akihiko Odaki (14):
target/arm: Use GDBFeature for dynamic XML target/ppc: Use GDBFeature for dynamic XML target/riscv: Use GDBFeature for dynamic XML
gdbstub: Use GDBFeature for gdb_register_coprocessor
gdbstub: Use GDBFeature for GDBRegisterState
gdbstub: Change gdb_get_reg_cb and gdb_set_reg_cb
gdbstub: Simplify XML lookup
gdbstub: Infer number of core registers from XML hw/core/cpu: Remove gdb_get_dynamic_xml member
gdbstub: Add members to identify registers to GDBFeature
gdbstub: Expose functions to read registers
plugins: Use different helpers when reading registers
plugins: Allow to read registers contrib/plugins: Allow to log registers

 docs/devel/tcg-plugins.rst   |  10 +-
 accel/tcg/plugin-helpers.h   |   3 +-
 include/exec/gdbstub.h       |  44 ++++++++-
 include/hw/core/cpu.h        |   7 +-
 include/qemu/plugin.h        |   1 +
 include/qemu/qemu-plugin.h   |  50 +++++++++-
 target/arm/cpu.h             |  27 ++---
 target/arm/internals.h       |  14 +--
 target/hexagon/internal.h    |   4 +-
 target/microblaze/cpu.h      |   4 +-
 target/ppc/cpu-qom.h         |   1 +
 target/ppc/cpu.h             |   5 +-
 target/riscv/cpu.h           |   5 +-
 target/s390x/cpu.h           |   2 -
 accel/tcg/plugin-gen.c       |  43 +++++++-
 contrib/plugins/execlog.c    | 120 ++++++++++++++++------
 gdbstub/gdbstub.c            | 173 +++++++++++++++++++-------------
 hw/core/cpu-common.c         |   5 +-
 plugins/api.c                |  32 +++++-
 target/arm/cpu.c             |   2 -
 target/arm/cpu64.c           |   1 -
 target/arm/gdbstub.c         | 230 ++++++++++++++++++++++---------------------
 target/arm/gdbstub64.c       | 122 ++++++++++++-----------
 target/avr/cpu.c             |   1 -
 target/hexagon/cpu.c         |   4 +-
 target/hexagon/gdbstub.c     |  10 +-
 target/i386/cpu.c            |   2 -
 target/loongarch/cpu.c       |   2 -
 target/loongarch/gdbstub.c   |  13 ++-
 target/m68k/cpu.c            |   1 -
 target/m68k/helper.c         |  26 +++--
 target/microblaze/cpu.c      |   6 +-
 target/microblaze/gdbstub.c  |   9 +-
 target/ppc/cpu_init.c        |   7 --
 target/ppc/gdbstub.c         | 114 ++++++++++-----------
 target/riscv/cpu.c           |  15 ---
 target/riscv/gdbstub.c       | 139 ++++++++++++++------------
 target/rx/cpu.c              |   1 -
 target/s390x/cpu.c           |   1 -
 target/s390x/gdbstub.c       | 105 ++++++++++++--------
 plugins/qemu-plugins.symbols |   3 +
 scripts/feature_to_c.py      |  14 ++-
 42 files changed, 836 insertions(+), 542 deletions(-)

---
base-commit: 651f18e5def549b67df934e38c474963b884ccc7
change-id: 20231213-gdb-349db0da93f2

Best regards,

Signature · 1 line
Akihiko Odaki <[email protected]>