qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND v5 00/26] plugins: Allow to read registers
@ 2023-08-18  3:36 Akihiko Odaki
  2023-08-18  3:36 ` [PATCH RESEND v5 01/26] contrib/plugins: Use GRWLock in execlog Akihiko Odaki
                   ` (25 more replies)
  0 siblings, 26 replies; 38+ messages in thread
From: Akihiko Odaki @ 2023-08-18  3:36 UTC (permalink / raw)
  Cc: Alex Bennée, Mikhail Tyutin, Aleksandr Anenkov, qemu-devel,
	Akihiko Odaki

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 GDBFeature structure that represents a GDB feature, which usually
includes registers. GDBFeature can be generated from static XML files or
dynamically generated by architecture-specific code. In fact, this is a
refactoring independent of the feature this series adds, and potentially
it's benefitial even without the plugin feature. The plugin feature will
utilize this new structure to describe registers exposed to plugins.

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 last one is to allow to implement a QEMU plugin in C++. A plugin that
I'll describe later is written in C++.

The below is a summary of patches:
Patch 01 fixes a bug in execlog plugin.
Patch [02, 16] introduce GDBFeature.
Patch 17 adds information useful for plugins to GDBFeature.
Patch [18, 21] make registers readable outside of gdbstub context.
Patch [22, 24] add the feature to read registers from plugins.
Patch [25, 26] make it possible to write plugins in C++.

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

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 (26):
  contrib/plugins: Use GRWLock in execlog
  gdbstub: Introduce GDBFeature structure
  gdbstub: Add num_regs member to GDBFeature
  gdbstub: Introduce gdb_find_static_feature()
  target/arm: Move the reference to arm-core.xml
  hw/core/cpu: Replace gdb_core_xml_file with gdb_core_feature
  gdbstub: Introduce GDBFeatureBuilder
  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
  hw/core/cpu: Return static value with gdb_arch_name()
  gdbstub: Dynamically allocate target.xml buffer
  gdbstub: Simplify XML lookup
  hw/core/cpu: Remove gdb_get_dynamic_xml member
  gdbstub: Add members to identify registers to GDBFeature
  target/arm: Remove references to gdb_has_xml
  target/ppc: Remove references to gdb_has_xml
  gdbstub: Remove gdb_has_xml variable
  gdbstub: Expose functions to read registers
  cpu: Call plugin hooks only when ready
  plugins: Allow to read registers
  contrib/plugins: Allow to log registers
  plugins: Support C++
  contrib/plugins: Add cc plugin

 MAINTAINERS                  |   2 +-
 docs/devel/tcg-plugins.rst   |  18 +++-
 configure                    |  15 ++-
 meson.build                  |   2 +-
 gdbstub/internals.h          |   2 +-
 include/exec/gdbstub.h       |  51 +++++++--
 include/hw/core/cpu.h        |  11 +-
 include/qemu/qemu-plugin.h   |  69 +++++++++++-
 target/arm/cpu.h             |  26 ++---
 target/arm/internals.h       |   2 +-
 target/ppc/cpu-qom.h         |   3 +-
 target/ppc/cpu.h             |   3 +-
 target/ppc/internal.h        |   2 +-
 target/riscv/cpu.h           |   4 +-
 target/s390x/cpu.h           |   2 -
 contrib/plugins/execlog.c    | 150 ++++++++++++++++++++------
 cpu.c                        |  11 --
 gdbstub/gdbstub.c            | 198 +++++++++++++++++++++++-----------
 gdbstub/softmmu.c            |   3 +-
 gdbstub/user.c               |   1 -
 hw/core/cpu-common.c         |  10 ++
 plugins/api.c                |  40 +++++++
 stubs/gdbstub.c              |   6 +-
 target/arm/cpu.c             |  12 +--
 target/arm/cpu64.c           |   8 +-
 target/arm/gdbstub.c         | 202 +++++++++++++----------------------
 target/arm/gdbstub64.c       |  90 +++++++---------
 target/arm/tcg/cpu32.c       |   3 +-
 target/avr/cpu.c             |   4 +-
 target/hexagon/cpu.c         |   5 +-
 target/i386/cpu.c            |  13 ++-
 target/loongarch/cpu.c       |   8 +-
 target/loongarch/gdbstub.c   |   2 +-
 target/m68k/cpu.c            |   7 +-
 target/m68k/helper.c         |   6 +-
 target/microblaze/cpu.c      |   9 +-
 target/ppc/cpu_init.c        |   9 +-
 target/ppc/gdbstub.c         |  80 ++++----------
 target/riscv/cpu.c           |  27 ++---
 target/riscv/gdbstub.c       |  89 +++++++--------
 target/rx/cpu.c              |   4 +-
 target/s390x/cpu.c           |   8 +-
 target/s390x/gdbstub.c       |  28 ++---
 target/tricore/cpu.c         |   4 +-
 contrib/plugins/Makefile     |   5 +
 contrib/plugins/cc.cc        |  17 +++
 plugins/qemu-plugins.symbols |   2 +
 scripts/feature_to_c.py      | 102 ++++++++++++++++++
 scripts/feature_to_c.sh      |  69 ------------
 tests/tcg/Makefile.target    |   3 +
 50 files changed, 825 insertions(+), 622 deletions(-)
 create mode 100644 contrib/plugins/cc.cc
 create mode 100755 scripts/feature_to_c.py
 delete mode 100644 scripts/feature_to_c.sh

