Debugger Model Overview

Hello there! In this post I will do my best to sum up the new debugger essentials. So let’s get to it!

In the old debugger all the actions and UI logic were all together. This makes it difficult to maintain and scale the debugger, and don’t even think of having new debuggers. So the new debugger came up to do some serious cleanup.

The intention is to separate the model from the UI, so any UI implementation, let’s say Glamour, Morphic, whatever, can be attached to the model, and use it. This is, the model does not know of how the stack is represented (a list, a table, a widget) , nor of the existence of the inspector, the selection handling, or the widgets that are being used.  The model only knows of processes and contexts.

So let’s see a little class diagram…

Debugger Model - New Page

The cool thing of this approach is that now you could take away everything above the dotted line (namely the UI components) and plug in any other implementation you may like. The default is one made in Spec.

Some considerations:

  • The SpecDebuggerProxy right now just adds the SpecDebugger button to the PreDebugWindow. That’s why it knows the old Debugger. This component should be removed once the new debugger is made the default for Pharo 3.0
  • A DebugSession has all the information of the current debugging process, this includes the interrupted process, the current context, and the possible actions for them.
  • A DebugContext right now just has helper methods to handle contexts. In the future, we should return a stack made of DebugContext, which would have more information (top context, active program counter, for instance) and more intelligence than a plain context.

So now about the model… A DebugSession is created for a process in a method context. The following code illustrates the creation of an interrupted process with a newly created context as top context:


context := [Set new] asContext

process:= Process
          forContext: context
          priority: Processor userInterruptPriority

And, to create a Debug session

session:= DebugSession process: process context: context

So now you have a new DebugSession, to which you can ask things like #stepOver or #stepInto to move between contexts and the stack.

And that’s pretty much it. Stay tuned in!

Cheers!

Advertisements
By clariallende