microsoft / microsoft/DirectXShaderCompiler
Generated separate PDB files have possibly invalid header
@adam-yang is already working on this.
Since Jul 14, 2023.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
The generated separate PDB files with e.g. -Fd or CompileWithDebug seem to have an invalid PDB header.
Taking a simple shader like this:
float4 main() : SV_Target0
{
return float4(0,0,0,0);
}
And compiling with latest dxc:
$ ./bin/dxc -help | grep Version
Version: dxcompiler.dll: 1.6 - 1.5.0.2616 (6ef33dce)
$ ./bin/dxc -Zi -Qstrip_debug -Zsb input.hlsl -T ps_6_0 -Fd /path/to/output/ -Fo /path/to/output/a.dxbc
warning: DXIL.dll not found. Resulting DXIL will not be signed for use in release environments.
I get a PDB file 7efd93578d970ff351afc3ab6a3d8b4a.pdb which is 5120 bytes long with this header:
00000000 4d 69 63 72 6f 73 6f 66 74 20 43 2f 43 2b 2b 20 |Microsoft C/C++ |
00000010 4d 53 46 20 37 2e 30 30 0d 0a 1a 44 53 00 00 00 |MSF 7.00...DS...|
00000020 00 02 00 00 01 00 00 00 09 00 00 00 30 00 00 00 |............0...|
00000030 00 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 |................|
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
So in particular the page count at 0x28 is 9, even though the file is 10 pages long - 5120 bytes.
The PDB is rather sparsely documented but I believe the page size (0x200 - 512 bytes) multiplied by the page count should equal the total file size.
Looking briefly at the code, the calculation of the number of pages/blocks seems off:
This accounts for 3 fixed blocks - superblock and two empty free block maps, plus the stream blocks and the stream directory blocks. However there's also at least one other block written for the block map. The list of blocks containing the stream directory which doesn't seem to have been counted:
In most cases this will probably mean that the page count is off-by-one as seen here, but it could be off by more. It's not clear what readers are expected to do if this page count is wrong since it can equally be derived by FileSize / PageSize.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.