[PATCH v2 00/29] first version of mcdstub

Nicolas Eder posted 29 patches 7 months ago
Failed in applying to current master (apply log)
Maintainers: Nicolas Eder <nicolas.eder@lauterbach.com>, "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Yanan Wang <wangyanan55@huawei.com>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Thomas Huth <thuth@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Peter Maydell <peter.maydell@linaro.org>
There is a newer version of this series
MAINTAINERS                          |   12 +
debug/debug-common.c                 |   42 +
debug/debug-gdb.c                    |   24 +
debug/debug-mcd.c                    |   25 +
gdbstub/meson.build                  |    4 +-
gdbstub/softmmu.c                    |    4 +
gdbstub/user.c                       |    2 +
include/exec/gdbstub.h               |    5 +
include/exec/mcdstub.h               |   12 +
include/hw/boards.h                  |    1 +
include/mcdstub/arm_mcdstub.h        |  139 ++
include/mcdstub/mcd_shared_defines.h |  105 ++
include/mcdstub/mcdstub.h            |  829 +++++++++++
include/mcdstub/mcdstub_common.h     |   64 +
include/mcdstub/syscalls.h           |    6 +
include/qemu/debug.h                 |   19 +
include/qemu/typedefs.h              |    2 +
mcdstub/mcd_syscalls.c               |   30 +
mcdstub/mcdstub.c                    | 1960 ++++++++++++++++++++++++++
mcdstub/meson.build                  |   19 +
meson.build                          |    1 +
qemu-options.hx                      |   18 +
softmmu/cpus.c                       |    9 +-
softmmu/vl.c                         |   13 +
target/arm/mcdstub.c                 |  559 ++++++++
target/arm/meson.build               |    1 +
26 files changed, 3902 insertions(+), 3 deletions(-)
create mode 100644 debug/debug-common.c
create mode 100644 debug/debug-gdb.c
create mode 100644 debug/debug-mcd.c
create mode 100644 include/exec/mcdstub.h
create mode 100644 include/mcdstub/arm_mcdstub.h
create mode 100644 include/mcdstub/mcd_shared_defines.h
create mode 100644 include/mcdstub/mcdstub.h
create mode 100644 include/mcdstub/mcdstub_common.h
create mode 100644 include/mcdstub/syscalls.h
create mode 100644 include/qemu/debug.h
create mode 100644 mcdstub/mcd_syscalls.c
create mode 100644 mcdstub/mcdstub.c
create mode 100644 mcdstub/meson.build
create mode 100644 target/arm/mcdstub.c
[PATCH v2 00/29] first version of mcdstub
Posted by Nicolas Eder 7 months ago
SUMMARY
=======

This patch-set introduces the first version of the mcdstub.
The mcdstub is a debug interface, which enables debugging QEMU
using the MCD (Multi-Core Debug) API.
The mcdstub uses TCP to communicate with the host debug software. However,
because MCD is merely an API, the TCP communication is not part of
the MCD spec but specific to this project.

To translate between the MCD API and the TCP data stream coming from the mcdstub,
the host has to use a shared library (.dll/.so).
Such a shared library will be available soon Lauterbach's open source site
and will be linked to from inside this project in a future patch.
The MCD API itself can be downloaded here: https://repo.lauterbach.com/sprint_mcd_api_v1_0.zip

QUICK START
===========

Attention: MCD is currently only supported for qemu-system-arm !

Three components are required to Debug QEMU via MCD:

1. qemu-system-arm (built with this patch series applied).
2. MCD shared library (translates between the MCD API and TCP data).
3. Host debugging software with support for the MCD API (e.g. Lauterbach TRACE32).

To activate the mcdstub, just use the "mcd" launch option in combination with
a TCP port.

With the default TCP port 1235:

$ qemu-system-arm -M virt -cpu cortex-a15 -mcd default

With a custom TCP port:

$ qemu-system-arm -M virt -cpu cortex-a15 -mcd tcp::1235

QEMU will listen for an MCD host to connect to the specified port.

