[PATCH] gdbstub: Generate a single gdbstub-xml.c / gdb_static_features[]

Philippe Mathieu-Daudé posted 1 patch 3 days, 8 hours ago
Failed in applying to current master (apply log)
There is a newer version of this series
meson.build       | 25 +++++++++++++++----------
stubs/gdbstub.c   |  6 ------
stubs/meson.build |  2 --
3 files changed, 15 insertions(+), 18 deletions(-)
delete mode 100644 stubs/gdbstub.c
[PATCH] gdbstub: Generate a single gdbstub-xml.c / gdb_static_features[]
Posted by Philippe Mathieu-Daudé 3 days, 8 hours ago
gdb_static_features[] only contains strings, nothing target-specific.
Instead of generating one file per target, generate a single file
with a single gdb_static_features[] array. Remove the stub.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 meson.build       | 25 +++++++++++++++----------
 stubs/gdbstub.c   |  6 ------
 stubs/meson.build |  2 --
 3 files changed, 15 insertions(+), 18 deletions(-)
 delete mode 100644 stubs/gdbstub.c

diff --git a/meson.build b/meson.build
index 451cb28149f..6d73ee40ea3 100644
--- a/meson.build
+++ b/meson.build
@@ -3867,6 +3867,21 @@ subdir('linux-user')
 subdir('tests/qtest/libqos')
 subdir('tests/qtest/fuzz')
 
+feature_to_c = find_program('scripts/feature_to_c.py')
+gdbstub_xml = []
+foreach target : target_dirs
+  config_target = config_target_mak[target]
+  if 'TARGET_XML_FILES' in config_target
+    gdbstub_xml += config_target['TARGET_XML_FILES'].split()
+  endif
+endforeach
+gdbstub_xml = custom_target('gdbstub-xml.c',
+                            output: 'gdbstub-xml.c',
+                            input: files(gdbstub_xml),
+                            command: [feature_to_c, '@INPUT@'],
+                            capture: true)
+common_ss.add(gdbstub_xml)
+
 ##############################################
 # Internal static_libraries and dependencies #
 ##############################################
@@ -4218,7 +4233,6 @@ if have_rust
 endif
 
 
-feature_to_c = find_program('scripts/feature_to_c.py')
 rust_root_crate = find_program('scripts/rust/rust_root_crate.sh')
 
 if host_os == 'darwin'
@@ -4298,15 +4312,6 @@ foreach target : target_dirs
     endif
   endif
 
-  if 'TARGET_XML_FILES' in config_target
-    gdbstub_xml = custom_target(target + '-gdbstub-xml.c',
-                                output: target + '-gdbstub-xml.c',
-                                input: files(config_target['TARGET_XML_FILES'].split()),
-                                command: [feature_to_c, '@INPUT@'],
-                                capture: true)
-    arch_srcs += gdbstub_xml
-  endif
-
   if target in config_target_info
     arch_srcs += config_target_info[target]
   else
diff --git a/stubs/gdbstub.c b/stubs/gdbstub.c
deleted file mode 100644
index 580e20702b2..00000000000
--- a/stubs/gdbstub.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "qemu/osdep.h"
-#include "exec/gdbstub.h"       /* gdb_static_features */
-
-const GDBFeature gdb_static_features[] = {
-  { NULL }
-};
diff --git a/stubs/meson.build b/stubs/meson.build
index 8a07059500d..1e0f6f47377 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -89,8 +89,6 @@ if have_system
 endif
 
 if have_system or have_user
-  stub_ss.add(files('gdbstub.c'))
-
   # Also included in have_system for --disable-tcg builds
   stub_ss.add(files('replay.c'))
 
-- 
2.52.0


Re: [PATCH] gdbstub: Generate a single gdbstub-xml.c / gdb_static_features[]
Posted by Philippe Mathieu-Daudé 3 days, 7 hours ago
On Thu, 26 Feb 2026 at 23:48, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> gdb_static_features[] only contains strings, nothing target-specific.
> Instead of generating one file per target, generate a single file
> with a single gdb_static_features[] array. Remove the stub.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  meson.build       | 25 +++++++++++++++----------
>  stubs/gdbstub.c   |  6 ------
>  stubs/meson.build |  2 --
>  3 files changed, 15 insertions(+), 18 deletions(-)
>  delete mode 100644 stubs/gdbstub.c
>
> diff --git a/meson.build b/meson.build
> index 451cb28149f..6d73ee40ea3 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -3867,6 +3867,21 @@ subdir('linux-user')
>  subdir('tests/qtest/libqos')
>  subdir('tests/qtest/fuzz')
>
> +feature_to_c = find_program('scripts/feature_to_c.py')
> +gdbstub_xml = []
> +foreach target : target_dirs
> +  config_target = config_target_mak[target]
> +  if 'TARGET_XML_FILES' in config_target
> +    gdbstub_xml += config_target['TARGET_XML_FILES'].split()
> +  endif
> +endforeach

Hmm I need to check gdbstub_xml.length() > 0.

> +gdbstub_xml = custom_target('gdbstub-xml.c',
> +                            output: 'gdbstub-xml.c',
> +                            input: files(gdbstub_xml),
> +                            command: [feature_to_c, '@INPUT@'],
> +                            capture: true)
> +common_ss.add(gdbstub_xml)