home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / SETWPS.C < prev    next >
Text File  |  1994-06-02  |  9KB  |  173 lines

  1. /*****************************************************************************/
  2. /* File:                                             IBM INTERNAL USE ONLY   */
  3. /*   setwps.c                                                                */
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*                                                                           */
  7. /*   Allow user to define watch points and put in the watch points.          */
  8. /*                                                                           */
  9. /* History:                                                                  */
  10. /*                                                                           */
  11. /*...Release 1.00 (03/03/92)                                                 */
  12. /*...                                                                        */
  13. /*... 03/10/92  602   Srinivas  Hooking up watch points.                     */
  14. /*                                                                           */
  15. /**Includes*******************************************************************/
  16.  
  17. #include "all.h"                        /* SD386 include files               */
  18.  
  19. extern DEBUG_REGISTER Debug_Regs[];     /* hardware debug registers          */
  20. #define MASK1  0x0000000f               /* masks used to align address on    */
  21. #define MASK2  0xfffffff0               /* double word boundary.             */
  22.  
  23. /*****************************************************************************/
  24. /* Setwps()                                                                  */
  25. /*                                                                           */
  26. /* Description:                                                              */
  27. /*                                                                           */
  28. /*    Allocates buffer for the display of watch point window and calls       */
  29. /*    function to process the key strokes.                                   */
  30. /*                                                                           */
  31. /* Parameters:                                                               */
  32. /*                                                                           */
  33. /*   fp      -  pointer to the current afile structure.                      */
  34. /*                                                                           */
  35. /* Return:                                                                   */
  36. /*   none                                                                    */
  37. /*****************************************************************************/
  38. void SetWps( AFILE *fp )
  39. {
  40.   Cua_SetWps( fp );
  41. }
  42.  
  43. /*****************************************************************************/
  44. /* EncodeSize()                                                              */
  45. /*                                                                           */
  46. /* Description:                                                              */
  47. /*                                                                           */
  48. /*    Converts a given size into a index value.                              */
  49. /*                                                                           */
  50. /* Parameters:                                                               */
  51. /*                                                                           */
  52. /*   Size     -  size of the address.                                        */
  53. /*                                                                           */
  54. /* Return:                                                                   */
  55. /*   index    - index into sizes array.                                      */
  56. /*****************************************************************************/
  57. uchar EncodeSize(uint size)
  58. {
  59.  uchar rc=0;
  60.  
  61.   switch (size)
  62.   {
  63.      case 2:
  64.        rc = 1;
  65.        break;
  66.  
  67.      case 4:
  68.        rc = 2;
  69.        break;
  70.  
  71.      default:
  72.        rc = 0;
  73.        break;
  74.   }
  75.  return(rc);
  76. }
  77.  
  78. /*****************************************************************************/
  79. /* AlignAddress()                                                            */
  80. /*                                                                           */
  81. /* Description:                                                              */
  82. /*                                                                           */
  83. /*    Aligns a given address to a word boundary if the size is two bytes     */
  84. /*    or to a double word boundary if the size is four bytes long.           */
  85. /*                                                                           */
  86. /* Parameters:                                                               */
  87. /*                                                                           */
  88. /*   Address  -  pointer to the address.                                     */
  89. /*   Size     -  size of the address.                                        */
  90. /*                                                                           */
  91. /* Return:                                                                   */
  92. /*                                                                           */
  93. /*    0    -    If address is not modified.                                  */
  94. /*    1    -    If address is aligned.                                       */
  95. /*****************************************************************************/
  96. uchar AlignAddress(uint *Address,uchar Size)
  97. {
  98.   uchar AlignmentDone;
  99.   uint  TempAddress;
  100.  
  101.   AlignmentDone = FALSE;
  102.  
  103.   switch (Size)
  104.   {
  105.      case 1:
  106.        if ( ((*Address) % 2 ) != 0)
  107.        {
  108.           *Address = *Address - 1;
  109.           AlignmentDone = TRUE;
  110.        }
  111.        break;
  112.  
  113.      case 2:
  114.        if ( (*Address) & 3 )
  115.        {
  116.           TempAddress = (*Address) & MASK1;
  117.           TempAddress = (TempAddress / 4) * 4;
  118.           (*Address) &= MASK2;
  119.           (*Address) |= TempAddress;
  120.           AlignmentDone = TRUE;
  121.        }
  122.        break;
  123.   }
  124.   return(AlignmentDone);
  125. }
  126.  
  127. /*****************************************************************************/
  128. /* PutInWps()                                                                */
  129. /*                                                                           */
  130. /* Description:                                                              */
  131. /*                                                                           */
  132. /*    Put watch points in x-server and update client indexes.                */
  133. /*                                                                           */
  134. /* Parameters:                                                               */
  135. /*                                                                           */
  136. /* Return:                                                                   */
  137. /*                                                                           */
  138. /*****************************************************************************/
  139. void  PutInWps( void )
  140. {
  141.  ULONG  Indexes[NODEBUGREGS];
  142.  int    i;
  143.  
  144.  memset(Indexes,0,sizeof(Indexes));
  145.  xPutInWps( Indexes );
  146.  
  147.  for(i=0;i < NODEBUGREGS; i++ )
  148.   Debug_Regs[i].Wpindex = Indexes[i];
  149.  
  150. }
  151.  
  152. /*****************************************************************************/
  153. /* IsWatchPoint()                                                            */
  154. /*                                                                           */
  155. /* Description:                                                              */
  156. /*                                                                           */
  157. /*    Is there a watch point defined.                                        */
  158. /*                                                                           */
  159. /* Parameters:                                                               */
  160. /*                                                                           */
  161. /* Return:                                                                   */
  162. /*   TRUE or FALSE                                                           */
  163. /*****************************************************************************/
  164. int IsWatchPoint( void )
  165. {
  166.  int i;
  167.  
  168.  for(i=0;i < NODEBUGREGS; i++ )
  169.   if( (Debug_Regs[i].Address != 0) && (Debug_Regs[i].Status == ENABLED) )
  170.    return( TRUE );
  171.  return(FALSE);
  172. }
  173.