view src/codeview/decl.d @ 1:4a9dcbd9e54f

-files of 0.13 beta -fixes so that it now compiles with the current dmd version
author marton@basel.hu
date Tue, 05 Apr 2011 20:44:01 +0200
parents
children
line wrap: on
line source

/*  Ddbg - Win32 Debugger for the D programming language
 *  Copyright (c) 2007 Jascha Wetzel
 *  All rights reserved. See LICENSE.TXT for details.
 */
module codeview.decl;

//=================================================================================================
// structs corresponding to the CodeView 4 file format specification NB09

align(1) struct DirHeader
{
	ushort	cbDirHeader,
			cbDirEntry;
	uint	cDir,
			lfoNextDir,
			flags;
}

align(1) struct DirEntry
{
	ushort	subsection,
			iMod;
	uint	lfo,
			cb;
}

enum
{
    sstModule = 0x120,
    sstTypes,
    sstPublic,
    sstPublicSym,
    sstSymbols,
    sstAlignSym,
    sstSrcLnSeg,
    sstSrcModule,
    sstLibraries,
    sstGlobalSym,
    sstGlobalPub,
    sstGlobalTypes,
    sstMPC,
    sstSegMap,
    sstSegName,
    sstPreComp,
    sstPreCompMap,
    sstOffsetMap16,
    sstOffsetMap32,
    sstFileIndex,
    sstStaticSym
}

align(1) struct ModuleHeader
{
	ushort	ovlNumber,
			iLib,
			cSeg,
			Style;
}

align(1) struct SegInfo
{
	ushort	Seg,
			pad;
	uint	offset,
			cbSeg;
}

enum SymbolIndex
{
	S_COMPILE		= 1,
	S_REGISTER,
	S_CONSTANT,
	S_UDT,
	S_SSEARCH,
	S_END,
	S_SKIP,
	S_CVRESERVE,
	S_OBJNAME,
	S_ENDARG,
	S_COBOLUDT,
	S_MANYREG,
	S_RETURN,
	S_ENTRYTHIS,

	S_BPREL16		= 0x100,
	S_LDATA16,
	S_GDATA16,
	S_PUB16,
	S_LPROC16,
	S_GPROC16,
	S_THUNK16,
	S_BLOCK16,
	S_WITH16,
	S_LABEL16,
	S_CEXMODEL16,
	S_VFTPATH16,
	S_REGREL16,

	S_BPREL32		= 0x200,
	S_LDATA32,
	S_GDATA32,
	S_PUB32,
	S_LPROC32,
	S_GPROC32,
	S_THUNK32,
	S_BLOCK32,
	S_WITH32,
	S_LABEL32,
	S_CEXMODEL32,
	S_VFTPATH32,
	S_REGREL32,
	S_LTHREAD32,
	S_GTHREAD32,

	S_PROCREF		= 0x400,
	S_DATAREF,
	S_ALIGN,
}

align(1) struct CVProcedureSymbol
{
	uint		pParent,
				pEnd,
				pNext,
				proc_length,
				debug_start,
				debug_end,
				offset;
	ushort		segment,
				proctype;
	ubyte		flags;
}

align(1) struct CVReturnSymbol
{
	ushort	flags;
	ubyte	style;
}

align(1) struct CVStackSymbol
{
	int		offset;
	ushort	type;
}

align(1) struct CVDataSymbol
{
	uint	offset;
	ushort	segment,
			type;
}

align(1) struct PackedSymbolsHeader
{
	ushort	symhash,
			addrhash;
	uint	cbSymbol,
			cbSymHash,
			cbAddrHash;
}

//=================================================================================================
// D recOEM's

const uint OEM_DIGITALMARS  = 0x0042;
const uint D_DYN_ARRAY 	    = 0x0001;
const uint D_ASSOC_ARRAY    = 0x0002;
const uint D_DELEGATE   	= 0x0003;

//=================================================================================================
// leaf indeces