-- 
2.41.0



^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2023-09-05  6:51 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-18  3:36 [PATCH RESEND v5 00/26] plugins: Allow to read registers Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 01/26] contrib/plugins: Use GRWLock in execlog Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 02/26] gdbstub: Introduce GDBFeature structure Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 03/26] gdbstub: Add num_regs member to GDBFeature Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 04/26] gdbstub: Introduce gdb_find_static_feature() Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 05/26] target/arm: Move the reference to arm-core.xml Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 06/26] hw/core/cpu: Replace gdb_core_xml_file with gdb_core_feature Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 07/26] gdbstub: Introduce GDBFeatureBuilder Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 08/26] target/arm: Use GDBFeature for dynamic XML Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 09/26] target/ppc: " Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 10/26] target/riscv: " Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 11/26] gdbstub: Use GDBFeature for gdb_register_coprocessor Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 12/26] gdbstub: Use GDBFeature for GDBRegisterState Akihiko Odaki
2023-08-30 14:59   ` Alex Bennée
2023-08-18  3:36 ` [PATCH RESEND v5 13/26] hw/core/cpu: Return static value with gdb_arch_name() Akihiko Odaki
2023-08-30 15:00   ` Alex Bennée
2023-08-18  3:36 ` [PATCH RESEND v5 14/26] gdbstub: Dynamically allocate target.xml buffer Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 15/26] gdbstub: Simplify XML lookup Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 16/26] hw/core/cpu: Remove gdb_get_dynamic_xml member Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 17/26] gdbstub: Add members to identify registers to GDBFeature Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 18/26] target/arm: Remove references to gdb_has_xml Akihiko Odaki
2023-08-30 15:02   ` Alex Bennée
2023-08-18  3:36 ` [PATCH RESEND v5 19/26] target/ppc: " Akihiko Odaki
2023-08-25  9:40   ` Nicholas Piggin
2023-08-18  3:36 ` [PATCH RESEND v5 20/26] gdbstub: Remove gdb_has_xml variable Akihiko Odaki
2023-08-30 15:02   ` Alex Bennée
2023-08-30 20:24     ` Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 21/26] gdbstub: Expose functions to read registers Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 22/26] cpu: Call plugin hooks only when ready Akihiko Odaki
2023-08-30 15:04   ` Alex Bennée
2023-08-18  3:36 ` [PATCH RESEND v5 23/26] plugins: Allow to read registers Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 24/26] contrib/plugins: Allow to log registers Akihiko Odaki
2023-08-30 15:08   ` Alex Bennée
2023-08-30 20:53     ` Akihiko Odaki
2023-09-04 15:30       ` Alex Bennée
2023-09-05  6:51         ` Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 25/26] plugins: Support C++ Akihiko Odaki
2023-08-18  3:36 ` [PATCH RESEND v5 26/26] contrib/plugins: Add cc plugin Akihiko Odaki

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).