All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Nicolas Eder <nicolas.eder@lauterbach.com>
Cc: qemu-devel@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Christian Boenig" <christian.boenig@lauterbach.com>
Subject: Re: [PATCH v5 04/18] gdbstub: DebugClass added to system mode.
Date: Thu, 29 Feb 2024 16:35:43 +0000	[thread overview]
Message-ID: <8734tb8bz4.fsf@draig.linaro.org> (raw)
In-Reply-To: <20231220162555.19545-5-nicolas.eder@lauterbach.com> (Nicolas Eder's message of "Wed, 20 Dec 2023 17:25:41 +0100")

Nicolas Eder <nicolas.eder@lauterbach.com> writes:

> This class is used to abstract debug features between different debuggers
> ---
>  debug/common/debug.c     | 33 +++++++++++++++++++++++++++++++++
>  debug/common/meson.build |  1 +
>  debug/gdbstub/system.c   | 18 ++++++++++++++++++
>  debug/meson.build        |  1 +
>  include/hw/boards.h      |  1 +
>  include/qemu/debug.h     | 20 ++++++++++++++++++++
>  include/qemu/typedefs.h  |  2 ++
>  system/cpus.c            |  9 ++++++++-
>  8 files changed, 84 insertions(+), 1 deletion(-)
>
> diff --git a/debug/common/debug.c b/debug/common/debug.c
> index c24aaf1202..476c969c98 100644
> --- a/debug/common/debug.c
> +++ b/debug/common/debug.c
> @@ -16,3 +16,36 @@
>   *
>   * SPDX-License-Identifier: LGPL-2.0+
>   */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/debug.h"
> +#include "qom/object_interfaces.h"
> +
> +static void debug_instance_init(Object *obj)
> +{
> +}
> +
> +static void debug_finalize(Object *obj)
> +{
> +}
> +
> +static void debug_class_init(ObjectClass *oc, void *data)
> +{
> +}
> +
> +static const TypeInfo debug_info = {
> +    .name = TYPE_DEBUG,
> +    .parent = TYPE_OBJECT,
> +    .instance_size = sizeof(DebugState),
> +    .instance_init = debug_instance_init,
> +    .instance_finalize = debug_finalize,
> +    .class_size = sizeof(DebugClass),
> +    .class_init = debug_class_init
> +};
> +
> +static void debug_register_types(void)
> +{
> +    type_register_static(&debug_info);
> +}

You shouldn't need empty functions if you are not using them. Moreover
you should use the inheritance feature and have something like:

static void gdb_debug_class_init(ObjectClass *klass, void *data)
{
    DebugClass *dc = DEBUG_CLASS(klass);
    dc->set_stop_cpu = gdb_set_stop_cpu;
};

static const TypeInfo debug_info[] = {
    {
        .name = TYPE_DEBUG,
        .parent = TYPE_OBJECT,
        .instance_size = sizeof(DebugState),
        .class_size = sizeof(DebugClass),
        .abstract = true,
    },
    {
        .name = TYPE_GDB_DEBUG,
        .parent = TYPE_DEBUG,
        .class_init = gdb_debug_class_init,
    },
};

DEFINE_TYPES(debug_info)


> +
<snip>
>  
> +/**
> + * gdb_init_debug_class() - initialize gdb-specific DebugClass
> + */
> +static void gdb_init_debug_class(void)
> +{
> +    Object *obj;
> +    obj = object_new(TYPE_DEBUG);
> +    DebugState *ds = DEBUG(obj);
> +    DebugClass *dc = DEBUG_GET_CLASS(ds);
> +    dc->set_stop_cpu = gdb_set_stop_cpu;

This should be part of the class init above

> +    MachineState *ms = MACHINE(qdev_get_machine());
> +    ms->debug_state = ds;
> +}
>          }
>      } else {
> -        gdb_set_stop_cpu(cpu);
> +        MachineState *ms = MACHINE(qdev_get_machine());
> +        DebugState *ds = ms->debug_state;
> +        DebugClass *dc = DEBUG_GET_CLASS(ds);
> +
> +        if (dc->set_stop_cpu) {
> +            dc->set_stop_cpu(cpu);
> +        }

If there is no explicit state perhaps we should just save the class
rather than the instance.

>          qemu_system_debug_request();
>          cpu->stopped = true;
>      }

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


  reply	other threads:[~2024-02-29 16:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20 16:25 [PATCH v5 00/18] first version of mcdstub Nicolas Eder
2023-12-20 16:25 ` [PATCH v5 01/18] gdbstub, mcdstub: file and build structure adapted to accomodate for the mcdstub Nicolas Eder
2024-02-29 15:33   ` Alex Bennée
2023-12-20 16:25 ` [PATCH v5 02/18] gdbstub: hex conversion functions moved to cutils.h Nicolas Eder
2024-02-29 15:33   ` Alex Bennée
2023-12-20 16:25 ` [PATCH v5 03/18] gdbstub: GDBRegisterState moved to gdbstub.h so it can be used outside of the gdbstub Nicolas Eder
2024-02-29 15:23   ` Alex Bennée
2023-12-20 16:25 ` [PATCH v5 04/18] gdbstub: DebugClass added to system mode Nicolas Eder
2024-02-29 16:35   ` Alex Bennée [this message]
2024-03-05 11:27     ` nicolas.eder
2023-12-20 16:25 ` [PATCH v5 05/18] mcdstub: memory helper functions added Nicolas Eder
2024-02-29 16:56   ` Alex Bennée
2024-03-05 11:03     ` nicolas.eder
2023-12-20 16:25 ` [PATCH v5 06/18] mcdstub: -mcd start option added, mcd specific defines added Nicolas Eder
2023-12-20 16:25 ` [PATCH v5 07/18] mcdstub: mcdserver initialization functions added Nicolas Eder
2023-12-20 16:25 ` [PATCH v5 08/18] cutils: qemu_strtou32 function added Nicolas Eder
2023-12-20 16:25 ` [PATCH v5 09/18] mcdstub: TCP packet plumbing added Nicolas Eder
2023-12-20 16:25 ` [PATCH v5 10/18] mcdstub: open and close server functions added Nicolas Eder
2023-12-20 16:25 ` [PATCH v5 11/18] mcdstub: system and core queries added Nicolas Eder
2024-02-29 15:11   ` Alex Bennée
2024-03-05 11:08     ` nicolas.eder
2023-12-20 16:25 ` [PATCH v5 12/18] mcdstub: all core specific " Nicolas Eder
2023-12-20 16:25 ` [PATCH v5 13/18] mcdstub: go, step and break added Nicolas Eder
2023-12-20 16:25 ` [PATCH v5 14/18] mcdstub: state query added Nicolas Eder
2023-12-20 16:25 ` [PATCH v5 15/18] mcdstub: skeleton for reset handling added Nicolas Eder
2023-12-20 16:25 ` [PATCH v5 16/18] mcdstub: register access added Nicolas Eder
2023-12-20 16:25 ` [PATCH v5 17/18] mcdstub: memory " Nicolas Eder
2023-12-20 16:25 ` [PATCH v5 18/18] mcdstub: break/watchpoints added Nicolas Eder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8734tb8bz4.fsf@draig.linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=christian.boenig@lauterbach.com \
    --cc=nicolas.eder@lauterbach.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.