const uint LF_MODIFIER_16t	= 0x0001;
const uint LF_POINTER_16t	= 0x0002;
const uint LF_ARRAY_16t		= 0x0003;
const uint LF_CLASS_16t		= 0x0004;
const uint LF_STRUCTURE_16t	= 0x0005;
const uint LF_UNION_16t		= 0x0006;
const uint LF_ENUM_16t		= 0x0007;
const uint LF_PROCEDURE_16t	= 0x0008;
const uint LF_MFUNCTION_16t	= 0x0009;
const uint LF_VTSHAPE		= 0x000a;
const uint LF_COBOL0_16t	= 0x000b;
const uint LF_COBOL1		= 0x000c;
const uint LF_BARRAY_16t	= 0x000d;
const uint LF_LABEL			= 0x000e;
const uint LF_NULL			= 0x000f;
const uint LF_NOTTRAN		= 0x0010;
const uint LF_DIMARRAY_16t	= 0x0011;
const uint LF_VFTPATH_16t	= 0x0012;
const uint LF_PRECOMP_16t	= 0x0013;
const uint LF_ENDPRECOMP	= 0x0014;
const uint LF_OEM_16t		= 0x0015;
const uint LF_TYPESERVER	= 0x0016;

const uint LF_MODIFIER		= 0x1001;
const uint LF_POINTER		= 0x1002;
const uint LF_ARRAY			= 0x1003;
const uint LF_CLASS			= 0x1004;
const uint LF_STRUCTURE		= 0x1005;
const uint LF_UNION			= 0x1006;
const uint LF_ENUM			= 0x1007;
const uint LF_PROCEDURE		= 0x1008;
const uint LF_MFUNCTION		= 0x1009;
const uint LF_COBOL0		= 0x100a;
const uint LF_BARRAY		= 0x100b;
const uint LF_DIMARRAY		= 0x100c;
const uint LF_VFTPATH		= 0x100d;
const uint LF_PRECOMP		= 0x100e;
const uint LF_OEM			= 0x100f;

const uint LF_SKIP_16t		= 0x0200;
const uint LF_ARGLIST_16t	= 0x0201;
const uint LF_DEFARG_16t	= 0x0202;
const uint LF_LIST			= 0x0203;
const uint LF_FIELDLIST_16t	= 0x0204;
const uint LF_DERIVED_16t	= 0x0205;
const uint LF_BITFIELD_16t	= 0x0206;
const uint LF_METHODLIST_16t= 0x0207;
const uint LF_DIMCONU_16t	= 0x0208;
const uint LF_DIMCONLU_16t	= 0x0209;
const uint LF_DIMVARU_16t	= 0x020a;
const uint LF_DIMVARLU_16t	= 0x020b;
const uint LF_REFSYM		= 0x020c;

const uint LF_SKIP			= 0x1200;
const uint LF_ARGLIST		= 0x1201;
const uint LF_DEFARG		= 0x1202;
const uint LF_FIELDLIST		= 0x1203;
const uint LF_DERIVED		= 0x1204;
const uint LF_BITFIELD		= 0x1205;
const uint LF_METHODLIST	= 0x1206;
const uint LF_DIMCONU		= 0x1207;
const uint LF_DIMCONLU		= 0x1208;
const uint LF_DIMVARU		= 0x1209;
const uint LF_DIMVARLU		= 0x120a;

const uint LF_BCLASS_16t	= 0x0400;
const uint LF_VBCLASS_16t	= 0x0401;
const uint LF_IVBCLASS_16t	= 0x0402;
const uint LF_ENUMERATE		= 0x0403;
const uint LF_FRIENDFCN_16t	= 0x0404;
const uint LF_INDEX_16t		= 0x0405;
const uint LF_MEMBER_16t	= 0x0406;
const uint LF_STMEMBER_16t	= 0x0407;
const uint LF_METHOD_16t	= 0x0408;
const uint LF_NESTTYPE_16t	= 0x0409;
const uint LF_VFUNCTAB_16t	= 0x040a;
const uint LF_FRIENDCLS_16t	= 0x040b;
const uint LF_ONEMETHOD_16t	= 0x040c;
const uint LF_VFUNCOFF_16t	= 0x040d;
const uint LF_NESTTYPEEX_16t= 0x040e;
const uint LF_MEMBERMODIFY_16t	= 0x040f;

