home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sherlock.zip / HLL / HLL.H < prev    next >
C/C++ Source or Header  |  1994-06-29  |  10KB  |  443 lines

  1. /*
  2. **  Sherlock - Copyright 1992, 1993, 1994
  3. **    Harfmann Software
  4. **    Compuserve: 73147,213
  5. **    All rights reserved
  6. */
  7. /*
  8. **  Header file to read the IBM HLL debug information from an EXE file.
  9. */
  10. #pragma pack(1)
  11.  
  12. /**********************************************
  13. **                         **
  14. ** These structures are uses to describe the **
  15. ** structure of the debugging information    **
  16. ** within the executable file             **
  17. **                         **
  18. **********************************************/
  19.     /*
  20.     ** This is the header linkage structure.
  21.     */
  22.     typedef struct {
  23.     char    signature[4];
  24.     long    offset;
  25.     } HLLHeader;
  26.  
  27.     /*
  28.     ** This structure preceeds the DNT structures.
  29.     */
  30.     typedef struct {
  31.     unsigned short    res1;
  32.     unsigned short    res2;
  33.     unsigned long    numEntries;
  34.     } SubSectionDictHeader;
  35.  
  36.     /*
  37.     ** This is the DNT structure.
  38.     */
  39.     typedef struct {
  40.     unsigned short    sectionType;
  41.     unsigned short    moduleIndex;
  42.     unsigned long    offsetStart;
  43.     unsigned long    sectionSize;
  44.     } SubSectionDictionary;
  45.  
  46. /**************************************
  47. **                     **
  48. ** sstModules - 0x0101             **
  49. **                     **
  50. **************************************/
  51. #define sstModules    0x101
  52.     typedef struct {
  53.     unsigned short    segment;
  54.     unsigned long    offset;
  55.     unsigned long    cbSeg;
  56.     unsigned short    ovlNbr;
  57.     unsigned short    iLibraries;
  58.     unsigned short    cSeg;
  59.     unsigned short    key;        /* HL */
  60.     unsigned short    version;    /* version x.y */
  61.     char        cbName;
  62.     char        name[1];
  63.     } ModulesDataEntry;
  64.  
  65.  
  66. /**************************************
  67. **                     **
  68. ** sstPublics - 0x0102             **
  69. **                     **
  70. **************************************/
  71. #define sstPublic    0x102
  72.     typedef struct {
  73.     unsigned long    offset;
  74.     unsigned short    segment;
  75.     unsigned short    type;
  76.     unsigned char    cbName;
  77.     char        name[1];
  78.     } PublicsDataEntry;
  79.  
  80.  
  81. /**************************************
  82. **                      *
  83. ** sstTypes    - 0x0103          *
  84. **                      *
  85. **************************************/
  86. #define sstTypes    0x103
  87. #define sstCompacted    0x108
  88.  
  89. /**************************************
  90. **                     **
  91. ** sstSymbols - 0x0104             **
  92. **                     **
  93. **************************************/
  94. #define sstSymbols    0x104
  95.  
  96.     /*
  97.     ** Begin Block - 0x00
  98.     */
  99.     typedef struct {
  100.     unsigned long    offset;
  101.     unsigned short    length;
  102.     unsigned char    cbName;
  103.     unsigned char    name[1];
  104.     } BlockStart;
  105. #define TYPE_BLOCKSTART 0x00
  106.  
  107.     /*
  108.     ** Procedure Start - 0x01
  109.     ** Secondary Entry - 0x0F
  110.     ** MemFunc    - 0x1A
  111.     ** C++ Proc - 0x1D
  112.     */
  113.     typedef struct {
  114.     unsigned long    offset;
  115.     unsigned short    type;
  116.     unsigned long    procLength;
  117.     unsigned short    prologueLength;
  118.     unsigned long    prologueAndBody;
  119.     unsigned short    classType;
  120.     unsigned char    nearFar;
  121.     unsigned char    cbName;
  122.     unsigned char    name[1];
  123.     } BeginBlock;
  124. #define TYPE_BEGINBLOCK 0x01
  125.     typedef BeginBlock    SecondaryEntry;
  126. #define TYPE_SECONDARYENTRY 0x0f
  127.     typedef BeginBlock    CPPProc;
  128. #define TYPE_CPPPROC    0x1D
  129.     typedef BeginBlock CPPMemFunc;
  130. #define TYPE_CPPMEMFUNC 0x1A
  131.  
  132.     /*
  133.     ** End - 0x02
  134.     */
  135.     /* typedef struct { } End; */
  136. #define TYPE_ENDBLOCK    0x02
  137.  
  138.     /*
  139.     ** BP-Relative symbol - 0x04
  140.     ** Based - 0x15
  141.     */
  142.     typedef struct {
  143.     unsigned long    offset;
  144.     unsigned short    type;
  145.     unsigned char    cbName;
  146.     unsigned char    name[1];
  147.     } BPRelativeSymbol;
  148. #define TYPE_BPRELATIVESYMBOL    0x04
  149.     typedef BPRelativeSymbol Based;
  150. #define TYPE_BASED  0x15
  151.  
  152.     /*
  153.     **    Local (Data) Symbols - 0x05
  154.     **    Public Symbol - 0x13
  155.     */
  156.     typedef struct {
  157.     unsigned long    offset;
  158.     unsigned short    segment;
  159.     unsigned short    type;
  160.     unsigned char    cbName;
  161.     unsigned char    name[1];
  162.     } LocalSymbol;
  163. #define TYPE_LOCALSYMBOL    0x05
  164.     typedef LocalSymbol PublicSymbol;
  165. #define TYPE_PUBLICSYMBOL   0x13
  166.     typedef LocalSymbol CPPStaticSymbol;
  167. #define TYPE_CPPSTATICSYMBOL    0x1e
  168.  
  169.     /*
  170.     ** Code Label - 0x0B
  171.     */
  172.     typedef struct {
  173.     unsigned long    offset;
  174.     unsigned char    distance;
  175.     unsigned char    cbName;
  176.     unsigned char    name[1];
  177.     } CodeLabel;
  178. #define TYPE_CODELABEL    0x0b
  179.  
  180.     /*
  181.     ** Register Symbol - 0x0D
  182.     */
  183.     typedef struct {
  184.     unsigned short    type;
  185.     unsigned char    registerNum;
  186.     unsigned char    cbName;
  187.     unsigned char    name[1];
  188.     } RegisterSymbol;
  189. #define TYPE_REGISTERSYMBOL 0x0d
  190.  
  191.     /*
  192.     ** Constant Symbol - 0x0E
  193.     */
  194.     typedef struct {
  195.     unsigned short    type;
  196.     unsigned char    lenValue;
  197.     } ConstantSymbol;
  198. #define TYPE_CONSTANTSYMBOL 0x0e
  199.  
  200.     /*
  201.     ** Skip - 0x10
  202.     */
  203.     /* typedef struct { unsigned char data[1]; } Skip; */
  204. #define TYPE_SKIP   0x10
  205.  
  206.     /*
  207.     ** Change Default Segment - 0x11
  208.     */
  209.     typedef struct {
  210.     unsigned short    segment;
  211.     unsigned short    reserved;
  212.     } ChangeDefaultSegment;
  213. #define TYPE_CHANGEDEFAULTSEGMENT   0x11
  214.  
  215.     /*
  216.     ** User Defined Symbol - 0x12
  217.     */
  218.     typedef struct {
  219.     unsigned short    type;
  220.     unsigned char    cbName;
  221.     unsigned char    name[1];
  222.     } UserDefinedSymbol;
  223. #define TYPE_USERDEFINEDSYMBOL    0x12
  224.     typedef UserDefinedSymbol CPPClass;
  225. #define TYPE_CCPCLASS    0x19
  226.  
  227.     /*
  228.     ** Member - 0x14
  229.     */
  230.     typedef struct {
  231.     unsigned short    offset;
  232.     unsigned char    cbName;
  233.     unsigned char    name[1];
  234.     } Member;
  235. #define TYPE_MEMBER    0x14
  236.  
  237.     /*
  238.     ** Tag - 0x16
  239.     */
  240.     typedef struct {
  241.     unsigned short    type;
  242.     unsigned char    cbName;
  243.     unsigned char    name[1];
  244.     } Tag;
  245. #define TYPE_TAG    0x16
  246.  
  247.     /*
  248.     ** Table - 0x17
  249.     */
  250.     typedef struct {
  251.     unsigned long    offset;
  252.     unsigned short    segment;
  253.     unsigned short    type;
  254.     unsigned long    indexOffset;
  255.     unsigned char    cbName;
  256.     unsigned char    name[1];
  257.     } Table;
  258. #define TYPE_TABLE  0x17
  259.  
  260.     /*
  261.     ** Map - 0x18
  262.     */
  263.     typedef struct {
  264.     unsigned char    cbName;
  265.     unsigned char    name[1];
  266.     } Map;
  267. #define TYPE_MAP    0x18
  268.  
  269.     /*
  270.     ** AutoScoped - 0x1B
  271.     */
  272.     typedef struct {
  273.     unsigned short    offset;
  274.     unsigned short    fileIndex;
  275.     unsigned long    lineNum;
  276.     unsigned short    type;
  277.     unsigned char    cbName;
  278.     unsigned char    name[1];
  279.     } CPPAutoScoped;
  280. #define TYPE_CPPAUTOSCOPED  0x1B
  281.  
  282.     /*
  283.     ** StaticScoped - 0x1C
  284.     */
  285.     typedef struct {
  286.     unsigned long    offset;
  287.     unsigned short    segment;
  288.     unsigned short    fileIndex;
  289.     unsigned long    lineNum;
  290.     unsigned short    type;
  291.     unsigned char    cbName;
  292.     unsigned char    name[1];
  293.     } CPPStaticScoped;
  294. #define TYPE_CPPSTATICSCOPED    0x1C
  295.  
  296.  
  297.     /*
  298.     ** Compilable Unit Information - 0x40
  299.     */
  300.     typedef struct {
  301.     unsigned char    compilerID;
  302.     unsigned char    lenOpts;
  303.     unsigned long    compilerOptions;
  304.     DATETIME    timeStamp;
  305.     } CompilableInfo;
  306. #define TYPE_COMPILABLEINFO 0x40
  307.  
  308.  
  309. /**************************************
  310. **                      *
  311. ** sstLibraries - 0x0106          *
  312. **                      *
  313. **************************************/
  314. #define sstLibraries    0x106
  315.  
  316.     typedef struct {
  317.     unsigned char    cbLibs;
  318.     char        Libs[1];
  319.     } LIB;
  320.  
  321. /**************************************
  322. **                      *
  323. ** sstNewLineData - 0x010B          *
  324. **                      *
  325. **************************************/
  326. #define sstNewLineData    0x10b
  327.  
  328. typedef struct _tag_SourceLines {
  329.     USHORT  lineNum;
  330.     UCHAR   srcFileIndex;
  331.     UCHAR   flags;
  332.     ULONG   offset;
  333. } SrcLine;
  334.  
  335. typedef struct _tag_StatementLines {
  336.     ULONG   lineNum;
  337.     ULONG   statementNum;
  338.     ULONG   offset;
  339. } Statement;
  340.  
  341. typedef struct _tag_SourceListLines {
  342.     USHORT  lineNum;
  343.     UCHAR   srcFileIndex;
  344.     UCHAR   flags;
  345.     ULONG   listLineNum;
  346.     ULONG   listStatementNum;
  347.     ULONG   offset;
  348. } SrcState;
  349.  
  350. typedef union EntryData {
  351.     SrcLine     *srcLines;
  352.     Statement   *statementLines;
  353.     SrcState    *srcStateLines;
  354. } EntryData;
  355.  
  356. typedef struct {
  357.     UCHAR   entryType;
  358.     USHORT  numEntries;
  359.     EntryData entryData;
  360.     USHORT  segmentNum;
  361.     union _tag_PathEntries {
  362.     struct _tag_NewPathEntries {
  363.         ULONG   offset;
  364.         USHORT  pathCode;
  365.         USHORT  fileIndex;
  366.     } newPathEntries;
  367.     struct _tag_OldPathEntries {
  368.         ULONG   offset;
  369.         USHORT  pathCode;
  370.         USHORT  fileIndex;
  371.     } oldPathEntries;
  372.     } *pathEntries;
  373.     ULONG   startRecNum;
  374.     ULONG   numPrimaries;
  375.     ULONG   numSrcFiles;
  376.     char   *fileNames[1];
  377. } HLLLineData;
  378.  
  379. /*
  380. ** Define the structures use to hold the HLL data internally.
  381. */
  382. typedef struct _HLLPublic {
  383.     struct _HLLPublic *next;
  384.     PublicsDataEntry  data;
  385. } HLLPublic;
  386.  
  387. typedef struct _HLLModule {
  388.     struct _HLLModule    *next;
  389.     ModulesDataEntry    *module;
  390.     HLLPublic        *public;
  391.     char        *type;
  392.     char        *symbols;
  393.     USHORT              typeSize;
  394.     USHORT              symbolSize;
  395.     HLLLineData     *newLineData;
  396. } HLLModule;
  397.  
  398. typedef struct {
  399.     char        tag[4];
  400.     ULONG       dirOffset;
  401.     char       *compactedData;
  402.     USHORT      compactedSize;
  403.     char      **libraries;
  404.     HLLModule    *moduleData;
  405.     char    *other;
  406. } HLLAuxData;
  407.  
  408. typedef struct {
  409.     HLLModule    *module;
  410.     USHORT    typeIndex;
  411.     SHORT    registerNum;
  412. } HLLTypeData;
  413.  
  414. UCHAR *FindType(HLLTypeData *hllType, USHORT targetIndex);
  415. int HLLGetBaseTypeSize(USHORT targetIndex);
  416. int elementSize(State *state);
  417. USHORT GetType(UCHAR *types);
  418. int HLLGetValue(DebugModule *module, State *state);
  419. int HLLGetRegisterValue(DebugModule *module, State *state);
  420. int HLLGetNumber(UCHAR *types, ULONG *num);
  421.  
  422. int _System HLLFindSource(DebugModule *module, ULONG eipOffset,
  423.             char *funcName, char *sourceName, ULONG *lineNum);
  424. ULONG _System HLLFindSourceLine(DebugModule *module, int line, char *fileName);
  425. ULONG _System HLLFindFuncAddr(DebugModule *module, char *funcName);
  426. int _System HLLGetName(DebugModule *module, State *state, State *state2);
  427. int _System HLLGetArray(DebugModule *module, State *state, State *state2);
  428. int _System HLLGetNumMembers(DebugModule *module, State *state);
  429. int _System HLLGetMemberIndex(DebugModule *module,
  430.     State *state, int memberIndex, char *name);
  431. int HLLGetMember(DebugModule *module, State *state, State *state2);
  432.  
  433. /*
  434. ** Manifest constants.
  435. */
  436. #define BYTE_INDEX_IN_LVAL 0x100
  437.  
  438. /*
  439. ** Global variables.
  440. */
  441. DebugBuffer *debugBuffer;
  442. #pragma pack()
  443.