On 3/14/25 09:37, Richard Henderson wrote:
On 3/13/25 03:39, Philippe Mathieu-Daudé wrote:
--- /dev/null
+++ b/common-user/watchpoint-stub.c
@@ -0,0 +1,28 @@
+/*
+ * CPU watchpoint stubs
+ *
+ * Copyright (c) 2003 Fabrice Bellard
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/core/cpu.h"
+
+int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,
+                          int flags, CPUWatchpoint **watchpoint)
+{
+    return -ENOSYS;
+}
+
+int cpu_watchpoint_remove(CPUState *cpu, vaddr addr, vaddr len, int flags)
+{
+    return -ENOSYS;
+}
+
+void cpu_watchpoint_remove_by_ref(CPUState *cpu, CPUWatchpoint *wp)
+{

Again, can this be elide? Otherwise better use g_assert_not_reached().

We can, including:

-- >8 --
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index dba1b3ffef..54d3879c56 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -7545,4 +7545,6 @@ static void x86_cpu_reset_hold(Object *obj, ResetType 
type)
       env->dr[7] = DR7_FIXED_1;
+#ifndef CONFIG_USER_ONLY
       cpu_breakpoint_remove_all(cs, BP_CPU);
       cpu_watchpoint_remove_all(cs, BP_CPU);
+#endif

But do we really want to add all those ifdefs?


I agree with Richard, trading ifdefs is not a win in the end.
Here, we replace header stubs (which are a problem, because they rely on ifdef by design) to different compilation units, which can be selected at link time.

In the end, we might even have to unify some stubs and their implementations, to have a single definition of those symbols.


r~

Reply via email to