IMPORTANT CHANGES
=================

1. DebugClass:

This patch-set introduces the DebugClass to the QOM, which is used to abstract
GDB/MCD specific debugger details.
It is declared in include/qemu/debug.h, defined in debug/debug-common.c
and configured in debug/debug-gdb.c and debug/debug-mcd.c respectively.
It currently only offers one function: set_stop_cpu, which gets called
in cpu_handle_guest_debug in softmmu/cpus.c.
In the future, other functions could be moved from the mcd/gdbstub
to the DebugClass.

2. mcd launch option:

This patch-set introduces the mcd launch option to QEMU. The quick start
section describes how to use it.

3. MCD debugging features:

* Go, break, step
* Read/write memory (user space only)
* Read/write registers (GPR and CP)
* Set breakpoints and watchpoints.

=================

Signed-off-by: Nicolas Eder <nicolas.eder@lauterbach.com>

neder (29):
  mcdstub initial commit, mcdstub file structure added
  TCP chardev added, handshake with TRACE32 working
  TCP packet handling added
  queries for resets and triggers added
  queries for memory spaces and register groups added
  query for registers added
  query data preparation improved
  shared header file added, used for TCP packet data
  memory and register query data now stored per core
  handler for resets added
  query for the VM state added
  handler for reading registers added
  handler for reading memory added
  handler for single step added
  adapting to the qemu coding style
  deleting the mcdd startup option
  handler for breakpoints and watchpoints added
  making step and go handlers core-specific
  adding trigger ID handling for TRACE32
  cp register read/write added
  switching between secure and non-secure memory added
  transitioning to unsinged integers in TCP packets and removing
    MCD-API-specific terms
  moved all ARM code to the ARM mcdstub and added now commom header file
  step and go handlers now propperly perform global operations
  Doxygen documentation added
  moved all mcd related header files into include/mcdstub
  MCD stub entry added to maintainers file
  added description to out-commented gdb function
  introducing the DebugClass. It is used to abstract the gdb/mcd
    set_stop_cpu function.

 MAINTAINERS                          |   12 +
 debug/debug-common.c                 |   42 +
 debug/debug-gdb.c                    |   24 +
 debug/debug-mcd.c                    |   25 +
 gdbstub/meson.build                  |    4 +-
 gdbstub/softmmu.c                    |    4 +
 gdbstub/user.c                       |    2 +
 include/exec/gdbstub.h               |    5 +
 include/exec/mcdstub.h               |   12 +
 include/hw/boards.h                  |    1 +
 include/mcdstub/arm_mcdstub.h        |  139 ++
 include/mcdstub/mcd_shared_defines.h |  105 ++
 include/mcdstub/mcdstub.h            |  829 +++++++++++
 include/mcdstub/mcdstub_common.h     |   64 +
 include/mcdstub/syscalls.h           |    6 +
 include/qemu/debug.h                 |   19 +
 include/qemu/typedefs.h              |    2 +
 mcdstub/mcd_syscalls.c               |   30 +
 mcdstub/mcdstub.c                    | 1960 ++++++++++++++++++++++++++
 mcdstub/meson.build                  |   19 +
 meson.build                          |    1 +
 qemu-options.hx                      |   18 +
 softmmu/cpus.c                       |    9 +-
 softmmu/vl.c                         |   13 +
 target/arm/mcdstub.c                 |  559 ++++++++
 target/arm/meson.build               |    1 +
 26 files changed, 3902 insertions(+), 3 deletions(-)
 create mode 100644 debug/debug-common.c
 create mode 100644 debug/debug-gdb.c
 create mode 100644 debug/debug-mcd.c
 create mode 100644 include/exec/mcdstub.h
 create mode 100644 include/mcdstub/arm_mcdstub.h
 create mode 100644 include/mcdstub/mcd_shared_defines.h
 create mode 100644 include/mcdstub/mcdstub.h
 create mode 100644 include/mcdstub/mcdstub_common.h
 create mode 100644 include/mcdstub/syscalls.h
 create mode 100644 include/qemu/debug.h
 create mode 100644 mcdstub/mcd_syscalls.c
 create mode 100644 mcdstub/mcdstub.c
 create mode 100644 mcdstub/meson.build
 create mode 100644 target/arm/mcdstub.c

