[Cuis-dev] Allow debugger to step into quick return methods

Facundo Javier Gelatti javiergelatti at gmail.com
Mon Nov 13 15:28:19 PST 2023


Hi!
I attach some code to be able to step into quick return methods from the
debugger, and there's also a demo video
<https://drive.google.com/file/d/1Iv5-hJ4TNjmR0pG-qm02KpTxCvKzsDZC/view?usp=sharing>.
Being able to step into a quick return method is very useful, especially in
situations where we are doing TDD (because the first implementation of a
method probably ends up being a quick return).

Most of these changes were developed during the Camp Smalltalk event of the
Smalltalks 2023 conference by me, Juan Vuletich and Felipe Zak (thank you
guys!).

I included automated tests for various debugging scenarios. The class
QuickReturnDebuggingTest should probably be moved to an appropriate
category (it's currently in the "Smalltalks 2023" category, just because
the changes were developed during the conference) or be merged into another
existing test class (I wasn't sure where to put it).

ℹ️ Extra interesting info: there are other places in which we're currently
treating quick return methods in a special way. See for example
Debugger>>#contents:notifying:, which handles the special case of a normal
method becoming a quick return method after saving the changes on the
debugger (the stack frame is removed in that case, try it!). As a
curiosity, another quirk related to quick returns is that you cannot debug
an expression that will compile to a quick return (e.g. ^2), the debugger
simply doesn't show up! None of this is modified on the code I'm submitting.

I include a summary of the changes below, that could be useful during code
review 👇

Cheers!
Facu

------------------------------
📝 Changes summary:

   - Do not run a quick return as a primitive in
   ContextPart>>#send:to:with:lookupIn:, treat it as a normal instruction
   —before which we can stop— and create a new stack frame for it.
   - Refactor: extracted an isPrimitive variable in
   ContextPart>>#send:to:with:lookupIn:, to avoid having repeated code.
   - Changed InstructionStream>>#willReturn to include quick returns there.
   This ends up telling the debugger that it's possible to pause the execution
   there.
   - In Process>>#resume, resolve pending quick returns before running
   #primitiveResume, so that the VM can resume the process without having
   an unexpected stack frame (if you remove this, the VM crashes).
   - Refactor: extracted the method Debugger class>>#newDebugging:, which
   is useful for tests (because it does not open the debugger UI).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20231113/7861b8dd/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: QuickReturnDebugging-FacundoJavierGelatti.cs.st
Type: application/octet-stream
Size: 6383 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20231113/7861b8dd/attachment.obj>


More information about the Cuis-dev mailing list