[Cuis-dev] Debugger lost variable name
Hernán Wilkinson
hernan.wilkinson at 10pines.com
Mon Apr 22 05:52:08 PDT 2024
Hi Hilaire,
ok, I know why this is happening then :-)
You can see the reason in the implementation of Compiler>>#evaluate:
textOrStream in: aContext to: aReceiver notifying: aRequestor ifFail:
failBlock logged: doLog profiled: doProfile, there is a comment there that
says: "I'm not keeping the source nor the methodNode for back compatibility.
The SmalltalkEditor sends the message #evaluateMethod:... which already
keeps the method node
for the debugger to show the right source code - Hernan"
For some reason the #evaluate:... messages do not keep the source code and
that is why you see the decompiled version in the debugger.
I do not why it is like that, but when I changed the debugger many years
ago to show the source code when debugging from the debugger I decided to
keep that behavior.
We can do two things:
1) You can, instead of using evaluate:, do what the workspace does. Look at
the method SmalltalkEditor>>#afterCompiling: aSourceCode do: aBlock for:
aReceiver in: anEvaluationContext ifFail: aFailBlock
2) Change Compiler>>#evaluate:in:to:notifying:ifFail:logged:profiled: to do
keep the source code. Something like this:
evaluate: textOrStream in: aContext to: aReceiver notifying: aRequestor
ifFail: failBlock logged: doLog profiled: doProfile
"Compiles the sourceStream into a parse tree, then generates code into
a method. If aContext is not nil, the text can refer to temporaries in that
context (the Debugger uses this). If aRequestor is not nil, then it will
receive
a notify:at: message before the attempt to evaluate is aborted. Finally,
the
compiled method is invoked from here via withArgs:executeMethod:, hence
the system no longer creates Doit method litter on errors."
| methodNode method sourceCodeWithDoIt |
class := (aReceiver ifNotNil: [ aReceiver ] ifNil: [ aContext ifNotNil: [
:c | c receiver ]]) class.
sourceCodeWithDoIt := ((WriteStream on: String new)
nextPutAll: Scanner doItSelector;
newLine;
nextPutAll: textOrStream readStream contents;
contents) readStream.
methodNode := self compileDoIt: sourceCodeWithDoIt in: class context:
aContext notifying: aRequestor ifFail: [^failBlock value].
method := methodNode generate.
method methodNode: methodNode.
^self evaluateMethod: method to: aReceiver logged: doLog profiled: doProfile
If we make this change all evaluations (for example, when saving from an
inspector) will show the source code when debugging.
@Juan Vuletich <juan at cuis.st> What do you think?
If you ask me, I think we should 2), I do not see any reason not to see the
source code when evaluating a string.
Cheers!
Hernan.
On Sun, Apr 21, 2024 at 5:42 PM Hilaire Fernandes <hfern at free.fr> wrote:
> The script is not executed from a Workspace.
>
> I execute it with Compiler evaluate: model
>
> For example:
>
> Compiler evaluate:'| f | f :=0. 1/f'
>
> When the debugger is raised f is replaced by temp1
> Le 21/04/2024 à 16:16, Hernán Wilkinson a écrit :
>
> it is rare... does that happen with all the scripts you run from the
> workspace?
> The reason it does that is because it is not finding the original source
> code and therefore decompiles the code.
> You have to look for that, why it is not finding the original source code
>
> --
> GNU Dr. Geohttp://gnu.org/s/dr-geo/http://gnu-drgeo.blogspot.com/
>
>
--
*Hernán WilkinsonAgile Software Development, Teaching & Coaching*
*Phone: +54-011*-4893-2057
*Twitter: @HernanWilkinson*
*site: http://www.10Pines.com <http://www.10pines.com/>*
Address: Alem 896, Floor 6, Buenos Aires, Argentina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240422/b9c6689e/attachment.htm>
More information about the Cuis-dev
mailing list