-- 
2.34.1
Re: [PATCH v2 00/29] first version of mcdstub
Posted by Philippe Mathieu-Daudé 7 months ago
On 6/10/23 11:05, Nicolas Eder wrote:
> SUMMARY
> =======
> 
> This patch-set introduces the first version of the mcdstub.
> The mcdstub is a debug interface, which enables debugging QEMU
> using the MCD (Multi-Core Debug) API.

[...]

> neder (29):
>    mcdstub initial commit, mcdstub file structure added
>    TCP chardev added, handshake with TRACE32 working
>    TCP packet handling added
>    queries for resets and triggers added
>    queries for memory spaces and register groups added
>    query for registers added
>    query data preparation improved
>    shared header file added, used for TCP packet data
>    memory and register query data now stored per core
>    handler for resets added
>    query for the VM state added
>    handler for reading registers added
>    handler for reading memory added
>    handler for single step added
>    adapting to the qemu coding style
>    deleting the mcdd startup option
>    handler for breakpoints and watchpoints added
>    making step and go handlers core-specific
>    adding trigger ID handling for TRACE32
>    cp register read/write added
>    switching between secure and non-secure memory added
>    transitioning to unsinged integers in TCP packets and removing
>      MCD-API-specific terms
>    moved all ARM code to the ARM mcdstub and added now commom header file
>    step and go handlers now propperly perform global operations
>    Doxygen documentation added
>    moved all mcd related header files into include/mcdstub
>    MCD stub entry added to maintainers file
>    added description to out-commented gdb function
>    introducing the DebugClass. It is used to abstract the gdb/mcd
>      set_stop_cpu function.

v2 is now reviewable, thank you!
Re: [PATCH v2 00/29] first version of mcdstub
Posted by Alex Bennée 6 months, 3 weeks ago
Nicolas Eder <nicolas.eder@lauterbach.com> writes:

<snip>
> Signed-off-by: Nicolas Eder <nicolas.eder@lauterbach.com>
>
> neder (29):

I think you need to fix your author attribution here.

>   mcdstub initial commit, mcdstub file structure added
>   TCP chardev added, handshake with TRACE32 working
>   TCP packet handling added
>   queries for resets and triggers added
>   queries for memory spaces and register groups added
>   query for registers added
>   query data preparation improved
>   shared header file added, used for TCP packet data
>   memory and register query data now stored per core
>   handler for resets added
>   query for the VM state added
>   handler for reading registers added
>   handler for reading memory added
>   handler for single step added
>   adapting to the qemu coding style
>   deleting the mcdd startup option
>   handler for breakpoints and watchpoints added
>   making step and go handlers core-specific
>   adding trigger ID handling for TRACE32
>   cp register read/write added
>   switching between secure and non-secure memory added
>   transitioning to unsinged integers in TCP packets and removing
>     MCD-API-specific terms
>   moved all ARM code to the ARM mcdstub and added now commom header file
>   step and go handlers now propperly perform global operations
>   Doxygen documentation added
>   moved all mcd related header files into include/mcdstub
>   MCD stub entry added to maintainers file
>   added description to out-commented gdb function
>   introducing the DebugClass. It is used to abstract the gdb/mcd
>     set_stop_cpu function.

As you need to re-base anyway for this to apply cleanly I'm going to
wait until v3 for another pass. However I have noticed these patches are
quite noisy with a number of issues:

  - commented out code
  - code introduced then deleted
  - code motion after introduction
  - random white space changes

All of which makes it hard to review. A lot of this stems from the c&p
scaffolding from gdbstub which I understand as an approach to write the
initial version. However this should be squashed and merged away in the
final patches presented for review. Also please make sure:

  - commit messages match changes
  - each patch compiles cleanly on its own
  - you run through checkpatch.pl

Thanks,

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro