[PATCH] meson.build: Add --enable-use-pdb option

Steve Aarnio posted 1 patch 2 weeks, 4 days ago
Failed in applying to current master (apply log)
meson.build       | 5 +++++
meson_options.txt | 2 ++
2 files changed, 7 insertions(+)
[PATCH] meson.build: Add --enable-use-pdb option
Posted by Steve Aarnio 2 weeks, 4 days ago
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.

Signed-off-by: Steve Aarnio <saarnio@qti.qualcomm.com>
---
 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

Re: [PATCH] meson.build: Add --enable-use-pdb option
Posted by Paolo Bonzini 6 days, 22 hours ago
On 3/18/26 20: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.
> 
> Signed-off-by: Steve Aarnio <saarnio@qti.qualcomm.com>

I would prefer to have support for this in Meson itself, but anyway, I 
have some questions below

> +if get_option('debug') and get_option('use_pdb')
> +  qemu_common_flags += cc.get_supported_arguments('-g','-gcodeview','- 
> gcolumn-info','-fno-omit-frame-pointer')

GCC documentation says -gcolumn-info enabled by default, also who is 
enabling -fomit-frame-pointer so that you have to drop it?

> +  qemu_ldflags += cc.get_supported_link_arguments('-g','-Wl,--pdb=')

What linkers support --pdb=, and what goes after the equal sign?

Also, the update to scripts/meson-buildoptions.sh is missing, just 
running "make" will regenerate it.

Paolo


Re: [PATCH] meson.build: Add --enable-use-pdb option
Posted by Mohamed Mediouni 6 days, 22 hours ago

> On 30. Mar 2026, at 18:33, Paolo Bonzini <pbonzini@redhat.com> wrote:
> 
> On 3/18/26 20: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.
>> Signed-off-by: Steve Aarnio <saarnio@qti.qualcomm.com>
> 
> I would prefer to have support for this in Meson itself, but anyway, I have some questions below
> 
>> +if get_option('debug') and get_option('use_pdb')
>> +  qemu_common_flags += cc.get_supported_arguments('-g','-gcodeview','- gcolumn-info','-fno-omit-frame-pointer')
> 
> GCC documentation says -gcolumn-info enabled by default, also who is enabling -fomit-frame-pointer so that you have to drop it?

Hello,

https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fomit-frame-pointer

Clang documentation says:
On many targets, -O1 and higher omit the frame pointer by default

> 
>> +  qemu_ldflags += cc.get_supported_link_arguments('-g','-Wl,--pdb=')
> 
> What linkers support --pdb=, and what goes after the equal sign?

lld, and pdb= is enough to have an autogenerated path (output[.pdb]).

gcc and GNU ld don't support this.

> 
> Also, the update to scripts/meson-buildoptions.sh is missing, just running "make" will regenerate it.
> 
> Paolo
> 
> 
Re: [PATCH] meson.build: Add --enable-use-pdb option
Posted by Michael Tokarev 2 weeks, 1 day ago
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 <saarnio@qti.qualcomm.com>
> ---
>   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
> 


Re: [PATCH] meson.build: Add --enable-use-pdb option
Posted by Mohamed Mediouni 2 weeks, 1 day ago
> On 22. Mar 2026, at 12:56, Michael Tokarev <mjt@tls.msk.ru> wrote:
> 
> 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.

Hello,

I think that’s a bit suboptimal because while Clang can generate PDBs, the same
isn’t true for a GCC build, where gdb + DWARF is in practice preferred instead.

A converter exists at https://github.com/rainers/cv2pdb however to cover the GCC
case but the compiler won’t do it by itself.

And people might also want to use gdb/lldb when they can :)

Thanks,
-Mohamed
Re: [PATCH v2 1/1] meson.build: Add --enable-pdb option
Posted by Steve Aarnio 1 week, 6 days ago
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. Prerequisites for this are host_os == Windows and
--enable-debug flag set.

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

Signed-off-by: Steve Aarnio <saarnio@qti.qualcomm.com>
---
 meson.build       | 5 +++++
 meson_options.txt | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/meson.build b/meson.build
index d7c4095b39..e6f17dd5f7 100644
--- a/meson.build
+++ b/meson.build
@@ -692,6 +692,11 @@ endif

 qemu_common_flags += hardening_flags

+if host_os == 'windows' and get_option('debug') and get_option('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..bffbc7923d 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('pdb', type: 'boolean', value: false,
+       description: 'use pdb symbol format on Windows debug builds')
 option('slirp_smbd', type : 'feature', value : 'auto',
        description: 'use smbd (at path --smbd=*) in slirp networking')

--
2.53.0
Re: [PATCH v2 1/1] meson.build: Add --enable-pdb option
Posted by Mohamed Mediouni 1 week, 6 days ago
> On 23. Mar 2026, at 18:44, Steve Aarnio <saarnio@qti.qualcomm.com> 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. Prerequisites for this are host_os == Windows and
> --enable-debug flag set.
> 
> This enables using native Windows debug tools (Windbg/Visual Studio) for
> debugging QEMU.
> 
> Signed-off-by: Steve Aarnio <saarnio@qti.qualcomm.com>
> ---
> meson.build       | 5 +++++
> meson_options.txt | 2 ++
> 2 files changed, 7 insertions(+)

Hello,

A small thing on top:

diff --git a/configure b/configure
index cd1dadd8bb..e355484921 100755
--- a/configure
+++ b/configure
@@ -709,6 +709,9 @@ for opt do
       meson_option_add -Doptimization=0
       default_cflags='-O0 -g'
   ;;
+  --enable-pdb)
+      meson_option_add -Dpdb=true
+  ;;
   --disable-tcg) tcg="disabled"
   ;;
   --enable-tcg) tcg=“enabled"
Re: [PATCH] meson.build: Add --enable-use-pdb option
Posted by Mohamed Mediouni 2 weeks, 4 days ago

> On 18. Mar 2026, at 20:18, Steve Aarnio <saarnio@qti.qualcomm.com> 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.
> 
> Signed-off-by: Steve Aarnio <saarnio@qti.qualcomm.com>


Reviewed-by: Mohamed Mediouni <mohamed@unpredictable.fr>

Already used something like this, it makes Windows debugging substantially easier.
> ---
>  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
Re: [PATCH] meson.build: Add --enable-use-pdb option
Posted by Steve Aarnio 2 weeks, 3 days ago
>> On 18. Mar 2026, at 20:18, Steve Aarnio <saarnio@qti.qualcomm.com> 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.
>>
>> Signed-off-by: Steve Aarnio <saarnio@qti.qualcomm.com>
>
>
> Reviewed-by: Mohamed Mediouni <mohamed@unpredictable.fr>
>
> Already used something like this, it makes Windows debugging substantially easier.

@Mohamed Mediouni<mailto:mohamed@unpredictable.fr>, thank you for the quick review. First, thank you for your WHPX on AARCH64 Windows - no more waiting 20 minutes for the guest to boot, which is amazing. Second, regarding this patch, are there other flags that you used for your work that I have missed here? I've had reasonable success with these, just wondering if there's something that I may have missed.

>> ---
>>  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