const uint LF_BCLASS		= 0x1400;
const uint LF_VBCLASS		= 0x1401;
const uint LF_IVBCLASS		= 0x1402;
const uint LF_FRIENDFCN		= 0x1403;
const uint LF_INDEX			= 0x1404;
const uint LF_MEMBER		= 0x1405;
const uint LF_STMEMBER		= 0x1406;
const uint LF_METHOD		= 0x1407;
const uint LF_NESTTYPE		= 0x1408;
const uint LF_VFUNCTAB		= 0x1409;
const uint LF_FRIENDCLS		= 0x140a;
const uint LF_ONEMETHOD		= 0x140b;
const uint LF_VFUNCOFF		= 0x140c;
const uint LF_NESTTYPEEX	= 0x140d;
const uint LF_MEMBERMODIFY	= 0x140e;

const uint LF_NUMERIC		= 0x8000;
const uint LF_CHAR			= 0x8000;
const uint LF_SHORT			= 0x8001;
const uint LF_USHORT		= 0x8002;
const uint LF_LONG			= 0x8003;
const uint LF_ULONG			= 0x8004;
const uint LF_REAL32		= 0x8005;
const uint LF_REAL64		= 0x8006;
const uint LF_REAL80		= 0x8007;
const uint LF_REAL128		= 0x8008;
const uint LF_QUADWORD		= 0x8009;
const uint LF_UQUADWORD		= 0x800a;
const uint LF_REAL48		= 0x800b;
const uint LF_COMPLEX32		= 0x800c;
const uint LF_COMPLEX64		= 0x800d;
const uint LF_COMPLEX80		= 0x800e;
const uint LF_COMPLEX128	= 0x800f;
const uint LF_VARSTRING		= 0x8010;
const uint LF_UCHAR			= 0x8011;

//=================================================================================================
// Primitive Types

// Special Types
const uint T_NOTYPE 	= 0x0000;
const uint T_ABS 		= 0x0001;
const uint T_SEGMENT 	= 0x0002;
const uint T_VOID 		= 0x0003;
const uint T_PVOID 		= 0x0103;
const uint T_PFVOID 	= 0x0203;
const uint T_PHVOID 	= 0x0303;
const uint T_32PVOID 	= 0x0403;
const uint T_32PFVOID 	= 0x0503;
const uint T_CURRENCY 	= 0x0004;
const uint T_NBASICSTR 	= 0x0005;
const uint T_FBASICSTR 	= 0x0006;
const uint T_NOTTRANS 	= 0x0007;
const uint T_BIT 		= 0x0060;
const uint T_PASCHAR 	= 0x0061;

// Character Types
const uint T_CHAR 		= 0x0010;
const uint T_UCHAR 		= 0x0020;
const uint T_PCHAR 		= 0x0110;
const uint T_PUCHAR 	= 0x0120;
const uint T_PFCHAR 	= 0x0210;
const uint T_PFUCHAR 	= 0x0220;
const uint T_PHCHAR 	= 0x0310;
const uint T_PHUCHAR 	= 0x0320;
const uint T_32PCHAR 	= 0x0410;
const uint T_32PUCHAR 	= 0x0420;
const uint T_32PFCHAR 	= 0x0510;
const uint T_32PFUCHAR 	= 0x0520;

// Real Character Types
const uint T_RCHAR 		= 0x0070;
const uint T_PRCHAR 	= 0x0170;
const uint T_PFRCHAR 	= 0x0270;
const uint T_PHRCHAR 	= 0x0370;
const uint T_32PRCHAR 	= 0x0470;
const uint T_32PFRCHAR 	= 0x0570;

