Questions about DebugSession>>isContextPostMortem:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Questions about DebugSession>>isContextPostMortem:

Thomas Dupriez-2

Hello,

While looking at the DebugSession>>isContextPostMortem: method (code below), I got three questions:

1) There is a check for whether the suspendedContext (top context) of the process is nil. Does it even make sense for a process not to have any top context?

2) It seems that all the last 3 lines are doing is to check whether selectedContext is in the context chain of the process. Could they be rewritten into this simpler one-liner?   `^ (suspendedContext hasContext: selectedContext) not`

3) Overall, this method says that a context C is "post mortem" if the process controlled by the DebugSession has a top context and C is not in its context chain. That's the practical definition. Could someone shed some light on the high-level definition of "post mortem"? Because "post mortem" is like "after death", but the death of what? A context that merely belongs to another context chain would be considered "post mortem" by the practical definition, but there's no death in this case...


```

DebugSession>>isContextPostMortem: selectedContext
	"return whether we're inspecting a frozen exception without a process attached"
	| suspendedContext |
	suspendedContext := interruptedProcess suspendedContext.
	suspendedContext ifNil: [ ^ false ].
	(suspendedContext == selectedContext)
		ifTrue: [ ^ false ].
	^ (suspendedContext findContextSuchThat: [:c | c sender == selectedContext]) isNil
```

Does someone know the answer to some (or all) of these questions?

Thomas

Reply | Threaded
Open this post in threaded view
|

Re: Questions about DebugSession>>isContextPostMortem:

Max Leske
On 21 Mar 2019, at 11:06, Thomas Dupriez wrote:

Hi Thomas,

> Hello,
>
> While looking at the DebugSession>>isContextPostMortem: method (code
> below), I got three questions:
>
> 1) There is a check for whether the suspendedContext (top context) of
> the process is nil. Does it even make sense for a process not to have
> any top context?

Yes, only suspended processes have a suspendedContext. Also, the process
might have been terminated already.

>
> 2) It seems that all the last 3 lines are doing is to check whether
> selectedContext is in the context chain of the process. Could they be
> rewritten into this simpler one-liner?   `|^ (suspendedContext
> hasContext: selectedContext) not`|

Yes, I think that would work.

>
> 3) Overall, this method says that a context C is "post mortem" if the
> process controlled by the DebugSession has a top context and C is not
> in its context chain. That's the practical definition. Could someone
> shed some light on the high-level definition of "post mortem"? Because
> "post mortem" is like "after death", but the death of what? A context
> that merely belongs to another context chain would be considered "post
> mortem" by the practical definition, but there's no death in this
> case...
> ||
>

You can create a copy of a process' stack. That stack will behave like a
process in the debugger but it can't run, as the VM doesn't have a
process to which the context are attached, hence it's considered
post-mortem.

>
> ```
>
> |DebugSession>>isContextPostMortem: selectedContext "return whether
> we're inspecting a frozen exception without a process attached" |
> suspendedContext | suspendedContext := interruptedProcess
> suspendedContext. suspendedContext ifNil: [ ^ false ].
> (suspendedContext == selectedContext) ifTrue: [ ^ false ]. ^
> (suspendedContext findContextSuchThat: [:c | c sender ==
> selectedContext]) isNil ``` |
>
> Does someone know the answer to some (or all) of these questions?
>
> Thomas


Hope that helps.

Max

Reply | Threaded
Open this post in threaded view
|

Re: Questions about DebugSession>>isContextPostMortem:

Eliot Miranda-2
Hi Thomas, Hi Max,

On Thu, Mar 21, 2019 at 3:35 AM Max Leske <[hidden email]> wrote:
On 21 Mar 2019, at 11:06, Thomas Dupriez wrote:

Hi Thomas,

> Hello,
>
> While looking at the DebugSession>>isContextPostMortem: method (code
> below), I got three questions:
>
> 1) There is a check for whether the suspendedContext (top context) of
> the process is nil. Does it even make sense for a process not to have
> any top context?

Yes, only suspended processes have a suspendedContext. Also, the process
might have been terminated already.

>
> 2) It seems that all the last 3 lines are doing is to check whether
> selectedContext is in the context chain of the process. Could they be
> rewritten into this simpler one-liner?   `|^ (suspendedContext
> hasContext: selectedContext) not`|

Yes, I think that would work.

>
> 3) Overall, this method says that a context C is "post mortem" if the
> process controlled by the DebugSession has a top context and C is not
> in its context chain. That's the practical definition. Could someone
> shed some light on the high-level definition of "post mortem"? Because
> "post mortem" is like "after death", but the death of what? A context
> that merely belongs to another context chain would be considered "post
> mortem" by the practical definition, but there's no death in this
> case...
> ||
>

You can create a copy of a process' stack. That stack will behave like a
process in the debugger but it can't run, as the VM doesn't have a
process to which the context are attached, hence it's considered
post-mortem.

>
> ```
>
> |DebugSession>>isContextPostMortem: selectedContext "return whether
> we're inspecting a frozen exception without a process attached" |
> suspendedContext | suspendedContext := interruptedProcess
> suspendedContext. suspendedContext ifNil: [ ^ false ].
> (suspendedContext == selectedContext) ifTrue: [ ^ false ]. ^
> (suspendedContext findContextSuchThat: [:c | c sender ==
> selectedContext]) isNil ``` |

In addition a context is post-mortem if its pc is nil, which at least in Squeak is answered by the Context>>isDead method.  So I might look at writing that method as

DebugSession>>isContextPostMortem: selectedContext
    "Answer if we're inspecting a frozen exception without a process attached."
    ^selectedContext isDead
      or: [(interruptedProcess suspendedContext hasContext: selectedContext) not]
 
>
> Does someone know the answer to some (or all) of these questions?
>
> Thomas


Hope that helps.

Max



--
_,,,^..^,,,_
best, Eliot