Commit f445b4a4b6 for qemu.org

commit f445b4a4b6fa5b03503bc8fdfa4c336e13afc48f
Author: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Date:   Thu Jan 8 21:31:32 2026 -0800

    target/arm/gdbstub: make compilation unit common

    Expose and stubs aarch64 functions. All call sites are under a
    "is_aarch64" check.

    Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
    Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
    Message-ID: <20260109053158.2800705-4-pierrick.bouvier@linaro.org>
    Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

diff --git a/target/arm/cpu32-stubs.c b/target/arm/cpu32-stubs.c
index 81be44d846..f0ce159572 100644
--- a/target/arm/cpu32-stubs.c
+++ b/target/arm/cpu32-stubs.c
@@ -24,3 +24,24 @@ void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp)
 {
     g_assert_not_reached();
 }
+
+int aarch64_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg)
+{
+    g_assert_not_reached();
+}
+
+int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg)
+{
+    g_assert_not_reached();
+}
+
+void aarch64_cpu_register_gdb_commands(ARMCPU *cpu, GString *qsupported,
+                                       GPtrArray *qtable, GPtrArray *stable)
+{
+    g_assert_not_reached();
+}
+
+void aarch64_cpu_register_gdb_regs_for_features(ARMCPU *cpu)
+{
+    g_assert_not_reached();
+}
diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
index 4e8e341cc0..c7d59fd372 100644
--- a/target/arm/gdbstub.c
+++ b/target/arm/gdbstub.c
@@ -44,11 +44,9 @@ int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
     ARMCPU *cpu = ARM_CPU(cs);
     CPUARMState *env = &cpu->env;

-#ifdef TARGET_AARCH64
     if (arm_gdbstub_is_aarch64(cpu)) {
         return aarch64_cpu_gdb_read_register(cs, mem_buf, n);
     }
-#endif

     if (n < 16) {
         /* Core integer register.  */
@@ -72,11 +70,9 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
     CPUARMState *env = &cpu->env;
     uint32_t tmp;

-#ifdef TARGET_AARCH64
     if (arm_gdbstub_is_aarch64(cpu)) {
         return aarch64_cpu_gdb_write_register(cs, mem_buf, n);
     }
-#endif

     tmp = ldl_p(mem_buf);

@@ -504,10 +500,8 @@ void arm_cpu_register_gdb_commands(ARMCPU *cpu)
     g_autoptr(GString) qsupported_features = g_string_new(NULL);

     if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
-    #ifdef TARGET_AARCH64
         aarch64_cpu_register_gdb_commands(cpu, qsupported_features, query_table,
                                           set_table);
-    #endif
     }

     /* Set arch-specific handlers for 'q' commands. */
@@ -536,9 +530,7 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu)
          * The lower part of each SVE register aliases to the FPU
          * registers so we don't need to include both.
          */
-#ifdef TARGET_AARCH64
         aarch64_cpu_register_gdb_regs_for_features(cpu);
-#endif
     } else {
         if (arm_feature(env, ARM_FEATURE_NEON)) {
             gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg,
diff --git a/target/arm/meson.build b/target/arm/meson.build
index 3df7e03654..462c71148d 100644
--- a/target/arm/meson.build
+++ b/target/arm/meson.build
@@ -1,8 +1,11 @@
 arm_ss = ss.source_set()
 arm_common_ss = ss.source_set()
-arm_ss.add(files(
-  'gdbstub.c',
-))
+arm_common_system_ss = ss.source_set()
+arm_system_ss = ss.source_set()
+arm_user_ss = ss.source_set()
+
+arm_common_system_ss.add(files('gdbstub.c'))
+arm_user_ss.add(files('gdbstub.c'))

 arm_ss.add(when: 'TARGET_AARCH64', if_true: files(
   'cpu64.c',
@@ -13,15 +16,12 @@ arm_common_ss.add(files(
   'mmuidx.c',
 ))

-arm_system_ss = ss.source_set()
-arm_common_system_ss = ss.source_set()
 arm_system_ss.add(files(
   'arm-qmp-cmds.c',
 ))
 arm_system_ss.add(when: 'CONFIG_KVM', if_true: files('hyp_gdbstub.c', 'kvm.c'))
 arm_system_ss.add(when: 'CONFIG_HVF', if_true: files('hyp_gdbstub.c'))

-arm_user_ss = ss.source_set()
 arm_user_ss.add(files('cpu.c'))
 arm_user_ss.add(when: 'TARGET_AARCH64', if_false: files(
   'cpu32-stubs.c',