DebugView.st
changeset 754 1848d4e89bc4
parent 745 89a242c66cda
child 755 94705dbabfe0
equal deleted inserted replaced
753:72a555a0c626 754:1848d4e89bc4
    18 		continueButton stepButton nextButton sendButton returnButton
    18 		continueButton stepButton nextButton sendButton returnButton
    19 		restartButton exclusive inspecting nChainShown inspectedProcess
    19 		restartButton exclusive inspecting nChainShown inspectedProcess
    20 		updateProcess stopButton updateButton monitorToggle stepping
    20 		updateProcess stopButton updateButton monitorToggle stepping
    21 		steppedContextLineno stepForReturn actualContext inWrap
    21 		steppedContextLineno stepForReturn actualContext inWrap
    22 		stackInspector'
    22 		stackInspector'
    23 	classVariableNames:'CachedDebugger CachedExclusive OpenDebuggers MoreDebuggingDetail'
    23 	classVariableNames:'CachedDebugger CachedExclusive OpenDebuggers MoreDebuggingDetail
       
    24 		DebuggingDebugger'
    24 	poolDictionaries:''
    25 	poolDictionaries:''
    25 	category:'Interface-Debugger'
    26 	category:'Interface-Debugger'
    26 !
    27 !
    27 
    28 
    28 !DebugView  class methodsFor:'documentation'!
    29 !DebugView  class methodsFor:'documentation'!
   633         ].
   634         ].
   634         self label:'single stepping - please wait ...'.
   635         self label:'single stepping - please wait ...'.
   635         stepping := true.
   636         stepping := true.
   636 
   637 
   637         ObjectMemory stepInterruptHandler:self.
   638         ObjectMemory stepInterruptHandler:self.
   638         stepForReturn == true ifFalse:[
   639         Context singleStepInterruptRequest isHandled ifTrue:[
   639             Context singleStepInterruptRequest isHandled ifTrue:[
   640             "bigStep" steppedContextLineno notNil ifTrue:[   
   640                 "bigStep" steppedContextLineno notNil ifTrue:[   
   641                 Context singleStepInterruptRequest raiseWith:#next
   641                     Context singleStepInterruptRequest raiseWith:#next
       
   642                 ] ifFalse:[
       
   643                     Context singleStepInterruptRequest raiseWith:#step
       
   644                 ]
       
   645             ] ifFalse:[
   642             ] ifFalse:[
   646                 ObjectMemory flushInlineCaches.
   643                 Context singleStepInterruptRequest raiseWith:#step
       
   644             ]
       
   645         ] ifFalse:[
       
   646             ObjectMemory flushInlineCaches.
       
   647             skipLineNr ~~ #return ifTrue:[
   647                 StepInterruptPending := 1.
   648                 StepInterruptPending := 1.
   648                 InterruptPending := 1.
   649                 InterruptPending := 1.
   649                 InStepInterrupt := nil
   650             ] ifFalse:[
   650             ]
   651                 'step for return' printCR.
       
   652             ].
       
   653             InStepInterrupt := nil
   651         ]
   654         ]
   652     ] ifFalse:[
   655     ] ifFalse:[
   653         OpenDebuggers notNil ifTrue:[
   656         OpenDebuggers notNil ifTrue:[
   654             idx := OpenDebuggers identityIndexOf:self.
   657             idx := OpenDebuggers identityIndexOf:self.
   655             idx ~~ 0 ifTrue:[
   658             idx ~~ 0 ifTrue:[
   659         self cacheMyself.
   662         self cacheMyself.
   660     ]
   663     ]
   661 
   664 
   662     "Created: 24.11.1995 / 19:52:54 / cg"
   665     "Created: 24.11.1995 / 19:52:54 / cg"
   663     "Modified: 3.5.1996 / 23:58:16 / stefan"
   666     "Modified: 3.5.1996 / 23:58:16 / stefan"
   664     "Modified: 26.7.1996 / 16:19:45 / cg"
   667     "Modified: 14.10.1996 / 13:41:19 / cg"
   665 !
   668 !
   666 
   669 
   667 openOn:aProcess
   670 openOn:aProcess
   668     "enter the debugger on a process - 
   671     "enter the debugger on a process - 
   669      in this case, we are just inspecting the context chain of the process,
   672      in this case, we are just inspecting the context chain of the process,
   951     ] ifFalse:[
   954     ] ifFalse:[
   952         labels := resources array:#(
   955         labels := resources array:#(
   953                                     'show more'
   956                                     'show more'
   954                                     '-'
   957                                     '-'
   955                                     'skip'
   958                                     'skip'
       
   959                                     'step out'
   956                                     '-'
   960                                     '-'
   957 "
   961 "
   958                                     'continue'
   962                                     'continue'
   959                                     'terminate'
   963                                     'terminate'
   960                                     'abort'
   964                                     'abort'
   986 
   990 
   987         selectors := #(
   991         selectors := #(
   988                                          showMore
   992                                          showMore
   989                                          nil
   993                                          nil
   990                                          skip
   994                                          skip
       
   995                                          skipForReturn
   991                                          nil
   996                                          nil
   992 "
   997 "
   993                                          doContinue
   998                                          doContinue
   994                                          doTerminate
   999                                          doTerminate
   995                                          doAbort
  1000                                          doAbort
  1030 
  1035 
  1031     inspecting ifTrue:[
  1036     inspecting ifTrue:[
  1032         m notNil ifTrue:[
  1037         m notNil ifTrue:[
  1033             m disableAll:#(doTraceStep removeBreakpoint browse browseClass
  1038             m disableAll:#(doTraceStep removeBreakpoint browse browseClass
  1034                            browseClassHierarchy browseFullClassProtocol
  1039                            browseClassHierarchy browseFullClassProtocol
  1035                            implementors senders inspectContext skip).
  1040                            implementors senders inspectContext skip doStepOut).
  1036         ].
  1041         ].
  1037     ]
  1042     ]
  1038 
  1043 
  1039     "Modified: 27.2.1996 / 14:41:53 / cg"
  1044     "Modified: 14.10.1996 / 13:21:26 / cg"
  1040 !
  1045 !
  1041 
  1046 
  1042 realize
  1047 realize
  1043     super realize.
  1048     super realize.
  1044 "/    exclusive ifTrue:[
  1049 "/    exclusive ifTrue:[
  1069     self label:l.
  1074     self label:l.
  1070 ! !
  1075 ! !
  1071 
  1076 
  1072 !DebugView methodsFor:'interrupt handling'!
  1077 !DebugView methodsFor:'interrupt handling'!
  1073 
  1078 
       
  1079 contextInterrupt
       
  1080     DebuggingDebugger == true ifTrue:[
       
  1081         'contextIRQ' printCR.
       
  1082     ].
       
  1083     ^ self stepOrNext
       
  1084 
       
  1085     "Modified: 14.10.1996 / 13:30:47 / cg"
       
  1086 !
       
  1087 
  1074 stepInterrupt
  1088 stepInterrupt
  1075     |where here s isWrap method lastWrappedConAddr wrappedMethod inBlock left ignore|
  1089     DebuggingDebugger == true ifTrue:[
  1076 
  1090         'stepIRQ' printCR.
  1077     "/
  1091     ].
  1078     "/ should no longer happen
  1092     ^ self stepOrNext
  1079     "/
  1093 
  1080     stepForReturn == true ifTrue:[
  1094     "Modified: 14.10.1996 / 13:30:56 / cg"
  1081 'stepForreturn' printCR.
  1095 !
  1082         self enter:thisContext sender.
  1096 
       
  1097 stepOrNext
       
  1098     |where here s isWrap method lastWrappedConAddr wrappedMethod 
       
  1099      inBlock left ignore contextBelow|
       
  1100 
       
  1101     skipLineNr == #return ifTrue:[
       
  1102         name := Processor activeProcess nameOrId.
       
  1103         self label:('context returned ' , ' (process: ' , name , ')').
       
  1104         here := thisContext sender sender.
       
  1105         here lineNumber printCR.
       
  1106         here := nil.
       
  1107         self enter:thisContext sender sender.
  1083         ^ self
  1108         ^ self
  1084     ].
  1109     ].
       
  1110 
       
  1111 "/    "/
       
  1112 "/    "/ should no longer happen
       
  1113 "/    "/
       
  1114 "/    stepForReturn == true ifTrue:[
       
  1115 "/"/'stepForreturn' printCR.
       
  1116 "/        self enter:thisContext sender.
       
  1117 "/        ^ self
       
  1118 "/    ].
  1085 
  1119 
  1086     Processor activeProcess ~~ inspectedProcess ifTrue:[
  1120     Processor activeProcess ~~ inspectedProcess ifTrue:[
  1087         'stray step interrupt' errorPrintNL.
  1121         'stray step interrupt' errorPrintNL.
  1088         ^ self
  1122         ^ self
  1089     ].
  1123     ].
  1092      kludge to hide breakpoint wrappers in the context list: 
  1126      kludge to hide breakpoint wrappers in the context list: 
  1093          check if we are in a wrapper methods hidden setup-sequence
  1127          check if we are in a wrapper methods hidden setup-sequence
  1094          if so, ignore the interrupt and continue single sending
  1128          if so, ignore the interrupt and continue single sending
  1095     "
  1129     "
  1096     here := thisContext.        "stepInterrupt"
  1130     here := thisContext.        "stepInterrupt"
       
  1131     here := here sender.        "the caller; step- or contextIRQ"  
  1097     here := here sender.        "the interrupted context"  
  1132     here := here sender.        "the interrupted context"  
  1098 
  1133 
  1099 "/ '*******' printNL.
  1134     DebuggingDebugger == true ifTrue:[
  1100 "/ 'here in ' print.
  1135         '*******' printNL.
  1101 "/  ((ObjectMemory addressOf:here) printStringRadix:16)print. '' printNL.
  1136         'here in ' print.
       
  1137         ((ObjectMemory addressOf:here) printStringRadix:16) print. ' ' print.
       
  1138         here selector printNL.
       
  1139     ].
  1102 
  1140 
  1103     where := here.
  1141     where := here.
  1104     isWrap := false.
  1142     isWrap := false.
  1105     left := false.
  1143     left := false.
  1106 
  1144 
  1136             ]
  1174             ]
  1137         ].
  1175         ].
  1138     ].
  1176     ].
  1139 
  1177 
  1140     isWrap ifTrue:[
  1178     isWrap ifTrue:[
  1141 "/ 'ignore wrap' printNL.
  1179         DebuggingDebugger == true ifTrue:[
  1142 "/ ' ' printNL.
  1180             'ignore wrap' printNL.
  1143         "
  1181         ].
  1144           ignore, while in wrappers hidden setup
  1182 
  1145         "
  1183         "/
       
  1184         "/ ignore, while in wrappers hidden setup
       
  1185         "/
  1146         where := nil. here := nil.
  1186         where := nil. here := nil.
  1147         ObjectMemory flushInlineCaches.
  1187         ObjectMemory flushInlineCaches.
       
  1188         
       
  1189         skipLineNr == #return ifTrue:[
       
  1190             'skipRet in wrap' printCR.
       
  1191         ].
       
  1192 
  1148         StepInterruptPending := 1.
  1193         StepInterruptPending := 1.
  1149         InterruptPending := 1.
  1194         InterruptPending := 1.
  1150         InStepInterrupt := nil.
  1195         InStepInterrupt := nil.
  1151         ^ nil
  1196         ^ nil
  1152     ].
  1197     ].
  1153 
  1198 
  1154     inBlock := false.
  1199     inBlock := false.
  1155 
  1200 
  1156     "
  1201     "/
  1157      is this for a send or a step/next ?
  1202     "/ is this for a send or a step/next ?
  1158     "
  1203     "/
  1159     bigStep ifTrue:[
  1204     bigStep ifTrue:[
  1160         "
  1205         "
  1161          a step or next - ignore all contexts below the interesting one
  1206          a step or next - ignore all contexts below the interesting one
  1162         "
  1207         "
  1163         where := here.      "the interrupted context"
  1208         where := here.      "the interrupted context"
       
  1209         contextBelow := nil.
  1164 
  1210 
  1165         where home notNil ifTrue:[
  1211         where home notNil ifTrue:[
  1166             "/
  1212             "/
  1167             "/ in a block called by 'our' context ?
  1213             "/ in a block called by 'our' context ?
  1168             "/
  1214             "/
  1192                   interrupted context. Not using context-ref but its
  1238                   interrupted context. Not using context-ref but its
  1193                   address to avoid creation of many useless contexts.)
  1239                   address to avoid creation of many useless contexts.)
  1194                 "
  1240                 "
  1195                 inBlock ifFalse:[
  1241                 inBlock ifFalse:[
  1196                     [where notNil] whileTrue:[
  1242                     [where notNil] whileTrue:[
  1197 "/  ((ObjectMemory addressOf:where) printStringRadix:16)print. ' ' print.
  1243 
  1198 "/  where selector printNL.
  1244                         DebuggingDebugger == true ifTrue:[
       
  1245                             ((ObjectMemory addressOf:where) printStringRadix:16)print. ' ' print.
       
  1246                             where selector printNL.
       
  1247                         ].
       
  1248 
  1199                         (ObjectMemory addressOf:where) == steppedContextAddress ifTrue:[
  1249                         (ObjectMemory addressOf:where) == steppedContextAddress ifTrue:[
  1200 "/ 'found it - below; ignore' printNL.
  1250 "/ 'found it - below; ignore' printNL.
  1201                             "
  1251                             "
  1202                              found the interesting context somwehere up in the
  1252                              found the interesting context somwehere up in the
  1203                              chain. We seem to be still below the interesting one ...
  1253                              chain. We seem to be still below the interesting one ...
  1211                               - continue and schedule another stepInterrupt.
  1261                               - continue and schedule another stepInterrupt.
  1212                               Must flush caches since optimized methods not always
  1262                               Must flush caches since optimized methods not always
  1213                               look for pending interrupts
  1263                               look for pending interrupts
  1214                             "
  1264                             "
  1215                             ObjectMemory flushInlineCaches.
  1265                             ObjectMemory flushInlineCaches.
  1216                             StepInterruptPending := 1.
  1266                             contextBelow notNil ifTrue:[
  1217                             InterruptPending := 1.
  1267 "/ 'prepare for unwind-catch' printNL.
       
  1268 "/ 'con= ' print. contextBelow printCR.
       
  1269                                 Processor activeProcess forceInterruptOnReturnOf:contextBelow.
       
  1270                                 StepInterruptPending := nil.
       
  1271                             ] ifFalse:[
       
  1272                                 StepInterruptPending := 1.
       
  1273                                 InterruptPending := 1.
       
  1274                             ].
  1218                             InStepInterrupt := nil.
  1275                             InStepInterrupt := nil.
  1219                             ^ nil
  1276                             ^ nil
  1220                         ].
  1277                         ].
       
  1278                         contextBelow := where.
  1221                         where := where sender
  1279                         where := where sender
  1222                     ].
  1280                     ].
  1223                     s := 'left stepped method'.
  1281                     s := 'left stepped method'.
  1224                     left := true.
  1282                     left := true.
  1225                 ].
  1283                 ].
  1243     inBlock ifTrue:[
  1301     inBlock ifTrue:[
  1244 "/ 'inBlock' printNL.
  1302 "/ 'inBlock' printNL.
  1245         s := 'in block'.
  1303         s := 'in block'.
  1246     ].
  1304     ].
  1247 
  1305 
  1248     where notNil ifTrue:[
  1306     DebuggingDebugger == true ifTrue:[
  1249         '(' print. steppedContextLineno print. ') ' print.
  1307         where notNil ifTrue:[
  1250         where print.
  1308             '(' print. steppedContextLineno print. ') ' print.
  1251         '[' print. where lineNumber print. ']' printNL.
  1309             where print.
       
  1310             '[' print. where lineNumber print. ']' printNL.
       
  1311         ].
  1252     ].
  1312     ].
  1253 
  1313 
  1254     ignore := false.
  1314     ignore := false.
  1255 
  1315 
  1256     (bigStep 
  1316     (bigStep 
  1263 
  1323 
  1264     (left not 
  1324     (left not 
  1265     and:[skipLineNr notNil 
  1325     and:[skipLineNr notNil 
  1266     and:[where lineNumber < skipLineNr]]) ifTrue:[
  1326     and:[where lineNumber < skipLineNr]]) ifTrue:[
  1267 "/ 'skip (' print. skipLineNr print. ' unreached - ignored' printNL.
  1327 "/ 'skip (' print. skipLineNr print. ' unreached - ignored' printNL.
       
  1328         ignore := true
       
  1329     ].
       
  1330 
       
  1331     (steppedContextLineno isNil 
       
  1332     and:[skipLineNr isNil
       
  1333     and:[thisContext sender selector == #contextInterrupt]]) ifTrue:[
       
  1334 "/ 'same line2 (after conIRQ) - ignored' printNL.
  1268         ignore := true
  1335         ignore := true
  1269     ].
  1336     ].
  1270 
  1337 
  1271     ignore ifTrue:[
  1338     ignore ifTrue:[
  1272 "/' ' printNL.
  1339 "/' ' printNL.
  1292     tracing := false.
  1359     tracing := false.
  1293     bigStep := false.
  1360     bigStep := false.
  1294 
  1361 
  1295     "release refs to context"
  1362     "release refs to context"
  1296     where := nil. here := nil.
  1363     where := nil. here := nil.
  1297 'enter' printCR.
  1364 "/'enter' printCR.
  1298     self enter:thisContext sender
  1365     self enter:thisContext sender sender
  1299 
  1366 
  1300     "Modified: 1.7.1996 / 11:35:44 / cg"
  1367     "Created: 14.10.1996 / 12:53:39 / cg"
       
  1368     "Modified: 14.10.1996 / 13:50:53 / cg"
  1301 ! !
  1369 ! !
  1302 
  1370 
  1303 !DebugView methodsFor:'menu / button actions'!
  1371 !DebugView methodsFor:'menu / button actions'!
  1304 
  1372 
  1305 autoUpdateOff
  1373 autoUpdateOff
  1557 
  1625 
  1558     self doStep:-1 
  1626     self doStep:-1 
  1559 !
  1627 !
  1560 
  1628 
  1561 doStep:lineNr
  1629 doStep:lineNr
  1562     "step until we pass lineNr (if nonNil) or to next line (if nil)
  1630     "common helper for step, skip & next.
  1563      or to next send (if -1)"
  1631      Arrange for single-steppping until we pass lineNr (if nonNil) 
       
  1632      or to next line (if nil) or to next send (if -1)"
  1564 
  1633 
  1565     |con method|
  1634     |con method|
  1566 
  1635 
  1567     inspecting ifTrue:[^ self].
  1636     inspecting ifTrue:[^ self].
  1568 
  1637 
  1572             steppedContextLineno := actualContext lineNumber.
  1641             steppedContextLineno := actualContext lineNumber.
  1573         ] ifFalse:[
  1642         ] ifFalse:[
  1574             con := contextArray at:2.
  1643             con := contextArray at:2.
  1575             steppedContextLineno := con lineNumber.
  1644             steppedContextLineno := con lineNumber.
  1576         ].
  1645         ].
       
  1646 
  1577         skipLineNr := lineNr.
  1647         skipLineNr := lineNr.
  1578 
  1648 
  1579         lineNr == -1 ifTrue:[
  1649         lineNr == -1 ifTrue:[
  1580             steppedContextLineno := skipLineNr := nil.
  1650             steppedContextLineno := skipLineNr := nil.
  1581         ].
  1651         ].
  1582 
  1652 
  1583         steppedContextAddress := ObjectMemory addressOf:con.
  1653         steppedContextAddress := ObjectMemory addressOf:con.
       
  1654 
  1584         "
  1655         "
  1585          if we step in a wrapped method,
  1656          if we step in a wrapped method,
  1586          prepare to skip the prolog ...
  1657          prepare to skip the prolog ...
  1587         "
  1658         "
  1588 "/ ' step con:' print. steppedContextAddress printHex. ' ' printNL.
  1659 "/ ' step con:' print. steppedContextAddress printHex. ' ' printNL.
  1590         method := con method.
  1661         method := con method.
  1591         (method notNil and:[method isWrapped]) ifTrue:[
  1662         (method notNil and:[method isWrapped]) ifTrue:[
  1592             inWrap := true
  1663             inWrap := true
  1593         ].
  1664         ].
  1594 
  1665 
       
  1666         lineNr == #return ifTrue:[
       
  1667             Processor activeProcess forceInterruptOnReturnOf:con.
       
  1668         ].
       
  1669 
  1595         con := nil.
  1670         con := nil.
  1596         bigStep := true.
  1671         bigStep := true.
  1597         haveControl := false.
  1672         haveControl := false.
  1598         exitAction := #step.
  1673         exitAction := #step.
  1599 
  1674 
  1605         stepButton turnOff.
  1680         stepButton turnOff.
  1606         nextButton turnOff.
  1681         nextButton turnOff.
  1607         sendButton turnOff.
  1682         sendButton turnOff.
  1608     ]
  1683     ]
  1609 
  1684 
  1610     "Modified: 29.5.1996 / 13:19:38 / cg"
  1685     "Modified: 14.10.1996 / 13:23:33 / cg"
  1611 !
  1686 !
  1612 
  1687 
  1613 doStop
  1688 doStop
  1614     "stop the process (if its running, otherwise this is a no-op)"
  1689     "stop the process (if its running, otherwise this is a no-op)"
  1615 
  1690 
  1785 
  1860 
  1786 skip
  1861 skip
  1787     "skip for cursor line in selected method"
  1862     "skip for cursor line in selected method"
  1788 
  1863 
  1789     self doStep:codeView cursorLine.
  1864     self doStep:codeView cursorLine.
       
  1865 !
       
  1866 
       
  1867 skipForReturn
       
  1868     "skip until context is left."
       
  1869 
       
  1870     self doStep:#return.
       
  1871 
       
  1872     "Modified: 14.10.1996 / 13:22:46 / cg"
  1790 ! !
  1873 ! !
  1791 
  1874 
  1792 !DebugView methodsFor:'private'!
  1875 !DebugView methodsFor:'private'!
  1793 
  1876 
  1794 busy
  1877 busy
  2655 ! !
  2738 ! !
  2656 
  2739 
  2657 !DebugView  class methodsFor:'documentation'!
  2740 !DebugView  class methodsFor:'documentation'!
  2658 
  2741 
  2659 version
  2742 version
  2660     ^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.100 1996-10-04 09:21:57 cg Exp $'
  2743     ^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.101 1996-10-14 13:41:21 cg Exp $'
  2661 ! !
  2744 ! !