On 18.03.2026 22:18, Steve Aarnio wrote:
This option will (attempt to) modify the QEMU compile and link flags to
emit PDB symbol files rather than the standard (DWARF?) symbol output
from gcc/clang.

This enables using native Windows debug tools (Windbg/Visual Studio) for
debugging QEMU.

While the change looks good (but please don't use html or
quoted-printable encoding when sending patches), the name for
the option is a bit.. non-English, so to say.  It might be
--enable-pdb for example, or --use-pdb, but probably not
what's suggested initially.   There's one more possible issue
with this approach: when pdb isn't supported by the compiler,
this option is silently ignored, instead of giving some
useful diagnostics.

Overall, I think there's no need to have separate option especially
for pdb, - it can be enabled on windows when --enable-debug is
specified (or is it --debug? I don't remember).

This code:

option_cflags = (get_option('debug') ? ['-g'] : [])

can be extended to add the necessary compiler options.

Thanks,

/mjt

Signed-off-by: Steve Aarnio <[email protected]>
---
  meson.build       | 5 +++++
  meson_options.txt | 2 ++
  2 files changed, 7 insertions(+)

diff --git a/meson.build b/meson.build
index d7c4095b39..d27581e0c2 100644
--- a/meson.build
+++ b/meson.build
@@ -692,6 +692,11 @@ endif
  qemu_common_flags += hardening_flags
+if get_option('debug') and get_option('use_pdb')
+  qemu_common_flags += cc.get_supported_arguments('-g','-gcodeview','- gcolumn-info','-fno-omit-frame-pointer')
+  qemu_ldflags += cc.get_supported_link_arguments('-g','-Wl,--pdb=')
+endif
+
  # Collect warning flags we want to set, sorted alphabetically
  warn_flags = [
    # First enable interesting warnings
diff --git a/meson_options.txt b/meson_options.txt
index 31d5916cfc..b1f3250d5c 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -372,6 +372,8 @@ option('debug_stack_usage', type: 'boolean', value: false,
         description: 'measure coroutine stack usage')
  option('qom_cast_debug', type: 'boolean', value: true,
         description: 'cast debugging support')
+option('use_pdb', type: 'boolean', value: false,
+       description: 'use pdb symbol format on debug windows builds')
  option('slirp_smbd', type : 'feature', value : 'auto',
         description: 'use smbd (at path --smbd=*) in slirp networking')
--
2.53.0



Reply via email to