home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / DEBFILE.C < prev    next >
Text File  |  1996-08-27  |  57KB  |  1,225 lines

  1. /*****************************************************************************/
  2. /* File:                                                                     */
  3. /*   debfile.c                                                               */
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*                                                                           */
  7. /*   Read the debug file and setup the MODULE linked list.                   */
  8. /*                                                                           */
  9. /*                                                                           */
  10. /* History:                                                                  */
  11. /*                                                                           */
  12. /*   04/06/95 Updated.                                                       */
  13. /*                                                                           */
  14. /*****************************************************************************/
  15.  
  16. #include "all.h"
  17.  
  18. #define __MIG_LIB__
  19. #include <io.h>
  20.  
  21. /*****************************************************************************/
  22. /* debfileinit()                                                             */
  23. /*                                                                           */
  24. /* Description:                                                              */
  25. /*                                                                           */
  26. /* Parameters:                                                               */
  27. /*                                                                           */
  28. /*   pdf        pointer to debug file structure.                             */
  29. /*                                                                           */
  30. /* Return:                                                                   */
  31. /*   rc         0 ==> success                                                */
  32. /*              1 ==> failure                                                */
  33. /* Assumptions:                                                              */
  34. /*                                                                           */
  35. /*  pdf -> EXE or DLL that contains a valid debug info block.                */
  36. /*                                                                           */
  37. /*****************************************************************************/
  38. APIRET debfileinit( DEBFILE *pdf )
  39. {
  40.  ULONG   DebHdrOff;
  41.  ULONG   NumEntries;
  42.  ULONG   DirectorySize = 0;
  43.  USHORT  usNumEntries;
  44.  ULONG   ulNumEntries;
  45.  UCHAR  *pDirectoryBuffer = NULL;
  46.  
  47.  pdf->MidAnchor = NULL;
  48.  
  49.  /*****************************************************************************/
  50.  /* - Move the file pointer to the start of the debug information past        */
  51.  /*   the first 4 bytes of the debug signature( NB00, etc. ).                 */
  52.  /* - Read the next 4 bytes. This is the lfo from the start of the debug      */
  53.  /*   info to the start of the directory header.                              */
  54.  /*****************************************************************************/
  55.  DebHdrOff = 0;
  56.  seekf( pdf, pdf->DebugOff+4 );
  57.  if( readf( (UCHAR *)&DebHdrOff, 4, pdf) )
  58.   return(1);
  59.  
  60.  /*****************************************************************************/
  61.  /* - The following code gets the number of directory entries.                */
  62.  /* - In the HLL format, the number of directory entries is contained in      */
  63.  /*   the 4 bytes following the first 4 bytes of useless information.         */
  64.  /* - In the other formats, the number of header entries is contained         */
  65.  /*   in the 2 bytes at the start of the directory.                           */
  66.  /*****************************************************************************/
  67.  NumEntries = usNumEntries = ulNumEntries = 0;
  68.  if( pdf->ExeFlags.NBxxType != NB04 )
  69.  {
  70.   seekf( pdf, pdf->DebugOff + DebHdrOff );
  71.   if( readf( (UCHAR*)&usNumEntries, 2, pdf ) )
  72.    return(1);
  73.   NumEntries = usNumEntries;
  74.  }
  75.  else
  76.  {
  77.   seekf(pdf, pdf->DebugOff + DebHdrOff + 4 );
  78.   if( readf( (UCHAR*)&ulNumEntries, 4, pdf ) )
  79.    return(1);
  80.   NumEntries = ulNumEntries;
  81.  }
  82.  /*****************************************************************************/
  83.  /* Check if the number of header entries is zero (!!). It happens in some    */
  84.  /* system DLL with some bogus debug info in them. If so report an error.     */
  85.  /*****************************************************************************/
  86.  if( NumEntries == 0 )
  87.   return(1);
  88.  
  89.  /******************************************************************************/
  90.  /* - Calculate the directory block size from the number of entries.           */
  91.  /* - Allocate memory for the directory block buffer.                          */
  92.  /* - Read the directory block into the buffer.                                */
  93.  /******************************************************************************/
  94.  if( pdf->ExeFlags.NBxxType == NB04 )
  95.   DirectorySize = NumEntries * sizeof( HDRENTRYHLL );
  96.  else
  97.   DirectorySize = NumEntries * sizeof( HDRENTRY );
  98.  
  99.  pDirectoryBuffer = (char *)Talloc( DirectorySize );
  100.  
  101.  if( readf( pDirectoryBuffer, DirectorySize, pdf ) )
  102.  {
  103.   if( pDirectoryBuffer ) Tfree( pDirectoryBuffer );
  104.    return(1);
  105.  }
  106.  
  107.  /*****************************************************************************/
  108.  /* - Call InitModules to build the module linked list.                       */
  109.  /*****************************************************************************/
  110.  InitModules( pDirectoryBuffer, NumEntries, pdf);
  111.  
  112.   /***************************************************************************/
  113.   /* - Call InitModuleAddrs to convert module object numbers to addresses.   */
  114.   /* - Call SetDebugFormatFlags to set the various flags in the modules.     */
  115.   /* - Free the directory and file name block buffers.                       */
  116.   /***************************************************************************/
  117.   if( InitModuleAddrs( pdf ) )
  118.     return(1);
  119.  
  120. #if 0
  121. /*---------------------------------------------------------------------------*/
  122. /* - dump the modules.                                                       */
  123. /*****************************************************************************/
  124. {
  125.  MODULE *pModule;
  126.  
  127.  for( pModule = pdf->MidAnchor; pModule; pModule = pModule->NextMod )
  128.  {
  129.   DumpModuleStructure( pModule );
  130.  }
  131. }
  132. /*---------------------------------------------------------------------------*/
  133. #endif
  134.  
  135.   SetDebugFormatFlags( pDirectoryBuffer, NumEntries, pdf );
  136.  
  137.   Tfree( pDirectoryBuffer );
  138.   return( 0 );
  139. }
  140.  
  141. /*****************************************************************************/
  142. /*  FindDebugStart()                                                         */
  143. /*                                                                           */
  144. /* Description:                                                              */
  145. /*                                                                           */
  146. /*   Gets some information about the exe/dll and finds the start of the      */
  147. /*   debug information.                                                      */
  148. /*                                                                           */
  149. /* Parameters:                                                               */
  150. /*   FileHandle  file handle returned from DosOpen().                        */
  151. /*   pDebugOff   -> receiver of lfo for the debug info.                      */
  152. /*   pNBxx       -> receiver of debug info signature...NB00, NB02, or NB04.  */
  153. /*   pExeType    -> receiver of executable type...LX or NE.                  */
  154. /*                                                                           */
  155. /* Return:                                                                   */
  156. /*   rc      0 - OK for source level or assembler level.                     */
  157. /*           1 - error.                                                      */
  158. /*                                                                           */
  159. /*****************************************************************************/
  160. #define  BLOB  512
  161. APIRET FindDebugStart( HFILE  FileHandle,
  162.                        ULONG *pDebugOff,
  163.                        int   *pNBxx,
  164.                        int   *pExeType )
  165. {
  166.  ULONG   EndOfFile;
  167.  ULONG   BackOff;
  168.  ULONG   LfoOfExeHdr;
  169.  UCHAR   buffer[BLOB];
  170.  UCHAR  *bp;
  171.  UCHAR  *cp;
  172.  UCHAR  *sp;
  173.  ULONG   blob;
  174.  char    DebugSignature[5];
  175.  int     ExeType;
  176.  USHORT  NE_or_LX;
  177.  int     NBxx;
  178.  char    NByy[4];
  179.  
  180.  /****************************************************************************/
  181.  /* - Get the type of the executable, NE or LX.                              */
  182.  /* - Init the file pointer to the lfo that contains the lfo of the start    */
  183.  /*   of the EXE header.                                                     */
  184.  /* - Read the lfo of the EXE header.                                        */
  185.  /* - Set the file pointer to the lfo of the EXE header.                     */
  186.  /* - Read the first 2 bytes of the EXE header( should be NE or LX )         */
  187.  /****************************************************************************/
  188.  if(
  189.     (seekdos(FileHandle, (ULONG)LFO_OF_EXE_HEADER_LFO, SEEK_SET)) ||
  190.     (readdos(&LfoOfExeHdr, sizeof(LfoOfExeHdr), 1, FileHandle)  ) ||
  191.     (seekdos(FileHandle, LfoOfExeHdr, SEEK_SET)                 ) ||
  192.     (readdos(&NE_or_LX, 2, 1, FileHandle)                       )
  193.    )
  194.   return(1);
  195.  
  196.  ExeType = 0;
  197.  if( !memcmp(&NE_or_LX, "LX", 2) )
  198.   ExeType = LX;
  199.  else if( !memcmp(&NE_or_LX, "NE", 2) )
  200.   ExeType = NE;
  201.  else
  202.   return(1);
  203.  
  204.  *pExeType = ExeType;
  205.  
  206. /*****************************************************************************/
  207. /* - We are now going to get the NBxx signature to determine whether or      */
  208. /*   not this file contains debug information.                               */
  209. /* - Set the file pointer to the end-of_file.                                */
  210. /* - Get the lfo of the end-of-file.                                         */
  211. /* - scan backwards BLOB bytes from the end of the file.                     */
  212. /* - make adjustments if the file is smaller than BLOB bytes.                */
  213. /* - allocate a blob and read the bytes.                                     */
  214. /*                                                                           */
  215. /*  Note:                                                                    */
  216. /*   Due to possible padding at the end of a file, we cannot establish the   */
  217. /*   absolute position of the debug signature.  So, we must scan backwards   */
  218. /*   a reasonable amount looking for it. This is why we use the blob bytes.  */
  219. /*                                                                           */
  220. /*****************************************************************************/
  221.  if( seekdos(FileHandle,0L,SEEK_END) )
  222.   return(1);
  223.  EndOfFile= tell(FileHandle);
  224.  
  225.  blob=BLOB;
  226.  if(EndOfFile < blob)
  227.    blob=(UINT)EndOfFile;
  228.  
  229.  memset(buffer, 0, sizeof(buffer) );
  230.  if( (seekdos(FileHandle, EndOfFile-(ULONG)blob, SEEK_SET) ) ||
  231.      (readdos(buffer, blob, 1, FileHandle)                 )
  232.    )
  233.   return(1);
  234.  
  235. /*****************************************************************************/
  236. /* -  At this point we have the ending blob of the file in a buffer.         */
  237. /* -  Now, start backing up looking for a valid NBxx signature. We can       */
  238. /*    start 8 bytes from the end.                                            */
  239. /* -  Also, the "true" end-of-file will be set.                              */
  240. /*****************************************************************************/
  241.  strcpy(DebugSignature,"NB00");
  242.  NBxx = 0;
  243.  bp   = buffer;
  244.  for(cp=bp+blob-8;
  245.      cp>=bp;
  246.      cp--,EndOfFile--
  247.     )
  248.  {
  249.   sp = cp;
  250.   if( *sp++ == 'N' &&
  251.       *sp++ == 'B' &&
  252.       *sp++ == '0'
  253.     )
  254.   {
  255.    if( *sp == '0' )
  256.    {
  257.     NBxx = NB00;
  258.     break;
  259.    }
  260.    if( *sp == '2' )
  261.    {
  262.     NBxx = NB02;
  263.     break;
  264.    }
  265.    if ( *sp == '4')
  266.    {
  267.     NBxx = NB04;
  268.     break;
  269.    }
  270.   }
  271.  }
  272.  *pNBxx = NBxx;
  273.  
  274.  /****************************************************************************/
  275.  /* - Now, we need to get the lfo of the start of the debug info.            */
  276.  /* - If NBxx == 0, then this executable does not have debug info.           */
  277.  /****************************************************************************/
  278.  if( NBxx == 0 )
  279.  {
  280.   *pDebugOff = 0;
  281.   return(0);
  282.  }
  283.  
  284.  /****************************************************************************/
  285.  /* - Define the debug signature string.                                     */
  286.  /****************************************************************************/
  287.  DebugSignature[0] = 'N';
  288.  DebugSignature[1] = 'B';
  289.  DebugSignature[2] = '0';
  290.  if( NBxx == NB00 )
  291.   DebugSignature[3] = '0';
  292.  else if( NBxx == NB02 )
  293.   DebugSignature[3] = '2';
  294.  else /* NBxx == NB04 */
  295.   DebugSignature[3] = '4';
  296.  
  297.  /****************************************************************************/
  298.  /* - At this point, we have the lfo for the "true" end-of-file, at least    */
  299.  /*   for our purposes.                                                      */
  300.  /* - Set the file pointer to the end-of-file - 4 bytes.  These last 4       */
  301.  /*   bytes contain the offset from the end-of-file back to the start of     */
  302.  /*   the debug information.                                                 */
  303.  /* - set the file pointer to the start of the debug information.            */
  304.  /* - read the NBxx bytes at the start of the debug information and          */
  305.  /*   verify that it matches the NBxx bytes that we read at the end of       */
  306.  /*   the file.                                                              */
  307.  /* - define the lfo of the debug offset.                                    */
  308.  /****************************************************************************/
  309.  if( (seekdos(FileHandle, EndOfFile-4L, SEEK_SET) ) ||
  310.      (readdos(&BackOff, 4 , 1 , FileHandle)       )
  311.    )
  312.   return(1);
  313.  
  314.  if(  (seekdos(FileHandle,EndOfFile-BackOff,SEEK_SET) ) ||
  315.       (readdos(NByy, 4, 1, FileHandle )               )
  316.    )
  317.   return(1);
  318.  
  319.  if( strncmp(NByy, DebugSignature, 4) )
  320.    return(1);
  321.  
  322.  *pDebugOff = EndOfFile - BackOff;
  323.  
  324.  return( 0 );
  325. }                                       /* end FindDebugStart()              */
  326.  
  327. /*****************************************************************************/
  328. /* FindOS2hdr()                                                              */
  329. /*                                                                           */
  330. /* Description:                                                              */
  331. /*                                                                           */
  332. /*   find the long offset into the debug file of the OS/2 header.            */
  333. /*                                                                           */
  334. /* Parameters:                                                               */
  335. /*                                                                           */
  336. /*   pdf        -> to the debug file node.                                   */
  337. /*                                                                           */
  338. /* Return:                                                                   */
  339. /*                                                                           */
  340. /*   offset     long offset of header begin.                                 */
  341. /*                                                                           */
  342. /* Assumptions:                                                              */
  343. /*                                                                           */
  344. /*   pdf is valid and the file is open.                                      */
  345. /*                                                                           */
  346. /*****************************************************************************/
  347. ULONG FindOS2hdr(DEBFILE *pdf)
  348. {
  349.  char     buffer[4];
  350.  
  351.  seekf(pdf, LFO_OF_EXE_HEADER_LFO);
  352.  if(readf(buffer, 4, pdf) == 0 )
  353.   return(*( ULONG *)buffer);
  354.  return(0L);
  355. }
  356.  
  357. /*****************************************************************************/
  358. /* InitModules()                                                             */
  359. /*                                                                           */
  360. /* Description:                                                              */
  361. /*                                                                           */
  362. /*  Build the module list from the directory block of information.           */
  363. /*                                                                           */
  364. /* Parameters:                                                               */
  365. /*                                                                           */
  366. /*  pDirectoryBuffer -> to the directory block read from file.               */
  367. /*  NumEntries          contains the number of entries in the directory      */
  368. /*                      block.                                               */
  369. /*  pdf              -> to debug file structure.                             */
  370. /*                                                                           */
  371. /* Return:                                                                   */
  372. /*                                                                           */
  373. /* Assumptions:                                                              */
  374. /*                                                                           */
  375. /*  - pdf != NULL.                                                           */
  376. /*  - NumEntries > 0.                                                        */
  377. /*                                                                           */
  378. /*****************************************************************************/
  379. void  InitModules( char *pDirectoryBuffer, int NumEntries, DEBFILE *pdf)
  380. {
  381.  int          i;
  382.  MODULE      *pModule;
  383.  MODULE      *pNewModule;
  384.  HDRENTRYHLL *pDirectoryEntryHLL;
  385.  HDRENTRY    *pDirectoryEntry;
  386.  
  387.  /****************************************************************************/
  388.  /* - Allocate the first module and connect it to the list.                  */
  389.  /****************************************************************************/
  390.  pModule        = (MODULE *)Talloc( sizeof( MODULE ) );
  391.  pdf->MidAnchor = pModule;
  392.  pModule->pdf   = pdf;
  393.  
  394.  if( pdf->ExeFlags.NBxxType == NB04 )
  395.  {
  396.   /***************************************************************************/
  397.   /* - Allocate/initialize the modules for HLL format.                       */
  398.   /***************************************************************************/
  399.   pDirectoryEntryHLL = (HDRENTRYHLL *)pDirectoryBuffer;
  400.   pModule->mid       = pDirectoryEntryHLL->ModIndex;
  401.  
  402.   pDirectoryEntryHLL++;
  403.  
  404.   for( i = 2; i <= NumEntries; i++, pDirectoryEntryHLL++ )
  405.   {
  406.    if( (pDirectoryEntryHLL->ModIndex != pModule->mid) &&
  407.        (pDirectoryEntryHLL->ModIndex != 0 )
  408.      )
  409.    {
  410.     pNewModule       = (MODULE *)Talloc( sizeof( MODULE ) );
  411.     pNewModule->mid  = pDirectoryEntryHLL->ModIndex;
  412.     pModule->NextMod = pNewModule;
  413.     pModule          = pNewModule;
  414.    }
  415.   }
  416.  }
  417.  else /* pdf->ExeFlags.NBxxType == NB00 or NB02 */
  418.  {
  419.   /***************************************************************************/
  420.   /* - Allocate/init the modules for MS formats( 32 and 16 bit ).            */
  421.   /***************************************************************************/
  422.   pDirectoryEntry = (HDRENTRY *)pDirectoryBuffer;
  423.   pModule->mid    = pDirectoryEntry->ModIndex;
  424.  
  425.   pDirectoryEntry++;
  426.  
  427.   for( i = 2; i <= NumEntries; i++, pDirectoryEntry++ )
  428.   {
  429.    if( (pDirectoryEntry->ModIndex != pModule->mid) &&
  430.        (pDirectoryEntry->ModIndex != 0 )
  431.      )
  432.    {
  433.     pNewModule       = (MODULE *)Talloc( sizeof( MODULE ) );
  434.     pNewModule->mid  = pDirectoryEntry->ModIndex;
  435.     pModule->NextMod = pNewModule;
  436.     pModule          = pNewModule;
  437.    }
  438.   }
  439.  }
  440.  
  441.  if( pdf->ExeFlags.NBxxType == NB04 )
  442.  {
  443.   /***************************************************************************/
  444.   /* - Finish initializing the modules for HLL format.                       */
  445.   /***************************************************************************/
  446.   pDirectoryEntryHLL = (HDRENTRYHLL *)pDirectoryBuffer;
  447.   for( i = 1; i <= NumEntries; i++, pDirectoryEntryHLL++ )
  448.   {
  449.    /***************************************************************************/
  450.    /* - We don't build modules for modindexes of 0.                           */
  451.    /***************************************************************************/
  452.    if( pDirectoryEntryHLL->ModIndex == 0 )
  453.     continue;
  454.  
  455.    /***************************************************************************/
  456.    /* - scan to module allocated for this directory entry.                    */
  457.    /***************************************************************************/
  458.    for( pModule = pdf->MidAnchor;/* no test */; pModule = pModule->NextMod )
  459.    {
  460.     if( pModule->mid == pDirectoryEntryHLL->ModIndex)
  461.      break;
  462.    }
  463.  
  464.    /***************************************************************************/
  465.    /* - now add additional information to the module based on the subsection  */
  466.    /*   type.                                                                 */
  467.    /***************************************************************************/
  468.    switch( pDirectoryEntryHLL->SubSectType  )
  469.    {
  470.      case SSTMODULES:
  471.       pModule->FileName    = pDirectoryEntryHLL->SubSectOff;
  472.       pModule->FileNameLen = pDirectoryEntryHLL->SubSectLen;
  473.       break;
  474.  
  475.      case SSTPUBLICS:
  476.       pModule->Publics = pDirectoryEntryHLL->SubSectOff;
  477.       pModule->PubLen  = pDirectoryEntryHLL->SubSectLen;
  478.       break;
  479.  
  480.      case SSTTYPES:
  481.       pModule->TypeDefs = pDirectoryEntryHLL->SubSectOff;
  482.       pModule->TypeLen  = pDirectoryEntryHLL->SubSectLen;
  483.       break;
  484.  
  485.      case SSTSYMBOLS:
  486.       pModule->Symbols = pDirectoryEntryHLL->SubSectOff;
  487.       pModule->SymLen  = pDirectoryEntryHLL->SubSectLen;
  488.       break;
  489.  
  490.      case SSTSRCLINES:
  491.       pModule->LineNums    = pDirectoryEntryHLL->SubSectOff;
  492.       pModule->LineNumsLen = pDirectoryEntryHLL->SubSectLen;
  493.       break;
  494.  
  495.      case SSTSRCLNSEG:
  496.       pModule->LineNums    = pDirectoryEntryHLL->SubSectOff;
  497.       pModule->LineNumsLen = pDirectoryEntryHLL->SubSectLen;
  498.       break;
  499.  
  500.      case SSTIBMSRC:
  501.       pModule->LineNums    = pDirectoryEntryHLL->SubSectOff;
  502.       pModule->LineNumsLen = pDirectoryEntryHLL->SubSectLen;
  503.       break;
  504.  
  505.      case SSTLIBRARIES:
  506.       break;
  507.    }
  508.   }
  509.  }
  510.  
  511.  if( (pdf->ExeFlags.NBxxType == NB00) || (pdf->ExeFlags.NBxxType == NB02) )
  512.  {
  513.   /***************************************************************************/
  514.   /* - Finish initializing the modules for MS formats( 32 and 16 bit).       */
  515.   /***************************************************************************/
  516.   pDirectoryEntry = (HDRENTRY *)pDirectoryBuffer;
  517.   for( i = 1; i <= NumEntries; i++, pDirectoryEntry++ )
  518.   {
  519.    /***************************************************************************/
  520.    /* - We don't build modules for modindexes of 0.                           */
  521.    /***************************************************************************/
  522.    if( pDirectoryEntry->ModIndex == 0 )
  523.     continue;
  524.  
  525.    /***************************************************************************/
  526.    /* - scan to module allocated for this directory entry.                    */
  527.    /***************************************************************************/
  528.    for( pModule = pdf->MidAnchor;/* no test */; pModule = pModule->NextMod )
  529.    {
  530.     if( pModule->mid == pDirectoryEntry->ModIndex)
  531.      break;
  532.    }
  533.  
  534.    /***************************************************************************/
  535.    /* - now add additional information to the module based on the subsection  */
  536.    /*   type.                                                                 */
  537.    /***************************************************************************/
  538.    switch( pDirectoryEntry->SubSectType  )
  539.    {
  540.      case SSTMODULES:
  541.       pModule->FileName    = pDirectoryEntry->SubSectOff;
  542.       pModule->FileNameLen = pDirectoryEntry->SubSectLen;
  543.       break;
  544.  
  545.      case SSTPUBLICS:
  546.       pModule->Publics = pDirectoryEntry->SubSectOff;
  547.       pModule->PubLen  = pDirectoryEntry->SubSectLen;
  548.       break;
  549.  
  550.      case SSTTYPES:
  551.       pModule->TypeDefs = pDirectoryEntry->SubSectOff;
  552.       pModule->TypeLen  = pDirectoryEntry->SubSectLen;
  553.       break;
  554.  
  555.      case SSTSYMBOLS:
  556.       pModule->Symbols = pDirectoryEntry->SubSectOff;
  557.       pModule->SymLen  = pDirectoryEntry->SubSectLen;
  558.       break;
  559.  
  560.      case SSTSRCLINES:
  561.       pModule->LineNums    = pDirectoryEntry->SubSectOff;
  562.       pModule->LineNumsLen = pDirectoryEntry->SubSectLen;
  563.       break;
  564.  
  565.      case SSTSRCLNSEG:
  566.       pModule->LineNums    = pDirectoryEntry->SubSectOff;
  567.       pModule->LineNumsLen = pDirectoryEntry->SubSectLen;
  568.       break;
  569.  
  570.      case SSTIBMSRC:
  571.       pModule->LineNums    = pDirectoryEntry->SubSectOff;
  572.       pModule->LineNumsLen = pDirectoryEntry->SubSectLen;
  573.       break;
  574.  
  575.      case SSTLIBRARIES:
  576.       break;
  577.    }
  578.   }
  579.  }
  580. }
  581.  
  582. /*****************************************************************************/
  583. /* InitModuleAddrs()                                                         */
  584. /*                                                                           */
  585. /* Description:                                                              */
  586. /*                                                                           */
  587. /*  Read the filename entry information for each module in the module list   */
  588. /*  and convert the memory object numbers for the modules to flat addresses. */
  589. /*                                                                           */
  590. /* Parameters:                                                               */
  591. /*                                                                           */
  592. /*  pdf      -> to debug file structure.                                     */
  593. /*                                                                           */
  594. /* Return:                                                                   */
  595. /*            0  -  Success.                                                 */
  596. /*            1  -  Failure.                                                 */
  597. /*                                                                           */
  598. /* Assumptions:                                                              */
  599. /*                                                                           */
  600. /*  - pdf is valid.                                                          */
  601. /*                                                                           */
  602. /*****************************************************************************/
  603. APIRET InitModuleAddrs( DEBFILE *pdf )
  604. {
  605.  MODULE       *pModule;
  606.  FREC_NE      *pFrec_NE;
  607.  FREC_NB00_LX *pFrec_NB00_LX;
  608.  FREC_NB00_LX  Frec_NB00_LX;
  609.  FREC_NB04    *pFrec_NB04;
  610.  ULONG         LoadAddr;
  611.  ULONG         CsectLo;
  612.  ULONG         CsectHi;
  613.  
  614.  /****************************************************************************/
  615.  /* - For each module get the filename information from the buffer. Add      */
  616.  /*   info about the seg#:offset and length of the module.                   */
  617.  /* - Convert the object numbers to flat addressess.                         */
  618.  /****************************************************************************/
  619.  for( pModule = pdf->MidAnchor; pModule; pModule = pModule->NextMod )
  620.  {
  621.   seekf(pdf,pdf->DebugOff + pModule->FileName);
  622.  
  623.   /***************************************************************************/
  624.   /* Process only the modules which have a ParentMid of zero.  This was      */
  625.   /* added because when we encounter a module with more than one segment we  */
  626.   /* add a new module at the end of the module linked list with all info     */
  627.   /* same as Parent module except the midbase parameters.  This new "child"  */
  628.   /* module will have Parentmid.                                             */
  629.   /***************************************************************************/
  630.   if( (pdf->ExeFlags.NBxxType == NB02) ||
  631.       ( (pdf->ExeFlags.NBxxType == NB00) && (pdf->ExeFlags.ExeType == NE) )
  632.     )
  633.   {
  634.    int reclen;
  635.  
  636.    /*************************************************************************/
  637.    /* - Case of Code View 16bit format.                                     */
  638.    /* - Multiple segments supported in this format.                         */
  639.    /*************************************************************************/
  640.    reclen   = pModule->FileNameLen;
  641.    pFrec_NE = (FREC_NE*)Talloc(reclen);
  642.    readf( (UCHAR*)pFrec_NE, reclen, pdf );
  643.  
  644.    pModule->pCsects          = (CSECT*)Talloc(sizeof(CSECT));
  645.    pModule->pCsects->next    = NULL;
  646.    pModule->pCsects->pModule = pModule;
  647.    pModule->pCsects->SegNum  = pFrec_NE->SegObject.SegNum;
  648.  
  649.    LoadAddr = GetLoadAddr(pdf->mte, pModule->pCsects->SegNum);
  650.    CsectLo  = CsectHi = 0;
  651.    if( LoadAddr != 0 )
  652.    {
  653.     CsectLo  = LoadAddr + pFrec_NE->SegObject.ImOff;
  654.     CsectHi  = CsectLo  + pFrec_NE->SegObject.ImLen - 1;
  655.    }
  656.  
  657.    pModule->pCsects->SegFlatAddr = LoadAddr;
  658.    pModule->pCsects->CsectLo     = CsectLo;
  659.    pModule->pCsects->CsectHi     = CsectHi;
  660.    pModule->pCsects->CsectSize   = pFrec_NE->SegObject.ImLen;
  661.  
  662.    if( pFrec_NE->NoSegs > 1 )
  663.    {
  664.     /************************************************************************/
  665.     /* - if more than one segment for this compile unit, then add the       */
  666.     /*   additional segments.                                               */
  667.     /************************************************************************/
  668.     FREC_NE_SEGOBJECT *pFrecCsect;
  669.  
  670.     CSECT *pCsect;
  671.     int    NumCsects;
  672.     UCHAR *pFrec;
  673.  
  674.     /************************************************************************/
  675.     /* - get a count of the number of additional csects.                    */
  676.     /* - build a ptr to the next csect record in the file.                  */
  677.     /************************************************************************/
  678.     NumCsects  = pFrec_NE->NoSegs - 1;
  679.     pFrec      = (UCHAR *)pFrec_NE + sizeof(FREC_NE)+ pFrec_NE->fnlength;
  680.     pFrecCsect = (FREC_NE_SEGOBJECT*)(pFrec);
  681.  
  682.     /************************************************************************/
  683.     /* - now, build the additional csects.                                  */
  684.     /************************************************************************/
  685.     pCsect = pModule->pCsects;
  686.     while( NumCsects > 0 )
  687.     {
  688.      pCsect->next         = (CSECT*)Talloc(sizeof(CSECT));
  689.      pCsect->pModule      = pModule;
  690.      pCsect->next->SegNum = pFrecCsect->SegNum;
  691.  
  692.      LoadAddr = GetLoadAddr(pdf->mte, pFrecCsect->SegNum);
  693.      CsectLo  = CsectHi = 0;
  694.      if( LoadAddr != 0 )
  695.      {
  696.       CsectLo  = LoadAddr + pFrecCsect->ImOff;
  697.       CsectHi  = CsectLo  + pFrecCsect->ImLen - 1;
  698.      }
  699.  
  700.      pCsect->next->SegFlatAddr = LoadAddr;
  701.      pCsect->next->CsectLo     = CsectLo;
  702.      pCsect->next->CsectHi     = CsectHi;
  703.      pCsect->next->CsectSize   = pFrecCsect->ImLen;
  704.  
  705.      pFrecCsect++;
  706.      pCsect = pCsect->next;
  707.      NumCsects--;
  708.     }
  709.    }
  710.  
  711.    /*************************************************************************/
  712.    /* - free the filename record.                                           */
  713.    /*************************************************************************/
  714.    Tfree(pFrec_NE);
  715.  
  716.   }
  717.   else if( (pdf->ExeFlags.NBxxType == NB00) && (pdf->ExeFlags.ExeType == LX) )
  718.   {
  719.    /*************************************************************************/
  720.    /* - Case of Code View 32bit format.                                     */
  721.    /* - Note that only one memory object per compile unit is supported      */
  722.    /*   for this format.                                                    */
  723.    /*************************************************************************/
  724.    pFrec_NB00_LX = &Frec_NB00_LX;
  725.    readf( (UCHAR*)pFrec_NB00_LX, sizeof(FREC_NB00_LX), pdf );
  726.  
  727.    pModule->pCsects          = (CSECT*)Talloc(sizeof(CSECT));
  728.    pModule->pCsects->next    = NULL;
  729.    pModule->pCsects->pModule = pModule;
  730.    pModule->pCsects->SegNum  = pFrec_NB00_LX->SegNum;
  731.  
  732.    LoadAddr = GetLoadAddr(pdf->mte, pModule->pCsects->SegNum);
  733.    CsectLo  = CsectHi = 0;
  734.    if( LoadAddr != 0 )
  735.    {
  736.     CsectLo  = LoadAddr + pFrec_NB00_LX->ImOff;
  737.     CsectHi  = CsectLo  + pFrec_NB00_LX->ImLen - 1;
  738.    }
  739.  
  740.    pModule->pCsects->SegFlatAddr = LoadAddr;
  741.    pModule->pCsects->CsectLo     = CsectLo;
  742.    pModule->pCsects->CsectHi     = CsectHi;
  743.    pModule->pCsects->CsectSize   = pFrec_NB00_LX->ImLen;
  744.   }
  745.   else if( pdf->ExeFlags.NBxxType == NB04 )
  746.   {
  747.    int reclen;
  748.  
  749.    /*************************************************************************/
  750.    /* - Case of IBM HLL 32bit format.                                       */
  751.    /* - Multiple segments supported in this format.                         */
  752.    /*************************************************************************/
  753.    reclen     = pModule->FileNameLen;
  754.    pFrec_NB04 = (FREC_NB04*)Talloc(reclen);
  755.    readf( (UCHAR*)pFrec_NB04, reclen, pdf );
  756.  
  757.    /*************************************************************************/
  758.    /* - put in the information for the first segment.                       */
  759.    /*************************************************************************/
  760.    pModule->pCsects          = (CSECT*)Talloc(sizeof(CSECT));
  761.    pModule->pCsects->next    = NULL;
  762.    pModule->pCsects->pModule = pModule;
  763.    pModule->pCsects->SegNum  = pFrec_NB04->SegObject.SegNum;
  764.  
  765.    LoadAddr = GetLoadAddr(pdf->mte, pModule->pCsects->SegNum);
  766.    CsectLo  = CsectHi = 0;
  767.    if( LoadAddr != 0 )
  768.    {
  769.     CsectLo = LoadAddr + pFrec_NB04->SegObject.ImOff;
  770.     CsectHi = CsectLo  + pFrec_NB04->SegObject.ImLen - 1;
  771.    }
  772.  
  773.    pModule->pCsects->SegFlatAddr = LoadAddr;
  774.    pModule->pCsects->CsectLo     = CsectLo;
  775.    pModule->pCsects->CsectHi     = CsectHi;
  776.    pModule->pCsects->CsectSize   = pFrec_NB04->SegObject.ImLen;
  777.  
  778.    if( pFrec_NB04->NoSegs > 1 )
  779.    {
  780.     /************************************************************************/
  781.     /* - if more than one segment for this compile unit, then add the       */
  782.     /*   additional segments.                                               */
  783.     /************************************************************************/
  784.     FREC_NB04_SEGOBJECT *pFrecCsect;
  785.  
  786.     CSECT *pCsect;
  787.     int    NumCsects;
  788.     UCHAR *pFrec;
  789.  
  790.     /************************************************************************/
  791.     /* - get a count of the number of additional csects.                    */
  792.     /* - build a ptr to the next csect record in the file.                  */
  793.     /************************************************************************/
  794.     NumCsects  = pFrec_NB04->NoSegs - 1;
  795.     pFrec      = (UCHAR *)pFrec_NB04 + sizeof(FREC_NB04)+ pFrec_NB04->fnlength;
  796.     pFrecCsect = (FREC_NB04_SEGOBJECT*)(pFrec);
  797.  
  798.     /************************************************************************/
  799.     /* - now, build the additional csects.                                  */
  800.     /************************************************************************/
  801.     pCsect = pModule->pCsects;
  802.     while( NumCsects > 0 )
  803.     {
  804.      pCsect->next         = (CSECT*)Talloc(sizeof(CSECT));
  805.      pCsect->pModule      = pModule;
  806.      pCsect->next->SegNum = pFrecCsect->SegNum;
  807.  
  808.      LoadAddr = GetLoadAddr(pdf->mte, pFrecCsect->SegNum);
  809.      CsectLo  = CsectHi = 0;
  810.      if( LoadAddr != 0 )
  811.      {
  812.       CsectLo  = LoadAddr + pFrecCsect->ImOff;
  813.       CsectHi  = CsectLo  + pFrecCsect->ImLen - 1;
  814.      }
  815.  
  816.      pCsect->next->SegFlatAddr = LoadAddr;
  817.      pCsect->next->CsectLo     = CsectLo;
  818.      pCsect->next->CsectHi     = CsectHi;
  819.      pCsect->next->CsectSize   = pFrecCsect->ImLen;
  820.  
  821.      pFrecCsect++;
  822.      pCsect = pCsect->next;
  823.      NumCsects--;
  824.     }
  825.    }
  826.    /*************************************************************************/
  827.    /* - free the filename record.                                           */
  828.    /*************************************************************************/
  829.    Tfree(pFrec_NB04);
  830.   }
  831.  }
  832.  return( 0 );
  833. }
  834.  
  835. /*****************************************************************************/
  836. /* SetDebugFormatFlags()                                                     */
  837. /*                                                                           */
  838. /* Description:                                                              */
  839. /*  Scan through the Directory buffer and File Name block buffer and set the */
  840. /*  various debug format flags for each module.                              */
  841. /*                                                                           */
  842. /* Parameters:                                                               */
  843. /*                                                                           */
  844. /*  DirectoryBuffer - contains the directory block of information.           */
  845. /*  NumEntries      - contains the number of entries in the                  */
  846. /*                    directory block.                                       */
  847. /*  pdf             - pointer to debug file structure.                       */
  848. /*                                                                           */
  849. /* Return:                                                                   */
  850. /*            None.                                                          */
  851. /*                                                                           */
  852. /* Assumptions:                                                              */
  853. /*                                                                           */
  854. /*  pdf is valid.                                                            */
  855. /*                                                                           */
  856. /*****************************************************************************/
  857. void  SetDebugFormatFlags( char    *pDirectoryBuffer,
  858.                            int      NumEntries,
  859.                            DEBFILE *pdf )
  860. {
  861.  int          i = 0;
  862.  MODULE      *pModule     = NULL;
  863.  FREC_NB04    *pFrec_NB04 = NULL;
  864.  FREC_NB04     Frec_NB04;
  865.  HDRENTRYHLL *pDirectoryEntryHLL = NULL;
  866.  HDRENTRY    *pDirectoryEntry    = NULL;
  867.  int          ModuleType = 0;
  868.  
  869.  memset( &Frec_NB04, 0, sizeof(Frec_NB04));
  870.  /****************************************************************************/
  871.  /* - Define the flags for the publics.                                      */
  872.  /*                                                                          */
  873.  /*      NB00,NB02             NB04                                          */
  874.  /*      ---------             ----                                          */
  875.  /*          |                  |                                            */
  876.  /*          |                  |                                            */
  877.  /*          |                  |                                            */
  878.  /*          |                  |                                            */
  879.  /*    ------------             |                                            */
  880.  /*   |            |            |                                            */
  881.  /*   |            |            |                                            */
  882.  /*   |            |            |                                            */
  883.  /*   |NE          |LX          |                                            */
  884.  /*   |            |            |                                            */
  885.  /*   |            |            |                                            */
  886.  /*   |            |            |                                            */
  887.  /*   |            |            |                                            */
  888.  /*   TYPE_PUB_16  TYPE_PUB_32  TYPE_PUB_32                                  */
  889.  /*                                                                          */
  890.  /*==========================================================================*/
  891.  /*                                                                          */
  892.  /* - Define the flags for the line numbers.                                 */
  893.  /*                                                                          */
  894.  /*   NB00        NB00,NB02                            NB04                  */
  895.  /*   ----        ---------                            ----                  */
  896.  /*    |              |                                 |                    */
  897.  /*    |              |                                 |                    */
  898.  /*   105            109                               10B ( always LX )     */
  899.  /*    |              |                                 |                    */
  900.  /*    |        ------------                    -----------------            */
  901.  /*    |       |            |                  |HL01 |HL02 |HL03 |HL04       */
  902.  /*    |       |            |                  |     |     |     |           */
  903.  /*    |       |            |                  |     |     |     TYPE10B_HL04*/
  904.  /*    |       |NE          |LX                |     |     |                 */
  905.  /*    |       |            |                  |     |     TYPE10B_HL03      */
  906.  /*    |       |            |                  |     |                       */
  907.  /*    |       |            |                  |     TYPE10B_HL02            */
  908.  /*    |       |            |                  |                             */
  909.  /* TYPE105    TYPE109_16   TYPE109_32         TYPE10B_HL01                  */
  910.  /* (16 bit)                                                                 */
  911.  /*                                                                          */
  912.  /*  NOTES:                                                                  */
  913.  /*                                                                          */
  914.  /*    - IBM C/2 1.1 generates type 105 line numbers.                        */
  915.  /*      LINK386 will map these to type 109.                                 */
  916.  /*    - MSC 6.0 generates type 109 line numbers.                            */
  917.  /*    - CL386 also generates type 109 line numbers.                         */
  918.  /*    - IBM C-Set/2 etc generates type 10B, but you have to                 */
  919.  /*      look in the file name records to find the true format, i.e.,        */
  920.  /*      HL01,HL02,..etc.                                                    */
  921.  /*==========================================================================*/
  922.  /*                                                                          */
  923.  /* - Define the symbols and types flags.                                    */
  924.  /*                                                                          */
  925.  /*            NB00,NB02                                                     */
  926.  /*            ---------                                                     */
  927.  /*                |                                                         */
  928.  /*                |                                                         */
  929.  /*               104,3                                                      */
  930.  /*                |                                                         */
  931.  /*          ---------------------                                           */
  932.  /*         |                     |                                          */
  933.  /*         |                     |                                          */
  934.  /*         |                     |                                          */
  935.  /*         |NE                   |LX                                        */
  936.  /*         |                     |                                          */
  937.  /*         |                     |                                          */
  938.  /*         |                     |                                          */
  939.  /*         |                     |                                          */
  940.  /*   ------------                |                                          */
  941.  /*  |            |               |                                          */
  942.  /*  |NB00        |NB02           |                                          */
  943.  /*  |            |               |                                          */
  944.  /*  TYPE104_C211 TYPE104_C600    TYPE104_CL386                              */
  945.  /*        3            3         |     3                                    */
  946.  /*                               |                                          */
  947.  /*                           Module 16,32                                   */
  948.  /*                      -------------------                                 */
  949.  /*                     |                   |                                */
  950.  /*                     |16(see note)       |                                */
  951.  /*                     |                   |                                */
  952.  /*                     TYPE104_C600        TYPE104_CL386                    */
  953.  /*                           3                   3                          */
  954.  /*                                                                          */
  955.  /*                                                                          */
  956.  /*          NB04                                                            */
  957.  /*          ----                                                            */
  958.  /*           |                                                              */
  959.  /*           |                                                              */
  960.  /*          104,3 ( always LX )                                             */
  961.  /*           |                                                              */
  962.  /*   ----------------------------------------                               */
  963.  /*  |HL01 |HL02 |HL03 |HL04                  |OTHER                         */
  964.  /*  |     |     |     |                      |                              */
  965.  /*  |     |     |     TYPE104_HL04           |                              */
  966.  /*  |     |     |           3                |                              */
  967.  /*  |     |     |                        Module 16,32                       */
  968.  /*  |     |     TYPE104_HL03        -------------------                     */
  969.  /*  |     |           3            |                   |                    */
  970.  /*  |     |                        |16(see note)       |                    */
  971.  /*  |     TYPE104_HL02             |                   |                    */
  972.  /*  |           3                  TYPE104_C600        TYPE104_CL386        */
  973.  /*  |                                    3                   3              */
  974.  /*  TYPE104_HL01                                       ( could happen       */
  975.  /*        3                                              when linking       */
  976.  /*                                                       assembler )        */
  977.  /*                                                                          */
  978.  /*                                                                          */
  979.  /*   - An LX 32 bit executable can contain 16 bit symbols and types         */
  980.  /*     subsectiions. Before we can assign a flag, we have to look at the    */
  981.  /*     bitness of the load address defined in the filename record for       */
  982.  /*     this subsection. If the bitness is 16 bit, then we use a             */
  983.  /*     TYPE104_C600(TYPE103_C600) flag.                                     */
  984.  /*                                                                          */
  985.  /****************************************************************************/
  986.  if( (pdf->ExeFlags.NBxxType == NB00) || (pdf->ExeFlags.NBxxType == NB02) )
  987.  {
  988.   pDirectoryEntry = (HDRENTRY *)pDirectoryBuffer;
  989.   for( i = 1; i <= NumEntries; i++, pDirectoryEntry++ )
  990.   {
  991.    /***************************************************************************/
  992.    /* - We don't build modules for modindexes of 0.                           */
  993.    /***************************************************************************/
  994.    if( pDirectoryEntry->ModIndex == 0 )
  995.     continue;
  996.  
  997.    /**************************************************************************/
  998.    /* - scan to module allocated for this directory entry.                   */
  999.    /**************************************************************************/
  1000.    for( pModule = pdf->MidAnchor;/* no test */; pModule = pModule->NextMod )
  1001.    {
  1002.     if( pModule->mid == pDirectoryEntry->ModIndex)
  1003.      break;
  1004.    }
  1005.  
  1006.    switch( pDirectoryEntry->SubSectType  )
  1007.    {
  1008.      case SSTMODULES:
  1009.      case SSTLIBRARIES:
  1010.       break;
  1011.  
  1012.      case SSTPUBLICS:
  1013.       if( pdf->ExeFlags.ExeType == NE )
  1014.        pModule->DbgFormatFlags.Pubs = TYPE_PUB_16;
  1015.       else /* if( pdf->ExeFlags.ExeType == LX ) */
  1016.        pModule->DbgFormatFlags.Pubs = TYPE_PUB_32;
  1017.       break;
  1018.  
  1019.      case SSTSYMBOLS:
  1020.       if( pdf->ExeFlags.ExeType == NE )
  1021.       {
  1022.        if( pdf->ExeFlags.NBxxType == NB00 )
  1023.         pModule->DbgFormatFlags.Typs = TYPE104_C211;
  1024.        else /* if( pdf->ExeFlags.NBxxType == NB00 ) */
  1025.         pModule->DbgFormatFlags.Typs = TYPE104_C600;
  1026.       }
  1027.       else /* if( pdf->ExeFlags.ExeType == LX ) */
  1028.       {
  1029.        pModule->DbgFormatFlags.Typs = TYPE104_CL386;
  1030.        /**********************************************************************/
  1031.        /* We could be having 16 bit modules linked with 32 bit exe, so check */
  1032.        /* for the bitness of the address and over ride the earlier settings. */
  1033.        /**********************************************************************/
  1034.        ModuleType = GetBitness( pModule->pCsects->CsectLo );
  1035.        if( ModuleType == BIT16 )
  1036.         pModule->DbgFormatFlags.Typs = TYPE104_C600;
  1037.       }
  1038.       break;
  1039.  
  1040.      case SSTTYPES:
  1041.       if( pdf->ExeFlags.ExeType == NE )
  1042.       {
  1043.        if( pdf->ExeFlags.NBxxType == NB00 )
  1044.         pModule->DbgFormatFlags.Syms = TYPE103_C211;
  1045.        else /* if( pdf->ExeFlags.NBxxType == NB00 ) */
  1046.         pModule->DbgFormatFlags.Syms = TYPE103_C600;
  1047.       }
  1048.       else /* if( pdf->ExeFlags.ExeType == LX ) */
  1049.       {
  1050.        pModule->DbgFormatFlags.Syms = TYPE103_CL386;
  1051.        /**********************************************************************/
  1052.        /* We could be having 16 bit modules linked with 32 bit exe, so check */
  1053.        /* for the bitness of the address and over ride the earlier settings. */
  1054.        /**********************************************************************/
  1055.        ModuleType = GetBitness( pModule->pCsects->CsectLo );
  1056.        if( ModuleType == BIT16 )
  1057.         pModule->DbgFormatFlags.Syms = TYPE103_C600;
  1058.       }
  1059.       break;
  1060.  
  1061.      case SSTSRCLINES:
  1062.       pModule->DbgFormatFlags.Lins = TYPE105;
  1063.       break;
  1064.  
  1065.      case SSTSRCLNSEG:
  1066.       if( pdf->ExeFlags.ExeType == NE )
  1067.        pModule->DbgFormatFlags.Lins = TYPE109_16;
  1068.       else /* if( pdf->ExeFlags.ExeType == LX ) */
  1069.        pModule->DbgFormatFlags.Lins = TYPE109_32;
  1070.       break;
  1071.    }
  1072.   }
  1073.  }
  1074.  else /*if( pdf->ExeFlags.NBxxType == NB04 )*/
  1075.  {
  1076.   pDirectoryEntryHLL = (HDRENTRYHLL *)pDirectoryBuffer;
  1077.   for( i = 1; i <= NumEntries; i++, pDirectoryEntryHLL++ )
  1078.   {
  1079.    /***************************************************************************/
  1080.    /* - We don't build modules for modindexes of 0.                           */
  1081.    /***************************************************************************/
  1082.    if( pDirectoryEntryHLL->ModIndex == 0 )
  1083.     continue;
  1084.  
  1085.    /***************************************************************************/
  1086.    /* - scan to module allocated for this directory entry.                    */
  1087.    /***************************************************************************/
  1088.    for( pModule = pdf->MidAnchor;/* no test */; pModule = pModule->NextMod )
  1089.    {
  1090.     if( pModule->mid == pDirectoryEntryHLL->ModIndex)
  1091.      break;
  1092.    }
  1093.  
  1094.    switch( pDirectoryEntryHLL->SubSectType  )
  1095.    {
  1096.     case SSTMODULES:
  1097.     case SSTLIBRARIES:
  1098.      break;
  1099.  
  1100.     case SSTPUBLICS:
  1101.      pModule->DbgFormatFlags.Pubs = TYPE_PUB_32;
  1102.      break;
  1103.  
  1104.     case SSTTYPES:
  1105.      /*********************************************************************/
  1106.      /* If the debug format is IBM, it can be either Level 1,2,3, or 4.   */
  1107.      /* Read the debug style info from the file block buffer and set the  */
  1108.      /* debug format flags accordingly.                                   */
  1109.      /*********************************************************************/
  1110.      seekf(pdf,pdf->DebugOff + pModule->FileName);
  1111.      pFrec_NB04 = &Frec_NB04;
  1112.      readf( (UCHAR*)pFrec_NB04,sizeof(FREC_NB04), pdf );
  1113.  
  1114.      if( pFrec_NB04->DebugStyle == HLL )
  1115.      {
  1116.       switch( pFrec_NB04->version[1] )
  1117.       {
  1118.        case 0x1:
  1119.         pModule->DbgFormatFlags.Typs = TYPE103_HL01;
  1120.         break;
  1121.  
  1122.        case 0x2:
  1123.         pModule->DbgFormatFlags.Typs = TYPE103_HL02;
  1124.         break;
  1125.  
  1126.        case 0x3:
  1127.         pModule->DbgFormatFlags.Typs = TYPE103_HL03;
  1128.         break;
  1129.  
  1130.        case 0x4:
  1131.         pModule->DbgFormatFlags.Typs = TYPE103_HL04;
  1132.         break;
  1133.       }
  1134.      }
  1135.      else /* If Debug style is not HLL */
  1136.      {
  1137.       pModule->DbgFormatFlags.Typs = TYPE103_CL386;
  1138.       ModuleType = GetBitness( pModule->pCsects->CsectLo );
  1139.       if( ModuleType == BIT16 )
  1140.        pModule->DbgFormatFlags.Typs = TYPE103_C600;
  1141.      }
  1142.      break;
  1143.  
  1144.     case SSTSYMBOLS:
  1145.      /*********************************************************************/
  1146.      /* If the debug format is IBM, it can be either Level 1,2,3, or 4.   */
  1147.      /* Read the debug style info from the file block buffer and set the  */
  1148.      /* debug format flags accordingly.                                   */
  1149.      /*********************************************************************/
  1150.      seekf(pdf,pdf->DebugOff + pModule->FileName);
  1151.      pFrec_NB04 = &Frec_NB04;
  1152.      readf( (UCHAR*)pFrec_NB04,sizeof(FREC_NB04), pdf );
  1153.  
  1154.      if( pFrec_NB04->DebugStyle == HLL )
  1155.      {
  1156.       switch( pFrec_NB04->version[1] )
  1157.       {
  1158.        case 0x1:
  1159.         pModule->DbgFormatFlags.Syms = TYPE104_HL01;
  1160.         break;
  1161.  
  1162.        case 0x2:
  1163.         pModule->DbgFormatFlags.Syms = TYPE104_HL02;
  1164.         break;
  1165.  
  1166.        case 0x3:
  1167.         pModule->DbgFormatFlags.Syms = TYPE104_HL03;
  1168.         break;
  1169.  
  1170.        case 0x4:
  1171.         pModule->DbgFormatFlags.Syms = TYPE104_HL04;
  1172.         break;
  1173.       }
  1174.      }
  1175.      else /* If Debug style is not HLL */
  1176.      {
  1177.       pModule->DbgFormatFlags.Syms = TYPE104_CL386;
  1178.       ModuleType = GetBitness( pModule->pCsects->CsectLo );
  1179.       if( ModuleType == BIT16 )
  1180.        pModule->DbgFormatFlags.Syms = TYPE104_C600;
  1181.      }
  1182.      break;
  1183.  
  1184.     case SSTSRCLINES:
  1185.      /* should never happen, but just in case. */
  1186.      pModule->DbgFormatFlags.Lins = TYPE105;
  1187.      break;
  1188.  
  1189.     case SSTSRCLNSEG:
  1190.      pModule->DbgFormatFlags.Lins = TYPE109_32;
  1191.      break;
  1192.  
  1193.     case SSTIBMSRC:
  1194.      /************************************************************************/
  1195.      /* - Now get some additional info from the the file name subsection     */
  1196.      /*   so we can decide HL01,HL02,HL03,HL04 styles.                       */
  1197.      /************************************************************************/
  1198.      seekf(pdf,pdf->DebugOff + pModule->FileName);
  1199.      pFrec_NB04 = &Frec_NB04;
  1200.      readf( (UCHAR*)pFrec_NB04,sizeof(FREC_NB04), pdf );
  1201.      switch( pFrec_NB04->version[1] )
  1202.      {
  1203.       case 0x1:
  1204.        pModule->DbgFormatFlags.Lins = TYPE10B_HL01;
  1205.        break;
  1206.  
  1207.       case 0x2:
  1208.        pModule->DbgFormatFlags.Lins = TYPE10B_HL02;
  1209.        break;
  1210.  
  1211.       case 0x3:
  1212.        pModule->DbgFormatFlags.Lins = TYPE10B_HL03;
  1213.        break;
  1214.  
  1215.       case 0x4:
  1216.        pModule->DbgFormatFlags.Lins = TYPE10B_HL04;
  1217.        break;
  1218.      }
  1219.      break;
  1220.    }
  1221.   }
  1222.  }
  1223. }
  1224.  
  1225.