Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

249 lines
9.7 KiB

  1. // Debug Information API
  2. // VC++5.0 Read-Only OEM Edition
  3. // Copyright (C) 1993-1997, Microsoft Corp. All Rights Reserved.
  4. #ifndef __OEMDBI_INCLUDED__
  5. #define __OEMDBI_INCLUDED__
  6. typedef int BOOL;
  7. typedef unsigned UINT;
  8. typedef unsigned char BYTE;
  9. typedef unsigned long ULONG;
  10. typedef unsigned short USHORT;
  11. typedef unsigned long DWORD;
  12. typedef short SHORT;
  13. typedef long LONG;
  14. typedef char * SZ;
  15. typedef unsigned long CV_typ_t;
  16. typedef CV_typ_t TI; // PDB name for type index
  17. typedef ULONG INTV; // interface version number
  18. typedef ULONG IMPV; // implementation version number
  19. typedef ULONG SIG; // unique (across PDB instances) signature
  20. typedef ULONG AGE; // no. of times this instance has been updated
  21. typedef BYTE* PB; // pointer to some bytes
  22. typedef LONG CB; // count of bytes
  23. typedef char* SZ; // zero terminated string
  24. typedef char* PCH; // char ptr
  25. typedef USHORT IFILE; // file index
  26. typedef USHORT IMOD; // module index
  27. typedef USHORT ISECT; // section index
  28. typedef USHORT LINE; // line number
  29. typedef LONG OFF; // offset
  30. typedef BYTE ITSM; // type server map index
  31. enum {
  32. PDBIntv50a = 19970116,
  33. PDBIntv50 = 19960502,
  34. PDBIntv41 = 920924,
  35. PDBIntvAlt = PDBIntv50, // Alternate (backward compatible) supported interface
  36. PDBIntv = PDBIntv50a,
  37. };
  38. enum {
  39. PDB_MAX_PATH = 260,
  40. cbErrMax = 1024, // max. length of error message
  41. };
  42. typedef CV_typ_t TI; // type index
  43. struct PDB; // program database
  44. struct DBI; // debug information within the PDB
  45. struct Mod; // a module within the DBI
  46. struct TPI; // type info within the DBI
  47. struct GSI;
  48. struct Enum; // generic enumerator
  49. struct EnumContrib; // enumerate contributions
  50. struct Dbg; // misc debug data (FPO, OMAP, etc)
  51. typedef struct PDB PDB;
  52. typedef struct DBI DBI;
  53. typedef struct Mod Mod;
  54. typedef struct TPI TPI;
  55. typedef struct GSI GSI;
  56. typedef struct Enum Enum;
  57. typedef struct EnumContrib EnumContrib;
  58. typedef struct Dbg Dbg;
  59. typedef long EC; // error code
  60. enum PDBErrors {
  61. EC_OK, // -, no problemo
  62. EC_USAGE, // -, invalid parameter or call order
  63. EC_OUT_OF_MEMORY, // -, out of RAM
  64. EC_FILE_SYSTEM, // "pdb name", can't write file, out of disk, etc.
  65. EC_NOT_FOUND, // "pdb name", PDB file not found
  66. EC_INVALID_SIG, // "pdb name", PDB::OpenValidate() and its clients only
  67. EC_INVALID_AGE, // "pdb name", PDB::OpenValidate() and its clients only
  68. EC_PRECOMP_REQUIRED, // "obj name", Mod::AddTypes() only
  69. EC_OUT_OF_TI, // "pdb name", TPI::QueryTiForCVRecord() only
  70. EC_NOT_IMPLEMENTED, // -
  71. EC_V1_PDB, // "pdb name", PDB::Open* only
  72. EC_FORMAT, // accessing pdb with obsolete format
  73. EC_LIMIT,
  74. EC_CORRUPT, // cv info corrupt, recompile mod
  75. EC_TI16, // no 16-bit type interface present
  76. EC_ACCESS_DENIED, // "pdb name", PDB file read-only
  77. EC_MAX
  78. };
  79. #ifndef PDBCALL
  80. #define PDBCALL __cdecl
  81. #endif
  82. #define PDB_IMPORT_EXPORT(RTYPE) __declspec(dllimport) RTYPE PDBCALL
  83. #define PDBAPI PDB_IMPORT_EXPORT
  84. #define IN /* in parameter, parameters are IN by default */
  85. #define OUT /* out parameter */
  86. struct _tagSEARCHDEBUGINFO;
  87. typedef BOOL (__stdcall * pfnFindDebugInfoFile) ( struct _tagSEARCHDEBUGINFO* );
  88. typedef BOOL (__stdcall * PFNVALIDATEDEBUGINFOFILE) (const char* szFile, ULONG * errcode );
  89. typedef struct _tagSEARCHDEBUGINFO {
  90. DWORD cb; // doubles as version detection
  91. BOOL fMainDebugFile; // indicates "core" or "ancillary" file
  92. // eg: main.exe has main.pdb and foo.lib->foo.pdb
  93. SZ szMod; // exe/dll
  94. SZ szLib; // lib if appropriate
  95. SZ szObj; // object file
  96. SZ * rgszTriedThese; // list of ones that were tried,
  97. // NULL terminated list of LSZ's
  98. char szValidatedFile[PDB_MAX_PATH]; // output of validated filename,
  99. PFNVALIDATEDEBUGINFOFILE
  100. pfnValidateDebugInfoFile; // validation function
  101. } SEARCHDEBUGINFO, *PSEARCHDEBUGINFO;
  102. enum DBGTYPE {
  103. dbgtypeFPO,
  104. dbgtypeException,
  105. dbgtypeFixup,
  106. dbgtypeOmapToSrc,
  107. dbgtypeOmapFromSrc,
  108. dbgtypeSectionHdr,
  109. };
  110. typedef enum DBGTYPE DBGTYPE;
  111. // ANSI C Binding
  112. #if __cplusplus
  113. extern "C" {
  114. #endif
  115. PDBAPI( BOOL )
  116. PDBOpenValidate(
  117. SZ szPDB,
  118. SZ szExeDir,
  119. SZ szMode,
  120. SIG sig,
  121. AGE age,
  122. OUT EC* pec,
  123. OUT char szError[cbErrMax],
  124. OUT PDB** pppdb);
  125. PDBAPI( BOOL )
  126. PDBOpen(
  127. SZ szPDB,
  128. SZ szMode,
  129. SIG sigInitial,
  130. OUT EC* pec,
  131. OUT char szError[cbErrMax],
  132. OUT PDB** pppdb);
  133. // a dbi client should never call PDBExportValidateInterface directly - use PDBValidateInterface
  134. PDBAPI( BOOL )
  135. PDBExportValidateInterface(
  136. INTV intv);
  137. __inline BOOL PDBValidateInterface()
  138. {
  139. return PDBExportValidateInterface(PDBIntv);
  140. }
  141. PDBAPI( EC ) PDBQueryLastError(PDB* ppdb, OUT char szError[cbErrMax]);
  142. PDBAPI( INTV ) PDBQueryInterfaceVersion(PDB* ppdb);
  143. PDBAPI( IMPV ) PDBQueryImplementationVersion(PDB* ppdb);
  144. PDBAPI( SZ ) PDBQueryPDBName(PDB* ppdb, OUT char szPDB[PDB_MAX_PATH]);
  145. PDBAPI( SIG ) PDBQuerySignature(PDB* ppdb);
  146. PDBAPI( AGE ) PDBQueryAge(PDB* ppdb);
  147. PDBAPI( BOOL ) PDBOpenDBI(PDB* ppdb, SZ szMode, SZ szTarget, OUT DBI** ppdbi);
  148. PDBAPI( BOOL ) PDBOpenTpi(PDB* ppdb, SZ szMode, OUT TPI** pptpi);
  149. PDBAPI( BOOL ) PDBClose(PDB* ppdb);
  150. PDBAPI( BOOL ) PDBOpenDBIEx(PDB* ppdb, const char* szTarget, const char* szMode, OUT DBI** ppdbi, pfnFindDebugInfoFile srchfcn);
  151. PDBAPI( BOOL ) DBIOpenMod(DBI* pdbi, SZ szModule, SZ szFile, OUT Mod** ppmod);
  152. PDBAPI( BOOL ) DBIQueryNextMod(DBI* pdbi, Mod* pmod, Mod** ppmodNext);
  153. PDBAPI( BOOL ) DBIOpenGlobals(DBI* pdbi, OUT GSI **ppgsi);
  154. PDBAPI( BOOL ) DBIOpenPublics(DBI* pdbi, OUT GSI **ppgsi);
  155. PDBAPI( BOOL ) DBIQueryModFromAddr(DBI* pdbi, ISECT isect, OFF off, OUT Mod** ppmod, OUT ISECT* pisect, OUT OFF* poff, OUT CB* pcb);
  156. PDBAPI( BOOL ) DBIQuerySecMap(DBI* pdbi, OUT PB pb, CB* pcb);
  157. PDBAPI( BOOL ) DBIQueryFileInfo(DBI* pdbi, OUT PB pb, CB* pcb);
  158. PDBAPI( BOOL ) DBIClose(DBI* pdbi);
  159. PDBAPI( BOOL ) DBIGetEnumContrib(DBI* pdbi, OUT Enum** ppenum);
  160. PDBAPI( BOOL ) DBIQueryTypeServer(DBI* pdbi, ITSM itsm, OUT TPI** pptpi );
  161. PDBAPI( BOOL ) DBIQueryItsmForTi(DBI* pdbi, TI ti, OUT ITSM* pitsm );
  162. PDBAPI( BOOL ) DBIQueryLazyTypes(DBI* pdbi);
  163. PDBAPI( BOOL ) DBIFindTypeServers( DBI* pdbi, OUT EC* pec, OUT char szError[cbErrMax] );
  164. PDBAPI( BOOL ) DBIOpenDbg(DBI* pdbi, DBGTYPE dbgtype, OUT Dbg **ppdbg);
  165. PDBAPI( BOOL ) DBIQueryDbgTypes(DBI* pdbi, OUT DBGTYPE *pdbgtype, OUT long* pcDbgtype);
  166. PDBAPI( BOOL ) ModQueryCBName(Mod* pmod, OUT CB* pcb);
  167. PDBAPI( BOOL ) ModQueryName(Mod* pmod, OUT char szName[PDB_MAX_PATH], OUT CB* pcb);
  168. PDBAPI( BOOL ) ModQuerySymbols(Mod* pmod, PB pbSym, CB* pcb);
  169. PDBAPI( BOOL ) ModQueryLines(Mod* pmod, PB pbLines, CB* pcb);
  170. PDBAPI( BOOL ) ModSetPvClient(Mod* pmod, void *pvClient);
  171. PDBAPI( BOOL ) ModGetPvClient(Mod* pmod, OUT void** ppvClient);
  172. PDBAPI( BOOL ) ModQuerySecContrib(Mod* pmod, OUT ISECT* pisect, OUT OFF* poff, OUT CB* pcb, OUT ULONG* pdwCharacteristics);
  173. PDBAPI( BOOL ) ModQueryImod(Mod* pmod, OUT IMOD* pimod);
  174. PDBAPI( BOOL ) ModQueryDBI(Mod* pmod, OUT DBI** ppdbi);
  175. PDBAPI( BOOL ) ModClose(Mod* pmod);
  176. PDBAPI( BOOL ) ModQueryCBFile(Mod* pmod, OUT long* pcb);
  177. PDBAPI( BOOL ) ModQueryFile(Mod* pmod, OUT char szFile[PDB_MAX_PATH], OUT long* pcb);
  178. PDBAPI( BOOL ) ModQueryTpi(Mod* pmod, OUT TPI** pptpi);
  179. PDBAPI( void ) EnumContribRelease(EnumContrib* penum);
  180. PDBAPI( void ) EnumContribReset(EnumContrib* penum);
  181. PDBAPI( BOOL ) EnumContribNext(EnumContrib* penum);
  182. PDBAPI( void ) EnumContribGet(EnumContrib* penum, OUT USHORT* pimod, OUT USHORT* pisect, OUT long* poff, OUT long* pcb, OUT ULONG* pdwCharacteristics);
  183. PDBAPI( BOOL ) DbgClose(Dbg *pdbg);
  184. PDBAPI( long ) DbgQuerySize(Dbg *pdbg);
  185. PDBAPI( void ) DbgReset(Dbg *pdbg);
  186. PDBAPI( BOOL ) DbgSkip(Dbg *pdbg, ULONG celt);
  187. PDBAPI( BOOL ) DbgQueryNext(Dbg *pdbg, ULONG celt, OUT void *rgelt);
  188. PDBAPI( BOOL ) DbgFind(Dbg *pdbg, IN OUT void *pelt);
  189. // can't use the same api's for 32-bit TIs.
  190. PDBAPI(BOOL) TypesQueryCVRecordForTiEx(TPI* ptpi, TI ti, OUT PB pb, IN OUT CB* pcb);
  191. PDBAPI(BOOL) TypesQueryPbCVRecordForTiEx(TPI* ptpi, TI ti, OUT PB* ppb);
  192. PDBAPI(TI) TypesQueryTiMinEx(TPI* ptpi);
  193. PDBAPI(TI) TypesQueryTiMacEx(TPI* ptpi);
  194. PDBAPI(CB) TypesQueryCb(TPI* ptpi);
  195. PDBAPI(BOOL) TypesClose(TPI* ptpi);
  196. PDBAPI(BOOL) TypesQueryTiForUDTEx(TPI* ptpi, char* sz, BOOL fCase, OUT TI* pti);
  197. PDBAPI(BOOL) TypesSupportQueryTiForUDT(TPI*);
  198. // Map all old ones to new ones for new compilands.
  199. #define TypesQueryCVRecordForTi TypesQueryCVRecordForTiEx
  200. #define TypesQueryPbCVRecordForTi TypesQueryPbCVRecordForTiEx
  201. #define TypesQueryTiMin TypesQueryTiMinEx
  202. #define TypesQueryTiMac TypesQueryTiMacEx
  203. PDBAPI( PB ) GSINextSym (GSI* pgsi, PB pbSym);
  204. PDBAPI( PB ) GSIHashSym (GSI* pgsi, SZ szName, PB pbSym);
  205. PDBAPI( PB ) GSINearestSym (GSI* pgsi, ISECT isect, OFF off,OUT OFF* pdisp);//currently only supported for publics
  206. PDBAPI( BOOL ) GSIClose(GSI* pgsi);
  207. #if __cplusplus
  208. };
  209. #endif
  210. #define tsNil ((TPI*)0)
  211. #define tiNil ((TI)0)
  212. #define imodNil ((IMOD)(-1))
  213. #define pdbRead "r"
  214. #define pdbGetRecordsOnly "c" /* open PDB for type record access */
  215. #endif // __OEMDBI_INCLUDED__