// Wide Character Types
const uint T_WCHAR 		= 0x0071;
const uint T_PWCHAR 	= 0x0171;
const uint T_PFWCHAR 	= 0x0271;
const uint T_PHWCHAR 	= 0x0371;
const uint T_32PWCHAR 	= 0x0471;
const uint T_32PFWCHAR 	= 0x0571;

// Double Wide Character Types - D enhancement
const uint T_DCHAR 		= 0x0078;
const uint T_32PDCHAR   = 0x0478;
const uint T_32PFDCHAR  = 0x0578;

// Real 16-bit Integer Types
const uint T_INT2 		= 0x0072;
const uint T_UINT2 		= 0x0073;
const uint T_PINT2 		= 0x0172;
const uint T_PUINT2 	= 0x0173;
const uint T_PFINT2 	= 0x0272;
const uint T_PFUINT2 	= 0x0273;
const uint T_PHINT2 	= 0x0372;
const uint T_PHUINT2 	= 0x0373;
const uint T_32PINT2 	= 0x0472;
const uint T_32PUINT2 	= 0x0473;
const uint T_32PFINT2 	= 0x0572;
const uint T_32PFUINT2 	= 0x0573;

// 16-bit Short Types
const uint T_SHORT 		= 0x0011;
const uint T_USHORT 	= 0x0021;
const uint T_PSHORT 	= 0x0111;
const uint T_PUSHORT 	= 0x0121;
const uint T_PFSHORT 	= 0x0211;
const uint T_PFUSHORT 	= 0x0221;
const uint T_PHSHORT 	= 0x0311;
const uint T_PHUSHORT 	= 0x0321;
const uint T_32PSHORT 	= 0x0411;
const uint T_32PUSHORT 	= 0x0421;
const uint T_32PFSHORT 	= 0x0511;
const uint T_32PFUSHORT = 0x0521;

// Real 32-bit Integer Types
const uint T_INT4 		= 0x0074;
const uint T_UINT4 		= 0x0075;
const uint T_PINT4 		= 0x0174;
const uint T_PUINT4 	= 0x0175;
const uint T_PFINT4 	= 0x0274;
const uint T_PFUINT4 	= 0x0275;
const uint T_PHINT4 	= 0x0374;
const uint T_PHUINT4 	= 0x0375;
const uint T_32PINT4 	= 0x0474;
const uint T_32PUINT4 	= 0x0475;
const uint T_32PFINT4 	= 0x0574;
const uint T_32PFUINT4 	= 0x0575;

// 32-bit Long Types
const uint T_LONG 		= 0x0012;
const uint T_ULONG 		= 0x0022;
const uint T_PLONG 		= 0x0112;
const uint T_PULONG 	= 0x0122;
const uint T_PFLONG 	= 0x0212;
const uint T_PFULONG 	= 0x0222;
const uint T_PHLONG 	= 0x0312;
const uint T_PHULONG 	= 0x0322;
const uint T_32PLONG 	= 0x0412;
const uint T_32PULONG 	= 0x0422;
const uint T_32PFLONG 	= 0x0512;
const uint T_32PFULONG 	= 0x0522;

// Real 64-bit int Types
const uint T_INT8 		= 0x0076;
const uint T_UINT8 		= 0x0077;
const uint T_PINT8 		= 0x0176;
const uint T_PUINT8 	= 0x0177;
const uint T_PFINT8 	= 0x0276;
const uint T_PFUINT8 	= 0x0277;
const uint T_PHINT8 	= 0x0376;
const uint T_PHUINT8 	= 0x0377;
const uint T_32PINT8 	= 0x0476;
const uint T_32PUINT8 	= 0x0477;
const uint T_32PFINT8 	= 0x0576;
const uint T_32PFUINT8 	= 0x0577;

