# RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj
# RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj
# RUN: lld-link /debug /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \
# RUN:   %t1.obj %t2.obj

# RUN: llvm-pdbutil pdb2yaml -stream-metadata -stream-directory -pdb-stream \
# RUN:   -dbi-stream -ipi-stream -tpi-stream %t.pdb | FileCheck %s

# RUN: llvm-pdbutil dump -modules -section-map -section-contribs \
# RUN:   -types -ids %t.pdb | FileCheck -check-prefix RAW %s

# CHECK:      MSF:
# CHECK-NEXT:   SuperBlock:
# CHECK-NEXT:     BlockSize:       4096
# CHECK-NEXT:     FreeBlockMap:    1
# CHECK-NEXT:     NumBlocks:
# CHECK-NEXT:     NumDirectoryBytes:
# CHECK-NEXT:     Unknown1:        0
# CHECK-NEXT:     BlockMapAddr:
# CHECK-NEXT:   NumDirectoryBlocks:
# CHECK-NEXT:   DirectoryBlocks:
# CHECK-NEXT:   NumStreams:
# CHECK-NEXT:   FileSize:
# CHECK-NEXT: StreamSizes:
# CHECK:      StreamMap:
# CHECK:      PdbStream:
# CHECK-NEXT:   Age:             1
# CHECK-NEXT:   Guid:
# CHECK-NEXT:   Signature:
# CHECK-NEXT:   Features:        [ VC140 ]
# CHECK-NEXT:   Version:         VC70
# CHECK-NEXT: DbiStream:
# CHECK-NEXT:   VerHeader:       V70
# CHECK-NEXT:   Age:             1
# CHECK-NEXT:   BuildNumber:     0
# CHECK-NEXT:   PdbDllVersion:   0
# CHECK-NEXT:   PdbDllRbld:      0
# CHECK-NEXT:   Flags:           0
# CHECK-NEXT:   MachineType:     x86
# CHECK-NEXT: TpiStream:
# CHECK-NEXT:   Version:         VC80
# CHECK-NEXT:   Records:
# CHECK-NEXT:     - Kind:            LF_ARGLIST
# CHECK-NEXT:       ArgList:
# CHECK-NEXT:         ArgIndices:      [  ]
# CHECK-NEXT:     - Kind:            LF_PROCEDURE
# CHECK-NEXT:       Procedure:
# CHECK-NEXT:         ReturnType:      116
# CHECK-NEXT:         CallConv:        NearC
# CHECK-NEXT:         Options:         [ None ]
# CHECK-NEXT:         ParameterCount:  0
# CHECK-NEXT:         ArgumentList:    4096
# CHECK-NEXT:     - Kind:            LF_POINTER
# CHECK-NEXT:       Pointer:
# CHECK-NEXT:         ReferentType:    4097
# CHECK-NEXT:         Attrs:           65548
# CHECK-NEXT:     - Kind:            LF_ARGLIST
# CHECK-NEXT:       ArgList:
# CHECK-NEXT:         ArgIndices:      [ 0 ]
# CHECK-NEXT:     - Kind:            LF_PROCEDURE
# CHECK-NEXT:       Procedure:
# CHECK-NEXT:         ReturnType:      116
# CHECK-NEXT:         CallConv:        NearC
# CHECK-NEXT:         Options:         [ None ]
# CHECK-NEXT:         ParameterCount:  0
# CHECK-NEXT:         ArgumentList:    4099
# CHECK-NEXT: IpiStream:
# CHECK-NEXT:   Version:         VC80
# CHECK-NEXT:   Records:
# CHECK-NEXT:     - Kind:            LF_FUNC_ID
# CHECK-NEXT:       FuncId:
# CHECK-NEXT:         ParentScope:     0
# CHECK-NEXT:         FunctionType:    4100
# CHECK-NEXT:         Name:            main
# CHECK-NEXT:     - Kind:            LF_FUNC_ID
# CHECK-NEXT:       FuncId:
# CHECK-NEXT:         ParentScope:     0
# CHECK-NEXT:         FunctionType:    4097
# CHECK-NEXT:         Name:            foo
# CHECK-NEXT:     - Kind:            LF_STRING_ID
# CHECK-NEXT:       StringId:
# CHECK-NEXT:         Id:              0
# CHECK-NEXT:         String:          'D:\b'
# CHECK-NEXT:     - Kind:            LF_STRING_ID
# CHECK-NEXT:       StringId:
# CHECK-NEXT:         Id:              0
# CHECK-NEXT:         String:          'C:\vs14\VC\BIN\amd64\cl.exe'
# CHECK-NEXT:     - Kind:            LF_STRING_ID
# CHECK-NEXT:       StringId:
# CHECK-NEXT:         Id:              0
# CHECK-NEXT:         String:          '-Z7 -c -MT -IC:\vs14\VC\INCLUDE -IC:\vs14\VC\ATLMFC\INCLUDE -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\shared"'
# CHECK-NEXT:     - Kind:            LF_SUBSTR_LIST
# CHECK-NEXT:       StringList:
# CHECK-NEXT:         StringIndices:   [ 4100 ]
# CHECK-NEXT:     - Kind:            LF_STRING_ID
# CHECK-NEXT:       StringId:
# CHECK-NEXT:         Id:              4101
# CHECK-NEXT:         String:          ' -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" -TC -X'
# CHECK-NEXT:     - Kind:            LF_STRING_ID
# CHECK-NEXT:       StringId:
# CHECK-NEXT:         Id:              0
# CHECK-NEXT:         String:          ret42-main.c
# CHECK-NEXT:     - Kind:            LF_STRING_ID
# CHECK-NEXT:       StringId:
# CHECK-NEXT:         Id:              0
# CHECK-NEXT:         String:          'D:\b\vc140.pdb'
# CHECK-NEXT:     - Kind:            LF_BUILDINFO
# CHECK-NEXT:       BuildInfo:
# CHECK-NEXT:         ArgIndices:      [ 4098, 4099, 4103, 4104, 4102 ]
# CHECK-NEXT:     - Kind:            LF_STRING_ID
# CHECK-NEXT:       StringId:
# CHECK-NEXT:         Id:              0
# CHECK-NEXT:         String:          ret42-sub.c
# CHECK-NEXT:     - Kind:            LF_BUILDINFO
# CHECK-NEXT:       BuildInfo:
# CHECK-NEXT:         ArgIndices:      [ 4098, 4099, 4106, 4104, 4102 ]

