From: Nicolas Eder <nicolas.eder@lauterbach.com>
To: qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Christian Boenig" <christian.boenig@lauterbach.com>,
"Nicolas Eder" <nicolas.eder@lauterbach.com>
Subject: [PATCH v5 04/18] gdbstub: DebugClass added to system mode.
Date: Wed, 20 Dec 2023 17:25:41 +0100 [thread overview]
Message-ID: <20231220162555.19545-5-nicolas.eder@lauterbach.com> (raw)
In-Reply-To: <20231220162555.19545-1-nicolas.eder@lauterbach.com>
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);
+}
+
+type_init(debug_register_types);
diff --git a/debug/common/meson.build b/debug/common/meson.build
index e69de29bb2..815cb6f0fc 100644
--- a/debug/common/meson.build
+++ b/debug/common/meson.build
@@ -0,0 +1 @@
+system_ss.add(files('debug.c'))
diff --git a/debug/gdbstub/system.c b/debug/gdbstub/system.c
index 83fd452800..06bc580147 100644
--- a/debug/gdbstub/system.c
+++ b/debug/gdbstub/system.c
@@ -14,6 +14,7 @@
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "qemu/cutils.h"
+#include "qemu/debug.h"
#include "exec/gdbstub.h"
#include "gdbstub/syscalls.h"
#include "exec/hwaddr.h"
@@ -46,6 +47,20 @@ static void reset_gdbserver_state(void)
gdbserver_state.allow_stop_reply = false;
}
+/**
+ * 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;
+ MachineState *ms = MACHINE(qdev_get_machine());
+ ms->debug_state = ds;
+}
+
/*
* Return the GDB index for a given vCPU state.
*
@@ -405,6 +420,9 @@ int gdbserver_start(const char *device)
gdbserver_system_state.mon_chr = mon_chr;
gdb_syscall_reset();
+ /* create new debug object */
+ gdb_init_debug_class();
+
return 0;
}
diff --git a/debug/meson.build b/debug/meson.build
index a5b093f31e..f46ab14af9 100644
--- a/debug/meson.build
+++ b/debug/meson.build
@@ -1 +1,2 @@
+subdir('common')
subdir('gdbstub')
diff --git a/include/hw/boards.h b/include/hw/boards.h
index da85f86efb..2e28913afc 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -400,6 +400,7 @@ struct MachineState {
CpuTopology smp;
struct NVDIMMState *nvdimms_state;
struct NumaState *numa_state;
+ DebugState *debug_state;
};
#define DEFINE_MACHINE(namestr, machine_initfn) \
diff --git a/include/qemu/debug.h b/include/qemu/debug.h
index c24aaf1202..9526f9fb48 100644
--- a/include/qemu/debug.h
+++ b/include/qemu/debug.h
@@ -16,3 +16,23 @@
*
* SPDX-License-Identifier: LGPL-2.0+
*/
+
+#ifndef QEMU_DEBUG_H
+#define QEMU_DEBUG_H
+
+#include "qom/object.h"
+#include "qemu/typedefs.h"
+
+struct DebugClass {
+ ObjectClass parent_class;
+ void (*set_stop_cpu)(CPUState *cpu);
+};
+
+struct DebugState {
+ Object parent_obj;
+};
+
+#define TYPE_DEBUG "debug"
+OBJECT_DECLARE_TYPE(DebugState, DebugClass, DEBUG)
+
+#endif /* QEMU_DEBUG_H */
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 5abdbc3874..e48b544173 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -46,6 +46,8 @@ typedef struct CpuInfoFast CpuInfoFast;
typedef struct CPUJumpCache CPUJumpCache;
typedef struct CPUState CPUState;
typedef struct CPUTLBEntryFull CPUTLBEntryFull;
+typedef struct DebugClass DebugClass;
+typedef struct DebugState DebugState;
typedef struct DeviceListener DeviceListener;
typedef struct DeviceState DeviceState;
typedef struct DirtyBitmapSnapshot DirtyBitmapSnapshot;
diff --git a/system/cpus.c b/system/cpus.c
index a444a747f0..7a7fff14bc 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -25,6 +25,7 @@
#include "qemu/osdep.h"
#include "monitor/monitor.h"
#include "qemu/coroutine-tls.h"
+#include "qemu/debug.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-machine.h"
#include "qapi/qapi-commands-misc.h"
@@ -313,7 +314,13 @@ void cpu_handle_guest_debug(CPUState *cpu)
cpu_single_step(cpu, 0);
}
} 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);
+ }
qemu_system_debug_request();
cpu->stopped = true;
}
--
2.34.1
next prev parent reply other threads:[~2023-12-20 16:29 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 ` Nicolas Eder [this message]
2024-02-29 16:35 ` [PATCH v5 04/18] gdbstub: DebugClass added to system mode Alex Bennée
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=20231220162555.19545-5-nicolas.eder@lauterbach.com \
--to=nicolas.eder@lauterbach.com \
--cc=alex.bennee@linaro.org \
--cc=christian.boenig@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 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).