=============== Summary ===============

Change Set:        stepThroughDeadHome
Date:            24 February 2024
Author:            Christoph Thiede

Patches Process>>#stepToHome: so that stepping through a bottom context that is not a home context works as expected.

Revises Kernel-ct.1384.

=============== Diff ===============

Context>>hasHome: {testing} · ct 10/21/2023 20:35
+ hasHome: aContext
+
+     self == aContext ifTrue: [^ true].
+     closureOrNil ifNil: [^ false].
+     ^ closureOrNil outerContext hasHome: aContext


Context>>livingHome {accessing} · ct 10/21/2023 20:36
+ livingHome
+
+     self isDead ifTrue: [^ nil].
+     closureOrNil ifNil: [^ self].
+     ^ closureOrNil outerContext livingHome ifNil: [self]


Process>>stepToHome: {changing suspended state} · ct 2/24/2024 21:54 (changed)
stepToHome: aContext
    "Resume self until the home of top context is aContext. Top context may be a block context.
     Catch any UnhandledErrors that are created while stepping, answering the relevant signalerContext
     if so. Note that this will cause weird effects if using through to step through UnhandledError
     code, but as the doctor ordered, don't do that; use over or into instead."
-
+     
    ^Processor activeProcess
        evaluate:
            [| home anError |
-             home := aContext home.
+             home := aContext livingHome. "aContext home may legitimally be dead, e.g. doing the followig separately from a workspace:
+                 
+                 p := Process forContext: ([[] ensure: []] asContext) priority: 40.
+                 p debug."
            [suspendedContext := suspendedContext step.
-              home == suspendedContext home or: [home isDead]] whileFalse:
+              home isDead or: [suspendedContext isDead or: [suspendedContext hasHome: home]]] whileFalse:
                [(suspendedContext selector == #signalForException:
                 and: [(suspendedContext receiver isBehavior and: [
                        suspendedContext receiver includesBehavior: UnhandledError])
                 and: [anError := suspendedContext tempAt: 1.
                     ((suspendedContext objectClass: anError) includesBehavior: Exception)
                 and: [anError canSearchForSignalerContext]]]) ifTrue:
                    [anError signalerContext ifNotNil:
                        [:unhandledErrorSignalerContext|
                        [unhandledErrorSignalerContext == suspendedContext] whileFalse:
                            [self completeStep: suspendedContext].
                        "Give a debugger a chance to update its title to reflect the new exception"
                         Notification new
                            tag: {unhandledErrorSignalerContext. anError};
                            signal.
                        ^unhandledErrorSignalerContext]]].
            suspendedContext]
        onBehalfOf: self

---
Sent from Squeak Inbox Talk
["stepThroughDeadHome.1.cs"]