mbox series

[v1,00/10] split user and system code in gdbstub

Message ID 20221216112206.3171578-1-alex.bennee@linaro.org
Headers show
Series split user and system code in gdbstub | expand

Message

Alex Bennée Dec. 16, 2022, 11:21 a.m. UTC
Hi,

We currently re-compile gdbstub for every single target on the system.
Part of the reason for this is we have a lot of conditional #ifdefs to
handle the differences between user and system mode debugging. To use
the CONFIG_USER_ONLY and CONFIG_SOFTMMU defines you require using
NEED_CPU which ensures CONFIG_TARGET is included.

This series starts to pull things apart so we split user and system
specific code into their appropriate files and reduce the amount of
#ifdef stuff in gdbstub. The work is not complete but hopefully shows
the direction of travel.

We also split up the public headers so other parts of the code aren't
forced to bring in all the additional NEED_CPU stuff just to access
the core API. The GDB helpers which do have to be host/target aware to
deal with byte swaps are now in their own mini-header.

What remains:

  - re-factoring inline #ifdef blocks
  - eliminating target_ulong usage
  - once no longer target dependent move gdbstub to common_ss

The command table is one section that still requires handling the
differences between user and system mode so I think that might end up
being split into a separate file or possibly figuring out how to
compile gdbstub just twice, once for user_ss (with CONFIG_USER_ONLY
manually defined) and once for system_ss. Any pointers on the meson
magic to do that gratefully received.

Please review

Alex Bennée (9):
  gdbstub/internals.h: clean up include guard
  gdbstub: fix-up copyright and license files
  gdbstub: split GDBConnection from main structure
  gdbstub: move GDBState to shared internals header
  includes: move tb_flush into its own header
  includes: add new gdbstub include directory
  gdbstub: move chunk of softmmu functionality to own file
  gdbstub: move chunks of user code into own files
  gdbstub: retire exec/gdbstub.h

Philippe Mathieu-Daudé (1):
  gdbstub: Make syscall_complete/[gs]et_reg target-agnostic typedefs

 bsd-user/qemu.h                              |    2 +-
 gdbstub/internals.h                          |  139 +-
 include/exec/exec-all.h                      |    1 -
 include/exec/tb-flush.h                      |   19 +
 include/{exec/gdbstub.h => gdbstub/common.h} |  141 +-
 include/gdbstub/helpers.h                    |  101 ++
 include/gdbstub/user.h                       |   43 +
 linux-user/user-internals.h                  |    1 +
 accel/kvm/kvm-all.c                          |    2 +-
 accel/stubs/tcg-stub.c                       |    1 +
 accel/tcg/tb-maint.c                         |    1 +
 accel/tcg/tcg-accel-ops.c                    |    2 +-
 accel/tcg/translate-all.c                    |    1 +
 cpu.c                                        |    1 +
 gdbstub/gdbstub.c                            | 1331 ++----------------
 gdbstub/softmmu.c                            |  514 ++++++-
 gdbstub/user-target.c                        |  283 ++++
 gdbstub/user.c                               |  348 ++++-
 hw/ppc/spapr_hcall.c                         |    1 +
 linux-user/exit.c                            |    2 +-
 linux-user/main.c                            |    3 +-
 linux-user/signal.c                          |    2 +-
 monitor/misc.c                               |    2 +-
 plugins/core.c                               |    1 +
 plugins/loader.c                             |    2 +-
 semihosting/arm-compat-semi.c                |    2 +-
 semihosting/console.c                        |    2 +-
 semihosting/guestfd.c                        |    2 +-
 semihosting/syscalls.c                       |    3 +-
 softmmu/cpus.c                               |    2 +-
 softmmu/runstate.c                           |    2 +-
 softmmu/vl.c                                 |    2 +-
 stubs/gdbstub.c                              |    2 +-
 target/alpha/gdbstub.c                       |    2 +-
 target/alpha/sys_helper.c                    |    1 +
 target/arm/gdbstub.c                         |    3 +-
 target/arm/gdbstub64.c                       |    2 +-
 target/arm/helper-a64.c                      |    2 +-
 target/arm/kvm64.c                           |    2 +-
 target/arm/m_helper.c                        |    2 +-
 target/avr/gdbstub.c                         |    2 +-
 target/cris/gdbstub.c                        |    2 +-
 target/hexagon/gdbstub.c                     |    2 +-
 target/hppa/gdbstub.c                        |    2 +-
 target/i386/gdbstub.c                        |    2 +-
 target/i386/kvm/kvm.c                        |    2 +-
 target/i386/whpx/whpx-all.c                  |    2 +-
 target/loongarch/gdbstub.c                   |    3 +-
 target/m68k/gdbstub.c                        |    2 +-
 target/m68k/helper.c                         |    3 +-
 target/m68k/m68k-semi.c                      |    4 +-
 target/microblaze/gdbstub.c                  |    2 +-
 target/mips/gdbstub.c                        |    2 +-
 target/mips/tcg/sysemu/mips-semi.c           |    3 +-
 target/nios2/cpu.c                           |    2 +-
 target/nios2/nios2-semi.c                    |    3 +-
 target/openrisc/gdbstub.c                    |    2 +-
 target/openrisc/interrupt.c                  |    2 +-
 target/openrisc/mmu.c                        |    2 +-
 target/ppc/cpu_init.c                        |    2 +-
 target/ppc/gdbstub.c                         |    3 +-
 target/ppc/kvm.c                             |    2 +-
 target/riscv/csr.c                           |    1 +
 target/riscv/gdbstub.c                       |    3 +-
 target/rx/gdbstub.c                          |    2 +-
 target/s390x/gdbstub.c                       |    3 +-
 target/s390x/helper.c                        |    2 +-
 target/s390x/kvm/kvm.c                       |    2 +-
 target/sh4/gdbstub.c                         |    2 +-
 target/sparc/gdbstub.c                       |    2 +-
 target/tricore/gdbstub.c                     |    2 +-
 target/xtensa/core-dc232b.c                  |    2 +-
 target/xtensa/core-dc233c.c                  |    2 +-
 target/xtensa/core-de212.c                   |    2 +-
 target/xtensa/core-de233_fpu.c               |    2 +-
 target/xtensa/core-dsp3400.c                 |    2 +-
 target/xtensa/core-fsf.c                     |    2 +-
 target/xtensa/core-lx106.c                   |    2 +-
 target/xtensa/core-sample_controller.c       |    2 +-
 target/xtensa/core-test_kc705_be.c           |    2 +-
 target/xtensa/core-test_mmuhifi_c3.c         |    2 +-
 target/xtensa/gdbstub.c                      |    2 +-
 target/xtensa/helper.c                       |    2 +-
 MAINTAINERS                                  |    2 +-
 gdbstub/meson.build                          |    2 +
 gdbstub/trace-events                         |    4 +-
 scripts/feature_to_c.sh                      |    2 +-
 target/xtensa/import_core.sh                 |    2 +-
 88 files changed, 1680 insertions(+), 1401 deletions(-)
 create mode 100644 include/exec/tb-flush.h
 rename include/{exec/gdbstub.h => gdbstub/common.h} (61%)
 create mode 100644 include/gdbstub/helpers.h
 create mode 100644 include/gdbstub/user.h
 create mode 100644 gdbstub/user-target.c