[Cuis-dev] Context in Exception

Juan Vuletich juan at cuis.st
Sat Apr 27 11:42:06 PDT 2024


Hi Hilaire,

On 4/27/2024 6:00 AM, Hilaire Fernandes via Cuis-dev wrote:
>
> Hi Juan,
>
> Yes, sure here is a ready to test situation in the archive below.
>
> https://www.dropbox.com/scl/fi/m9s9m1s50l3te8slmmet8/drgeoMiniDebugger.zip?rlkey=aofxd63uf3n3d5jqxutjcsy0z&st=roeypadk&dl=0
>

Thanks. This is most helpful.

> In this Cuis image, the window at the top-left presents the Smalltalk 
> sketch editor with the mini-debugger. The debugger presents the four 
> local variables to the script f a b s, with the correct classes. But 
> once you clic in one of these variables, its value is printed as nil.
>
> In the Browser at the top-right, the method handling the exception and 
> plugging the error. There is one line comment to open the regular 
> debugger.
>

The regular debugger suspends the process being debugged, and debugs it 
from a separate UI process. In your code, by the time the mini debugger 
is opened, the sketch execution as already been terminated and pruned 
from the stack. So, those variables don't even exist at that point.

A way to fix this is to suspend the sketch process, and debug it from 
outside it. Something like:

executeSketch
     | myContext |
     self stopSketch.
     codeView scroller acceptContents.
     self switchToPauseButton.
     DrGeoSketch when: #newSmalltalkSketch send: #compiledSketch: to: self.
     sketchProcess := [ | t |
         t := DateAndTime now.
         (DrGeoSystem preferences at: #advancedDebugger)
             ifTrue: [Compiler evaluate: model]
             ifFalse: [
                 [Compiler evaluate: model]
                     on: Exception
                     do: [:ex |
                         myContext := ex signalerContext 
findContextSuchThat: [:aContext |
                             aContext method defaultSelector == #DoIt].
                         "Debugger openProcess: sketchProcess context: 
myContext label: 'Debugg'"
                         sketchProcess suspend ]
             ].
         " When we get there, sketch has been entirely executed, switch 
back to play button "
         self switchToPlayButton.
         Transcript show: DateAndTime now - t ;cr
     ] newProcess.
     sketchProcess
         priority: Processor userSchedulingPriority + 1;
         name: '[DrGeo] Smalltalk Sketch execution';
         resume.
     sketchProcess isSuspended ifTrue: [
         debugger := Debugger
             openMinimalDebuggingProcess: sketchProcess
             context: myContext.
         self plugDebugger ]

> Another issue, I have with both my mini-debugger and the stock 
> debugger: the line of error in the code is not highlighted as expected.
>

I could not see this, but it is likely that update #6334 helps.

You are still far from a working debugger. For instance, in this case, 
the error happens in a stack frame that is not visible, so you can't 
point the user to it. I don't know if a debugger without a view of the 
stack call is of use... Maybe if you set the context to the one throwing 
the Error?

I wonder if it would best to simply use the regular debugger.

> ...
>
>
> Thanks
>
> -- 
> GNU Dr. Geo
> http://gnu.org/s/dr-geo/
> http://gnu-drgeo.blogspot.com/

HTH,

-- 
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240427/27a5ea75/attachment.htm>


More information about the Cuis-dev mailing list