# Producing DWARF on PE/COFF targets

**URL:** <https://ziggit.dev/t/producing-dwarf-on-pe-coff-targets/5485>\
**Category:** Brainstorming\
**Tags:** build-system, debugger\
**Created:** [August 3, 2024, 8:49pm UTC](https://ziggit.dev/t/producing-dwarf-on-pe-coff-targets/5485 "2024-08-03T20:49:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tliltocatl](https://ziggit.dev/letter_avatar_proxy/v4/letter/t/a4c791/32.png) [@tliltocatl](https://ziggit.dev/u/tliltocatl)\
**Post date:** [August 3, 2024, 8:49pm UTC](https://ziggit.dev/t/producing-dwarf-on-pe-coff-targets/5485/1 "2024-08-03T20:49:43Z")

</div>

I’m playing with UEFI and right now the compiler outputs .pdb file for debug symbols which is 0.001% as useful as a punched card deck unless you use Microsoft tooling. LLVM has a way to produce separate DWARF for PE files, but looks like there is no way to trigger it without patching the compiler itself? In general, the build system should have a way to inject LLVM parameters for stuff it’s doesn’t know about, rather than assume “if I don’t need that, then nobody does”.

---

<div class="post-metadata">

**Author:** ![dimdin](https://ziggit.dev/user_avatar/ziggit.dev/dimdin/32/1457_2.png) [@dimdin](https://ziggit.dev/u/dimdin)\
**Post date:** [August 3, 2024, 9:23pm UTC](https://ziggit.dev/t/producing-dwarf-on-pe-coff-targets/5485/2 "2024-08-03T21:23:32Z")

</div>

See this merged pull request: [Dwarf on windows](https://github.com/ziglang/zig/pull/8717)

> - Emit Dwarf debug info if targetting gnu abi on windows (maybe this should be a flag instead)
> - Add support for reading Dwarf info from COFF executables for stack and error tracing

---

<div class="post-metadata">

**Author:** ![tliltocatl](https://ziggit.dev/letter_avatar_proxy/v4/letter/t/a4c791/32.png) [@tliltocatl](https://ziggit.dev/u/tliltocatl)\
**Post date:** [August 3, 2024, 10:58pm UTC](https://ziggit.dev/t/producing-dwarf-on-pe-coff-targets/5485/3 "2024-08-03T22:58:14Z")

</div>

Thanks dimdin. But maybe I’m being dumb, but while the pull request says “Emit Dwarf debug info if targetting gnu abi on windows” I can’t see any emit code/LLVM parameter passing, only parsing? And in 0.13.0 debug\_info isn’t even used anywere…

---

<div class="post-metadata">

**Author:** ![dimdin](https://ziggit.dev/user_avatar/ziggit.dev/dimdin/32/1457_2.png) [@dimdin](https://ziggit.dev/u/dimdin)\
**Post date:** [August 4, 2024, 10:31am UTC](https://ziggit.dev/t/producing-dwarf-on-pe-coff-targets/5485/4 "2024-08-04T10:31:58Z")

</div>

I am not sure that this is going to work but I find some kind of support.  
Try to search for dwarf debug section in the image even if a pdb file is generated.

For C the flag is: `-gdwarf`  
For Zig the flags are: `-gdwarf32` and `-gdwarf64`  
In [std.Build.Module](https://ziglang.org/documentation/master/std/#std.Build.Module) there is the `dwarf_format` member that controls the `-gdwarf32` and `-gdwarf64` flags.
