Documentation ¶
Overview ¶
Package pdb provides access to the PDB (Microsoft C/C++ program database) file format.
ref: https://www.nationalarchives.gov.uk/pronom/fmt/1078 ref: https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/msf/msf.cpp ref: https://llvm.org/docs/PDB/MsfFile.html ref: https://llvm.org/docs/PDB/index.html
Index ¶
- type File
- type FreePageMap
- type GUID
- type MSFHeader
- type PDBStream
- type PDBStreamHeader
- type PDBVersion
- type Stream
- type StreamID
- type StreamInfo
- type StreamNameMap
- type StreamNumber
- type StreamTable
- type TPIStream
- type TPIStreamHeader16
- type TPIVersion
- type TypeID16
- type TypeKind
- type TypeMode
- type TypeRecord
- type TypeRecordHeader
- type TypeRecordKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct { // File header of MSF. FileHdr *MSFHeader // Free page map. FreePageMap *FreePageMap // Stream table. StreamTbl *StreamTable // Streams. Streams []Stream // Contents of underlying PDB file. Data []byte // TODO: rename to buf }
File is a PDB file.
type FreePageMap ¶
type FreePageMap struct { // Each bit specifies whether the corresponding page is used or unused. // // 0 = used // 1 = unused PageBits []byte // length: msfHdr.PageSize }
FreePageMap specifies what pages are used/unused.
ref: https://llvm.org/docs/PDB/MsfFile.html#the-free-block-map ref: FPM
func (*FreePageMap) IsFree ¶
func (fpm *FreePageMap) IsFree(pageNum int) bool
IsFree reports whether the given page number is unused.
type MSFHeader ¶
type MSFHeader struct { // File format identifier. Magic [44]byte // Page size in bytes. PageSize int32 // Page number of free page map. FreePageMapPageNum uint16 // Number of pages. NPages uint16 // Stream information about the stream table. StreamTblInfo StreamInfo // Maps from stream page number to page number. PageNumMap []uint16 // length: math.Ceil(msfHdr.StreamTblInfo.Size / msfHdr.PageSize) }
MSFHeader is the header of a multistream file (MSF). The MSF header is always at page 0.
ref: https://llvm.org/docs/PDB/MsfFile.html#the-superblock ref: MSF_HDR
type PDBStream ¶
type PDBStream struct { // PDB stream header. Hdr *PDBStreamHeader // Map from stream name to stream number. StreamNameMap *StreamNameMap }
PDBStream records information about the PDB.
type PDBStreamHeader ¶
type PDBStreamHeader struct { // PDB version. Version PDBVersion // Creation date. Date time.Time // Number of times the PDB file as been written to. Age uint32 // Unique ID of the PDB. UniqueID GUID }
PDBStreamHeader is a header of the PDB stream.
type PDBVersion ¶
type PDBVersion uint32
PDBVersion specifies the version of Visual Studio Code used to produce the PDB. However, in practise, VC70 is almost always used (even if the version of VC used to produce the PDB was newer).
const ( PDBVersionVC2 PDBVersion = 19941610 // VC 2 (1994-10-16) PDBVersionVC4 PDBVersion = 19950623 // VC 4 (1995-06-23) PDBVersionVC41 PDBVersion = 19950814 // VC 4.1 (1995-08-14) PDBVersionVC50 PDBVersion = 19960307 // VC 5.0 (1996-03-07) PDBVersionVC98 PDBVersion = 19970604 // VC 98 (1997-06-04) PDBVersionVC70Deprecated PDBVersion = 19990604 // VC 7.0 - deprecated (1999-06-04) PDBVersionVC70 PDBVersion = 20000404 // VC 7.0 (2000-04-04) PDBVersionVC80 PDBVersion = 20030901 // VC 8.0 (2003-09-01) PDBVersionVC110 PDBVersion = 20091201 // VC 11.0 (2009-12-01) PDBVersionVC140 PDBVersion = 20140508 // VC 14.0 (2014-05-08) )
PDB versions.
ref: PDBIMPV
func (PDBVersion) String ¶
func (i PDBVersion) String() string
type Stream ¶
type Stream interface{}
Stream is a stream of a PDB file.
Stream is one of the following types.
*PDBStream
TODO: add more stream types.
type StreamID ¶
type StreamID uint32
StreamID specifies a fixed stream index.
type StreamInfo ¶
type StreamInfo struct { // Size in bytes of stream table. Size int32 // ref: SI_PERSIST.mpspnpn Unknown int32 }
StreamInfo specifies stream information.
ref: SI_PERSIST
type StreamNameMap ¶
type StreamNameMap struct { }
StreamNameMap maps from stream name to stream number.
ref: https://llvm.org/docs/PDB/PdbStream.html#named-stream-map
type StreamTable ¶
type StreamTable struct { // Number of streams. NStreams uint32 // Stream information about each stream of the MSF. StreamInfos []StreamInfo // length: NStreams // Maps from stream number and stream page number to page number. Note that // the array is jagged, and as such, the length of the page number slices may // differ. PageNumMaps [][]uint16 // length of PageNumMaps[i]: math.Ceil(streamTbl.StreamInfos[i].Size / msfHdr.PageSize) }
StreamTable contains information about each stream of the MSF.
Example [1]: Suppose a hypothetical PDB file with a 4KiB block size, and 4 streams of lengths {1000 bytes, 8000 bytes, 16000 bytes, 9000 bytes}.
Stream 0: ceil(1000 / 4096) = 1 block
Stream 1: ceil(8000 / 4096) = 2 blocks
Stream 2: ceil(16000 / 4096) = 4 blocks
Stream 3: ceil(9000 / 4096) = 3 blocks
type StreamTable struct { NStreams = uint32(4) StreamInfos = []StreamInfo{{Size: 1000}, {Size: 8000}, {Size: 16000}, {Size: 9000}} PageNumMaps = [][]uint16{ {4}, {5, 6}, {11, 9, 7, 8}, {10, 15, 12}, }, }
ref [1]: https://llvm.org/docs/PDB/MsfFile.html#the-stream-directory ref: StrmTbl
type TPIStream ¶
type TPIStream struct { // TPI stream header. Hdr *TPIStreamHeader16 // Type records. Types []TypeRecord }
TPIStream records information about types used in the program. Types are referenced by their type index from other parts of the PDB.
type TPIStreamHeader16 ¶
type TPIStreamHeader16 struct { // TPI version. Version TPIVersion // First type index, inclusive; type index of first type record in the TPI // stream. FirstTypeID TypeID16 // Last type index, exclusive. LastTypeID TypeID16 // Size in bytes of type records data following header. TypeRecordsSize int32 // Index of TPI hash stream. HashStreamNum StreamNumber }
TPIStreamHeader16 is a header of the TPI stream with 16-bit type IDs.
ref: HDR_16t in PDB/dbi/tpi.h
type TPIVersion ¶
type TPIVersion uint32
TPIVersion specifies the version of Visual Studio Code used to produce the TPI. However, in practise, VC80 is almost always used (even if the version of VC used to produce the TPI was newer).
const ( TPIVersionV40 TPIVersion = 19950410 // V 4.0 (1995-04-10) TPIVersionV41 TPIVersion = 19951122 // V 4.1 (1995-11-22) TPIVersionV50Interim TPIVersion = 19960307 // V 5.0 - interim (1996-03-07) TPIVersionV50 TPIVersion = 19961031 // V 5.0 (1996-10-31) TPIVersionV70 TPIVersion = 19990903 // V 7.0 (1999-09-03) TPIVersionV80 TPIVersion = 20040203 // V 8.0 (2004-02-03) )
TPI versions.
ref: TPIIMPV
func (TPIVersion) String ¶
func (i TPIVersion) String() string
type TypeID16 ¶
type TypeID16 uint16
TypeID16 is a 16-bit type index which uniquely identifies a type of the PDB.
Any typeID >= Hdr.FirstTypeID is persumed to come from the corresponding TPI (or IPI) stream.
A typeID < Hdr.FirstTypeID is decomposed as follows:
+----------+----------+------------------+ | unused | mode | kind | +----------+----------+------------------+ |+16 |+12 |+8 |+0
A basic type composed of a type kind and a type mode.
BasicType = TypeKind | TypeMode 0b0000MMMMKKKKKKKK // mode and kind bits marked with 'M' and 'K' respectively.
ref [2]: https://llvm.org/docs/PDB/TpiStream.html#type-indices
type TypeKind ¶
type TypeKind uint16 // actually 8 bits.
TypeKind specifies the kind of basic types (e.g. int8, uint8).
0b0000MMMMKKKKKKKK // mode and kind bits marked with 'M' and 'K' respectively.
const ( // Special Types TypeKindNone TypeKind = 0x0000 // uncharacterized type (no type) TypeKindAbs TypeKind = 0x0001 // absolute symbol TypeKindSegment TypeKind = 0x0002 // segment type TypeKindVoid TypeKind = 0x0003 // void TypeKindHResult TypeKind = 0x0008 // HRESULT TypeKindCurrency TypeKind = 0x0004 // BASIC 8 byte currency value TypeKindBasicStringNear TypeKind = 0x0005 // near BASIC string TypeKindBasicStringFar TypeKind = 0x0006 // far BASIC string TypeKindNotTranslated TypeKind = 0x0007 // type not translated by cvpack TypeKindBit TypeKind = 0x0060 // bit TypeKindPascalChar TypeKind = 0x0061 // Pascal CHAR TypeKindBool32FFFFFFFF TypeKind = 0x0062 // 32-bit BOOL where true is 0xffffffff // Character types TypeKindCharacter TypeKind = 0x0070 // really a char TypeKindWideCharacter TypeKind = 0x0071 // wide char // unicode char types TypeKindRune16 TypeKind = 0x007A // 16-bit unicode char TypeKindRune32 TypeKind = 0x007B // 32-bit unicode char // int types TypeKindInt8 TypeKind = 0x0068 // 8 bit signed int TypeKindUint8 TypeKind = 0x0069 // 8 bit unsigned int TypeKindInt16 TypeKind = 0x0072 // 16 bit signed int TypeKindUint16 TypeKind = 0x0073 // 16 bit unsigned int TypeKindInt32 TypeKind = 0x0074 // 32 bit signed int TypeKindUint32 TypeKind = 0x0075 // 32 bit unsigned int TypeKindInt64 TypeKind = 0x0076 // 64 bit signed int TypeKindUint64 TypeKind = 0x0077 // 64 bit unsigned int TypeKindInt128 TypeKind = 0x0078 // 128 bit signed int TypeKindUint128 TypeKind = 0x0079 // 128 bit unsigned int // 8 bit character types TypeKindInt8Byte TypeKind = 0x0010 // 8 bit signed TypeKindUint8Byte TypeKind = 0x0020 // 8 bit unsigned // 16 bit short types TypeKindInt16Short TypeKind = 0x0011 // 16 bit signed TypeKindUint16Short TypeKind = 0x0021 // 16 bit unsigned // 32 bit long types TypeKindInt32Long TypeKind = 0x0012 // 32 bit signed // 64 bit quad types TypeKindInt64Quad TypeKind = 0x0013 // 64 bit signed TypeKindUint64Quad TypeKind = 0x0023 // 64 bit unsigned // 128 bit octet types TypeKindInt128Octet TypeKind = 0x0014 // 128 bit signed TypeKindUint128Octet TypeKind = 0x0024 // 128 bit unsigned // floating-point types TypeKindFloat16 TypeKind = 0x0046 // 16 bit real TypeKindFloat32 TypeKind = 0x0040 // 32 bit real TypeKindFloat32PP TypeKind = 0x0045 // 32 bit partial-precision real TypeKindFloat48 TypeKind = 0x0044 // 48 bit real TypeKindFloat64 TypeKind = 0x0041 // 64 bit real TypeKindFloat80 TypeKind = 0x0042 // 80 bit real TypeKindFloat128 TypeKind = 0x0043 // 128 bit real // complex types TypeKindComplex32 TypeKind = 0x0050 // 32 bit complex TypeKindComplex64 TypeKind = 0x0051 // 64 bit complex TypeKindComplex80 TypeKind = 0x0052 // 80 bit complex TypeKindComplex128 TypeKind = 0x0053 // 128 bit complex // boolean types TypeKindBool8 TypeKind = 0x0030 // 8 bit boolean TypeKindBool16 TypeKind = 0x0031 // 16 bit boolean TypeKindBool32 TypeKind = 0x0032 // 32 bit boolean TypeKindBool64 TypeKind = 0x0033 // 64 bit boolean TypeKindBool128 TypeKind = 0x0034 // 128 bit boolean // ??? TypeKindInternal TypeKind = 0x00F0 // CV internal type )
Type kinds.
ref: TYPE_ENUM_e
type TypeMode ¶
type TypeMode uint16 // actually 4 bits.
TypeMode specifies the mode of basic types (e.g. 32-bit pointer, 64-bit pointer).
0b0000 0b0010 - 16 bit pointer 0b0011 - 16:16 far pointer 0b0100 - 16:16 huge pointer 0b0101 - 32 bit pointer 0b0110 - 16:32 pointer 0b0111 - 64 bit pointer 0b0000MMMMKKKKKKKK // mode and kind bits marked with 'M' and 'K' respectively.
const ( TypeModeNone TypeMode = 0x0000 // TypeMode(none) // near pointer TypeModePointer16 TypeMode = 0x0100 // 16 bit pointer // far pointer TypeModePointer16Far TypeMode = 0x0200 // 16:16 far pointer pointer TypeModePointer16Huge TypeMode = 0x0300 // 16:16 huge pointer pointer TypeModePointer32 TypeMode = 0x0400 // 32 bit pointer TypeModePointer32Far TypeMode = 0x0500 // 16:32 far pointer TypeModePointer64 TypeMode = 0x0600 // 64 bit pointer TypeModePointer128 TypeMode = 0x0700 // 128 bit pointer )
Type modes.
ref: TYPE_ENUM_e
type TypeRecord ¶
type TypeRecord struct {
Hdr *TypeRecordHeader
}
TypeRecord records information about a type.
type TypeRecordHeader ¶
type TypeRecordHeader struct { // Size in bytes of type record, excluding the 2 bytes that make up the size // field. RecordSize uint16 RecordKind TypeRecordKind // contains filtered or unexported fields }
TypeRecordHeader is a type record header.
type TypeRecordKind ¶
type TypeRecordKind uint16
TypeRecordKind denotes the kind of a type record.
ref: LEAF_ENUM_e
const ( TypeRecordKindNone TypeRecordKind = 0x0000 // leaf indices starting records but referenced from symbol records TypeRecordKindPointer TypeRecordKind = 0x1002 )
Type record kinds.