Hi Thomas,
On May 29, 2017, at 7:41 AM, Ben Coman <btc@openinworld.com> wrote:
On Mon, May 29, 2017 at 9:34 PM, <tdupriez@ens-paris-saclay.fr> wrote: Hi,
I'm working with DebugSession to see if I can implement something that would step into an execution until a given expression evaluates to a different value than the value it had at the beginning to quickly localise the precise point where an invariant is broken.
But it appears that if the expression always evaluate to the same value, then the VM freezes.
I simplified my program to just stepInto a debugSession indefinitely, and it makes the VM freeze, while I would rather expect an exception to be raised (something like "ReachedEndOfExecution").
Here is my example code. Beware, running it will freeze the VM.
| program process context debugSession | program := [1+2]. process := program newProcess. context := process suspendedContext. debugSession := process newDebugSessionNamed: 'StepIntoForever' startedAt: context. [ true ] whileTrue: [ debugSession stepInto ].
Is there a way to have an exception be raised when a stepInto message is sent to a debugSession whose execution is finished, instead of just freezing the VM?
I like looking into these sort of things, but right now don't have time. (I'm trying to be disciplined.) Probably a way does not currently existing, so the way is to change the implementation. What I'd suggest is debugging into #stepInto to maybe discover how to do it yourself. :)
In particular, your use of stepInto: will soon step into the process termination code. See newProcess. You have to stop simulating before you stop the current process by mistake.
As a novice I found it really accessible to dig into this stuff, found it quite enlightening and made me feel cool I could do it.
To be able to debug the debugger, first copy method #stepInto to #myStepInto with a halt at the top, then try... [ true ] whileTrue: [ debugSession myStepInto ].
btw, if you are executing your example from then Playground, note that it executes in the UI thread, which you've blocked from progressing. Does the Image hang with this...? [ [ true ] whileTrue: [ debugSession stepInto ] ] forkAt: Processor currentPriority - 1.
Note the lowered priority since processes are only pre-emptive between priorities. At the same priority processes are scheduled cooperatively, so require an explicit yield or the tight loop would dominate the UI process. So you might also try this... [ [ true ] whileTrue: [ debugSession stepInto. Processor yield. ] ] fork.
Give it a go and report back what you find and propose how you'd like it to work. Then we can see what it might break and wider implications I can't think of right now. (Its a great learning experience for the experts to describe why some things are a bad idea, and maybe alternatives.)
cheers -ben
P.S. This might be the sort of thing that MetaLinks is good for, but I'm not much familiar with them.