RAW:                               Modules
RAW-NEXT: ============================================================
RAW-NEXT:   Mod 0000 | Name: `{{.*}}pdb.test.tmp1.obj`:
RAW-NEXT:              Obj: `{{.*}}pdb.test.tmp1.obj`:
RAW-NEXT:              debug stream: 9, # files: 1, has ec info: false
RAW-NEXT:              pdb file ni: 0 ``, src file ni: 0 ``
RAW-NEXT:   Mod 0001 | Name: `{{.*}}pdb.test.tmp2.obj`:
RAW-NEXT:              Obj: `{{.*}}pdb.test.tmp2.obj`:
RAW-NEXT:              debug stream: 10, # files: 1, has ec info: false
RAW-NEXT:              pdb file ni: 0 ``, src file ni: 0 ``
RAW-NEXT:   Mod 0002 | Name: `* Linker *`:
RAW-NEXT:              Obj: ``:
RAW-NEXT:              debug stream: 11, # files: 0, has ec info: false
RAW-NEXT:              pdb file ni: 1 `{{.*pdb.test.tmp.pdb}}`, src file ni: 0 ``
RAW:                          Types (TPI Stream)
RAW-NEXT: ============================================================
RAW-NEXT:   Showing 5 records
RAW-NEXT:   0x1000 | LF_ARGLIST [size = 8]
RAW-NEXT:   0x1001 | LF_PROCEDURE [size = 16]
RAW-NEXT:            return type = 0x0074 (int), # args = 0, param list = 0x1000
RAW-NEXT:            calling conv = cdecl, options = None
RAW-NEXT:   0x1002 | LF_POINTER [size = 12]
RAW-NEXT:            referent = 0x1001, mode = pointer, opts = None, kind = ptr64
RAW-NEXT:   0x1003 | LF_ARGLIST [size = 12]
RAW-NEXT:            <no type>: ``
RAW-NEXT:   0x1004 | LF_PROCEDURE [size = 16]
RAW-NEXT:            return type = 0x0074 (int), # args = 0, param list = 0x1003
RAW-NEXT:            calling conv = cdecl, options = None
RAW:                          Types (IPI Stream)
RAW-NEXT: ============================================================
RAW-NEXT:   Showing 12 records
RAW-NEXT:   0x1000 | LF_FUNC_ID [size = 20]
RAW-NEXT:            name = main, type = 0x1004, parent scope = <no type>
RAW-NEXT:   0x1001 | LF_FUNC_ID [size = 16]
RAW-NEXT:            name = foo, type = 0x1001, parent scope = <no type>
RAW-NEXT:   0x1002 | LF_STRING_ID [size = 16] ID: <no type>, String: D:\b
RAW-NEXT:   0x1003 | LF_STRING_ID [size = 36] ID: <no type>, String: C:\vs14\VC\BIN\amd64\cl.exe
RAW-NEXT:   0x1004 | LF_STRING_ID [size = 260] ID: <no type>, String: -Z7 -c -MT -IC:\vs14\VC\INCLUDE -IC:\vs14\VC\ATLMFC\INCLUDE -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\shared"
RAW-NEXT:   0x1005 | LF_SUBSTR_LIST [size = 12]
RAW-NEXT:            0x1004: `-Z7 -c -MT -IC:\vs14\VC\INCLUDE -IC:\vs14\VC\ATLMFC\INCLUDE -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\shared"`
RAW-NEXT:   0x1006 | LF_STRING_ID [size = 132] ID: 0x1005, String:  -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" -TC -X
RAW-NEXT:   0x1007 | LF_STRING_ID [size = 24] ID: <no type>, String: ret42-main.c
RAW-NEXT:   0x1008 | LF_STRING_ID [size = 24] ID: <no type>, String: D:\b\vc140.pdb
RAW-NEXT:   0x1009 | LF_BUILDINFO [size = 28]
RAW-NEXT:            0x1002: `D:\b`
RAW-NEXT:            0x1003: `C:\vs14\VC\BIN\amd64\cl.exe`
RAW-NEXT:            0x1007: `ret42-main.c`
RAW-NEXT:            0x1008: `D:\b\vc140.pdb`
RAW-NEXT:            0x1006: ` -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" -TC -X`
RAW-NEXT:   0x100A | LF_STRING_ID [size = 20] ID: <no type>, String: ret42-sub.c
RAW-NEXT:   0x100B | LF_BUILDINFO [size = 28]
RAW-NEXT:            0x1002: `D:\b`
RAW-NEXT:            0x1003: `C:\vs14\VC\BIN\amd64\cl.exe`
RAW-NEXT:            0x100A: `ret42-sub.c`
RAW-NEXT:            0x1008: `D:\b\vc140.pdb`
RAW-NEXT:            0x1006: ` -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" -TC -X`
RAW:                        Section Contributions
RAW-NEXT: ============================================================
RAW-NEXT:   SC  | mod = 0, 65535:1288, size = 14, data crc = 0, reloc crc = 0
RAW-NEXT:         IMAGE_SCN_CNT_CODE | IMAGE_SCN_ALIGN_16BYTES | IMAGE_SCN_MEM_EXECUTE |
RAW-NEXT:         IMAGE_SCN_MEM_READ
RAW-NEXT:   SC  | mod = 0, 65535:1312, size = 8, data crc = 0, reloc crc = 0
RAW-NEXT:         IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_MEM_READ
RAW-NEXT:   SC  | mod = 0, 65535:1320, size = 12, data crc = 0, reloc crc = 0
RAW-NEXT:         IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_MEM_READ
RAW-NEXT:   SC  | mod = 1, 65535:1144, size = 6, data crc = 0, reloc crc = 0
RAW-NEXT:         IMAGE_SCN_CNT_CODE | IMAGE_SCN_ALIGN_16BYTES | IMAGE_SCN_MEM_EXECUTE |
RAW-NEXT:         IMAGE_SCN_MEM_READ
RAW:                             Section Map
RAW-NEXT: ============================================================
RAW-NEXT:   Section 0000 | ovl = 0, group = 0, frame = 0, name = 1
RAW-NEXT:                  class = 65535, offset = 0, size =
RAW-NEXT:                  flags = read | 32 bit addr | selector
RAW-NEXT:   Section 0001 | ovl = 1, group = 0, frame = 0, name = 2
RAW-NEXT:                  class = 65535, offset = 0, size =
RAW-NEXT:                  flags = read | execute | 32 bit addr | selector
RAW-NEXT:   Section 0002 | ovl = 2, group = 0, frame = 0, name = 3
RAW-NEXT:                  class = 65535, offset = 0, size =
RAW-NEXT:                  flags = read | 32 bit addr | selector
RAW-NEXT:   Section 0003 | ovl = 3, group = 0, frame = 0, name = 4
RAW-NEXT:                  class = 65535, offset = 0, size =
RAW-NEXT:                  flags = read | 32 bit addr | selector
RAW-NEXT:   Section 0004 | ovl = 4, group = 0, frame = 0, name = 5
RAW-NEXT:                  class = 65535, offset = 0, size =
RAW-NEXT:                  flags = 32 bit addr | absolute addr