// 64-bit Integral Types
const uint T_QUAD 		= 0x0013;
const uint T_UQUAD 		= 0x0023;
const uint T_PQUAD 		= 0x0113;
const uint T_PUQUAD 	= 0x0123;
const uint T_PFQUAD 	= 0x0213;
const uint T_PFUQUAD 	= 0x0223;
const uint T_PHQUAD 	= 0x0313;
const uint T_PHUQUAD 	= 0x0323;
const uint T_32PQUAD 	= 0x0413;
const uint T_32PUQUAD 	= 0x0423;
const uint T_32PFQUAD 	= 0x0513;
const uint T_32PFUQUAD 	= 0x0523;

// 32-bit Real Types
const uint T_REAL32 	= 0x0040;
const uint T_PREAL32 	= 0x0140;
const uint T_PFREAL32 	= 0x0240;
const uint T_PHREAL32 	= 0x0340;
const uint T_32PREAL32 	= 0x0440;
const uint T_32PFREAL32 = 0x0540;

// 48-bit Real Types
const uint T_REAL48 	= 0x0044;
const uint T_PREAL48 	= 0x0144;
const uint T_PFREAL48 	= 0x0244;
const uint T_PHREAL48 	= 0x0344;
const uint T_32PREAL48 	= 0x0444;
const uint T_32PFREAL48 = 0x0544;

// 64-bit Real Types
const uint T_REAL64 	= 0x0041;
const uint T_PREAL64 	= 0x0141;
const uint T_PFREAL64 	= 0x0241;
const uint T_PHREAL64 	= 0x0341;
const uint T_32PREAL64 	= 0x0441;
const uint T_32PFREAL64 = 0x0541;

// 80-bit Real Types
const uint T_REAL80 	= 0x0042;
const uint T_PREAL80 	= 0x0142;
const uint T_PFREAL80 	= 0x0242;
const uint T_PHREAL80 	= 0x0342;
const uint T_32PREAL80 	= 0x0442;
const uint T_32PFREAL80 = 0x0542;

// 128-bit Real Types
const uint T_REAL128 	= 0x0043;
const uint T_PREAL128 	= 0x0143;
const uint T_PFREAL128 	= 0x0243;
const uint T_PHREAL128 	= 0x0343;
const uint T_32PREAL128 = 0x0443;
const uint T_32PFREAL128 = 0x0543;

// 32-bit Complex Types
const uint T_CPLX32 	= 0x0050;
const uint T_PCPLX32 	= 0x0150;
const uint T_PFCPLX32 	= 0x0250;
const uint T_PHCPLX32 	= 0x0350;
const uint T_32PCPLX32 	= 0x0450;
const uint T_32PFCPLX32 = 0x0550;

// 64-bit Complex Types
const uint T_CPLX64 	= 0x0051;
const uint T_PCPLX64 	= 0x0151;
const uint T_PFCPLX64	= 0x0251;
const uint T_PHCPLX64 	= 0x0351;
const uint T_32PCPLX64 	= 0x0451;
const uint T_32PFCPLX64 = 0x0551;

// 80-bit Complex Types
const uint T_CPLX80 	= 0x0052;
const uint T_PCPLX80 	= 0x0152;
const uint T_PFCPLX80 	= 0x0252;
const uint T_PHCPLX80 	= 0x0352;
const uint T_32PCPLX80 	= 0x0452;
const uint T_32PFCPLX80 = 0x0552;

// 128-bit Complex Types
const uint T_CPLX128 	= 0x0053;
const uint T_PCPLX128 	= 0x0153;
const uint T_PFCPLX128 	= 0x0253;
const uint T_PHCPLX128 	= 0x0353;
const uint T_32PCPLX128 = 0x0453;
const uint T_32PFCPLX128 = 0x0553;

