DebugView.st
changeset 19020 7c16c8db82dd
parent 18863 8ca8ff8081a1
child 19030 892df81100b6
equal deleted inserted replaced
19019:88062aff617b 19020:7c16c8db82dd
    35 		hideSupportCode contextInfoLabel resendButton
    35 		hideSupportCode contextInfoLabel resendButton
    36 		gotoDialogOpenerButton isStoppedInModalDialog selectorToDefine
    36 		gotoDialogOpenerButton isStoppedInModalDialog selectorToDefine
    37 		classToDefineIn gotoApplicationActionMethodButton
    37 		classToDefineIn gotoApplicationActionMethodButton
    38 		isStoppedInApplicationAction isStoppedAtStatementBreakpoint
    38 		isStoppedInApplicationAction isStoppedAtStatementBreakpoint
    39 		verboseBacktraceHolder foundRaisingMethod gotoRaisingMethodButton
    39 		verboseBacktraceHolder foundRaisingMethod gotoRaisingMethodButton
    40 		stepInButton infoLabelHolder isStoppedAtError'
    40 		stepInButton infoLabelHolder isStoppedAtError isStoppedAtAssert'
    41 	classVariableNames:'CachedDebugger CachedExclusive OpenDebuggers MoreDebuggingDetail
    41 	classVariableNames:'CachedDebugger CachedExclusive OpenDebuggers MoreDebuggingDetail
    42 		DebuggingDebugger DebuggingDebugger2 DebuggingContextWalk
    42 		DebuggingDebugger DebuggingDebugger2 DebuggingContextWalk
    43 		DefaultDebuggerBackgroundColor InitialNChainShown IgnoredHalts
    43 		DefaultDebuggerBackgroundColor InitialNChainShown IgnoredHalts
    44 		ShowThreadID LastIgnoreHaltNTimes LastIgnoreHaltDuration
    44 		ShowThreadID LastIgnoreHaltNTimes LastIgnoreHaltDuration
    45 		LastExtent LastOrigin RememberedCallChain DebuggingDebugger3
    45 		LastExtent LastOrigin RememberedCallChain DebuggingDebugger3
    46 		NumberOfDebuggers DebuggerOnMainDisplayOnly IgnoredErrors'
    46 		NumberOfDebuggers DebuggerOnMainDisplayOnly IgnoredErrors
       
    47 		IgnoredAsserts'
    47 	poolDictionaries:''
    48 	poolDictionaries:''
    48 	category:'Interface-Debugger'
    49 	category:'Interface-Debugger'
    49 !
    50 !
    50 
    51 
    51 Object subclass:#IgnoredHaltOrBreakpoint
    52 Object subclass:#IgnoredHaltOrBreakpoint
   301 hasIgnoredHalts
   302 hasIgnoredHalts
   302     self removeInactiveIgnores.
   303     self removeInactiveIgnores.
   303     ^ IgnoredHalts notEmptyOrNil
   304     ^ IgnoredHalts notEmptyOrNil
   304 !
   305 !
   305 
   306 
       
   307 ignoreAssertIn:haltingMethod at:lineNrOfHalt
       
   308         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
       
   309         orReceiverClass:receiverClassOrNil orProcess:processOrNil
       
   310         orIfCalledFromMethod:ifCalledForMethodOrNil
       
   311 
       
   312     "remember to ignore an assert in some method for some number of invocations
       
   313      or until some time has elapsed. 
       
   314      With a count of -1, it is ignored forever (i.e. until reenabled via the settings).
       
   315      With nil count and time arguments, such an ignored assert is reactivated"
       
   316 
       
   317     self
       
   318         ignoreHaltOrBreakpoint:#assert
       
   319         method:haltingMethod line:lineNrOfHalt
       
   320         parameter:nil
       
   321         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
       
   322         orReceiverClass:receiverClassOrNil orProcess:processOrNil
       
   323         orIfCalledFromMethod:ifCalledForMethodOrNil
       
   324 !
       
   325 
   306 ignoreBreakpointWithParameter:parameterOrNil
   326 ignoreBreakpointWithParameter:parameterOrNil
   307         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
   327         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
   308         orReceiverClass:receiverClassOrNil orProcess:processOrNil
   328         orReceiverClass:receiverClassOrNil orProcess:processOrNil
   309 
   329 
   310     "remember to ignore a breakpoint with a parameter (i.e. breakpoint:#cg) for some number of invocations
   330     "remember to ignore a breakpoint with a parameter (i.e. breakpoint:#cg) 
   311      or until some time has elapsed.
   331      for some number of invocations or until some time has elapsed.
   312      With nil count and time arguments, such an ignored breakpoint is reactivated"
   332      With nil count and time arguments, such an ignored breakpoint is reactivated"
   313 
   333 
   314     self
   334     self
   315         ignoreHaltOrBreakpoint:#halt
   335         ignoreHaltOrBreakpoint:#halt
   316         method:nil line:nil
   336         method:nil line:nil
   323 ignoreErrorIn:methodOrNil line:lineNrOrNil 
   343 ignoreErrorIn:methodOrNil line:lineNrOrNil 
   324         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
   344         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
   325         orReceiverClass:receiverClassOrNil orProcess:processOrNil
   345         orReceiverClass:receiverClassOrNil orProcess:processOrNil
   326         orIfCalledFromMethod:ifCalledFromMethodOrNil
   346         orIfCalledFromMethod:ifCalledFromMethodOrNil
   327 
   347 
   328     "remember to ignore an error, either forEver, for some number of invocations
   348     "remember to ignore an error, either forEver, for some number of invocations,
   329      or until some time has elapsed.
   349      or until some time has elapsed.
   330      With nil count and time arguments, such an ignored error is reactivated"
   350      With nil count and time arguments, such an ignored error is reactivated"
   331 
   351 
   332     |oldEntry ign|
   352     |oldEntry ign|
   333 
   353 
   391 
   411 
   392 ignoreHaltIn:haltingMethod at:lineNrOfHalt
   412 ignoreHaltIn:haltingMethod at:lineNrOfHalt
   393         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
   413         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
   394         orReceiverClass:receiverClassOrNil orProcess:processOrNil
   414         orReceiverClass:receiverClassOrNil orProcess:processOrNil
   395 
   415 
   396     "remember to ignore a halt in some method for some number of invocations
   416     "remember to ignore a halt in some method for some number of invocations,
   397      or until some time has elapsed.
   417      or until some time has elapsed.
   398      With nil count and time arguments, such an ignored halt is reactivated"
   418      With nil count and time arguments, such an ignored halt is reactivated"
   399 
   419 
   400     self
   420     self
   401         ignoreHaltOrBreakpoint:#halt
   421         ignoreHaltOrBreakpoint:#halt
   411         orReceiverClass:receiverClassOrNil orProcess:processOrNil
   431         orReceiverClass:receiverClassOrNil orProcess:processOrNil
   412         orIfCalledFromMethod:ifCalledForMethodOrNil
   432         orIfCalledFromMethod:ifCalledForMethodOrNil
   413 
   433 
   414     "remember to ignore a halt in some method for some number of invocations
   434     "remember to ignore a halt in some method for some number of invocations
   415      or until some time has elapsed. 
   435      or until some time has elapsed. 
   416      With a count of -1, it is ignored forever (i.e. until reenabled via the
   436      With a count of -1, it is ignored forever (i.e. until reenabled via the settings).
   417      settings).
       
   418      With nil count and time arguments, such an ignored halt is reactivated"
   437      With nil count and time arguments, such an ignored halt is reactivated"
   419 
   438 
   420     self
   439     self
   421         ignoreHaltOrBreakpoint:#halt
   440         ignoreHaltOrBreakpoint:#halt
   422         method:haltingMethod line:lineNrOfHalt
   441         method:haltingMethod line:lineNrOfHalt
   428 
   447 
   429 ignoreHaltOrBreakpoint:type method:methodOrNil line:lineNrOfHaltOrNil parameter:parameterOrNil
   448 ignoreHaltOrBreakpoint:type method:methodOrNil line:lineNrOfHaltOrNil parameter:parameterOrNil
   430         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
   449         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
   431         orReceiverClass:receiverClassOrNil orProcess:processOrNil
   450         orReceiverClass:receiverClassOrNil orProcess:processOrNil
   432 
   451 
   433     "remember to ignore a breakpoint with a parameter (i.e. breakpoint:#cg) for some number of invocations
   452     "remember to ignore a breakpoint with a parameter (i.e. breakpoint:#cg) 
   434      or until some time has elapsed.
   453      for some number of invocations or until some time has elapsed.
   435      With nil count and time arguments, such an ignored breakpoint is reactivated"
   454      With nil count and time arguments, such an ignored breakpoint is reactivated"
   436 
   455 
   437     ^ self
   456     ^ self
   438         ignoreHaltOrBreakpoint:type method:methodOrNil line:lineNrOfHaltOrNil parameter:parameterOrNil
   457         ignoreHaltOrBreakpoint:type method:methodOrNil line:lineNrOfHaltOrNil parameter:parameterOrNil
   439         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
   458         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
   444 ignoreHaltOrBreakpoint:type method:methodOrNil line:lineNrOfHaltOrNil parameter:parameterOrNil
   463 ignoreHaltOrBreakpoint:type method:methodOrNil line:lineNrOfHaltOrNil parameter:parameterOrNil
   445         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
   464         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
   446         orReceiverClass:receiverClassOrNil orProcess:processOrNil
   465         orReceiverClass:receiverClassOrNil orProcess:processOrNil
   447         orIfCalledFromMethod:ifCalledFromMethodOrNil
   466         orIfCalledFromMethod:ifCalledFromMethodOrNil
   448 
   467 
   449     "remember to ignore a breakpoint with a parameter (i.e. breakpoint:#cg) for some number of invocations
   468     "remember to ignore a breakpoint with a parameter (i.e. breakpoint:#cg) 
   450      or until some time has elapsed.
   469      for some number of invocations or until some time has elapsed.
   451      With nil count and time arguments, such an ignored breakpoint is reactivated"
   470      With nil count and time arguments, such an ignored breakpoint is reactivated"
   452 
   471 
   453     |oldEntry ign|
   472     |oldEntry ign|
   454 
   473 
   455     IgnoredHalts notNil ifTrue:[
   474     IgnoredHalts notNil ifTrue:[
   515     ].
   534     ].
   516     Smalltalk changed:#ignoredHalts.
   535     Smalltalk changed:#ignoredHalts.
   517 
   536 
   518     "Created: / 06-03-2012 / 12:37:58 / cg"
   537     "Created: / 06-03-2012 / 12:37:58 / cg"
   519     "Modified: / 05-06-2018 / 18:34:17 / Claus Gittinger"
   538     "Modified: / 05-06-2018 / 18:34:17 / Claus Gittinger"
       
   539 !
       
   540 
       
   541 isAssertToBeIgnoredIn:haltingMethod atLineNr:lineNrInHaltingMethod context:aContext modifyEntryCount:modifyCount
       
   542     "should an assert be ignored ?"
       
   543 
       
   544     IgnoredAsserts isNil ifTrue:[^ false].
       
   545 
       
   546     "/ Transcript showCR:'halt/break in ',haltingMethod printString,' at ',lineNrInHaltingMethod printString.
       
   547     IgnoredAsserts do:[:ign |
       
   548         (ign isAssertIgnoredInMethod:haltingMethod line:lineNrInHaltingMethod context:aContext) ifTrue:[
       
   549             Transcript showCR:'Debugger [info]: assert ignored: %1' with:ign.
       
   550 
       
   551             modifyCount ifTrue:[ ign decrementIgnoreCount ].
       
   552             ign isHaltIgnored ifFalse:[
       
   553                 Transcript showCR:'Debugger [info]: no longer ignored (rest count=0)'.
       
   554                 IgnoredHalts remove:ign ifAbsent:[].
       
   555             ].
       
   556             ^ true.
       
   557         ].
       
   558     ].
       
   559 
       
   560     IgnoredAsserts := (IgnoredAsserts reject:[:ign | ign isActive not]) asNilIfEmpty.
       
   561 
       
   562     ^ false.
       
   563 
       
   564     "Modified (comment): / 06-03-2012 / 12:51:43 / cg"
   520 !
   565 !
   521 
   566 
   522 isBreakpointToBeIgnoredForParameter:parameter context:aContext modifyEntryCount:modifyCount
   567 isBreakpointToBeIgnoredForParameter:parameter context:aContext modifyEntryCount:modifyCount
   523     "/ should a breakpoint be ignored ?
   568     "/ should a breakpoint be ignored ?
   524 
   569 
  1049          (MenuItem
  1094          (MenuItem
  1050             label: '-'
  1095             label: '-'
  1051           )
  1096           )
  1052          (MenuItem
  1097          (MenuItem
  1053             label: 'Ignore this Halt/BreakPoint'
  1098             label: 'Ignore this Halt/BreakPoint'
       
  1099             enabled: isStoppedAtHaltOrBreakPointOrSelectedContextIsWrappedAndHasPreviousIgnoreTime
  1054             submenu: 
  1100             submenu: 
  1055            (Menu
  1101            (Menu
  1056               (
  1102               (
  1057                (MenuItem
  1103                (MenuItem
  1058                   enabled: isStoppedAtHaltOrBreakPointOrSelectedContextIsWrapped
  1104                   enabled: isStoppedAtHaltOrBreakPointOrSelectedContextIsWrapped
  1149                )
  1195                )
  1150               nil
  1196               nil
  1151               nil
  1197               nil
  1152             )
  1198             )
  1153           )
  1199           )
       
  1200 
  1154          (MenuItem
  1201          (MenuItem
  1155             label: 'Ignore all Halts/BreakPoints'
  1202             label: 'Ignore all Halts/BreakPoints'
  1156             submenu: 
  1203             submenu: 
  1157            (Menu
  1204            (Menu
  1158               (
  1205               (
  1175           )
  1222           )
  1176          (MenuItem
  1223          (MenuItem
  1177             enabled: hasHaltsToIgnore
  1224             enabled: hasHaltsToIgnore
  1178             label: 'Stop Ignoring'
  1225             label: 'Stop Ignoring'
  1179             itemValue: stopIgnoringHalts
  1226             itemValue: stopIgnoringHalts
       
  1227           )
       
  1228          (MenuItem
       
  1229             label: '-'
       
  1230           )
       
  1231          (MenuItem
       
  1232             label: 'Ignore this Assertion'
       
  1233             enabled: isStoppedAtAssert
       
  1234             submenu: 
       
  1235            (Menu
       
  1236               (
       
  1237                (MenuItem
       
  1238                   enabled: isStoppedAtAssert
       
  1239                   label: 'Forever (Until Ignoring is Stopped)'
       
  1240                   itemValue: ignoreAssertionForever
       
  1241                 )
       
  1242                (MenuItem
       
  1243                   enabled: isStoppedAtAssert
       
  1244                   label: 'For Some Time...'
       
  1245                   itemValue: openIgnoreAssertionUntilTimeElapsedDialog
       
  1246                 )
       
  1247                (MenuItem
       
  1248                   label: 'For Another Timeduration'
       
  1249                   itemValue: ignoreAssertionUntilAnotherTimeDurationElapsed
       
  1250                   isVisible: isStoppedAtAssertAndHasPreviousIgnoreTime
       
  1251                 )
       
  1252                (MenuItem
       
  1253                   enabled: isStoppedAtAssert
       
  1254                   label: 'For the Next N Times...'
       
  1255                   itemValue: openIgnoreAssertionNTimesDialog
       
  1256                 )
       
  1257                (MenuItem
       
  1258                   enabled: isStoppedAtAssert
       
  1259                   label: 'Until Shift-Key is Pressed'
       
  1260                   itemValue: ignoreAssertionUntilShiftKeyIsPressed
       
  1261                 )
       
  1262                (MenuItem
       
  1263                   label: '-'
       
  1264                 )
       
  1265                (MenuItem
       
  1266                   enabled: isStoppedAtAssert
       
  1267                   label: 'In Current Process'
       
  1268                   itemValue: ignoreAssertionForCurrentProcess
       
  1269                 )
       
  1270                (MenuItem
       
  1271                   enabled: isStoppedAtAssert
       
  1272                   label: 'For this Receiver Class'
       
  1273                   itemValue: ignoreAssertionForThisReceiverClass
       
  1274                 )
       
  1275                (MenuItem
       
  1276                   enabled: isStoppedAtAssert
       
  1277                   label: 'If Called From'
       
  1278                   submenuChannel: menuForIgnoreAssertionIfCalledFromAnyOf
       
  1279                 )
       
  1280                )
       
  1281               nil
       
  1282               nil
       
  1283             )
  1180           )
  1284           )
  1181          (MenuItem
  1285          (MenuItem
  1182             label: '-'
  1286             label: '-'
  1183           )
  1287           )
  1184          (MenuItem
  1288          (MenuItem
  2128     "Modified: / 01-02-2018 / 23:35:30 / stefan"
  2232     "Modified: / 01-02-2018 / 23:35:30 / stefan"
  2129 ! !
  2233 ! !
  2130 
  2234 
  2131 !DebugView class methodsFor:'private'!
  2235 !DebugView class methodsFor:'private'!
  2132 
  2236 
       
  2237 assertSelectors
       
  2238     "these can be ignored via the menu"
       
  2239     
       
  2240     ^ #( 
       
  2241         #'assert:' #'assert:description:' #'assert:message:' #'assertNotNil'   
       
  2242     ).
       
  2243 
       
  2244     "Created: / 27-02-2019 / 13:38:12 / Claus Gittinger"
       
  2245 !
       
  2246 
  2133 errorSelectors
  2247 errorSelectors
  2134     "these can be ignored via the menu"
  2248     "these can be ignored via the menu"
  2135     
  2249     
  2136     ^ #( 
  2250     ^ #( 
  2137         #'subclassResponsibility' #'subclassResponsibility:' 
  2251         #'subclassResponsibility' #'subclassResponsibility:' 
  7034 
  7148 
  7035 doNotIgnoreBreakpoints
  7149 doNotIgnoreBreakpoints
  7036     self allowBreakPointsInDebugger:true
  7150     self allowBreakPointsInDebugger:true
  7037 !
  7151 !
  7038 
  7152 
       
  7153 ignoreAllAssertsForCurrentProcess
       
  7154     self
       
  7155         addIgnoredAssertForCount:nil orTimeDuration:nil orUntilShiftKey:false
       
  7156         orThisReceiverClass:false orCurrentProcess:true
       
  7157         orIfCalledFromMethod:nil
       
  7158         forAll:true.
       
  7159 
       
  7160     "Created: / 27-01-2012 / 11:32:14 / cg"
       
  7161 !
       
  7162 
       
  7163 ignoreAllAssertsForThisReceiverClass
       
  7164     self
       
  7165         addIgnoredAssertForCount:nil orTimeDuration:nil orUntilShiftKey:false
       
  7166         orThisReceiverClass:true orCurrentProcess:false
       
  7167         orIfCalledFromMethod:nil
       
  7168         forAll:true.
       
  7169 
       
  7170     "Created: / 27-01-2012 / 11:32:14 / cg"
       
  7171 !
       
  7172 
       
  7173 ignoreAllAssertsForever
       
  7174     self
       
  7175         addIgnoredAssertForCount:-1 orTimeDuration:nil orUntilShiftKey:false
       
  7176         orThisReceiverClass:false orCurrentProcess:false
       
  7177         orIfCalledFromMethod:nil
       
  7178         forAll:true.
       
  7179 
       
  7180     "Created: / 08-05-2011 / 10:19:56 / cg"
       
  7181 !
       
  7182 
       
  7183 ignoreAllAssertsIfCalledFromMethod:aMethod
       
  7184     self
       
  7185         addIgnoredAssertForCount:nil orTimeDuration:nil orUntilShiftKey:false
       
  7186         orThisReceiverClass:false orCurrentProcess:false
       
  7187         orIfCalledFromMethod:aMethod
       
  7188         forAll:true.
       
  7189 !
       
  7190 
       
  7191 ignoreAllAssertsUntilShiftKeyIsPressed
       
  7192     self
       
  7193         addIgnoredAssertForCount:nil orTimeDuration:nil orUntilShiftKey:true
       
  7194         orThisReceiverClass:false orCurrentProcess:false
       
  7195         orIfCalledFromMethod:nil
       
  7196         forAll:true.
       
  7197 
       
  7198     "Created: / 27-01-2012 / 11:32:14 / cg"
       
  7199 !
       
  7200 
  7039 ignoreAllHaltsForCurrentProcess
  7201 ignoreAllHaltsForCurrentProcess
  7040     self
  7202     self
  7041         addIgnoredHaltForCount:nil orTimeDuration:nil orUntilShiftKey:false
  7203         addIgnoredHaltForCount:nil orTimeDuration:nil orUntilShiftKey:false
  7042         orThisReceiverClass:false orCurrentProcess:true
  7204         orThisReceiverClass:false orCurrentProcess:true
  7043         orIfCalledFromMethod:nil
  7205         orIfCalledFromMethod:nil
  7080         orThisReceiverClass:false orCurrentProcess:false
  7242         orThisReceiverClass:false orCurrentProcess:false
  7081         orIfCalledFromMethod:nil
  7243         orIfCalledFromMethod:nil
  7082         forAll:true.
  7244         forAll:true.
  7083 
  7245 
  7084     "Created: / 27-01-2012 / 11:32:14 / cg"
  7246     "Created: / 27-01-2012 / 11:32:14 / cg"
       
  7247 !
       
  7248 
       
  7249 ignoreAssertForCurrentProcess
       
  7250     self
       
  7251         addIgnoredAssertForCount:nil orTimeDuration:nil orUntilShiftKey:false
       
  7252         orThisReceiverClass:false orCurrentProcess:true
       
  7253         orIfCalledFromMethod:nil
       
  7254         forAll:false.
       
  7255 
       
  7256     "Created: / 27-01-2012 / 11:32:14 / cg"
       
  7257 !
       
  7258 
       
  7259 ignoreAssertForThisReceiverClass
       
  7260     self
       
  7261         addIgnoredAssertForCount:nil orTimeDuration:nil orUntilShiftKey:false
       
  7262         orThisReceiverClass:true orCurrentProcess:false
       
  7263         orIfCalledFromMethod:nil
       
  7264         forAll:false.
       
  7265 
       
  7266     "Created: / 27-01-2012 / 11:32:14 / cg"
       
  7267 !
       
  7268 
       
  7269 ignoreAssertForever
       
  7270     self
       
  7271         addIgnoredAssertForCount:-1 orTimeDuration:nil orUntilShiftKey:false
       
  7272         orThisReceiverClass:false orCurrentProcess:false
       
  7273         orIfCalledFromMethod:nil
       
  7274         forAll:false.
       
  7275 
       
  7276     "Modified: / 27-01-2012 / 11:31:37 / cg"
       
  7277 !
       
  7278 
       
  7279 ignoreAssertIfCalledFromMethod:aMethod
       
  7280     self
       
  7281         addIgnoredAssertForCount:nil orTimeDuration:nil orUntilShiftKey:false
       
  7282         orThisReceiverClass:false orCurrentProcess:false
       
  7283         orIfCalledFromMethod:aMethod
       
  7284         forAll:false.
       
  7285 !
       
  7286 
       
  7287 ignoreAssertUntilAnotherTimeDurationElapsed
       
  7288     self
       
  7289         addIgnoredAssertForCount:nil orTimeDuration:LastIgnoreHaltDuration orUntilShiftKey:false
       
  7290         orThisReceiverClass:false orCurrentProcess:false
       
  7291         orIfCalledFromMethod:nil
       
  7292         forAll:false.
       
  7293 
       
  7294     "Created: / 09-11-2018 / 20:40:17 / Claus Gittinger"
       
  7295 !
       
  7296 
       
  7297 ignoreAssertUntilShiftKeyIsPressed
       
  7298     self
       
  7299         addIgnoredAssertForCount:nil orTimeDuration:nil orUntilShiftKey:true
       
  7300         orThisReceiverClass:false orCurrentProcess:false
       
  7301         orIfCalledFromMethod:nil
       
  7302         forAll:false.
       
  7303 
       
  7304     "Created: / 27-01-2012 / 11:36:54 / cg"
  7085 !
  7305 !
  7086 
  7306 
  7087 ignoreBreakpointsWithThisParameterForever
  7307 ignoreBreakpointsWithThisParameterForever
  7088     Object disableBreakPoint:breakPointParameter.
  7308     Object disableBreakPoint:breakPointParameter.
  7089     "/ self addIgnoredHaltForCount:-1 orTimeDuration:nil orUntilShiftKey:false forAll:false.
  7309     "/ self addIgnoredHaltForCount:-1 orTimeDuration:nil orUntilShiftKey:false forAll:false.
  7623 
  7843 
  7624 selectedInterval
  7844 selectedInterval
  7625     ^ codeView selectedInterval
  7845     ^ codeView selectedInterval
  7626 !
  7846 !
  7627 
  7847 
  7628 showError:message
       
  7629     codeView contents:(resources string:message).
       
  7630     shown ifTrue:[
       
  7631         exclusive ifTrue:[
       
  7632             "/ consider this a kludge:
       
  7633             "/ if exclusive, cannot use flash, since it suspends
       
  7634             "/ (but we cannot suspend here ...)
       
  7635             codeView redrawInverted. self flush.
       
  7636             OperatingSystem millisecondDelay:200.
       
  7637             codeView redraw
       
  7638         ] ifFalse:[
       
  7639             codeView flash
       
  7640         ]
       
  7641     ]
       
  7642 
       
  7643     "Modified: / 18.11.2001 / 00:01:13 / cg"
       
  7644 !
       
  7645 
       
  7646 showTerminated
       
  7647     self showError:'** the process has terminated **'
       
  7648 !
       
  7649 
       
  7650 showValue:aValue
       
  7651     infoLabelHolder value:aValue printString
       
  7652 
       
  7653     "Modified: / 28-07-2018 / 11:25:57 / Claus Gittinger"
       
  7654 !
       
  7655 
       
  7656 showWarning:aString
       
  7657     infoLabelHolder value:(aString withColor:Color red)
       
  7658 
       
  7659     "Created: / 02-07-2019 / 21:27:03 / Claus Gittinger"
       
  7660 !
       
  7661 
       
  7662 stepping
       
  7663     ^ stepping
       
  7664 !
       
  7665 
       
  7666 unstep
       
  7667     stepping := false.
       
  7668     bigStep := false.
       
  7669     steppedContext := wrapperContext := nil.
       
  7670     exitAction := nil
       
  7671 
       
  7672     "Modified: 22.10.1996 / 11:59:57 / cg"
       
  7673 !
       
  7674 
       
  7675 updateButtonsAndMenuItemsForContext:aContext
       
  7676     |m|
       
  7677 
       
  7678     m := contextView middleButtonMenu.
       
  7679     m notNil ifTrue:[
       
  7680         self updateMenuItems.
       
  7681 
       
  7682         (aContext notNil and:[(inspecting or:[AbortOperationRequest isHandledIn:aContext])]) ifTrue:[
       
  7683             abortButton enable.
       
  7684             m enable:#doAbort.
       
  7685         ] ifFalse:[
       
  7686             abortButton disable.
       
  7687             m disable:#doAbort.
       
  7688         ].
       
  7689         exclusive ifTrue:[
       
  7690             terminateButton disable.
       
  7691             m disable:#doTerminate.
       
  7692         ] ifFalse:[
       
  7693             terminateButton enable.
       
  7694             m enable:#doTerminate.
       
  7695         ].
       
  7696     ].
       
  7697 
       
  7698     mayProceed == false ifTrue:[
       
  7699         continueButton disable.
       
  7700         m notNil ifTrue:[m disable:#doContinue].
       
  7701     ] ifFalse:[
       
  7702         continueButton enable.
       
  7703         m notNil ifTrue:[m enable:#doContinue]
       
  7704     ].
       
  7705 
       
  7706     foundRaisingMethod ifTrue:[
       
  7707         gotoRaisingMethodButton enable.
       
  7708         gotoRaisingMethodButton beVisible.
       
  7709     ] ifFalse:[
       
  7710         gotoRaisingMethodButton beInvisible.
       
  7711     ].
       
  7712     
       
  7713     isStoppedInModalDialog ifTrue:[
       
  7714         gotoDialogOpenerButton enable.
       
  7715         gotoDialogOpenerButton beVisible.
       
  7716     ] ifFalse:[
       
  7717         gotoDialogOpenerButton beInvisible.
       
  7718     ].
       
  7719 
       
  7720     (isStoppedInModalDialog not & isStoppedInApplicationAction) ifTrue:[
       
  7721         gotoApplicationActionMethodButton enable.
       
  7722         gotoApplicationActionMethodButton beVisible.
       
  7723     ] ifFalse:[
       
  7724         gotoApplicationActionMethodButton beInvisible.
       
  7725     ].
       
  7726 
       
  7727     "Created: / 06-07-2011 / 12:24:53 / cg"
       
  7728     "Modified: / 30-11-2017 / 12:16:44 / cg"
       
  7729     "Modified: / 02-07-2019 / 16:46:46 / Claus Gittinger"
       
  7730 !
       
  7731 
       
  7732 updateContext
       
  7733     |oldContext idx|
       
  7734 
       
  7735     inspectedProcess isDead ifTrue:[
       
  7736         self showTerminated.
       
  7737         ^ self
       
  7738     ].
       
  7739 
       
  7740     oldContext := selectedContext.
       
  7741     [
       
  7742         (self setContextSkippingInterruptContexts:inspectedProcess suspendedContext) ifTrue:[
       
  7743             oldContext notNil ifTrue:[
       
  7744                 contextArray notNil ifTrue:[
       
  7745                     idx := contextArray identityIndexOf:oldContext.
       
  7746                     idx ~~ 0 ifTrue:[
       
  7747                         self showSelection:idx
       
  7748                     ] ifFalse:[
       
  7749                         codeView contents:('** context returned **')
       
  7750                     ]
       
  7751                 ]
       
  7752             ]
       
  7753         ].
       
  7754     ] valueUninterruptably.
       
  7755 
       
  7756     "Modified: / 20-10-1996 / 18:11:24 / cg"
       
  7757     "Modified: / 29-05-2019 / 01:02:43 / Claus Gittinger"
       
  7758 !
       
  7759 
       
  7760 withNodeValueAtInterval:interval do:aBlock
       
  7761     "helper for tooltops and explain-selection;
       
  7762      evaluate aBlock with description of what it is and its value
       
  7763      (if known)"
       
  7764 
       
  7765     |node definingNode nm nmBold nameSymbol
       
  7766      varIdx parentNode receiver con receiversNonMetaClass|
       
  7767 
       
  7768     "/ interval printCR.
       
  7769     Error
       
  7770         handle:[:ex | ]
       
  7771         do:[
       
  7772             [
       
  7773                 node := self findNodeForInterval:interval
       
  7774             ] valueWithWatchDog:[ ^ self ] afterMilliseconds:50.
       
  7775         ].
       
  7776 
       
  7777     node isNil ifTrue:[ ^ self ].
       
  7778     node isVariable ifFalse:[
       
  7779         "/ Transcript showCR:node.
       
  7780         ^ self
       
  7781     ].
       
  7782 
       
  7783     nm := node name.
       
  7784     nmBold := nm allBold.
       
  7785     actualContext isNil ifTrue:[^ self ].
       
  7786     actualContext methodHome isNil ifTrue:[^ self ].
       
  7787     receiver := actualContext methodHome receiver.
       
  7788 
       
  7789     (nm = 'self') ifTrue:[
       
  7790         aBlock value:receiver value:'receiver' allBold.
       
  7791         ^ self
       
  7792     ].
       
  7793     (nm = 'super') ifTrue:[
       
  7794         aBlock value:receiver value:'receiver' allBold.
       
  7795         ^ self
       
  7796     ].
       
  7797     (nm = 'thisContext') ifTrue:[
       
  7798         aBlock value:actualContext value:'context' allBold.
       
  7799         ^ self
       
  7800     ].
       
  7801 
       
  7802     definingNode := node whoDefines:nm.
       
  7803     definingNode isNil ifTrue:[
       
  7804         (receiver class allInstVarNames includes:nm) ifTrue:[
       
  7805             receiver class isMetaclass ifTrue:[
       
  7806                 aBlock value:(receiver instVarNamed:nm) value:'classInstVar ',nmBold.
       
  7807             ] ifFalse:[
       
  7808                 aBlock value:(receiver instVarNamed:nm) value:'instVar ',nmBold.
       
  7809             ].
       
  7810             ^ self
       
  7811         ].
       
  7812 
       
  7813         receiversNonMetaClass := receiver class theNonMetaclass.
       
  7814         (receiversNonMetaClass privateClasses contains:[:cls | cls nameWithoutPrefix = nm]) ifTrue:[
       
  7815             aBlock value:'' value:'private class ',nmBold.
       
  7816             ^ self
       
  7817         ].
       
  7818         (receiversNonMetaClass classVarNames includes:nm) ifTrue:[
       
  7819             aBlock value:((currentMethod mclass ? receiversNonMetaClass) theNonMetaclass classVarAt:nm) value:'classVar ',nmBold.
       
  7820             ^ self
       
  7821         ].
       
  7822         receiversNonMetaClass sharedPoolNames do:[:eachPoolName |
       
  7823             |pool|
       
  7824 
       
  7825             pool := Smalltalk at:eachPoolName.
       
  7826             pool isNil ifTrue:[ pool := receiversNonMetaClass topNameSpace at:eachPoolName].
       
  7827             (pool classVarNames includes:nm) ifTrue:[
       
  7828                 aBlock value:(pool classVarAt:nm) value:'poolVar ',nm allBold,' in ',eachPoolName allBold,' '.
       
  7829                 ^ self
       
  7830             ].
       
  7831         ].
       
  7832         nameSymbol := nm asSymbolIfInterned.
       
  7833         nameSymbol notNil ifTrue:[
       
  7834             (Smalltalk includesKey:nameSymbol) ifTrue:[
       
  7835                 (Smalltalk at:nameSymbol) isClass ifTrue:[
       
  7836                     aBlock value:(Smalltalk at:nameSymbol) value:''.
       
  7837                     "/ aBlock value:''(Smalltalk at:nameSymbol) value:'class ',nmBold.
       
  7838                 ] ifFalse:[
       
  7839                     aBlock value:(Smalltalk at:nameSymbol) value:'global ',nmBold.
       
  7840                 ].
       
  7841                 ^ self
       
  7842             ].
       
  7843         ].
       
  7844         aBlock value:'' value:'unknown'.
       
  7845         ^ self
       
  7846     ].
       
  7847 "/definingNode printCR.
       
  7848 
       
  7849     definingNode isMethod ifTrue:[
       
  7850         varIdx := definingNode arguments findFirst:[:arg | arg name = nm].
       
  7851         varIdx ~~ 0 ifTrue:[
       
  7852             Error
       
  7853                 handle:[:ex | ]
       
  7854                 do:[ aBlock value:(actualContext methodHome argAt:varIdx) value:'methodArg ',nmBold ].
       
  7855             ^ self
       
  7856         ].
       
  7857         varIdx := definingNode temporaries findFirst:[:var | var name = nm].
       
  7858         varIdx ~~ 0 ifTrue:[
       
  7859             actualContext methodHome numVars >= varIdx ifTrue:[
       
  7860                 Error
       
  7861                     handle:[:ex | ]
       
  7862                     do:[ aBlock value:(actualContext methodHome varAt:varIdx) value:'methodVar ',nmBold ].
       
  7863                 ^ self
       
  7864             ]
       
  7865         ].
       
  7866     ].
       
  7867 
       
  7868     definingNode isBlock ifTrue:[
       
  7869         varIdx := definingNode arguments findFirst:[:arg | arg name = nm].
       
  7870         (definingNode arguments contains:[:arg | arg name = nm]) ifTrue:[
       
  7871             varIdx ~~ 0 ifTrue:[
       
  7872                 "/ am I in this block ?
       
  7873                 (actualContext lineNumber notNil
       
  7874                 and:[ definingNode lastLineNumber notNil
       
  7875                 and:[ (actualContext lineNumber
       
  7876                             between:definingNode firstLineNumber
       
  7877                             and:definingNode lastLineNumber)
       
  7878                 and:[ varIdx <= actualContext numArgs ] ]])
       
  7879                 ifTrue:[
       
  7880                     aBlock value:(actualContext argAt:varIdx) value:'blockArg ',nmBold .
       
  7881                     ^ self
       
  7882                 ].
       
  7883                 aBlock value:nmBold , ' is not in scope of selected context' value:nil.
       
  7884                 ^ self
       
  7885             ]
       
  7886         ].
       
  7887     ].
       
  7888 
       
  7889     parentNode := definingNode parent.
       
  7890 
       
  7891     [parentNode notNil] whileTrue:[
       
  7892         "/'isMethod ' print. parentNode isMethod printCR.
       
  7893         parentNode isMethod ifTrue:[
       
  7894             varIdx := parentNode temporaries findFirst:[:var | var name = nm].
       
  7895             varIdx ~~ 0 ifTrue:[
       
  7896                 actualContext methodHome numVars >= varIdx ifTrue:[
       
  7897                     Error
       
  7898                         handle:[:ex | ]
       
  7899                         do:[ aBlock value:(actualContext methodHome varAt:varIdx) value:'methodVar ',nmBold ].
       
  7900                     ^ self
       
  7901                 ]
       
  7902             ].
       
  7903         ].
       
  7904         "/'isBlock ' print. parentNode isBlock printCR.
       
  7905         parentNode isBlock ifTrue:[
       
  7906             "/ we don't have any information on the inlineability
       
  7907             "/ of this block here (RBParser does not know what
       
  7908             "/ the compiler does).
       
  7909             "/ therefore, it is questionable if we can use the
       
  7910             "/ context's home context here.
       
  7911             "/ am I in this block ?
       
  7912             con := actualContext.
       
  7913             [con notNil
       
  7914             and:[ parentNode lastLineNumber notNil
       
  7915             and:[ con lineNumber notNil
       
  7916             and:[ con lineNumber
       
  7917                     between:parentNode firstLineNumber
       
  7918                     and:parentNode lastLineNumber ]]]] whileTrue:[
       
  7919                 con := con sender.
       
  7920             ].
       
  7921             con notNil ifTrue:[
       
  7922                 varIdx := parentNode arguments findFirst:[:arg | arg name = nm].
       
  7923                 varIdx ~~ 0 ifTrue:[
       
  7924                     Error
       
  7925                         handle:[:ex | ]
       
  7926                         do:[ aBlock value:(con argAt:varIdx) value:'blockArg ',nmBold ].
       
  7927                     ^ self
       
  7928                 ].
       
  7929                 varIdx := parentNode body temporaries findFirst:[:var | var name = nm].
       
  7930                 varIdx ~~ 0 ifTrue:[
       
  7931                     Error
       
  7932                         handle:[:ex | ]
       
  7933                         do:[ aBlock value:(con varAt:varIdx) value:'blockVar ',nmBold ].
       
  7934                     ^ self
       
  7935                 ].
       
  7936             ].
       
  7937         ].
       
  7938         parentNode := parentNode parent.
       
  7939     ].
       
  7940     aBlock value:nmBold , ' is not in scope of selected context' value:nil.
       
  7941 
       
  7942     "Modified: / 18-01-2011 / 17:57:34 / cg"
       
  7943     "Modified: / 28-07-2018 / 11:46:46 / Claus Gittinger"
       
  7944 ! !
       
  7945 
       
  7946 !DebugView methodsFor:'private queries'!
       
  7947 
       
  7948 canBrowseClassHierarchy
       
  7949     |m|
       
  7950 
       
  7951     m := contextView middleButtonMenu.
       
  7952     ^ m notNil and:[m isEnabled:#browseClassHierarchy]
       
  7953 !
       
  7954 
       
  7955 canBrowseFullClassProtocol
       
  7956     |m|
       
  7957 
       
  7958     m := contextView middleButtonMenu.
       
  7959     ^ m notNil and:[m isEnabled:#browseFullClassProtocol]
       
  7960 !
       
  7961 
       
  7962 canBrowseImplementingClass
       
  7963     |m|
       
  7964 
       
  7965     m := contextView middleButtonMenu.
       
  7966     ^ m notNil and:[m isEnabled:#browseImplementingClass]
       
  7967 !
       
  7968 
       
  7969 canBrowseProcessesApplication
       
  7970     |p|
       
  7971 
       
  7972     p := inspectedProcess ? Processor activeProcess.
       
  7973     p isNil ifTrue:[^ false].
       
  7974     ^ p isGUIProcess and:[self processesApplication notNil ].
       
  7975 !
       
  7976 
       
  7977 canBrowseReceiversClass
       
  7978     |m|
       
  7979 
       
  7980     m := contextView middleButtonMenu.
       
  7981     ^ m notNil 
       
  7982         and:[
       
  7983             (m isEnabled:#browseReceiversClass)
       
  7984             or:[ m isEnabled:#browseImplementingClass ]
       
  7985         ]
       
  7986 
       
  7987     "Modified: / 25-11-2016 / 13:25:55 / cg"
       
  7988 !
       
  7989 
       
  7990 canCloseAllDebuggers
       
  7991     self class allInstancesDo:[:debugger |
       
  7992         debugger ~~ self ifTrue:[
       
  7993             debugger busy ifTrue:[^ true].
       
  7994         ]
       
  7995     ].
       
  7996     ^ false
       
  7997 
       
  7998     "Created: / 23-03-2012 / 12:40:18 / cg"
       
  7999 !
       
  8000 
       
  8001 canDefineMethod
       
  8002     ^ defineButton isVisible
       
  8003 !
       
  8004 
       
  8005 canInspectWidgetHierarchy
       
  8006     |rcvr|
       
  8007 
       
  8008     ^ (selectedContext notNil
       
  8009         and:[(rcvr := selectedContext receiver) isProtoObject not 
       
  8010         and:[rcvr isView or:[rcvr isKindOf: ApplicationModel]]])
       
  8011     or:[
       
  8012         self canBrowseProcessesApplication
       
  8013     ]
       
  8014 
       
  8015     "Modified: / 25-11-2016 / 13:17:20 / cg"
       
  8016 !
       
  8017 
       
  8018 canRedefineMethodInReceiverClass
       
  8019     "true if a context is selected, where an inherited method was called.
       
  8020      Used to enable the redefine menu option"
       
  8021      
       
  8022     |con selector receiverClass implClass|
       
  8023     
       
  8024     (con := actualContext) notNil ifTrue:[
       
  8025         (actualContext home) notNil ifTrue:[
       
  8026             con := actualContext home 
       
  8027         ].
       
  8028         selector := con selector.
       
  8029         receiverClass := con receiver class.
       
  8030         (receiverClass implements:selector) ifFalse:[
       
  8031             implClass := receiverClass whichClassIncludesSelector:selector.
       
  8032             ^ implClass notNil
       
  8033         ].    
       
  8034     ].    
       
  8035     ^ false
       
  8036 
       
  8037     "Created: / 08-02-2017 / 08:45:38 / cg"
       
  8038 !
       
  8039 
       
  8040 canRestart
       
  8041     ^ restartButton isEnabled
       
  8042 
       
  8043     "Modified: / 17.11.2001 / 19:59:49 / cg"
       
  8044 !
       
  8045 
       
  8046 canReturn
       
  8047     ^ returnButton isEnabled
       
  8048 
       
  8049     "Modified: / 17.11.2001 / 19:59:18 / cg"
       
  8050 !
       
  8051 
       
  8052 canSendEmail
       
  8053     ^ SendMailTool notNil
       
  8054 
       
  8055     "Created: / 15-10-2010 / 11:51:23 / cg"
       
  8056 !
       
  8057 
       
  8058 canShowMore
       
  8059     ^ canShowMore
       
  8060 !
       
  8061 
       
  8062 hasBlockContextSelected
       
  8063     ^ contextView hasSelection
       
  8064     and:[ self selectedContext isBlockContext ]
       
  8065 !
       
  8066 
       
  8067 hasContextSelected
       
  8068     ^ contextView hasSelection
       
  8069 
       
  8070     "Created: / 17.11.2001 / 19:57:03 / cg"
       
  8071 !
       
  8072 
       
  8073 hasHaltsToIgnore
       
  8074     ^ IgnoredHalts notEmptyOrNil
       
  8075 !
       
  8076 
       
  8077 isAborting
       
  8078     ^ exitAction == #abort
       
  8079 !
       
  8080 
       
  8081 isStoppedAtBreakPointWithParameter
       
  8082     ^ isStoppedAtBreakPointWithParameter
       
  8083 
       
  8084     "Created: / 06-03-2012 / 12:16:56 / cg"
       
  8085 !
       
  8086 
       
  8087 isStoppedAtError
       
  8088     ^ isStoppedAtError "/ ^ self isStoppedAtHaltOrBreakPoint not
       
  8089 
       
  8090     "Created: / 27-02-2019 / 12:36:35 / Claus Gittinger"
       
  8091     "Modified: / 27-02-2019 / 22:18:04 / Claus Gittinger"
       
  8092 !
       
  8093 
       
  8094 isStoppedAtHaltOrBreakPoint
       
  8095     ^ isStoppedAtHaltOrBreakPoint
       
  8096 !
       
  8097 
       
  8098 isStoppedAtHaltOrBreakPointOrSelectedContextIsWrapped
       
  8099     ^ isStoppedAtHaltOrBreakPoint or:[self selectedContextIsWrapped]
       
  8100 !
       
  8101 
       
  8102 isStoppedAtHaltOrBreakPointOrSelectedContextIsWrappedAndHasPreviousIgnoreTime
       
  8103     ^ self isStoppedAtHaltOrBreakPointOrSelectedContextIsWrapped
       
  8104     and:[LastIgnoreHaltDuration notEmptyOrNil]
       
  8105 
       
  8106     "Created: / 09-11-2018 / 20:37:02 / Claus Gittinger"
       
  8107 !
       
  8108 
       
  8109 selectedContextIsWrapped
       
  8110     |con mthd|
       
  8111 
       
  8112     (con := self selectedContext) notNil ifTrue:[
       
  8113         mthd := con method.
       
  8114         ^ mthd notNil and:[mthd isWrapped]
       
  8115     ].
       
  8116     ^ false.
       
  8117 
       
  8118     "Modified: / 19-07-2012 / 11:36:28 / cg"
       
  8119 !
       
  8120 
       
  8121 setOfHiddenCallingSelectors
       
  8122     ^ setOfHiddenCallingSelectors ? #( #'doIt' #'doIt:' )
       
  8123 !
       
  8124 
       
  8125 setOfHiddenCallingSelectors:aCollectionOfSymbols
       
  8126     setOfHiddenCallingSelectors := aCollectionOfSymbols
       
  8127 ! !
       
  8128 
       
  8129 !DebugView methodsFor:'private-breakpoints'!
       
  8130 
       
  8131 addIgnoredErrorForCount:countOrNil
       
  8132         orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
       
  8133         orThisReceiverClass:forThisReceiverClass orCurrentProcess:forCurrentProcess
       
  8134         orIfCalledFromMethod:ifCalledForMethodOrNil
       
  8135         forAll:aBoolean
       
  8136 
       
  8137     |errorContext errorMethod lineNrOfError receiverClassOrNil processOrNil|
       
  8138 
       
  8139     aBoolean ifTrue:[
       
  8140         errorMethod := #all
       
  8141     ] ifFalse:[
       
  8142         errorContext := self findErrorContext.
       
  8143         errorContext isNil ifTrue:[
       
  8144             Transcript showCR:'no error context found'.
       
  8145             ^ self
       
  8146         ].
       
  8147 
       
  8148         errorMethod := errorContext method.
       
  8149         lineNrOfError := errorContext lineNumber.
       
  8150         (lineNrOfError isNil or:[lineNrOfError <= 0]) ifTrue:[
       
  8151             Transcript showCR:'no Error lineNr found'.
       
  8152             ^ self
       
  8153         ].
       
  8154         forThisReceiverClass ifTrue:[
       
  8155             receiverClassOrNil := errorContext receiver class
       
  8156         ].
       
  8157         forCurrentProcess ifTrue:[
       
  8158             processOrNil := Processor activeProcess
       
  8159         ].
       
  8160     ].
       
  8161 
       
  8162     self class
       
  8163         ignoreErrorIn:errorMethod line:lineNrOfError
       
  8164         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
       
  8165         orReceiverClass:receiverClassOrNil orProcess:processOrNil
       
  8166         orIfCalledFromMethod:ifCalledForMethodOrNil
       
  8167 
       
  8168     "Created: / 27-02-2019 / 12:42:12 / Claus Gittinger"
       
  8169     "Modified: / 27-02-2019 / 22:23:17 / Claus Gittinger"
       
  8170 !
       
  8171 
       
  8172 addIgnoredHaltForCount:countOrNil
       
  8173         orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
       
  8174         orThisReceiverClass:forThisReceiverClass orCurrentProcess:forCurrentProcess
       
  8175         orIfCalledFromMethod:ifCalledForMethodOrNil
       
  8176         forAll:aBoolean
       
  8177 
       
  8178     |haltingContext haltingMethod lineNrOfHalt receiverClassOrNil processOrNil|
       
  8179 
       
  8180     aBoolean ifTrue:[
       
  8181         haltingMethod := #all
       
  8182     ] ifFalse:[
       
  8183         haltingContext := self findHaltingContext.
       
  8184         haltingContext isNil ifTrue:[
       
  8185             Transcript showCR:'no halting context found'.
       
  8186             ^ self
       
  8187         ].
       
  8188 
       
  8189         haltingMethod := haltingContext method.
       
  8190         lineNrOfHalt := haltingContext lineNumber.
       
  8191         (lineNrOfHalt isNil or:[lineNrOfHalt <= 0]) ifTrue:[
       
  8192             Transcript showCR:'no halt lineNr found'.
       
  8193             ^ self
       
  8194         ].
       
  8195         forThisReceiverClass ifTrue:[
       
  8196             receiverClassOrNil := haltingContext receiver class
       
  8197         ].
       
  8198         forCurrentProcess ifTrue:[
       
  8199             processOrNil := Processor activeProcess
       
  8200         ].
       
  8201     ].
       
  8202 
       
  8203     self class
       
  8204         ignoreHaltIn:haltingMethod at:lineNrOfHalt
       
  8205         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
       
  8206         orReceiverClass:receiverClassOrNil orProcess:processOrNil
       
  8207         orIfCalledFromMethod:ifCalledForMethodOrNil
       
  8208 
       
  8209     "Created: / 27-01-2012 / 11:31:12 / cg"
       
  8210 !
       
  8211 
       
  8212 canAddBreakpoint
       
  8213     |m|
       
  8214 
       
  8215     m := contextView middleButtonMenu.
       
  8216     ^ m notNil and:[m isEnabled:#addBreakpoint]
       
  8217 !
       
  8218 
       
  8219 canRemoveBreakpoint
       
  8220     |m|
       
  8221 
       
  8222     m := contextView middleButtonMenu.
       
  8223     ^ m notNil and:[m isEnabled:#removeBreakpoint]
       
  8224 !
       
  8225 
       
  8226 findContextWithAnySelector:selectors orMClass:mClass orWrapped:orWrappedBoolean
       
  8227     |con|
       
  8228 
       
  8229     con := firstContext.
       
  8230     [con notNil] whileTrue:[
       
  8231     "/ contextArray keysAndValuesDo:[:idx :con |
       
  8232         |sel con2 sel2 method|
       
  8233 
       
  8234         sel := con selector.
       
  8235         (selectors includes:sel) ifTrue:[
       
  8236             (method := con method) notNil ifTrue:[
       
  8237                 method mclass == Object ifTrue:[
       
  8238                     con2 := con sender. "/ contextArray at:idx+1.
       
  8239                     sel2 := con2 selector.
       
  8240                     (selectors includes:sel2) ifTrue:[
       
  8241                         con2 method mclass == Object ifTrue:[
       
  8242                             ^ con2 sender "/ contextArray at:idx+2.
       
  8243                         ]
       
  8244                     ].
       
  8245                     ^ con2. "/ contextArray at:idx+1
       
  8246                 ].
       
  8247                 (mClass notNil and:[method mclass == mClass]) ifTrue:[
       
  8248                     "/ (contextArray at:idx+1) infoPrintCR.
       
  8249                     ^ con sender "/ contextArray at:idx+1
       
  8250                 ].
       
  8251             ].
       
  8252         ].
       
  8253         (orWrappedBoolean and:[con method isWrapped]) ifTrue:[
       
  8254             ^ con
       
  8255         ].
       
  8256         con := con sender.
       
  8257     ].
       
  8258     ^ nil
       
  8259 
       
  8260     "Created: / 27-02-2019 / 13:40:25 / Claus Gittinger"
       
  8261     "Modified: / 27-02-2019 / 22:20:27 / Claus Gittinger"
       
  8262 !
       
  8263 
       
  8264 findErrorContext
       
  8265     ^ self
       
  8266         findContextWithAnySelector:(self class errorSelectors) 
       
  8267         orMClass:nil 
       
  8268         orWrapped:false
       
  8269 
       
  8270     "Created: / 27-02-2019 / 13:41:18 / Claus Gittinger"
       
  8271     "Modified: / 27-02-2019 / 22:37:14 / Claus Gittinger"
       
  8272 !
       
  8273 
       
  8274 findHaltingContext
       
  8275     ^ self
       
  8276         findContextWithAnySelector:(self class haltSelectors) 
       
  8277         orMClass:Breakpoint 
       
  8278         orWrapped:true
       
  8279 
       
  8280     "Modified: / 27-01-2012 / 11:06:02 / cg"
       
  8281     "Modified: / 27-02-2019 / 22:39:03 / Claus Gittinger"
       
  8282 !
       
  8283 
       
  8284 ignoreBreakpoints
       
  8285     ^ ignoreBreakpoints ? false
       
  8286 
       
  8287     "Created: / 17-11-2001 / 18:20:16 / cg"
       
  8288     "Modified: / 10-02-2019 / 12:47:22 / Claus Gittinger"
       
  8289 ! !
       
  8290 
       
  8291 !DebugView methodsFor:'private-cache handling'!
       
  8292 
       
  8293 cacheMyself
       
  8294     "remember myself for next debug session"
       
  8295 
       
  8296     "caching the last debugger will make the next debugger appear
       
  8297      faster, since no resources have to be allocated in the display.
       
  8298      We have to be careful to release all refs to the debuggee, though.
       
  8299      Otherwise, the GC will not be able to release it."
       
  8300 
       
  8301     windowGroup notNil ifTrue:[
       
  8302         windowGroup setProcess:nil.
       
  8303     ].
       
  8304 
       
  8305     self releaseDebuggee.
       
  8306 
       
  8307     cachable ~~ true ifTrue:[^ self].
       
  8308 
       
  8309     "/
       
  8310     "/ only cache if I am on the Display (i.e. the default screen)
       
  8311     "/
       
  8312     device == Display ifTrue:[
       
  8313         exclusive ifTrue:[
       
  8314             CachedExclusive := self
       
  8315         ] ifFalse:[
       
  8316             CachedDebugger := self
       
  8317         ].
       
  8318     ].
       
  8319 
       
  8320     ObjectMemory stepInterruptHandler == self ifTrue:[
       
  8321         ObjectMemory stepInterruptHandler:nil
       
  8322     ].
       
  8323 
       
  8324     "Modified: 10.7.1997 / 15:50:46 / stefan"
       
  8325     "Modified: 31.7.1997 / 21:20:14 / cg"
       
  8326 !
       
  8327 
       
  8328 isCached
       
  8329     "tell whether we are a cached debugger"
       
  8330 
       
  8331     CachedExclusive == self ifTrue:[
       
  8332         ^ true.
       
  8333     ].
       
  8334     CachedDebugger == self ifTrue:[
       
  8335         ^ true.
       
  8336     ].
       
  8337 
       
  8338     ^ false.
       
  8339 
       
  8340     "Created: / 10-07-1997 / 15:22:43 / stefan"
       
  8341     "Modified (comment): / 27-07-2013 / 15:38:47 / cg"
       
  8342 !
       
  8343 
       
  8344 uncacheMyself
       
  8345     "do not remember myself any longer for next debug session"
       
  8346 
       
  8347     cachable := false.
       
  8348 
       
  8349     CachedExclusive == self ifTrue:[
       
  8350         CachedExclusive := nil.
       
  8351     ].
       
  8352     CachedDebugger == self ifTrue:[
       
  8353         CachedDebugger := nil.
       
  8354     ].
       
  8355     OpenDebuggers notNil ifTrue:[
       
  8356         OpenDebuggers remove:self ifAbsent:[].
       
  8357     ].
       
  8358 
       
  8359     "Modified: 31.7.1997 / 21:20:11 / cg"
       
  8360 ! !
       
  8361 
       
  8362 !DebugView methodsFor:'private-code generation helpers'!
       
  8363 
       
  8364 argumentNamesForNewMethodOfContext:context
       
  8365     "generate argument names for a prototypeMethod for the message in context.
       
  8366      Used by doDefine and doRedefine"
       
  8367 
       
  8368     |bagOfClassNames bagOfUsedClassNames argNames|
       
  8369     
       
  8370     bagOfClassNames := (actualContext args collect:[:eachArg | eachArg class name]) asBag.
       
  8371     bagOfUsedClassNames := Bag new.
       
  8372     argNames := actualContext args
       
  8373                     collect:
       
  8374                         [:eachArg |
       
  8375                             |nm|
       
  8376 
       
  8377                             nm := eachArg class nameWithoutPrefix.
       
  8378                             (bagOfClassNames occurrencesOf:nm) == 1 ifTrue:[
       
  8379                                 nm article , nm
       
  8380                             ] ifFalse:[
       
  8381                                 bagOfUsedClassNames add:nm.
       
  8382                                 nm asLowercaseFirst , (bagOfUsedClassNames occurrencesOf:nm) printString
       
  8383                             ].
       
  8384                         ].
       
  8385     ^ argNames
       
  8386 
       
  8387     "Created: / 08-02-2017 / 08:57:24 / cg"
       
  8388 ! !
       
  8389 
       
  8390 !DebugView methodsFor:'private-code view'!
       
  8391 
       
  8392 codeAspect
       
  8393     ^ SyntaxHighlighter codeAspectMethod
       
  8394 
       
  8395     "Created: / 27-07-2011 / 13:07:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
  8396     "Modified: / 27-07-2012 / 22:20:27 / cg"
       
  8397 ! !
       
  8398 
       
  8399 !DebugView methodsFor:'private-context handling'!
       
  8400 
       
  8401 contextListEntryFor:aContext
       
  8402     ^ Error
       
  8403         handle:[:ex | '???' ]
       
  8404         do:[
       
  8405             |s|
       
  8406 
       
  8407             aContext selector == #doIt ifTrue:[
       
  8408                 aContext receiver isNil ifTrue:[
       
  8409                     s := 'doIt' allBold
       
  8410                 ]
       
  8411             ].
       
  8412 
       
  8413             s := Text streamContents:[:s | aContext printWithSeparator:' ยป ' on:s ].
       
  8414             "/ s infoPrintCR.
       
  8415             RememberedCallChain notNil ifTrue:[
       
  8416                 (RememberedCallChain includesIdentical:aContext) ifTrue:[
       
  8417                     s := s withColor:#red.
       
  8418                 ].
       
  8419             ].
       
  8420             s
       
  8421         ].
       
  8422 
       
  8423     "Created: / 21-05-2007 / 13:30:24 / cg"
       
  8424     "Modified: / 27-06-2018 / 17:15:47 / Claus Gittinger"
       
  8425 !
       
  8426 
       
  8427 is:aHomeContext inCallingChainOf:aContext
       
  8428     |con|
       
  8429 
       
  8430     con := aContext.
       
  8431     [con notNil and:[con ~~ aHomeContext]] whileTrue:[
       
  8432         con := con sender
       
  8433     ].
       
  8434     ^ con notNil
       
  8435 
       
  8436     "Created: / 10-06-2012 / 18:46:29 / cg"
       
  8437 !
       
  8438 
       
  8439 isEnteredDueToBreakpointOrHalt
       
  8440     "see if we came here due to a step interrupt"
       
  8441 
       
  8442     |c cReceiver|
       
  8443 
       
  8444     "/ look for a breakpoint-wrapper's context
       
  8445     c := thisContext findNextContextWithSelector:#'raiseRequestWith:errorString:in:' or:nil or:nil.
       
  8446     c isNil ifTrue:[
       
  8447         ^ true.
       
  8448     ].
       
  8449     cReceiver := c receiver.
       
  8450     ^ cReceiver == BreakPointInterrupt
       
  8451 
       
  8452     "Modified: / 01-08-2013 / 23:34:01 / cg"
       
  8453 !
       
  8454 
       
  8455 isHaltToBeIgnored
       
  8456     "see if the current halt (if any) is in the ignore-list"
       
  8457 
       
  8458     |c cReceiver sender haltingMethod lineNrInHaltingMethod breakpointParameter
       
  8459      sReceiver|
       
  8460 
       
  8461     "/ should a halt be ignored ?
       
  8462     IgnoredHalts isNil ifTrue:[^ false].
       
  8463 
       
  8464     "/ look for a method breakpoint-wrapper's context
       
  8465     c := thisContext findNextContextWithSelector:#doRaise or:nil or:nil.
       
  8466     c notNil ifTrue:[
       
  8467         ((cReceiver := c receiver) isKindOf:NoHandlerError) ifTrue:[
       
  8468             c := c sender findNextContextWithSelector:#doRaise or:nil or:nil.
       
  8469             cReceiver := c receiver.
       
  8470         ].
       
  8471         (cReceiver isKindOf:BreakPointInterrupt) ifFalse:[
       
  8472             c := nil
       
  8473         ] ifTrue:[
       
  8474             [
       
  8475                 sender := c sender.
       
  8476                 ((sReceiver := sender receiver) isKindOf:BreakPointInterrupt)
       
  8477                 or:[ sReceiver == BreakPointInterrupt ]
       
  8478             ] whileTrue:[
       
  8479                 c := sender
       
  8480             ].
       
  8481             [ (sender := c sender) isBlockContext ] whileTrue:[
       
  8482                 c := sender
       
  8483             ].
       
  8484             sender := nil. "/ avoid keeping a reference to this context
       
  8485         ].
       
  8486     ].
       
  8487     "/ Transcript showCR:c.
       
  8488     c isNil ifTrue:[
       
  8489         "/ look for halts or explicit breakpoints
       
  8490         c := thisContext findNextContextWithSelector:#halt or:#halt: or:nil.
       
  8491         c isNil ifTrue:[
       
  8492             c := thisContext findNextContextWithSelector:#breakPoint: or:#breakPoint:info: or:nil.
       
  8493             c isNil ifTrue:[
       
  8494                ^ false
       
  8495             ].
       
  8496             breakpointParameter := c argAt:1.
       
  8497             (self class
       
  8498                     isBreakpointToBeIgnoredForParameter:breakpointParameter
       
  8499                     context:(c sender)
       
  8500                     modifyEntryCount:true
       
  8501             ) ifTrue:[
       
  8502                 ^ true.
       
  8503             ].
       
  8504         ].
       
  8505     ].
       
  8506 
       
  8507     c := c sender.
       
  8508     "/ a code-breakpoint ?
       
  8509     (c receiver isKindOf:Breakpoint) ifTrue:[
       
  8510         c := c sender.
       
  8511     ].
       
  8512     haltingMethod := c method.
       
  8513 
       
  8514     haltingMethod isWrapped ifTrue:[
       
  8515         lineNrInHaltingMethod := 1.
       
  8516     ] ifFalse:[
       
  8517         lineNrInHaltingMethod := c lineNumber.
       
  8518         "/ Transcript showCR:c.
       
  8519     ].
       
  8520 
       
  8521     ^ self class
       
  8522         isHaltToBeIgnoredIn:haltingMethod
       
  8523         atLineNr:lineNrInHaltingMethod
       
  8524         context:c
       
  8525         modifyEntryCount:true.
       
  8526 
       
  8527     "Created: / 22-10-2010 / 12:09:53 / cg"
       
  8528     "Modified: / 06-03-2012 / 12:54:09 / cg"
       
  8529 !
       
  8530 
       
  8531 setContext:aContext
       
  8532     "show calling chain from aContext in the walk-back listview"
       
  8533 
       
  8534     ^ self setContext:aContext releaseInspectors:true
       
  8535 
       
  8536     "Modified: 27.6.1996 / 17:21:59 / cg"
       
  8537 !
       
  8538 
       
  8539 setContext:aContext releaseInspectors:releaseInspectors
  7848 setContext:aContext releaseInspectors:releaseInspectors
  8540     "show calling chain from aContext in the walk-back listview.
  7849     "show calling chain from aContext in the walk-back listview.
  8541      Most complications here arise from filtering less-interesting contexts
  7850      Most complications here arise from filtering less-interesting contexts
  8542      if not in verbose-context mode or when hiding implementation contexts.
  7851      if not in verbose-context mode or when hiding implementation contexts.
  8543      There is a lot of heuristic magic here, to make the debugger as useful
  7852      There is a lot of heuristic magic here, to make the debugger as useful
  8545      On the fly, as we move along the contexts, update the isStoppedAtXXX booleans."
  7854      On the fly, as we move along the contexts, update the isStoppedAtXXX booleans."
  8546 
  7855 
  8547     |con sel text method caller caller2 called called2 m count c cc sndr
  7856     |con sel text method caller caller2 called called2 m count c cc sndr
  8548      suspendContext calledBySuspendContext nm h calledContext show2
  7857      suspendContext calledBySuspendContext nm h calledContext show2
  8549      alreadyInApplicationCode verboseBacktrace
  7858      alreadyInApplicationCode verboseBacktrace
  8550      errorSelectors haltSelectors|
  7859      errorSelectors haltSelectors assertSelectors|
  8551 
  7860 
  8552 "/    (contextArray size > 0 and:[aContext == (contextArray at:1)]) ifTrue:[
  7861 "/    (contextArray size > 0 and:[aContext == (contextArray at:1)]) ifTrue:[
  8553 "/        "no change"
  7862 "/        "no change"
  8554 "/        ^ false
  7863 "/        ^ false
  8555 "/    ].
  7864 "/    ].
  8556 
  7865 
  8557     errorSelectors := self class errorSelectors.
  7866     errorSelectors := self class errorSelectors.
  8558     haltSelectors := self class haltSelectors.
  7867     haltSelectors := self class haltSelectors.
  8559     
  7868     assertSelectors := self class assertSelectors.
       
  7869 
  8560     isStoppedAtHaltOrBreakPoint := isStoppedAtBreakPointWithParameter := false.
  7870     isStoppedAtHaltOrBreakPoint := isStoppedAtBreakPointWithParameter := false.
  8561     foundRaisingMethod := false.
  7871     foundRaisingMethod := false.
  8562     isStoppedInModalDialog := isStoppedInApplicationAction := alreadyInApplicationCode := false.
  7872     isStoppedInModalDialog := isStoppedInApplicationAction := alreadyInApplicationCode := false.
  8563     isStoppedAtStatementBreakpoint := isStoppedAtError := false.
  7873     isStoppedAtStatementBreakpoint := isStoppedAtError := isStoppedAtAssert := false.
  8564     firstContext := aContext.
  7874     firstContext := aContext.
  8565     verboseBacktrace := self verboseBacktraceHolder value.
  7875     verboseBacktrace := self verboseBacktraceHolder value.
  8566 
  7876 
  8567     m := contextView middleButtonMenu.
  7877     m := contextView middleButtonMenu.
  8568     m notNil ifTrue:[
  7878     m notNil ifTrue:[
  8645                 ].
  7955                 ].
  8646             ].
  7956             ].
  8647             (errorSelectors includes:sel) ifTrue:[
  7957             (errorSelectors includes:sel) ifTrue:[
  8648                 isStoppedAtError := true.
  7958                 isStoppedAtError := true.
  8649             ].
  7959             ].
       
  7960             (assertSelectors includes:sel) ifTrue:[
       
  7961                 isStoppedAtAssert := true.
       
  7962             ].
  8650         ].
  7963         ].
  8651 
  7964 
  8652         (verboseBacktrace not or:[ hideSupportCode]) ifTrue:[
  7965         (verboseBacktrace not or:[ hideSupportCode]) ifTrue:[
  8653             [
  7966             [
  8654                 con notNil
  7967                 con notNil
  8657                 and:[ (con method shouldBeSkippedInDebuggersWalkBack)
  7970                 and:[ (con method shouldBeSkippedInDebuggersWalkBack)
  8658                 and:[ (haltSelectors includes: con selector) not]]]]
  7971                 and:[ (haltSelectors includes: con selector) not]]]]
  8659             ] whileTrue:[
  7972             ] whileTrue:[
  8660                 (errorSelectors includes:con selector) ifTrue:[
  7973                 (errorSelectors includes:con selector) ifTrue:[
  8661                     isStoppedAtError := true.
  7974                     isStoppedAtError := true.
       
  7975                 ].
       
  7976                 (assertSelectors includes:con selector) ifTrue:[
       
  7977                     isStoppedAtAssert := true.
  8662                 ].
  7978                 ].
  8663                 "/ Transcript show:'xx '; showCR:con.
  7979                 "/ Transcript show:'xx '; showCR:con.
  8664                 calledContext := con.
  7980                 calledContext := con.
  8665                 con := con sender
  7981                 con := con sender
  8666             ].
  7982             ].
  8681             DebuggingContextWalk == true ifTrue:[ '---' print. con printCR ].
  7997             DebuggingContextWalk == true ifTrue:[ '---' print. con printCR ].
  8682 
  7998 
  8683             sel := con selector.
  7999             sel := con selector.
  8684             (errorSelectors includes:sel) ifTrue:[
  8000             (errorSelectors includes:sel) ifTrue:[
  8685                 isStoppedAtError := true.
  8001                 isStoppedAtError := true.
       
  8002             ].
       
  8003             (assertSelectors includes:sel) ifTrue:[
       
  8004                 isStoppedAtAssert := true.
  8686             ].
  8005             ].
  8687             (haltSelectors includes:sel) ifTrue:[
  8006             (haltSelectors includes:sel) ifTrue:[
  8688                 (method := con method) notNil ifTrue:[
  8007                 (method := con method) notNil ifTrue:[
  8689                     method mclass == Object ifTrue:[
  8008                     method mclass == Object ifTrue:[
  8690                         (sel isSymbol and:[sel startsWith:'breakPoint:']) ifTrue:[
  8009                         (sel isSymbol and:[sel startsWith:'breakPoint:']) ifTrue:[
  8896     ^ true
  8215     ^ true
  8897 
  8216 
  8898     "Created: / 14-12-1995 / 19:10:31 / cg"
  8217     "Created: / 14-12-1995 / 19:10:31 / cg"
  8899     "Modified: / 30-11-2017 / 12:16:08 / cg"
  8218     "Modified: / 30-11-2017 / 12:16:08 / cg"
  8900     "Modified: / 27-02-2019 / 22:38:55 / Claus Gittinger"
  8219     "Modified: / 27-02-2019 / 22:38:55 / Claus Gittinger"
       
  8220 !
       
  8221 
       
  8222 showError:message
       
  8223     codeView contents:(resources string:message).
       
  8224     shown ifTrue:[
       
  8225         exclusive ifTrue:[
       
  8226             "/ consider this a kludge:
       
  8227             "/ if exclusive, cannot use flash, since it suspends
       
  8228             "/ (but we cannot suspend here ...)
       
  8229             codeView redrawInverted. self flush.
       
  8230             OperatingSystem millisecondDelay:200.
       
  8231             codeView redraw
       
  8232         ] ifFalse:[
       
  8233             codeView flash
       
  8234         ]
       
  8235     ]
       
  8236 
       
  8237     "Modified: / 18.11.2001 / 00:01:13 / cg"
       
  8238 !
       
  8239 
       
  8240 showTerminated
       
  8241     self showError:'** the process has terminated **'
       
  8242 !
       
  8243 
       
  8244 showValue:aValue
       
  8245     infoLabelHolder value:aValue printString
       
  8246 
       
  8247     "Modified: / 28-07-2018 / 11:25:57 / Claus Gittinger"
       
  8248 !
       
  8249 
       
  8250 showWarning:aString
       
  8251     infoLabelHolder value:(aString withColor:Color red)
       
  8252 
       
  8253     "Created: / 02-07-2019 / 21:27:03 / Claus Gittinger"
       
  8254 !
       
  8255 
       
  8256 stepping
       
  8257     ^ stepping
       
  8258 !
       
  8259 
       
  8260 unstep
       
  8261     stepping := false.
       
  8262     bigStep := false.
       
  8263     steppedContext := wrapperContext := nil.
       
  8264     exitAction := nil
       
  8265 
       
  8266     "Modified: 22.10.1996 / 11:59:57 / cg"
       
  8267 !
       
  8268 
       
  8269 updateButtonsAndMenuItemsForContext:aContext
       
  8270     |m|
       
  8271 
       
  8272     m := contextView middleButtonMenu.
       
  8273     m notNil ifTrue:[
       
  8274         self updateMenuItems.
       
  8275 
       
  8276         (aContext notNil and:[(inspecting or:[AbortOperationRequest isHandledIn:aContext])]) ifTrue:[
       
  8277             abortButton enable.
       
  8278             m enable:#doAbort.
       
  8279         ] ifFalse:[
       
  8280             abortButton disable.
       
  8281             m disable:#doAbort.
       
  8282         ].
       
  8283         exclusive ifTrue:[
       
  8284             terminateButton disable.
       
  8285             m disable:#doTerminate.
       
  8286         ] ifFalse:[
       
  8287             terminateButton enable.
       
  8288             m enable:#doTerminate.
       
  8289         ].
       
  8290     ].
       
  8291 
       
  8292     mayProceed == false ifTrue:[
       
  8293         continueButton disable.
       
  8294         m notNil ifTrue:[m disable:#doContinue].
       
  8295     ] ifFalse:[
       
  8296         continueButton enable.
       
  8297         m notNil ifTrue:[m enable:#doContinue]
       
  8298     ].
       
  8299 
       
  8300     foundRaisingMethod ifTrue:[
       
  8301         gotoRaisingMethodButton enable.
       
  8302         gotoRaisingMethodButton beVisible.
       
  8303     ] ifFalse:[
       
  8304         gotoRaisingMethodButton beInvisible.
       
  8305     ].
       
  8306     
       
  8307     isStoppedInModalDialog ifTrue:[
       
  8308         gotoDialogOpenerButton enable.
       
  8309         gotoDialogOpenerButton beVisible.
       
  8310     ] ifFalse:[
       
  8311         gotoDialogOpenerButton beInvisible.
       
  8312     ].
       
  8313 
       
  8314     (isStoppedInModalDialog not & isStoppedInApplicationAction) ifTrue:[
       
  8315         gotoApplicationActionMethodButton enable.
       
  8316         gotoApplicationActionMethodButton beVisible.
       
  8317     ] ifFalse:[
       
  8318         gotoApplicationActionMethodButton beInvisible.
       
  8319     ].
       
  8320 
       
  8321     "Created: / 06-07-2011 / 12:24:53 / cg"
       
  8322     "Modified: / 30-11-2017 / 12:16:44 / cg"
       
  8323     "Modified: / 02-07-2019 / 16:46:46 / Claus Gittinger"
       
  8324 !
       
  8325 
       
  8326 updateContext
       
  8327     |oldContext idx|
       
  8328 
       
  8329     inspectedProcess isDead ifTrue:[
       
  8330         self showTerminated.
       
  8331         ^ self
       
  8332     ].
       
  8333 
       
  8334     oldContext := selectedContext.
       
  8335     [
       
  8336         (self setContextSkippingInterruptContexts:inspectedProcess suspendedContext) ifTrue:[
       
  8337             oldContext notNil ifTrue:[
       
  8338                 contextArray notNil ifTrue:[
       
  8339                     idx := contextArray identityIndexOf:oldContext.
       
  8340                     idx ~~ 0 ifTrue:[
       
  8341                         self showSelection:idx
       
  8342                     ] ifFalse:[
       
  8343                         codeView contents:('** context returned **')
       
  8344                     ]
       
  8345                 ]
       
  8346             ]
       
  8347         ].
       
  8348     ] valueUninterruptably.
       
  8349 
       
  8350     "Modified: / 20-10-1996 / 18:11:24 / cg"
       
  8351     "Modified: / 29-05-2019 / 01:02:43 / Claus Gittinger"
       
  8352 !
       
  8353 
       
  8354 withNodeValueAtInterval:interval do:aBlock
       
  8355     "helper for tooltops and explain-selection;
       
  8356      evaluate aBlock with description of what it is and its value
       
  8357      (if known)"
       
  8358 
       
  8359     |node definingNode nm nmBold nameSymbol
       
  8360      varIdx parentNode receiver con receiversNonMetaClass|
       
  8361 
       
  8362     "/ interval printCR.
       
  8363     Error
       
  8364         handle:[:ex | ]
       
  8365         do:[
       
  8366             [
       
  8367                 node := self findNodeForInterval:interval
       
  8368             ] valueWithWatchDog:[ ^ self ] afterMilliseconds:50.
       
  8369         ].
       
  8370 
       
  8371     node isNil ifTrue:[ ^ self ].
       
  8372     node isVariable ifFalse:[
       
  8373         "/ Transcript showCR:node.
       
  8374         ^ self
       
  8375     ].
       
  8376 
       
  8377     nm := node name.
       
  8378     nmBold := nm allBold.
       
  8379     actualContext isNil ifTrue:[^ self ].
       
  8380     actualContext methodHome isNil ifTrue:[^ self ].
       
  8381     receiver := actualContext methodHome receiver.
       
  8382 
       
  8383     (nm = 'self') ifTrue:[
       
  8384         aBlock value:receiver value:'receiver' allBold.
       
  8385         ^ self
       
  8386     ].
       
  8387     (nm = 'super') ifTrue:[
       
  8388         aBlock value:receiver value:'receiver' allBold.
       
  8389         ^ self
       
  8390     ].
       
  8391     (nm = 'thisContext') ifTrue:[
       
  8392         aBlock value:actualContext value:'context' allBold.
       
  8393         ^ self
       
  8394     ].
       
  8395 
       
  8396     definingNode := node whoDefines:nm.
       
  8397     definingNode isNil ifTrue:[
       
  8398         (receiver class allInstVarNames includes:nm) ifTrue:[
       
  8399             receiver class isMetaclass ifTrue:[
       
  8400                 aBlock value:(receiver instVarNamed:nm) value:'classInstVar ',nmBold.
       
  8401             ] ifFalse:[
       
  8402                 aBlock value:(receiver instVarNamed:nm) value:'instVar ',nmBold.
       
  8403             ].
       
  8404             ^ self
       
  8405         ].
       
  8406 
       
  8407         receiversNonMetaClass := receiver class theNonMetaclass.
       
  8408         (receiversNonMetaClass privateClasses contains:[:cls | cls nameWithoutPrefix = nm]) ifTrue:[
       
  8409             aBlock value:'' value:'private class ',nmBold.
       
  8410             ^ self
       
  8411         ].
       
  8412         (receiversNonMetaClass classVarNames includes:nm) ifTrue:[
       
  8413             aBlock value:((currentMethod mclass ? receiversNonMetaClass) theNonMetaclass classVarAt:nm) value:'classVar ',nmBold.
       
  8414             ^ self
       
  8415         ].
       
  8416         receiversNonMetaClass sharedPoolNames do:[:eachPoolName |
       
  8417             |pool|
       
  8418 
       
  8419             pool := Smalltalk at:eachPoolName.
       
  8420             pool isNil ifTrue:[ pool := receiversNonMetaClass topNameSpace at:eachPoolName].
       
  8421             (pool classVarNames includes:nm) ifTrue:[
       
  8422                 aBlock value:(pool classVarAt:nm) value:'poolVar ',nm allBold,' in ',eachPoolName allBold,' '.
       
  8423                 ^ self
       
  8424             ].
       
  8425         ].
       
  8426         nameSymbol := nm asSymbolIfInterned.
       
  8427         nameSymbol notNil ifTrue:[
       
  8428             (Smalltalk includesKey:nameSymbol) ifTrue:[
       
  8429                 (Smalltalk at:nameSymbol) isClass ifTrue:[
       
  8430                     aBlock value:(Smalltalk at:nameSymbol) value:''.
       
  8431                     "/ aBlock value:''(Smalltalk at:nameSymbol) value:'class ',nmBold.
       
  8432                 ] ifFalse:[
       
  8433                     aBlock value:(Smalltalk at:nameSymbol) value:'global ',nmBold.
       
  8434                 ].
       
  8435                 ^ self
       
  8436             ].
       
  8437         ].
       
  8438         aBlock value:'' value:'unknown'.
       
  8439         ^ self
       
  8440     ].
       
  8441 "/definingNode printCR.
       
  8442 
       
  8443     definingNode isMethod ifTrue:[
       
  8444         varIdx := definingNode arguments findFirst:[:arg | arg name = nm].
       
  8445         varIdx ~~ 0 ifTrue:[
       
  8446             Error
       
  8447                 handle:[:ex | ]
       
  8448                 do:[ aBlock value:(actualContext methodHome argAt:varIdx) value:'methodArg ',nmBold ].
       
  8449             ^ self
       
  8450         ].
       
  8451         varIdx := definingNode temporaries findFirst:[:var | var name = nm].
       
  8452         varIdx ~~ 0 ifTrue:[
       
  8453             actualContext methodHome numVars >= varIdx ifTrue:[
       
  8454                 Error
       
  8455                     handle:[:ex | ]
       
  8456                     do:[ aBlock value:(actualContext methodHome varAt:varIdx) value:'methodVar ',nmBold ].
       
  8457                 ^ self
       
  8458             ]
       
  8459         ].
       
  8460     ].
       
  8461 
       
  8462     definingNode isBlock ifTrue:[
       
  8463         varIdx := definingNode arguments findFirst:[:arg | arg name = nm].
       
  8464         (definingNode arguments contains:[:arg | arg name = nm]) ifTrue:[
       
  8465             varIdx ~~ 0 ifTrue:[
       
  8466                 "/ am I in this block ?
       
  8467                 (actualContext lineNumber notNil
       
  8468                 and:[ definingNode lastLineNumber notNil
       
  8469                 and:[ (actualContext lineNumber
       
  8470                             between:definingNode firstLineNumber
       
  8471                             and:definingNode lastLineNumber)
       
  8472                 and:[ varIdx <= actualContext numArgs ] ]])
       
  8473                 ifTrue:[
       
  8474                     aBlock value:(actualContext argAt:varIdx) value:'blockArg ',nmBold .
       
  8475                     ^ self
       
  8476                 ].
       
  8477                 aBlock value:nmBold , ' is not in scope of selected context' value:nil.
       
  8478                 ^ self
       
  8479             ]
       
  8480         ].
       
  8481     ].
       
  8482 
       
  8483     parentNode := definingNode parent.
       
  8484 
       
  8485     [parentNode notNil] whileTrue:[
       
  8486         "/'isMethod ' print. parentNode isMethod printCR.
       
  8487         parentNode isMethod ifTrue:[
       
  8488             varIdx := parentNode temporaries findFirst:[:var | var name = nm].
       
  8489             varIdx ~~ 0 ifTrue:[
       
  8490                 actualContext methodHome numVars >= varIdx ifTrue:[
       
  8491                     Error
       
  8492                         handle:[:ex | ]
       
  8493                         do:[ aBlock value:(actualContext methodHome varAt:varIdx) value:'methodVar ',nmBold ].
       
  8494                     ^ self
       
  8495                 ]
       
  8496             ].
       
  8497         ].
       
  8498         "/'isBlock ' print. parentNode isBlock printCR.
       
  8499         parentNode isBlock ifTrue:[
       
  8500             "/ we don't have any information on the inlineability
       
  8501             "/ of this block here (RBParser does not know what
       
  8502             "/ the compiler does).
       
  8503             "/ therefore, it is questionable if we can use the
       
  8504             "/ context's home context here.
       
  8505             "/ am I in this block ?
       
  8506             con := actualContext.
       
  8507             [con notNil
       
  8508             and:[ parentNode lastLineNumber notNil
       
  8509             and:[ con lineNumber notNil
       
  8510             and:[ con lineNumber
       
  8511                     between:parentNode firstLineNumber
       
  8512                     and:parentNode lastLineNumber ]]]] whileTrue:[
       
  8513                 con := con sender.
       
  8514             ].
       
  8515             con notNil ifTrue:[
       
  8516                 varIdx := parentNode arguments findFirst:[:arg | arg name = nm].
       
  8517                 varIdx ~~ 0 ifTrue:[
       
  8518                     Error
       
  8519                         handle:[:ex | ]
       
  8520                         do:[ aBlock value:(con argAt:varIdx) value:'blockArg ',nmBold ].
       
  8521                     ^ self
       
  8522                 ].
       
  8523                 varIdx := parentNode body temporaries findFirst:[:var | var name = nm].
       
  8524                 varIdx ~~ 0 ifTrue:[
       
  8525                     Error
       
  8526                         handle:[:ex | ]
       
  8527                         do:[ aBlock value:(con varAt:varIdx) value:'blockVar ',nmBold ].
       
  8528                     ^ self
       
  8529                 ].
       
  8530             ].
       
  8531         ].
       
  8532         parentNode := parentNode parent.
       
  8533     ].
       
  8534     aBlock value:nmBold , ' is not in scope of selected context' value:nil.
       
  8535 
       
  8536     "Modified: / 18-01-2011 / 17:57:34 / cg"
       
  8537     "Modified: / 28-07-2018 / 11:46:46 / Claus Gittinger"
       
  8538 ! !
       
  8539 
       
  8540 !DebugView methodsFor:'private queries'!
       
  8541 
       
  8542 canBrowseClassHierarchy
       
  8543     |m|
       
  8544 
       
  8545     m := contextView middleButtonMenu.
       
  8546     ^ m notNil and:[m isEnabled:#browseClassHierarchy]
       
  8547 !
       
  8548 
       
  8549 canBrowseFullClassProtocol
       
  8550     |m|
       
  8551 
       
  8552     m := contextView middleButtonMenu.
       
  8553     ^ m notNil and:[m isEnabled:#browseFullClassProtocol]
       
  8554 !
       
  8555 
       
  8556 canBrowseImplementingClass
       
  8557     |m|
       
  8558 
       
  8559     m := contextView middleButtonMenu.
       
  8560     ^ m notNil and:[m isEnabled:#browseImplementingClass]
       
  8561 !
       
  8562 
       
  8563 canBrowseProcessesApplication
       
  8564     |p|
       
  8565 
       
  8566     p := inspectedProcess ? Processor activeProcess.
       
  8567     p isNil ifTrue:[^ false].
       
  8568     ^ p isGUIProcess and:[self processesApplication notNil ].
       
  8569 !
       
  8570 
       
  8571 canBrowseReceiversClass
       
  8572     |m|
       
  8573 
       
  8574     m := contextView middleButtonMenu.
       
  8575     ^ m notNil 
       
  8576         and:[
       
  8577             (m isEnabled:#browseReceiversClass)
       
  8578             or:[ m isEnabled:#browseImplementingClass ]
       
  8579         ]
       
  8580 
       
  8581     "Modified: / 25-11-2016 / 13:25:55 / cg"
       
  8582 !
       
  8583 
       
  8584 canCloseAllDebuggers
       
  8585     self class allInstancesDo:[:debugger |
       
  8586         debugger ~~ self ifTrue:[
       
  8587             debugger busy ifTrue:[^ true].
       
  8588         ]
       
  8589     ].
       
  8590     ^ false
       
  8591 
       
  8592     "Created: / 23-03-2012 / 12:40:18 / cg"
       
  8593 !
       
  8594 
       
  8595 canDefineMethod
       
  8596     ^ defineButton isVisible
       
  8597 !
       
  8598 
       
  8599 canInspectWidgetHierarchy
       
  8600     |rcvr|
       
  8601 
       
  8602     ^ (selectedContext notNil
       
  8603         and:[(rcvr := selectedContext receiver) isProtoObject not 
       
  8604         and:[rcvr isView or:[rcvr isKindOf: ApplicationModel]]])
       
  8605     or:[
       
  8606         self canBrowseProcessesApplication
       
  8607     ]
       
  8608 
       
  8609     "Modified: / 25-11-2016 / 13:17:20 / cg"
       
  8610 !
       
  8611 
       
  8612 canRedefineMethodInReceiverClass
       
  8613     "true if a context is selected, where an inherited method was called.
       
  8614      Used to enable the redefine menu option"
       
  8615      
       
  8616     |con selector receiverClass implClass|
       
  8617     
       
  8618     (con := actualContext) notNil ifTrue:[
       
  8619         (actualContext home) notNil ifTrue:[
       
  8620             con := actualContext home 
       
  8621         ].
       
  8622         selector := con selector.
       
  8623         receiverClass := con receiver class.
       
  8624         (receiverClass implements:selector) ifFalse:[
       
  8625             implClass := receiverClass whichClassIncludesSelector:selector.
       
  8626             ^ implClass notNil
       
  8627         ].    
       
  8628     ].    
       
  8629     ^ false
       
  8630 
       
  8631     "Created: / 08-02-2017 / 08:45:38 / cg"
       
  8632 !
       
  8633 
       
  8634 canRestart
       
  8635     ^ restartButton isEnabled
       
  8636 
       
  8637     "Modified: / 17.11.2001 / 19:59:49 / cg"
       
  8638 !
       
  8639 
       
  8640 canReturn
       
  8641     ^ returnButton isEnabled
       
  8642 
       
  8643     "Modified: / 17.11.2001 / 19:59:18 / cg"
       
  8644 !
       
  8645 
       
  8646 canSendEmail
       
  8647     ^ SendMailTool notNil
       
  8648 
       
  8649     "Created: / 15-10-2010 / 11:51:23 / cg"
       
  8650 !
       
  8651 
       
  8652 canShowMore
       
  8653     ^ canShowMore
       
  8654 !
       
  8655 
       
  8656 hasBlockContextSelected
       
  8657     ^ contextView hasSelection
       
  8658     and:[ self selectedContext isBlockContext ]
       
  8659 !
       
  8660 
       
  8661 hasContextSelected
       
  8662     ^ contextView hasSelection
       
  8663 
       
  8664     "Created: / 17.11.2001 / 19:57:03 / cg"
       
  8665 !
       
  8666 
       
  8667 hasHaltsToIgnore
       
  8668     ^ IgnoredHalts notEmptyOrNil
       
  8669 !
       
  8670 
       
  8671 isAborting
       
  8672     ^ exitAction == #abort
       
  8673 !
       
  8674 
       
  8675 isStoppedAtAssert
       
  8676     ^ isStoppedAtAssert ? false 
       
  8677 !
       
  8678 
       
  8679 isStoppedAtBreakPointWithParameter
       
  8680     ^ isStoppedAtBreakPointWithParameter ? false 
       
  8681 
       
  8682     "Created: / 06-03-2012 / 12:16:56 / cg"
       
  8683 !
       
  8684 
       
  8685 isStoppedAtError
       
  8686     ^ isStoppedAtError ? false  "/ ^ self isStoppedAtHaltOrBreakPoint not
       
  8687 
       
  8688     "Created: / 27-02-2019 / 12:36:35 / Claus Gittinger"
       
  8689     "Modified: / 27-02-2019 / 22:18:04 / Claus Gittinger"
       
  8690 !
       
  8691 
       
  8692 isStoppedAtHaltOrBreakPoint
       
  8693     ^ isStoppedAtHaltOrBreakPoint ? false 
       
  8694 !
       
  8695 
       
  8696 isStoppedAtHaltOrBreakPointOrSelectedContextIsWrapped
       
  8697     ^ (isStoppedAtHaltOrBreakPoint ? false) or:[self selectedContextIsWrapped]
       
  8698 !
       
  8699 
       
  8700 isStoppedAtHaltOrBreakPointOrSelectedContextIsWrappedAndHasPreviousIgnoreTime
       
  8701     ^ self isStoppedAtHaltOrBreakPointOrSelectedContextIsWrapped
       
  8702     and:[LastIgnoreHaltDuration notEmptyOrNil]
       
  8703 
       
  8704     "Created: / 09-11-2018 / 20:37:02 / Claus Gittinger"
       
  8705 !
       
  8706 
       
  8707 selectedContextIsWrapped
       
  8708     |con mthd|
       
  8709 
       
  8710     (con := self selectedContext) notNil ifTrue:[
       
  8711         mthd := con method.
       
  8712         ^ mthd notNil and:[mthd isWrapped]
       
  8713     ].
       
  8714     ^ false.
       
  8715 
       
  8716     "Modified: / 19-07-2012 / 11:36:28 / cg"
       
  8717 !
       
  8718 
       
  8719 setOfHiddenCallingSelectors
       
  8720     ^ setOfHiddenCallingSelectors ? #( #'doIt' #'doIt:' )
       
  8721 !
       
  8722 
       
  8723 setOfHiddenCallingSelectors:aCollectionOfSymbols
       
  8724     setOfHiddenCallingSelectors := aCollectionOfSymbols
       
  8725 ! !
       
  8726 
       
  8727 !DebugView methodsFor:'private-breakpoints'!
       
  8728 
       
  8729 addIgnoredAssertForCount:countOrNil
       
  8730         orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
       
  8731         orThisReceiverClass:forThisReceiverClass orCurrentProcess:forCurrentProcess
       
  8732         orIfCalledFromMethod:ifCalledForMethodOrNil
       
  8733         forAll:aBoolean
       
  8734 
       
  8735     |assertingContext assertingMethod lineNrOfHalt receiverClassOrNil processOrNil|
       
  8736 
       
  8737     aBoolean ifTrue:[
       
  8738         assertingMethod := #all
       
  8739     ] ifFalse:[
       
  8740         assertingContext := self findHaltingContext.
       
  8741         assertingContext isNil ifTrue:[
       
  8742             Transcript showCR:'no asserting context found'.
       
  8743             ^ self
       
  8744         ].
       
  8745 
       
  8746         assertingMethod := assertingContext method.
       
  8747         lineNrOfHalt := assertingContext lineNumber.
       
  8748         (lineNrOfHalt isNil or:[lineNrOfHalt <= 0]) ifTrue:[
       
  8749             Transcript showCR:'no assert lineNr found'.
       
  8750             ^ self
       
  8751         ].
       
  8752         forThisReceiverClass ifTrue:[
       
  8753             receiverClassOrNil := assertingContext receiver class
       
  8754         ].
       
  8755         forCurrentProcess ifTrue:[
       
  8756             processOrNil := Processor activeProcess
       
  8757         ].
       
  8758     ].
       
  8759 
       
  8760     self class
       
  8761         ignoreHaltIn:assertingMethod at:lineNrOfHalt
       
  8762         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
       
  8763         orReceiverClass:receiverClassOrNil orProcess:processOrNil
       
  8764         orIfCalledFromMethod:ifCalledForMethodOrNil
       
  8765 
       
  8766     "Created: / 27-01-2012 / 11:31:12 / cg"
       
  8767 !
       
  8768 
       
  8769 addIgnoredErrorForCount:countOrNil
       
  8770         orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
       
  8771         orThisReceiverClass:forThisReceiverClass orCurrentProcess:forCurrentProcess
       
  8772         orIfCalledFromMethod:ifCalledForMethodOrNil
       
  8773         forAll:aBoolean
       
  8774 
       
  8775     |errorContext errorMethod lineNrOfError receiverClassOrNil processOrNil|
       
  8776 
       
  8777     aBoolean ifTrue:[
       
  8778         errorMethod := #all
       
  8779     ] ifFalse:[
       
  8780         errorContext := self findErrorContext.
       
  8781         errorContext isNil ifTrue:[
       
  8782             Transcript showCR:'no error context found'.
       
  8783             ^ self
       
  8784         ].
       
  8785 
       
  8786         errorMethod := errorContext method.
       
  8787         lineNrOfError := errorContext lineNumber.
       
  8788         (lineNrOfError isNil or:[lineNrOfError <= 0]) ifTrue:[
       
  8789             Transcript showCR:'no Error lineNr found'.
       
  8790             ^ self
       
  8791         ].
       
  8792         forThisReceiverClass ifTrue:[
       
  8793             receiverClassOrNil := errorContext receiver class
       
  8794         ].
       
  8795         forCurrentProcess ifTrue:[
       
  8796             processOrNil := Processor activeProcess
       
  8797         ].
       
  8798     ].
       
  8799 
       
  8800     self class
       
  8801         ignoreErrorIn:errorMethod line:lineNrOfError
       
  8802         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
       
  8803         orReceiverClass:receiverClassOrNil orProcess:processOrNil
       
  8804         orIfCalledFromMethod:ifCalledForMethodOrNil
       
  8805 
       
  8806     "Created: / 27-02-2019 / 12:42:12 / Claus Gittinger"
       
  8807     "Modified: / 27-02-2019 / 22:23:17 / Claus Gittinger"
       
  8808 !
       
  8809 
       
  8810 addIgnoredHaltForCount:countOrNil
       
  8811         orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
       
  8812         orThisReceiverClass:forThisReceiverClass orCurrentProcess:forCurrentProcess
       
  8813         orIfCalledFromMethod:ifCalledForMethodOrNil
       
  8814         forAll:aBoolean
       
  8815 
       
  8816     |haltingContext haltingMethod lineNrOfHalt receiverClassOrNil processOrNil|
       
  8817 
       
  8818     aBoolean ifTrue:[
       
  8819         haltingMethod := #all
       
  8820     ] ifFalse:[
       
  8821         haltingContext := self findHaltingContext.
       
  8822         haltingContext isNil ifTrue:[
       
  8823             Transcript showCR:'no halting context found'.
       
  8824             ^ self
       
  8825         ].
       
  8826 
       
  8827         haltingMethod := haltingContext method.
       
  8828         lineNrOfHalt := haltingContext lineNumber.
       
  8829         (lineNrOfHalt isNil or:[lineNrOfHalt <= 0]) ifTrue:[
       
  8830             Transcript showCR:'no halt lineNr found'.
       
  8831             ^ self
       
  8832         ].
       
  8833         forThisReceiverClass ifTrue:[
       
  8834             receiverClassOrNil := haltingContext receiver class
       
  8835         ].
       
  8836         forCurrentProcess ifTrue:[
       
  8837             processOrNil := Processor activeProcess
       
  8838         ].
       
  8839     ].
       
  8840 
       
  8841     self class
       
  8842         ignoreHaltIn:haltingMethod at:lineNrOfHalt
       
  8843         forCount:countOrNil orTimeDuration:dTOrNil orUntilShiftKey:untilShiftKey
       
  8844         orReceiverClass:receiverClassOrNil orProcess:processOrNil
       
  8845         orIfCalledFromMethod:ifCalledForMethodOrNil
       
  8846 
       
  8847     "Created: / 27-01-2012 / 11:31:12 / cg"
       
  8848 !
       
  8849 
       
  8850 canAddBreakpoint
       
  8851     |m|
       
  8852 
       
  8853     m := contextView middleButtonMenu.
       
  8854     ^ m notNil and:[m isEnabled:#addBreakpoint]
       
  8855 !
       
  8856 
       
  8857 canRemoveBreakpoint
       
  8858     |m|
       
  8859 
       
  8860     m := contextView middleButtonMenu.
       
  8861     ^ m notNil and:[m isEnabled:#removeBreakpoint]
       
  8862 !
       
  8863 
       
  8864 findAssertingContext
       
  8865     ^ self
       
  8866         findContextWithAnySelector:(self class assertSelectors) 
       
  8867         orMClass:nil 
       
  8868         orWrapped:false
       
  8869 !
       
  8870 
       
  8871 findContextWithAnySelector:selectors orMClass:mClass orWrapped:orWrappedBoolean
       
  8872     |con|
       
  8873 
       
  8874     con := firstContext.
       
  8875     [con notNil] whileTrue:[
       
  8876     "/ contextArray keysAndValuesDo:[:idx :con |
       
  8877         |sel con2 sel2 method|
       
  8878 
       
  8879         sel := con selector.
       
  8880         (selectors includes:sel) ifTrue:[
       
  8881             (method := con method) notNil ifTrue:[
       
  8882                 method mclass == Object ifTrue:[
       
  8883                     con2 := con sender. "/ contextArray at:idx+1.
       
  8884                     sel2 := con2 selector.
       
  8885                     (selectors includes:sel2) ifTrue:[
       
  8886                         con2 method mclass == Object ifTrue:[
       
  8887                             ^ con2 sender "/ contextArray at:idx+2.
       
  8888                         ]
       
  8889                     ].
       
  8890                     ^ con2. "/ contextArray at:idx+1
       
  8891                 ].
       
  8892                 (mClass notNil and:[method mclass == mClass]) ifTrue:[
       
  8893                     "/ (contextArray at:idx+1) infoPrintCR.
       
  8894                     ^ con sender "/ contextArray at:idx+1
       
  8895                 ].
       
  8896             ].
       
  8897         ].
       
  8898         (orWrappedBoolean and:[con method isWrapped]) ifTrue:[
       
  8899             ^ con
       
  8900         ].
       
  8901         con := con sender.
       
  8902     ].
       
  8903     ^ nil
       
  8904 
       
  8905     "Created: / 27-02-2019 / 13:40:25 / Claus Gittinger"
       
  8906     "Modified: / 27-02-2019 / 22:20:27 / Claus Gittinger"
       
  8907 !
       
  8908 
       
  8909 findErrorContext
       
  8910     ^ self
       
  8911         findContextWithAnySelector:(self class errorSelectors) 
       
  8912         orMClass:nil 
       
  8913         orWrapped:false
       
  8914 
       
  8915     "Created: / 27-02-2019 / 13:41:18 / Claus Gittinger"
       
  8916     "Modified: / 27-02-2019 / 22:37:14 / Claus Gittinger"
       
  8917 !
       
  8918 
       
  8919 findHaltingContext
       
  8920     ^ self
       
  8921         findContextWithAnySelector:(self class haltSelectors) 
       
  8922         orMClass:Breakpoint 
       
  8923         orWrapped:true
       
  8924 
       
  8925     "Modified: / 27-01-2012 / 11:06:02 / cg"
       
  8926     "Modified: / 27-02-2019 / 22:39:03 / Claus Gittinger"
       
  8927 !
       
  8928 
       
  8929 ignoreBreakpoints
       
  8930     ^ ignoreBreakpoints ? false
       
  8931 
       
  8932     "Created: / 17-11-2001 / 18:20:16 / cg"
       
  8933     "Modified: / 10-02-2019 / 12:47:22 / Claus Gittinger"
       
  8934 ! !
       
  8935 
       
  8936 !DebugView methodsFor:'private-cache handling'!
       
  8937 
       
  8938 cacheMyself
       
  8939     "remember myself for next debug session"
       
  8940 
       
  8941     "caching the last debugger will make the next debugger appear
       
  8942      faster, since no resources have to be allocated in the display.
       
  8943      We have to be careful to release all refs to the debuggee, though.
       
  8944      Otherwise, the GC will not be able to release it."
       
  8945 
       
  8946     windowGroup notNil ifTrue:[
       
  8947         windowGroup setProcess:nil.
       
  8948     ].
       
  8949 
       
  8950     self releaseDebuggee.
       
  8951 
       
  8952     cachable ~~ true ifTrue:[^ self].
       
  8953 
       
  8954     "/
       
  8955     "/ only cache if I am on the Display (i.e. the default screen)
       
  8956     "/
       
  8957     device == Display ifTrue:[
       
  8958         exclusive ifTrue:[
       
  8959             CachedExclusive := self
       
  8960         ] ifFalse:[
       
  8961             CachedDebugger := self
       
  8962         ].
       
  8963     ].
       
  8964 
       
  8965     ObjectMemory stepInterruptHandler == self ifTrue:[
       
  8966         ObjectMemory stepInterruptHandler:nil
       
  8967     ].
       
  8968 
       
  8969     "Modified: 10.7.1997 / 15:50:46 / stefan"
       
  8970     "Modified: 31.7.1997 / 21:20:14 / cg"
       
  8971 !
       
  8972 
       
  8973 isCached
       
  8974     "tell whether we are a cached debugger"
       
  8975 
       
  8976     CachedExclusive == self ifTrue:[
       
  8977         ^ true.
       
  8978     ].
       
  8979     CachedDebugger == self ifTrue:[
       
  8980         ^ true.
       
  8981     ].
       
  8982 
       
  8983     ^ false.
       
  8984 
       
  8985     "Created: / 10-07-1997 / 15:22:43 / stefan"
       
  8986     "Modified (comment): / 27-07-2013 / 15:38:47 / cg"
       
  8987 !
       
  8988 
       
  8989 uncacheMyself
       
  8990     "do not remember myself any longer for next debug session"
       
  8991 
       
  8992     cachable := false.
       
  8993 
       
  8994     CachedExclusive == self ifTrue:[
       
  8995         CachedExclusive := nil.
       
  8996     ].
       
  8997     CachedDebugger == self ifTrue:[
       
  8998         CachedDebugger := nil.
       
  8999     ].
       
  9000     OpenDebuggers notNil ifTrue:[
       
  9001         OpenDebuggers remove:self ifAbsent:[].
       
  9002     ].
       
  9003 
       
  9004     "Modified: 31.7.1997 / 21:20:11 / cg"
       
  9005 ! !
       
  9006 
       
  9007 !DebugView methodsFor:'private-code generation helpers'!
       
  9008 
       
  9009 argumentNamesForNewMethodOfContext:context
       
  9010     "generate argument names for a prototypeMethod for the message in context.
       
  9011      Used by doDefine and doRedefine"
       
  9012 
       
  9013     |bagOfClassNames bagOfUsedClassNames argNames|
       
  9014     
       
  9015     bagOfClassNames := (actualContext args collect:[:eachArg | eachArg class name]) asBag.
       
  9016     bagOfUsedClassNames := Bag new.
       
  9017     argNames := actualContext args
       
  9018                     collect:
       
  9019                         [:eachArg |
       
  9020                             |nm|
       
  9021 
       
  9022                             nm := eachArg class nameWithoutPrefix.
       
  9023                             (bagOfClassNames occurrencesOf:nm) == 1 ifTrue:[
       
  9024                                 nm article , nm
       
  9025                             ] ifFalse:[
       
  9026                                 bagOfUsedClassNames add:nm.
       
  9027                                 nm asLowercaseFirst , (bagOfUsedClassNames occurrencesOf:nm) printString
       
  9028                             ].
       
  9029                         ].
       
  9030     ^ argNames
       
  9031 
       
  9032     "Created: / 08-02-2017 / 08:57:24 / cg"
       
  9033 ! !
       
  9034 
       
  9035 !DebugView methodsFor:'private-code view'!
       
  9036 
       
  9037 codeAspect
       
  9038     ^ SyntaxHighlighter codeAspectMethod
       
  9039 
       
  9040     "Created: / 27-07-2011 / 13:07:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
  9041     "Modified: / 27-07-2012 / 22:20:27 / cg"
       
  9042 ! !
       
  9043 
       
  9044 !DebugView methodsFor:'private-context handling'!
       
  9045 
       
  9046 contextListEntryFor:aContext
       
  9047     ^ Error
       
  9048         handle:[:ex | '???' ]
       
  9049         do:[
       
  9050             |s|
       
  9051 
       
  9052             aContext selector == #doIt ifTrue:[
       
  9053                 aContext receiver isNil ifTrue:[
       
  9054                     s := 'doIt' allBold
       
  9055                 ]
       
  9056             ].
       
  9057 
       
  9058             s := Text streamContents:[:s | aContext printWithSeparator:' ยป ' on:s ].
       
  9059             "/ s infoPrintCR.
       
  9060             RememberedCallChain notNil ifTrue:[
       
  9061                 (RememberedCallChain includesIdentical:aContext) ifTrue:[
       
  9062                     s := s withColor:#red.
       
  9063                 ].
       
  9064             ].
       
  9065             s
       
  9066         ].
       
  9067 
       
  9068     "Created: / 21-05-2007 / 13:30:24 / cg"
       
  9069     "Modified: / 27-06-2018 / 17:15:47 / Claus Gittinger"
       
  9070 !
       
  9071 
       
  9072 is:aHomeContext inCallingChainOf:aContext
       
  9073     |con|
       
  9074 
       
  9075     con := aContext.
       
  9076     [con notNil and:[con ~~ aHomeContext]] whileTrue:[
       
  9077         con := con sender
       
  9078     ].
       
  9079     ^ con notNil
       
  9080 
       
  9081     "Created: / 10-06-2012 / 18:46:29 / cg"
       
  9082 !
       
  9083 
       
  9084 isEnteredDueToBreakpointOrHalt
       
  9085     "see if we came here due to a step interrupt"
       
  9086 
       
  9087     |c cReceiver|
       
  9088 
       
  9089     "/ look for a breakpoint-wrapper's context
       
  9090     c := thisContext findNextContextWithSelector:#'raiseRequestWith:errorString:in:' or:nil or:nil.
       
  9091     c isNil ifTrue:[
       
  9092         ^ true.
       
  9093     ].
       
  9094     cReceiver := c receiver.
       
  9095     ^ cReceiver == BreakPointInterrupt
       
  9096 
       
  9097     "Modified: / 01-08-2013 / 23:34:01 / cg"
       
  9098 !
       
  9099 
       
  9100 isHaltToBeIgnored
       
  9101     "see if the current halt (if any) is in the ignore-list"
       
  9102 
       
  9103     |c cReceiver sender haltingMethod lineNrInHaltingMethod breakpointParameter
       
  9104      sReceiver|
       
  9105 
       
  9106     "/ should a halt be ignored ?
       
  9107     IgnoredHalts isNil ifTrue:[^ false].
       
  9108 
       
  9109     "/ look for a method breakpoint-wrapper's context
       
  9110     c := thisContext findNextContextWithSelector:#doRaise or:nil or:nil.
       
  9111     c notNil ifTrue:[
       
  9112         ((cReceiver := c receiver) isKindOf:NoHandlerError) ifTrue:[
       
  9113             c := c sender findNextContextWithSelector:#doRaise or:nil or:nil.
       
  9114             cReceiver := c receiver.
       
  9115         ].
       
  9116         (cReceiver isKindOf:BreakPointInterrupt) ifFalse:[
       
  9117             c := nil
       
  9118         ] ifTrue:[
       
  9119             [
       
  9120                 sender := c sender.
       
  9121                 ((sReceiver := sender receiver) isKindOf:BreakPointInterrupt)
       
  9122                 or:[ sReceiver == BreakPointInterrupt ]
       
  9123             ] whileTrue:[
       
  9124                 c := sender
       
  9125             ].
       
  9126             [ (sender := c sender) isBlockContext ] whileTrue:[
       
  9127                 c := sender
       
  9128             ].
       
  9129             sender := nil. "/ avoid keeping a reference to this context
       
  9130         ].
       
  9131     ].
       
  9132     "/ Transcript showCR:c.
       
  9133     c isNil ifTrue:[
       
  9134         "/ look for halts or explicit breakpoints
       
  9135         c := thisContext findNextContextWithSelector:#halt or:#halt: or:nil.
       
  9136         c isNil ifTrue:[
       
  9137             c := thisContext findNextContextWithSelector:#breakPoint: or:#breakPoint:info: or:nil.
       
  9138             c isNil ifTrue:[
       
  9139                ^ false
       
  9140             ].
       
  9141             breakpointParameter := c argAt:1.
       
  9142             (self class
       
  9143                     isBreakpointToBeIgnoredForParameter:breakpointParameter
       
  9144                     context:(c sender)
       
  9145                     modifyEntryCount:true
       
  9146             ) ifTrue:[
       
  9147                 ^ true.
       
  9148             ].
       
  9149         ].
       
  9150     ].
       
  9151 
       
  9152     c := c sender.
       
  9153     "/ a code-breakpoint ?
       
  9154     (c receiver isKindOf:Breakpoint) ifTrue:[
       
  9155         c := c sender.
       
  9156     ].
       
  9157     haltingMethod := c method.
       
  9158 
       
  9159     haltingMethod isWrapped ifTrue:[
       
  9160         lineNrInHaltingMethod := 1.
       
  9161     ] ifFalse:[
       
  9162         lineNrInHaltingMethod := c lineNumber.
       
  9163         "/ Transcript showCR:c.
       
  9164     ].
       
  9165 
       
  9166     ^ self class
       
  9167         isHaltToBeIgnoredIn:haltingMethod
       
  9168         atLineNr:lineNrInHaltingMethod
       
  9169         context:c
       
  9170         modifyEntryCount:true.
       
  9171 
       
  9172     "Created: / 22-10-2010 / 12:09:53 / cg"
       
  9173     "Modified: / 06-03-2012 / 12:54:09 / cg"
       
  9174 !
       
  9175 
       
  9176 setContext:aContext
       
  9177     "show calling chain from aContext in the walk-back listview"
       
  9178 
       
  9179     ^ self setContext:aContext releaseInspectors:true
       
  9180 
       
  9181     "Modified: 27.6.1996 / 17:21:59 / cg"
  8901 !
  9182 !
  8902 
  9183 
  8903 setContextSkippingInterruptContexts:aContext
  9184 setContextSkippingInterruptContexts:aContext
  8904     "show calling chain from aContext in the walk-back listview.
  9185     "show calling chain from aContext in the walk-back listview.
  8905      Ignore any non-interesting interrupt-context."
  9186      Ignore any non-interesting interrupt-context."