home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sherlock.zip / HLL.10 / HLL.H < prev    next >
C/C++ Source or Header  |  1994-06-29  |  9KB  |  409 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    res1;
  60.     unsigned short    res2;
  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.  
  106.     /*
  107.     ** Procedure Start - 0x01
  108.     */
  109.     typedef struct {
  110.     unsigned long    offset;
  111.     unsigned short    type;
  112.     unsigned long    procLength;
  113.     unsigned short    prologueLength;
  114.     unsigned long    prologueAndBody;
  115.     unsigned short    reserved;
  116.     unsigned char    nearFar;
  117.     unsigned char    cbName;
  118.     unsigned char    name[1];
  119.     } BeginBlock;
  120.  
  121.     /*
  122.     ** End - 0x02
  123.     */
  124.     /* typedef struct { } End; */
  125.  
  126.     /*
  127.     ** BP-Relative symbol - 0x04
  128.     */
  129.     typedef struct {
  130.     unsigned long    offset;
  131.     unsigned short    type;
  132.     unsigned char    cbName;
  133.     unsigned char    name[1];
  134.     } BPRelativeSymbol;
  135.  
  136.     /*
  137.     **    Local (Data) Symbols - 0x05
  138.     */
  139.     typedef struct {
  140.     unsigned long    offset;
  141.     unsigned short    segment;
  142.     unsigned short    type;
  143.     unsigned char    cbName;
  144.     unsigned char    name[1];
  145.     } LocalSymbol;
  146.  
  147.     /*
  148.     ** Code Label - 0x0B
  149.     */
  150.     typedef struct {
  151.     unsigned long    offset;
  152.     unsigned char    distance;
  153.     unsigned char    cbName;
  154.     unsigned char    name[1];
  155.     } CodeLabel;
  156.  
  157.     /*
  158.     ** Register Symbol - 0x0D
  159.     */
  160.     typedef struct {
  161.     unsigned short    type;
  162.     unsigned char    registerNum;
  163.     unsigned char    cbName;
  164.     unsigned char    name[1];
  165.     } RegisterSymbol;
  166.  
  167.     /*
  168.     ** Constant Symbol - 0x0E
  169.     */
  170.     typedef struct {
  171.     unsigned short    type;
  172.     unsigned char    lenValue;
  173.     } ConstantSymbol;
  174.  
  175.     /*
  176.     ** Secondary Entry - 0x0F
  177.     */
  178.     typedef struct {
  179.     unsigned long    offset;
  180.     unsigned short    typeIndex;
  181.     unsigned long    procLength;
  182.     unsigned short    prologueStart;
  183.     unsigned long    prologuePlusBody;
  184.     unsigned short    reserved;
  185.     unsigned char    distance;
  186.     unsigned char    cbName;
  187.     unsigned char    name[1];
  188.     } SecondaryEntry;
  189.  
  190.     /*
  191.     ** Skip - 0x10
  192.     */
  193.     /* typedef struct { unsigned char data[1]; } Skip; */
  194.  
  195.     /*
  196.     ** Change Default Segment - 0x11
  197.     */
  198.     typedef struct {
  199.     unsigned short    segment;
  200.     unsigned short    reserved;
  201.     } ChangeDefaultSegment;
  202.  
  203.     /*
  204.     ** User Defined Symbol - 0x12
  205.     */
  206.     typedef struct {
  207.     unsigned short    type;
  208.     unsigned char    cbName;
  209.     unsigned char    name[1];
  210.     } UserDefinedSymbol;
  211.  
  212.     /*
  213.     ** Public Symbol - 0x13
  214.     */
  215.     typedef struct {
  216.     unsigned long    offset;
  217.     unsigned short    segment;
  218.     unsigned short    type;
  219.     unsigned char    cbName;
  220.     unsigned char    name[1];
  221.     } PublicSymbol;
  222.  
  223.     /*
  224.     ** Member - 0x14
  225.     */
  226.     typedef struct {
  227.     unsigned short    offset;
  228.     unsigned char    cbName;
  229.     unsigned char    name[1];
  230.     } Member;
  231.  
  232.     /*
  233.     ** Based - 0x15
  234.     */
  235.     typedef struct {
  236.     unsigned short    offset;
  237.     unsigned short    type;
  238.     unsigned char    cbName;
  239.     unsigned char    name[1];
  240.     } Based;
  241.  
  242.     /*
  243.     ** Tag - 0x16
  244.     */
  245.     typedef struct {
  246.     unsigned short    type;
  247.     unsigned char    cbName;
  248.     unsigned char    name[1];
  249.     } Tag;
  250.  
  251.     /*
  252.     ** Table - 0x17
  253.     */
  254.     typedef struct {
  255.     unsigned long    offset;
  256.     unsigned short    segment;
  257.     unsigned short    type;
  258.     unsigned long    indexOffset;
  259.     unsigned char    cbName;
  260.     unsigned char    name[1];
  261.     } Table;
  262.  
  263.     /*
  264.     ** Map - 0x18
  265.     */
  266.     typedef struct {
  267.     unsigned char    cbName;
  268.     unsigned char    name[1];
  269.     } Map;
  270.  
  271.     /*
  272.     ** Compilable Unit Information - 0x40
  273.     */
  274.     typedef struct {
  275.     unsigned char    compilerID;
  276.     unsigned char    lenOpts;
  277.     unsigned long    compilerOptions;
  278.     DATETIME    timeStamp;
  279.     } CompilableInfo;
  280.  
  281.  
  282. /**************************************
  283. **                      *
  284. ** sstLibraries - 0x0106          *
  285. **                      *
  286. **************************************/
  287. #define sstLibraries    0x106
  288.  
  289.     typedef struct {
  290.     unsigned char    cbLibs;
  291.     char        Libs[1];
  292.     } LIB;
  293.  
  294. /**************************************
  295. **                      *
  296. ** sstNewLineData - 0x010B          *
  297. **                      *
  298. **************************************/
  299. #define sstNewLineData    0x10b
  300.  
  301. typedef struct _tag_SourceLines {
  302.     USHORT  lineNum;
  303.     UCHAR   srcFileIndex;
  304.     UCHAR   flags;
  305.     ULONG   offset;
  306. } SrcLine;
  307.  
  308. typedef struct _tag_StatementLines {
  309.     ULONG   lineNum;
  310.     ULONG   statementNum;
  311.     ULONG   offset;
  312. } Statement;
  313.  
  314. typedef struct _tag_SourceListLines {
  315.     USHORT  lineNum;
  316.     UCHAR   srcFileIndex;
  317.     UCHAR   flags;
  318.     ULONG   listLineNum;
  319.     ULONG   listStatementNum;
  320.     ULONG   offset;
  321. } SrcState;
  322.  
  323. typedef union EntryData {
  324.     SrcLine     *srcLines;
  325.     Statement   *statementLines;
  326.     SrcState    *srcStateLines;
  327. } EntryData;
  328.  
  329. typedef struct {
  330.     UCHAR   entryType;
  331.     USHORT  numEntries;
  332.     EntryData entryData;
  333.     USHORT  numPathEntries;
  334.     struct _tag_PathEntries {
  335.     ULONG    offset;
  336.     USHORT    pathCode;
  337.     } *pathEntries;
  338.  
  339.     ULONG   startRecNum;
  340.     ULONG   numPrimaries;
  341.     ULONG   numSrcFiles;
  342.     char   *fileNames[1];
  343. } HLLLineData;
  344.  
  345. /*
  346. ** Define the structures use to hold the HLL data internally.
  347. */
  348. typedef struct _HLLPublic {
  349.     struct _HLLPublic *next;
  350.     PublicsDataEntry  data;
  351. } HLLPublic;
  352.  
  353. typedef struct _HLLModule {
  354.     struct _HLLModule    *next;
  355.     ModulesDataEntry    *module;
  356.     HLLPublic        *public;
  357.     char        *type;
  358.     char        *symbols;
  359.     USHORT              typeSize;
  360.     USHORT              symbolSize;
  361.     HLLLineData     *newLineData;
  362. } HLLModule;
  363.  
  364. typedef struct {
  365.     char        tag[4];
  366.     ULONG       dirOffset;
  367.     char       *compactedData;
  368.     USHORT      compactedSize;
  369.     char      **libraries;
  370.     HLLModule    *moduleData;
  371.     char    *other;
  372. } HLLAuxData;
  373.  
  374. typedef struct {
  375.     HLLModule    *module;
  376.     USHORT    typeIndex;
  377.     SHORT    registerNum;
  378. } HLLTypeData;
  379.  
  380. UCHAR *FindType(HLLTypeData *hllType, USHORT targetIndex);
  381. int HLLGetBaseTypeSize(USHORT targetIndex);
  382. int elementSize(State *state);
  383. USHORT GetType(UCHAR *types);
  384. int HLLGetValue(DebugModule *module, State *state);
  385. int HLLGetRegisterValue(DebugModule *module, State *state);
  386. int HLLGetNumber(UCHAR *types, ULONG *num);
  387.  
  388. int _System HLLFindSource(DebugModule *module, ULONG eipOffset,
  389.             char *funcName, char *sourceName, ULONG *lineNum);
  390. ULONG _System HLLFindSourceLine(DebugModule *module, int line, char *fileName);
  391. ULONG _System HLLFindFuncAddr(DebugModule *module, char *funcName);
  392. int _System HLLGetName(DebugModule *module, State *state, State *state2);
  393. int _System HLLGetArray(DebugModule *module, State *state, State *state2);
  394. int _System HLLGetNumMembers(DebugModule *module, State *state);
  395. int _System HLLGetMemberIndex(DebugModule *module,
  396.     State *state, int memberIndex, char *name);
  397. int HLLGetMember(DebugModule *module, State *state, State *state2);
  398.  
  399. /*
  400. ** Manifest constants.
  401. */
  402. #define BYTE_INDEX_IN_LVAL 0x100
  403.  
  404. /*
  405. ** Global variables.
  406. */
  407. DebugBuffer *debugBuffer;
  408. #pragma pack()
  409.