home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / CUASETWP.C < prev    next >
Text File  |  1996-03-03  |  42KB  |  951 lines

  1. /*****************************************************************************/
  2. /* File:                                             IBM INTERNAL USE ONLY   */
  3. /*   cuasetwp.c                                                              */
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*                                                                           */
  7. /*   Cua watch point dialog functions.                                       */
  8. /*                                                                           */
  9. /*...Release 1.01 (04/03/92)                                                 */
  10. /*...                                                                        */
  11. /*... 05/08/92  701   Samuel    Cua Interface.                               */
  12. /*...                                                                        */
  13. /*...Release 1.02 (10/22/92)                                                 */
  14. /*...                                                                        */
  15. /*... 04/15/93  821   Selwyn    Changes in processing clicks on buttons.     */
  16. /*... 12/10/93  910   Joe       Clear fields on cursor sensitive prompting.  */
  17. /*****************************************************************************/
  18. #include "all.h"
  19. #include "diawhpnt.h"                   /* data for watch point dialog.      */
  20.  
  21. #define MAXLINESIZE   74
  22. #define DISPPROMPTLEN 35
  23.  
  24. extern uchar   msgbuf[];                /* msgbuf to hold info msg           */
  25. extern uint    ExprAddr;                /* Set by ParseExpr                  */
  26. extern uint    ExprMid;                 /* Set by ParseExpr                  */
  27. extern uint    ExprTid;                 /* Set by ParseExpr                  */
  28. extern SCOPE   ExprScope;               /* Set by ParseExpr                  */
  29. extern uint    ProcessID;               /* Process id of debuggee.           */
  30. extern uchar   VideoAtr;                /* logical screen attribute          */
  31. extern uchar   normal[];                /* normal field attributes        701*/
  32. extern uchar   ClearField[];            /* clear field attributes         701*/
  33. extern VIOCURSORINFO  NormalCursor;     /* make underscore flashing cursor   */
  34. extern CmdParms cmd;
  35.  
  36. DEBUG_REGISTER Debug_Regs[4];           /* hardware debug registers          */
  37.  
  38. static uchar Header[] = "RegNo      Expression                Size   Addr   Scope    Type    Status";
  39.  
  40. static char *Sizes[3] =                 /* size of the watch points          */
  41. {                                       /*                                   */
  42.   "1",                                  /*  - one byte long                  */
  43.   "2",                                  /*  - two bytes long                 */
  44.   "4"                                   /*  - four bytes long                */
  45. };                                      /*                                   */
  46.  
  47. static char *Scopes[2] =                /* type of scope for watch points    */
  48. {                                       /*                                   */
  49.   "Local ",                             /*  - Local watchpoint               */
  50.   "Global"                              /*  - Global watchpoint              */
  51. };                                      /*                                   */
  52.  
  53. static char *Types[3] =                 /* type of watch points              */
  54. {                                       /*                                   */
  55.   "Readwrite",                          /*  - Readwrite watchpoint           */
  56.   "Write    ",                          /*  - Write watchpoint               */
  57.   "Execute  "                           /*  - Execute watchpoint             */
  58. };                                      /*                                   */
  59.  
  60. static char *Status[2] =                /* status of the watch points        */
  61. {                                       /*                                   */
  62.   "Disabled",                           /*  - Watch point not set            */
  63.   "Enabled "                            /*  - Watch point hit                */
  64. };                                      /*                                   */
  65.  
  66. static enum { ExprField,
  67.               SizeField,
  68.               ScopeField,
  69.               TypeField,
  70.               StatusField
  71.             } Field;
  72.  
  73. static DEBUG_REGISTER LDebug_Regs[4];
  74. static PEVENT Event;
  75.  
  76. /*****************************************************************************/
  77. /* Cua_Setwps()                                                           701*/
  78. /*                                                                           */
  79. /* Description:                                                              */
  80. /*                                                                           */
  81. /*  Calls functions to display, process choices and remove watchpoint dialog */
  82. /*                                                                           */
  83. /* Parameters:                                                               */
  84. /*                                                                           */
  85. /*   fp      -  pointer to the current afile structure.                      */
  86. /*                                                                           */
  87. /* Return:                                                                   */
  88. /*   none                                                                    */
  89. /*****************************************************************************/
  90. void Cua_SetWps( AFILE *fp )
  91. {
  92.   GetScrAccess();
  93.   DisplayDialog( &Dia_WhPnt, FALSE );
  94.   GetDialogWhPntChoice( &Dia_WhPnt, &Dia_WhPnt_Choices, fp );
  95.   RemoveDialog( &Dia_WhPnt );
  96.   fmterr( msgbuf );
  97.   SetScrAccess();
  98. }
  99.  
  100. #define NOSCROLLBAR FALSE
  101. /*****************************************************************************/
  102. /* GetDialogWhPntChoice:  Selects an entry from a list on a dialog window    */
  103. /*                                                                           */
  104. /*   shell   ->  pointer to a dialog shell structure.                        */
  105. /*   ptr     ->  pointer to a dialog choice structure.                       */
  106. /*   choice  ->  field number that was selected.                             */
  107. /*****************************************************************************/
  108. uint GetDialogWhPntChoice( DIALOGSHELL *shell, DIALOGCHOICE *ptr, AFILE *fp )
  109. {
  110.   uint   key;                           /* the entered key                   */
  111.   uint   skip;                          /* # of lines to choices             */
  112.   uint   fldcol;
  113.   uint   ButtonKey;                                                     /*821*/
  114.   uint   fldcursor;
  115.   uint   fldrow;
  116.   uint   DebugRegNo;
  117.   uint   CursorStartRow;
  118.   uint   i, sfx;
  119.   uchar  TempPrompt[ PROMPTLEN + 1 ];
  120.   uchar  buffer[ MAXSYM+1 ], msg[80];
  121.   uchar  ExprChgFlag;
  122.   uchar  *cp;
  123.   uint   Pos;
  124.  
  125.   POPUPSHELL PopShell;                                                  /*910*/
  126.  
  127.   /****************************************************************************/
  128.   /* copy the Global debug register to local copy.                            */
  129.   /****************************************************************************/
  130.   for ( i = 0 ; i < 4 ; i++)
  131.      LDebug_Regs[i] = Debug_Regs[i];
  132.  
  133.   /***************************************************************************/
  134.   /* - set up string length for the arttribute strings.                      */
  135.   /* - set default video attribute.                                          */
  136.   /***************************************************************************/
  137.   normal[1]    = (UCHAR) shell->width - 2 - SCROLLBARCOLOFFSET;
  138.   VideoAtr     = vaMenuBar;
  139.  
  140.  
  141.   /***************************************************************************/
  142.   /* Start one line past the title.                                          */
  143.   /***************************************************************************/
  144.   skip = 3;
  145.  
  146.   /***************************************************************************/
  147.   /* Put the watch point entries into the dialog box.                        */
  148.   /***************************************************************************/
  149.   DisplayWhPntChoice (shell,ptr);
  150.  
  151.   /***************************************************************************/
  152.   /* - Put up the header text.                                               */
  153.   /* - Set the cursor type.                                                  */
  154.   /***************************************************************************/
  155.   putrc( shell->row+2, shell->col+2, Header );
  156.   VioSetCurType( &NormalCursor, 0 );
  157.  
  158.   /***************************************************************************/
  159.   /* Init the various variables.                                             */
  160.   /***************************************************************************/
  161.   DebugRegNo   = 1;
  162.   Field        = ExprField;
  163.   fldcol       = shell->col + 5;
  164.   CursorStartRow = fldrow = shell->row + skip;
  165.   /***************************************************************************/
  166.   /* - Build a local POPUPSHELL from the DIALOGSHELL. GetString requires  910*/
  167.   /*   this structure after fix 910.                                      910*/
  168.   /***************************************************************************/
  169.   PopShell.row          = shell->row;                                   /*910*/
  170.   PopShell.col          = shell->col;                                   /*910*/
  171.   PopShell.length       = shell->length;                                /*910*/
  172.   PopShell.width        = shell->width;                                 /*910*/
  173.   PopShell.NoOfButtons  = shell->NoOfButtons;                           /*910*/
  174.   PopShell.title        = NULL;                                         /*910*/
  175.   PopShell.instructions = NULL;                                         /*910*/
  176.   PopShell.help         = 0;                                            /*910*/
  177.   PopShell.Buttons      = shell->Buttons;                               /*910*/
  178.   PopShell.Flags        = AUTOEXIT;                                     /*910*/
  179.  
  180.   for(;;)
  181.   {
  182. GetExpr:
  183.  
  184.     VioSetCurPos( (short)fldrow, (short)fldcol+1, 0 );
  185.  
  186.     if( Field == ExprField )
  187.     {
  188.       ExprChgFlag = FALSE;
  189.       strcpy(TempPrompt,LDebug_Regs[DebugRegNo - 1].Prompt);
  190.  
  191.       fldcursor = 0;
  192.       key = GetString( fldrow, fldcol, PROMPTLEN, DISPPROMPTLEN, &fldcursor,
  193.                LDebug_Regs[ DebugRegNo-1 ].Prompt, AUTOEXIT,&PopShell); /*910*/
  194.  
  195.       if( key == LEFTMOUSECLICK )
  196.       {
  197.         Pos = GetEventPositionInDialog( shell, ptr, &key, NOSCROLLBAR );
  198.         if( !Pos )
  199.           continue;
  200.         else
  201.         {                                                               /*821*/
  202.          goto ValidateExpr;                                             /*910*/
  203.         }                                                               /*821*/
  204.       }
  205.       else
  206.       if( key == ESC )
  207.         goto ProcessKey;
  208.       else
  209.       {
  210. ValidateExpr:
  211.  
  212.         if( strcmp( TempPrompt, LDebug_Regs[DebugRegNo - 1].Prompt ) )
  213.            ExprChgFlag = TRUE;
  214.  
  215.         cp = LDebug_Regs[DebugRegNo - 1].Prompt;
  216.  
  217.         if ( *cp )
  218.         {
  219.        /***********************************************************************/
  220.        /* If the Expression in not empty.                                     */
  221.        /***********************************************************************/
  222.           if( ExprChgFlag == TRUE ||
  223.               LDebug_Regs[DebugRegNo - 1].Status == DISABLED )
  224.           {
  225.        /*********************************************************************/
  226.        /* Expression has changed. So parse the expression with the current  */
  227.        /* context.                                                          */
  228.        /*********************************************************************/
  229.             cp = ParseExpr(LDebug_Regs[DebugRegNo - 1].Prompt,0x10,
  230.                            fp->mid, fp->csrline+fp->Nbias, fp->sfi);
  231.  
  232. #if 0
  233.             if(((uint) cp) < 20)  {/*MSH return code.*/
  234.                 int iret=((uint)cp)-10;
  235.                 switch (iret)  {
  236.                 case -3:
  237.                    return((uchar *) "MSH exit.");
  238.                 case -2:
  239.                    return((uchar *) "MSH semantic error.");
  240.                 case -1:
  241.                    return((uchar *) "MSH syntax error.");
  242.                 case  0:
  243.                    return((uchar *) "MSH Return code 0.");
  244.                 case  1:
  245.                    return((uchar *) "MSH Return code 1.");
  246.                 default:
  247.                    return((uchar *) "MSH Unknown return code.");
  248.                 } /* endswitch */
  249.             }
  250. #endif
  251.        /*********************************************************************/
  252.        /* Handle errors from parsing the expression.                        */
  253.        /*********************************************************************/
  254.             if ( (!cp) || (*cp) || (!ExprAddr) )
  255.             {
  256.               beep();
  257.               fmterr( "Invalid Expression" );
  258.               LDebug_Regs[DebugRegNo - 1].Wpindex = 0;
  259.               LDebug_Regs[DebugRegNo - 1].Size  = 0;
  260.               LDebug_Regs[DebugRegNo - 1].Address = 0;
  261.               LDebug_Regs[DebugRegNo - 1].Aligned = FALSE;
  262.               LDebug_Regs[DebugRegNo - 1].Scope = WPS_LOCAL;
  263.               LDebug_Regs[DebugRegNo - 1].Type  = READWRITE;
  264.               LDebug_Regs[DebugRegNo - 1].Status = DISABLED;
  265.               DisplayWhPntChoice( shell, ptr );
  266.               goto GetExpr;
  267.             }
  268.        /*********************************************************************/
  269.        /* Filter out the register addresses.                                */
  270.        /*********************************************************************/
  271.             if( (ExprAddr >> REGADDCHECKPOS) == REGISTERTYPEADDR )
  272.             {
  273.                beep();
  274.                fmterr( "Can't set watch points on register variables" );
  275.                goto GetExpr;
  276.             }
  277.        /*********************************************************************/
  278.        /* If the address is stack address, check for the scope stuff and if */
  279.        /* every thing is O.k convert the address to actual address.         */
  280.        /*********************************************************************/
  281.             if ( TestBit(ExprAddr,STACKADDRBIT) )
  282.             {
  283.               sfx = StackFrameIndex( ExprScope );
  284.               if( ExprScope && !sfx )
  285.               {
  286.                  beep();
  287.                  CopyProcName(ExprScope,buffer,sizeof(buffer));
  288.                  sprintf(msg,"\"%s\" not active",buffer);
  289.                  fmterr(msg);
  290.                  goto GetExpr;
  291.               }
  292.               ExprAddr = StackBPRelToAddr(ExprAddr,sfx);
  293.             }
  294.        /*********************************************************************/
  295.        /* Get the size of the expression and put the size in encoded form   */
  296.        /* into the debug registers.                                         */
  297.        /*********************************************************************/
  298.             if( ExprTid )
  299.             {
  300.                switch( QtypeGroup(ExprMid, ExprTid) )
  301.                {
  302.                   case TG_SCALAR:
  303.                   case TG_POINTER:
  304.                     LDebug_Regs[DebugRegNo-1].Size = EncodeSize(QtypeSize(ExprMid,ExprTid));
  305.                     break;
  306.                   case TG_CONSTANT:
  307.                     LDebug_Regs[DebugRegNo - 1].Size = EncodeSize(sizeof(uint));
  308.                     break;
  309.                   default:
  310.                      beep();
  311.                      goto GetExpr;
  312.                }
  313.             }
  314.             else
  315.                LDebug_Regs[DebugRegNo - 1].Size = EncodeSize(sizeof(uint));
  316.  
  317.       /*********************************************************************/
  318.       /* Assign the address and align it if neccessary.                    */
  319.       /*********************************************************************/
  320.             LDebug_Regs[DebugRegNo - 1].Address = ExprAddr;
  321.             LDebug_Regs[DebugRegNo - 1].Status = ENABLED;
  322.             if (LDebug_Regs[DebugRegNo - 1].Type != EXECUTE)
  323.             {
  324.                if (AlignAddress( &(LDebug_Regs[DebugRegNo - 1].Address),
  325.                                   LDebug_Regs[DebugRegNo - 1].Size))
  326.                   LDebug_Regs[DebugRegNo - 1].Aligned = TRUE;
  327.                else
  328.                   LDebug_Regs[DebugRegNo - 1].Aligned = FALSE;
  329.             }
  330.             else
  331.             {
  332.                LDebug_Regs[DebugRegNo - 1].Size = 0;
  333.                LDebug_Regs[DebugRegNo - 1].Aligned = FALSE;
  334.             }
  335.             DisplayWhPntChoice( shell, ptr );
  336.             VioSetCurType( &NormalCursor, 0 );
  337.             VioSetCurPos( (short)fldrow, (short)fldcol+1, 0 );
  338.             goto ProcessKey;
  339.           }
  340.         }
  341.         else
  342.         {
  343.       /************************************************************************/
  344.       /* If the expression is Empty, then reset all other field values to     */
  345.       /* defaults and refresh the display.                                    */
  346.       /* Don't allow the user to go to attribute fields with empty expression */
  347.       /************************************************************************/
  348.           LDebug_Regs[DebugRegNo - 1].Wpindex = 0;
  349.           LDebug_Regs[DebugRegNo - 1].Size  = 0;
  350.           LDebug_Regs[DebugRegNo - 1].Address = 0;
  351.           LDebug_Regs[DebugRegNo - 1].Aligned = FALSE;
  352.           LDebug_Regs[DebugRegNo - 1].Scope = WPS_LOCAL;
  353.           LDebug_Regs[DebugRegNo - 1].Type  = READWRITE;
  354.           LDebug_Regs[DebugRegNo - 1].Status = DISABLED;
  355.           switch( key )
  356.           {
  357.               case ENTER:               /* If all the expressions are empty  */
  358.               {                         /* the user might want to clear all  */
  359.                 int  Flag = FALSE;      /* watch points, so go process the   */
  360.                                         /* key (ENTER).                      */
  361.                 for( i = 0; i < NODEBUGREGS; i++ )
  362.                 {
  363.                   cp = LDebug_Regs[DebugRegNo - 1].Prompt;
  364.                   if( *cp )
  365.                     Flag = TRUE;
  366.                 }
  367.                 if( !Flag )
  368.                   goto ProcessKey;
  369.               }                         /* intentional fall-through          */
  370.               goto caseright;
  371. caseright:
  372.  
  373.               case RIGHT:
  374.               case TAB:
  375.               case LEFT:
  376.               case S_TAB:
  377.               case TYNEXT:
  378.               case STNEXT:
  379.               case SZNEXT:
  380.               case SPNEXT:
  381.                  DisplayWhPntChoice( shell, ptr );
  382.                  beep();
  383.                  goto GetExpr;
  384.  
  385.               default:
  386.                  DisplayWhPntChoice( shell, ptr );
  387.                  VioSetCurType( &NormalCursor, 0 );
  388.                  goto ProcessKey;
  389.           }
  390.         }
  391.         DisplayWhPntChoice( shell, ptr );
  392.         VioSetCurType( &NormalCursor, 0 );
  393.         goto ProcessKey;
  394.     }                                   /* endif ( Field == ExprField )      */
  395.   }
  396.  
  397.     /*************************************************************************/
  398.     /* Get the data from keyboard or mouse.                                  */
  399.     /*************************************************************************/
  400. GetEvents:                                                              /*821*/
  401.     Event = GetEvent( SEM_INDEFINITE_WAIT );
  402.     switch( Event->Type )
  403.     {
  404.       case TYPE_MOUSE_EVENT:
  405.       {
  406.         switch( Event->Value )
  407.         {
  408.           case EVENT_BUTTON_1_DOWN:
  409.           {
  410.             Pos = GetEventPositionInDialog( shell, ptr, &key, NOSCROLLBAR );
  411.             if( Pos == BUTTONS )
  412.             {                                                           /*821*/
  413.               ButtonKey = key;                                          /*821*/
  414.               goto GetEvents;                                           /*821*/
  415.             }                                                           /*821*/
  416.             else
  417.               key = LEFTMOUSECLICK;
  418.             break;
  419.           }
  420.  
  421.           case EVENT_NO_BUTTONS_DOWN:                                   /*821*/
  422.           case EVENT_NO_BUTTONS_DOWN_MOVE:                              /*821*/
  423.           {                                                             /*821*/
  424.             Pos = GetEventPositionInDialog( shell, ptr, &key, NOSCROLLBAR );
  425.             if( Pos == BUTTONS )                                        /*821*/
  426.              if( ButtonKey == key )                                     /*821*/
  427.                break;                                                   /*821*/
  428.             ButtonKey = 0;                                              /*821*/
  429.             continue;                                                   /*821*/
  430.           }                                                             /*821*/
  431.  
  432.           default:
  433.             continue;
  434.         }
  435.         break;
  436.       }
  437.  
  438.       case TYPE_KBD_EVENT:
  439.         key = Event->Value;
  440.         break;
  441.     }
  442.  
  443.     /*************************************************************************/
  444.     /* switch on the key stroke.                                             */
  445.     /*************************************************************************/
  446. ProcessKey:
  447.     switch( key )
  448.     {
  449.       case DOWN:
  450.         ++DebugRegNo;
  451.         fldrow++;
  452.         if( DebugRegNo > NODEBUGREGS )
  453.         {
  454.           DebugRegNo = 1;
  455.           fldrow = CursorStartRow;
  456.         }
  457.         break;
  458.  
  459.       case UP:
  460.         --DebugRegNo;
  461.         fldrow--;
  462.         if( DebugRegNo < 1 )
  463.         {
  464.           DebugRegNo = NODEBUGREGS;
  465.           fldrow = CursorStartRow + NODEBUGREGS - 1;
  466.         }
  467.         break;
  468.  
  469.       case TYNEXT:
  470.          Field = TypeField;
  471.          key = SPACEBAR;
  472.          fldcol = shell->col + 10 + DISPPROMPTLEN + ADDRESSLEN + SCOPELEN;
  473.          goto ProcessKey;
  474.  
  475.       case STNEXT:
  476.          Field = StatusField;
  477.          key = SPACEBAR;
  478.          fldcol = shell->col + 11 + DISPPROMPTLEN + ADDRESSLEN + SCOPELEN +
  479.                   TYPELEN;
  480.          goto ProcessKey;
  481.  
  482.       case SZNEXT:
  483.          Field = SizeField;
  484.          key = SPACEBAR;
  485.          fldcol = shell->col + 5 + DISPPROMPTLEN;
  486.          goto ProcessKey;
  487.  
  488.       case SPNEXT:
  489.          Field = ScopeField;
  490.          key = SPACEBAR;
  491.          fldcol = shell->col + 9 + DISPPROMPTLEN + ADDRESSLEN;
  492.          goto ProcessKey;
  493.  
  494.       case SPACEBAR:                      /* if space,                         */
  495.         switch( Field )                   /* see which field user is in        */
  496.         {
  497.           case SizeField:
  498.             /*******************************************************************/
  499.             /*  - Increment the Size index in the debug register.              */
  500.             /*  - If the index exceeds the limit reset it to start.            */
  501.             /*  - Parse the expression to arrive at the address.               */
  502.             /*  - Align the address with the new selected address.             */
  503.             /*  - Depending on alignment set the flag.                         */
  504.             /*******************************************************************/
  505.             LDebug_Regs[DebugRegNo - 1].Size++;
  506.             if (LDebug_Regs[DebugRegNo - 1].Size > 2)
  507.                 LDebug_Regs[DebugRegNo - 1].Size = 0;
  508.             ParseExpr(LDebug_Regs[DebugRegNo - 1].Prompt,0x10,
  509.                            fp->mid,fp->csrline+fp->Nbias, fp->sfi);
  510.             if( TestBit(ExprAddr,STACKADDRBIT) )
  511.                 ExprAddr = StackBPRelToAddr(ExprAddr,sfx);
  512.             LDebug_Regs[DebugRegNo - 1].Address = ExprAddr;
  513.             if (AlignAddress( &(LDebug_Regs[DebugRegNo - 1].Address),
  514.                                 LDebug_Regs[DebugRegNo - 1].Size))
  515.                LDebug_Regs[DebugRegNo - 1].Aligned = TRUE;
  516.             else
  517.                LDebug_Regs[DebugRegNo - 1].Aligned = FALSE;
  518.  
  519.             break;
  520.  
  521.           case ScopeField:
  522.             /*******************************************************************/
  523.             /*  - Increment the Scope index in the debug register.             */
  524.             /*  - If the index exceeds the limit reset it to start.            */
  525.             /*******************************************************************/
  526.             LDebug_Regs[DebugRegNo - 1].Scope++;
  527.             if (LDebug_Regs[DebugRegNo - 1].Scope > 1)
  528.                 LDebug_Regs[DebugRegNo - 1].Scope = 0;
  529.             break;
  530.  
  531.           case StatusField:
  532.  
  533.             LDebug_Regs[DebugRegNo - 1].Status++;
  534.             if( LDebug_Regs[DebugRegNo - 1].Status > 1 )
  535.                 LDebug_Regs[DebugRegNo - 1].Status = 0;
  536.             break;
  537.  
  538.           case TypeField:
  539.            /*******************************************************************/
  540.            /*  - Increment the type index in the debug register.              */
  541.            /*  - If the index exceeds the limit reset it to start.            */
  542.            /*  - Reset the parameters accordingly if the user selected        */
  543.            /*    execute watch point.                                         */
  544.            /*******************************************************************/
  545.             LDebug_Regs[DebugRegNo - 1].Type++;
  546.             if (LDebug_Regs[DebugRegNo - 1].Type > 2)
  547.                 LDebug_Regs[DebugRegNo - 1].Type = 0;
  548.             if (LDebug_Regs[DebugRegNo - 1].Type == EXECUTE)
  549.             {
  550.                 ParseExpr(LDebug_Regs[DebugRegNo - 1].Prompt,0x10,
  551.                          fp->mid,fp->csrline+fp->Nbias, fp->sfi);
  552.                 if( TestBit(ExprAddr,STACKADDRBIT) )
  553.                     ExprAddr = StackBPRelToAddr(ExprAddr,sfx);
  554.                 LDebug_Regs[DebugRegNo - 1].Size = 0;
  555.                 LDebug_Regs[DebugRegNo - 1].Aligned = FALSE;
  556.                 LDebug_Regs[DebugRegNo - 1].Address = ExprAddr;
  557.             }
  558.             break;
  559.         }
  560.         DisplayWhPntChoice( shell, ptr );
  561.         break;
  562.  
  563.       case RIGHT:                        /* if right or tab,                  */
  564.       case TAB:                          /*                                   */
  565.         switch( Field )                  /* see which field user is in        */
  566.         {                                /*                                   */
  567.           case ExprField:                /* if user in expression field       */
  568.             fldcol = shell->col + 5 + DISPPROMPTLEN;
  569.             Field = SizeField;           /* move user right to Size field     */
  570.             LDebug_Regs[DebugRegNo - 1].Status = ENABLED;
  571.             DisplayWhPntChoice( shell, ptr );
  572.             break;                       /*                                   */
  573.  
  574.           case SizeField:                /* if user in size field             */
  575.             fldcol = shell->col + 9 + DISPPROMPTLEN + ADDRESSLEN;
  576.             Field = ScopeField;          /* move user right to Scope field    */
  577.             break;                       /*                                   */
  578.  
  579.           case ScopeField:               /* if user in scope field            */
  580.             fldcol = shell->col + 10 + DISPPROMPTLEN + ADDRESSLEN + SCOPELEN;
  581.             Field = TypeField;           /* move user right to type field     */
  582.             break;                       /*                                   */
  583.  
  584.           case TypeField:                /* if user in scope field            */
  585.             fldcol = shell->col + 11 + DISPPROMPTLEN + ADDRESSLEN + SCOPELEN +
  586.                      TYPELEN;
  587.             Field = StatusField;         /* move user right to type field     */
  588.             break;                       /*                                   */
  589.  
  590.           case StatusField:              /* if user in status field           */
  591.             fldcol = shell->col + 5;
  592.             Field = ExprField;           /* move user right to expr field     */
  593.             break;                       /*                                   */
  594.         }                                /*                                   */
  595.         break;                           /*                                   */
  596.  
  597.       case LEFT:                         /* if left or shift_tab,             */
  598.       case S_TAB:                        /*                                   */
  599.         switch( Field )                  /* see which field user is in        */
  600.         {                                /*                                   */
  601.           case ExprField:                /* if user in scope field            */
  602.             fldcol = shell->col + 11 + DISPPROMPTLEN + ADDRESSLEN + SCOPELEN +
  603.                      TYPELEN;
  604.             Field = StatusField;         /* move user right to type field     */
  605.             break;                       /*                                   */
  606.  
  607.           case StatusField:              /* if user in expression field       */
  608.             fldcol = shell->col + 10 + DISPPROMPTLEN + ADDRESSLEN + SCOPELEN;
  609.             Field = TypeField;           /* move user left to type field      */
  610.             break;                       /*                                   */
  611.  
  612.           case SizeField:                /* if user in size field             */
  613.             fldcol = shell->col + 5;
  614.             Field = ExprField;           /* move user left to expr field      */
  615.             break;                       /*                                   */
  616.  
  617.           case ScopeField:               /* if user in scope field            */
  618.             fldcol = shell->col + 5 + DISPPROMPTLEN;
  619.             Field = SizeField;           /* move user left to size field      */
  620.             break;                       /*                                   */
  621.  
  622.           case TypeField:                /* if user in type field             */
  623.             fldcol = shell->col + 9 + DISPPROMPTLEN + ADDRESSLEN;
  624.             Field = ScopeField;          /* move user left to Scope field     */
  625.             break;                       /*                                   */
  626.         }                                /*                                   */
  627.         break;                           /*                                   */
  628.  
  629.       case F1:
  630.       {
  631.         uchar  *HelpMsg;
  632.  
  633.         HelpMsg = GetHelpMsg( HELP_DLG_WATCH, NULL,0 );
  634.         CuaShowHelpBox( HelpMsg );
  635.         break;
  636.       }
  637.  
  638.  
  639.       case C_ENTER:
  640.       case ENTER:
  641. #if 0
  642.       /***********************************************************************/
  643.       /* Pull out the watch points.                                          */
  644.       /***********************************************************************/
  645.       rc = PullOutWps(&Debug_Regs[0]);
  646.  
  647.       /***********************************************************************/
  648.       /* - Put in the watch points.                                          */
  649.       /* - If we get a error setting the watch points display error message  */
  650.       /*   and go to the watch point which caused it.                        */
  651.       /***********************************************************************/
  652.       rc = PutInWps(&LDebug_Regs[0]);
  653.       if (rc)
  654.       {
  655.          sprintf(msg,"Error Setting Watch point %1d",rc);
  656.          fmterr(msg);
  657.          beep();
  658.          DebugRegNo = rc;               /* put rc into debugRegNo            */
  659.          fldcol = shell->col + 5;       /* move to 1st expression field      */
  660.          fldrow = shell->row + 3 + DebugRegNo - 1;
  661.          Field  = ExprField;            /* Start user in Expression field    */
  662.          goto GetExpr;
  663.       }
  664. #endif
  665.  
  666.       /***********************************************************************/
  667.       /* copy the local debug registers to global registers.                 */
  668.       /***********************************************************************/
  669.       for ( i = 0 ; i < NODEBUGREGS ; i++)
  670.           Debug_Regs[i] = LDebug_Regs[i];
  671.  
  672.       /***********************************************************************/
  673.       /* - define the watchpoints to the x-server.                        827*/
  674.       /***********************************************************************/
  675.       {                                                                 /*827*/
  676.        WP_REGISTER  regs[NODEBUGREGS];                                  /*827*/
  677.                                                                         /*827*/
  678.        for ( i = 0 ; i < NODEBUGREGS ; i++)                             /*827*/
  679.        {                                                                /*827*/
  680.         regs[i].Address = Debug_Regs[i].Address;                        /*827*/
  681.         regs[i].Size    = Debug_Regs[i].Size   ;                        /*827*/
  682.         regs[i].Scope   = Debug_Regs[i].Scope  ;                        /*827*/
  683.         regs[i].Type    = Debug_Regs[i].Type   ;                        /*827*/
  684.         regs[i].Status  = Debug_Regs[i].Status ;                        /*827*/
  685.         regs[i].Wpindex = Debug_Regs[i].Wpindex;                        /*827*/
  686.         regs[i].IsSet   = FALSE;                                        /*827*/
  687.        }                                                                /*827*/
  688.        xDefWps(regs,sizeof(regs));                                                   /*827*/
  689.       }                                                                 /*827*/
  690.       return(key);
  691.  
  692.       case ESC:
  693.       case F10:
  694.       {
  695. #if 0
  696.         int i;
  697.  
  698.         for( i = 0; i < NODEBUGREGS; i++ )
  699.         {
  700.           if( strcmp( Debug_Regs[i].Prompt, LDebug_Regs[i].Prompt ) )
  701.           {
  702.             int j;
  703.             for( j = 0 ; j < NODEBUGREGS ; j++ )
  704.               LDebug_Regs[j] = Debug_Regs[j];
  705.             DisplayWhPntChoice( shell, ptr );
  706.             goto GetExpr;
  707.           }
  708.         }
  709. #endif
  710.         if( memcmp( Debug_Regs, LDebug_Regs, sizeof( LDebug_Regs ) ) )
  711.         {
  712.           int j;
  713.           for( j = 0 ; j < NODEBUGREGS ; j++ )
  714.             LDebug_Regs[j] = Debug_Regs[j];
  715.           DisplayWhPntChoice( shell, ptr );
  716.           Field = ExprField;
  717.           fldcol = shell->col + 5;
  718.           goto GetExpr;
  719.         }
  720.         return( key );
  721.       }
  722.  
  723.       case LEFTMOUSECLICK:
  724.       /***********************************************************************/
  725.       /*  - Item was selected by clicking on the choices with mouse.         */
  726.       /***********************************************************************/
  727.       {
  728.         uint  PrevDebugRegNo;
  729.         uchar *sp;
  730.  
  731.         Event = GetCurrentEvent();
  732.         PrevDebugRegNo = DebugRegNo;
  733.         DebugRegNo = Event->Row - shell->row - 2;
  734.  
  735.         if( (!DebugRegNo) || (DebugRegNo > 4) )
  736.         {
  737.           DebugRegNo = PrevDebugRegNo;
  738.           beep();
  739.           break;
  740.         }
  741.  
  742.         sp  = LDebug_Regs[DebugRegNo - 1].Prompt;
  743.  
  744.         /*********************************************************************/
  745.         /* Depending on the mouse position set the fld col and field we are  */
  746.         /* in.                                                               */
  747.         /*********************************************************************/
  748.         if ( ((uint)Event->Col >= ( shell->col + 5 )) &&
  749.              ((uint)Event->Col < ( shell->col + 5 + DISPPROMPTLEN )))
  750.         {
  751. #if 0
  752.           if( *sp || *psp )
  753.           {
  754. #endif
  755.             fldcol = shell->col + 5;
  756.             fldrow = (uint)Event->Row;
  757.             Field = ExprField;
  758. #if 0
  759.           }
  760.           else
  761.             DebugRegNo = PrevDebugRegNo;
  762. #endif
  763.           goto GetExpr;
  764.         }
  765.         else
  766.         if( ((uint)Event->Col > ( shell->col + 5 + DISPPROMPTLEN )) &&
  767.             ((uint)Event->Col < ( shell->col + 5 + DISPPROMPTLEN + 4 )) )
  768.         {
  769. #if 0
  770.           if( *psp )
  771.           {
  772. #endif
  773.             if( *sp )
  774.             {
  775.               fldcol = shell->col + 5 + DISPPROMPTLEN;
  776.               Field = SizeField;
  777.               fldrow = (uint)Event->Row;
  778.               key = SPACEBAR;
  779.               goto ProcessKey;
  780.             }
  781.             else
  782.             {
  783.               DebugRegNo = PrevDebugRegNo;
  784.               goto GetExpr;
  785.             }
  786. #if 0
  787.           }
  788.           else
  789.           {
  790.             DebugRegNo = PrevDebugRegNo;
  791.             goto GetExpr;
  792.           }
  793. #endif
  794.         }
  795.         else
  796.         if( ((uint)Event->Col > ( shell->col + 9 + DISPPROMPTLEN + ADDRESSLEN )) &&
  797.             ((uint)Event->Col < ( shell->col + 9 + DISPPROMPTLEN + ADDRESSLEN +
  798.                                   SCOPELEN )) )
  799.  
  800.         {
  801. #if 0
  802.           if( *psp )
  803.           {
  804. #endif
  805.             if( *sp )
  806.             {
  807.               fldcol = shell->col + 9 + DISPPROMPTLEN + ADDRESSLEN;
  808.               Field = ScopeField;
  809.               fldrow = (uint)Event->Row;
  810.               key = SPACEBAR;
  811.               goto ProcessKey;
  812.             }
  813.             else
  814.             {
  815.               DebugRegNo = PrevDebugRegNo;
  816.               goto GetExpr;
  817.             }
  818. #if 0
  819.           }
  820.           else
  821.           {
  822.             DebugRegNo = PrevDebugRegNo;
  823.             goto GetExpr;
  824.           }
  825. #endif
  826.         }
  827.         else
  828.         if ( ((uint)Event->Col > ( shell->col + 9 + DISPPROMPTLEN + ADDRESSLEN +
  829.                                  SCOPELEN )) &&
  830.              ((uint)Event->Col < ( shell->col + 9 + DISPPROMPTLEN + ADDRESSLEN +
  831.                                  SCOPELEN + 9 )))
  832.         {
  833. #if 0
  834.           if( *psp )
  835.           {
  836. #endif
  837.             if( *sp )
  838.             {
  839.               fldcol = shell->col + 10 + DISPPROMPTLEN + ADDRESSLEN + SCOPELEN;
  840.               Field = TypeField;
  841.               fldrow = (uint)Event->Row;
  842.               key = SPACEBAR;
  843.               goto ProcessKey;
  844.             }
  845.             else
  846.             {
  847.               DebugRegNo = PrevDebugRegNo;
  848.               goto GetExpr;
  849.             }
  850. #if 0
  851.           }
  852.           else
  853.           {
  854.             DebugRegNo = PrevDebugRegNo;
  855.             goto GetExpr;
  856.           }
  857. #endif
  858.         }
  859.         else
  860.         if( ((uint)Event->Col > ( shell->col + 10 + DISPPROMPTLEN + ADDRESSLEN +
  861.                                   SCOPELEN + TYPELEN )) &&
  862.             ((uint)Event->Col < ( shell->col + shell->width - 1 )))
  863.         {
  864. #if 0
  865.           if( *psp )
  866.           {
  867. #endif
  868.             if( *sp )
  869.             {
  870.               fldcol = shell->col + 11 + DISPPROMPTLEN + ADDRESSLEN + SCOPELEN +
  871.                        TYPELEN;
  872.               Field = StatusField;
  873.               fldrow = (uint)Event->Row;
  874.               key = SPACEBAR;
  875.               goto ProcessKey;
  876.             }
  877.             else
  878.             {
  879.               DebugRegNo = PrevDebugRegNo;
  880.               goto GetExpr;
  881.             }
  882. #if 0
  883.           }
  884. #endif
  885.         }
  886.         DebugRegNo = PrevDebugRegNo;
  887.         beep();
  888.         goto GetExpr;
  889.       }
  890.  
  891.       default:
  892.         beep();
  893.         break;
  894.     }
  895.   }
  896. }
  897.  
  898. /*****************************************************************************/
  899. /* DisplayWhpntChoice()                                                   701*/
  900. /*                                                                           */
  901. /* Description:                                                              */
  902. /*                                                                           */
  903. /*   Displays the details of the watch points in the watch point dialog.     */
  904. /*                                                                           */
  905. /* Parameters:                                                               */
  906. /*                                                                           */
  907. /*   shell   ->  pointer to a dialog shell structure.                        */
  908. /*   ptr     ->  pointer to a dialog choice structure.                       */
  909. /*                                                                           */
  910. /* Return:                                                                   */
  911. /*   none                                                                    */
  912. /*****************************************************************************/
  913. void  DisplayWhPntChoice (DIALOGSHELL *shell,DIALOGCHOICE *ptr)
  914. {
  915.   uint   skip, i, n;
  916.   uchar  *buf;
  917.   uchar  Line[ MAXLINESIZE+1 ];
  918.  
  919.   skip = 3;
  920.  
  921.   for(i=0;i<ptr->MaxRows;i++)
  922.   {
  923.     memset( Line, ' ', MAXLINESIZE );
  924.     Line[ MAXLINESIZE ] = '\0';
  925.     buf = Line;
  926.  
  927.     n = sprintf( buf, "%1d.", i+1 );
  928.     *( buf+n ) = ' ';
  929.     buf = buf + 3;
  930.  
  931.     strncpy( buf, LDebug_Regs[i].Prompt, strlen( LDebug_Regs[i].Prompt ) );
  932.     buf = buf + DISPPROMPTLEN + 1;
  933.  
  934.     strncpy( buf, Sizes[LDebug_Regs[i].Size], 1 );
  935.     buf =  buf + 3;
  936.     if( LDebug_Regs[i].Aligned == TRUE )
  937.        strncpy( buf-1, "*", 1 );
  938.  
  939.     n = sprintf( buf, "%08X", LDebug_Regs[i].Address );
  940.     *( buf+n ) = ' ';
  941.     buf = buf + ADDRESSLEN + 1;
  942.  
  943.     sprintf( buf, "%s %s %s",
  944.                   Scopes[LDebug_Regs[i].Scope],
  945.                   Types[LDebug_Regs[i].Type],
  946.                   Status[LDebug_Regs[i].Status] );
  947.  
  948.     putrc( shell->row+i+skip, shell->col+2, Line );
  949.   }
  950. }
  951.