// Boolean Types
const uint T_BOOL08 	= 0x0030;
const uint T_BOOL16 	= 0x0031;
const uint T_BOOL32 	= 0x0032;
const uint T_BOOL64 	= 0x0033;
const uint T_PBOOL08 	= 0x0130;
const uint T_PBOOL16 	= 0x0131;
const uint T_PBOOL32 	= 0x0132;
const uint T_PBOOL64 	= 0x0133;
const uint T_PFBOOL08 	= 0x0230;
const uint T_PFBOOL16 	= 0x0231;
const uint T_PFBOOL32 	= 0x0232;
const uint T_PFBOOL64 	= 0x0233;
const uint T_PHBOOL08 	= 0x0330;
const uint T_PHBOOL16 	= 0x0331;
const uint T_PHBOOL32 	= 0x0332;
const uint T_PHBOOL64 	= 0x0333;
const uint T_32PBOOL08 	= 0x0430;
const uint T_32PBOOL16 	= 0x0431;
const uint T_32PBOOL32 	= 0x0432;
const uint T_32PBOOL64 	= 0x0433;
const uint T_32PFBOOL08 = 0x0530;
const uint T_32PFBOOL16 = 0x0531;
const uint T_32PFBOOL32 = 0x0532;
const uint T_32PFBOOL64 = 0x0533;

//=================================================================================================
// classes for representing types

class Leaf
{
	ushort	leaf_index;
}

class LeafModifer : Leaf
{
	ushort	attribute, index;
}

class LeafPointer : Leaf
{
	ushort	attribute,
			type;
}

class LeafArgList : Leaf
{
	ushort		argcount;
	ushort[]	indeces;
}

class LeafProcedure : Leaf
{
	ushort	rvtype;
	ubyte	call,
			reserved;
	ushort	cParms,
			arglist;
}

class LeafMFunction : Leaf
{
	ushort	rvtype,
			_class,
			_this;
	ubyte	call,
			reserved;
	ushort	cParms,
			arglist;
	uint	thisadjust;
}

class LeafNumeric : Leaf
{
	union {
		char	c;
		ubyte	uc;
		short	s;
		ushort	us;
		int		i;
		uint	ui;
		long	l;
		ulong	ul;
		float	f;
		double	d;
		real	r;
		cfloat	cf;
		cdouble	cd;
		creal	cr;
		string	str;
	}

	uint getUint()
	{
		switch ( leaf_index )
		{
			case LF_USHORT:	return us;
			case LF_ULONG:	return cast(uint)ul;
			case LF_UCHAR:	return uc;
			default:
				assert ( 0, "unsupported numeric leaf" );
		}
		return 0;
	}
}

class LeafClassStruc : Leaf
{
	ushort	count,
			field,
			property,
			dList,
			vshape,
			type;
	LeafNumeric	length;
	string	name;
}

class LeafVTShape : Leaf
{
	ubyte[]	descriptor;
}

class LeafFieldList : Leaf
{
	Leaf[]	fields;
}

class LeafMethodList : Leaf
{
}

class LeafDerived : Leaf
{
	ushort[]	types;
}

class LeafBaseClass : Leaf
{
	ushort	type,
			attribute;
	LeafNumeric	offset;
}

class LeafMember : Leaf
{
	ushort	type,
			attribute;
	LeafNumeric	offset;
	string	name;
}

class LeafMethod : Leaf
{
	ushort	count,
			mList;
	string	name;
}

class LeafArray : Leaf
{
	ushort	elemtype,
			idxtype;
	LeafNumeric	length;
	string	name;
}

class LeafEnum : Leaf
{
	ushort	count,
			type,
			field,
			property;
	string	name;
}

class LeafEnumNameValue : Leaf
{
	ushort	attribute;
	LeafNumeric	value;
	string	name;
}

class LeafNestedType : Leaf
{
	ushort	index;
	string	name;
}

class LeafStaticDataMember : Leaf
{
	ushort	type,
			attribute;
	string	name;
}

class LeafUnion : Leaf
{
	ushort	count,
			field,
			property;
	LeafNumeric	length;
	string	name;
}

class LeafDynArray : Leaf
{
	ushort	index_type,
			elem_type;
}

class LeafAssocArray : Leaf
{
	ushort	key_type,
			elem_type;
}

class LeafDelegate : Leaf
{
	ushort	this_type,
			func_type;
}