<body><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
Hi Levente,<div><br></div><div>good idea. Except for</div><div><br></div><div>Context>>cannotReturn:</div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Context>>doPrimitive:method:receiver:args:</span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br></span></div><div><span style="font-family: Arial, Helvetica, sans-serif"><span style="font-size: 13px">Correct? Since code simulation is part of the Process interface itself.</span></span></div><div><span style="font-family: Arial, Helvetica, sans-serif"><span style="font-size: 13px"><br></span></span></div><div><span style="font-family: Arial, Helvetica, sans-serif"><span style="font-size: 13px">Best,</span></span></div><div><span style="font-family: Arial, Helvetica, sans-serif"><span style="font-size: 13px">Marcel</span></span></div><div class="mb_sig"></div><blockquote class="history_container" type="cite" style="border-left-style:solid;border-width:1px; margin-top:20px; margin-left:0px;padding-left:10px;">
<p style="color: #AAAAAA; margin-top: 10px;">Am 07.10.2019 23:58:05 schrieb Levente Uzonyi <leves@caesar.elte.hu>:</p><div style="font-family:Arial,Helvetica,sans-serif">I think these methods should all be extension methods in Kernel, and be <br>methods of System, since that's where ToolSet is.<br><br>Levente<br><br>On Mon, 7 Oct 2019, commits@source.squeak.org wrote:<br><br>> Marcel Taeumel uploaded a new version of Kernel to project The Trunk:<br>> http://source.squeak.org/trunk/Kernel-mt.1272.mcz<br>><br>> ==================== Summary ====================<br>><br>> Name: Kernel-mt.1272<br>> Author: mt<br>> Time: 7 October 2019, 10:09:56.205231 am<br>> UUID: 8fe3f896-0806-fe46-8e86-68f3c0f98d4d<br>> Ancestors: Kernel-ul.1271<br>><br>> Complements System-mt.1112, which fixes and clean-up in the debugger infrastructure.<br>><br>> =============== Diff against Kernel-ul.1271 ===============<br>><br>> Item was changed:<br>> ----- Method: Context>>cannotReturn: (in category 'private-exceptions') -----<br>> cannotReturn: result<br>><br>> closureOrNil notNil ifTrue:<br>> [^self cannotReturn: result to: self home sender].<br>> + Processor activeProcess<br>> + debug: thisContext<br>> + title: 'computation has been terminated'<br>> + full: false.!<br>> - ToolSet<br>> - debugActiveProcessContext: thisContext<br>> - label: 'computation has been terminated'<br>> - contents: nil!<br>><br>> Item was changed:<br>> ----- Method: Context>>doPrimitive:method:receiver:args: (in category 'private') -----<br>> doPrimitive: primitiveIndex method: meth receiver: receiver args: arguments<br>> "Simulate a primitive method whose index is primitiveIndex. The simulated receiver and<br>> arguments are given as arguments to this message. If successful, push result and return<br>> resuming context, else ^ {errCode, PrimitiveFailToken}. Any primitive which provokes<br>> execution needs to be intercepted and simulated to avoid execution running away."<br>><br>> | value |<br>> "Judicious use of primitive 19 (a null primitive that doesn't do anything) prevents<br>> the debugger from entering various run-away activities such as spawning a new<br>> process, etc. Injudicious use results in the debugger not being able to debug<br>> interesting code, such as the debugger itself. Hence use primitive 19 with care :-)"<br>> "SystemNavigation new browseAllSelect: [:m| m primitive = 19]"<br>> + primitiveIndex = 19 ifTrue: [<br>> + Processor activeProcess<br>> + debug: self<br>> + title:'Code simulation error'<br>> + full: false].<br>> - primitiveIndex = 19 ifTrue:<br>> - [ToolSet <br>> - debugActiveProcessContext: self<br>> - label:'Code simulation error'<br>> - contents: nil].<br>><br>> ((primitiveIndex between: 201 and: 222)<br>> and: [(self objectClass: receiver) includesBehavior: BlockClosure]) ifTrue:<br>> [(primitiveIndex = 206<br>> or: [primitiveIndex = 208]) ifTrue: "[Full]BlockClosure>>valueWithArguments:"<br>> [^receiver simulateValueWithArguments: arguments first caller: self].<br>> ((primitiveIndex between: 201 and: 209) "[Full]BlockClosure>>value[:value:...]"<br>> or: [primitiveIndex between: 221 and: 222]) ifTrue: "[Full]BlockClosure>>valueNoContextSwitch[:]"<br>> [^receiver simulateValueWithArguments: arguments caller: self]].<br>><br>> primitiveIndex = 83 ifTrue: "afr 9/11/1998 19:50" "Object>>perform:[with:...]"<br>> [^self send: arguments first to: receiver with: arguments allButFirst].<br>> primitiveIndex = 84 ifTrue: "afr 9/11/1998 19:50 & eem 8/18/2009 17:04" "Object>>perform:withArguments:"<br>> [^self send: arguments first to: receiver with: (arguments at: 2) lookupIn: (self objectClass: receiver)].<br>> primitiveIndex = 100 ifTrue: "eem 8/18/2009 16:57" "Object>>perform:withArguments:inSuperclass:"<br>> [^self send: arguments first to: receiver with: (arguments at: 2) lookupIn: (arguments at: 3)].<br>><br>> "Mutex>>primitiveEnterCriticalSection<br>> Mutex>>primitiveTestAndSetOwnershipOfCriticalSection"<br>> (primitiveIndex = 186 or: [primitiveIndex = 187]) ifTrue:<br>> [| effective |<br>> effective := Processor activeProcess effectiveProcess.<br>> "active == effective"<br>> value := primitiveIndex = 186<br>> ifTrue: [receiver primitiveEnterCriticalSectionOnBehalfOf: effective]<br>> ifFalse: [receiver primitiveTestAndSetOwnershipOfCriticalSectionOnBehalfOf: effective].<br>> ^(self isPrimFailToken: value)<br>> ifTrue: [value]<br>> ifFalse: [self push: value]].<br>><br>> primitiveIndex = 188 ifTrue: "Object>>withArgs:executeMethod:<br>> CompiledMethod class>>receiver:withArguments:executeMethod:<br>> VMMirror>>ifFail:object:with:executeMethod: et al"<br>> [| n args methodArg thisReceiver |<br>> ((n := arguments size) between: 2 and: 4) ifFalse:<br>> [^self class primitiveFailTokenFor: #'unsupported operation'].<br>> ((self objectClass: (args := arguments at: n - 1)) == Array<br>> and: [(self objectClass: (methodArg := arguments at: n)) includesBehavior: CompiledMethod]) ifFalse:<br>> [^self class primitiveFailTokenFor: #'bad argument'].<br>> methodArg numArgs = args size ifFalse:<br>> [^self class primitiveFailTokenFor: #'bad number of arguments'].<br>> thisReceiver := arguments at: n - 2 ifAbsent: [receiver].<br>> methodArg primitive > 0 ifTrue:<br>> [methodArg isQuick ifTrue:<br>> [^self push: (methodArg valueWithReceiver: thisReceiver arguments: args)].<br>> ^self doPrimitive: methodArg primitive method: meth receiver: thisReceiver args: args].<br>> ^Context<br>> sender: self<br>> receiver: thisReceiver<br>> method: methodArg<br>> arguments: args].<br>><br>> primitiveIndex = 118 ifTrue: "[receiver:]tryPrimitive:withArgs:; avoid recursing in the VM"<br>> [(arguments size = 3<br>> and: [(self objectClass: arguments second) == SmallInteger<br>> and: [(self objectClass: arguments last) == Array]]) ifTrue:<br>> [^self doPrimitive: arguments second method: meth receiver: arguments first args: arguments last].<br>> (arguments size = 2<br>> and: [(self objectClass: arguments first) == SmallInteger<br>> and: [(self objectClass: arguments last) == Array]]) ifFalse:<br>> [^self class primitiveFailTokenFor: nil].<br>> ^self doPrimitive: arguments first method: meth receiver: receiver args: arguments last].<br>><br>> value := primitiveIndex = 120 "FFI method"<br>> ifTrue: [(meth literalAt: 1) tryInvokeWithArguments: arguments]<br>> ifFalse:<br>> [primitiveIndex = 117 "named primitives"<br>> ifTrue: [self tryNamedPrimitiveIn: meth for: receiver withArgs: arguments]<br>> ifFalse: "should use self receiver: receiver tryPrimitive: primitiveIndex withArgs: arguments but this is only in later VMs (and appears to be broken)"<br>> [receiver tryPrimitive: primitiveIndex withArgs: arguments]].<br>><br>> ^(self isPrimFailToken: value)<br>> ifTrue: [value]<br>> ifFalse: [self push: value]!<br>><br>> Item was changed:<br>> ----- Method: Process>>debug (in category 'debugging') -----<br>> debug<br>> + <br>> + ^ self debugWithTitle: 'Debug'!<br>> - self debugWithTitle: 'Debug'.!<br>><br>> Item was added:<br>> + ----- Method: Process>>debug: (in category 'debugging') -----<br>> + debug: context<br>> + <br>> + ^ self debug: context title: 'Debug'!<br>><br>> Item was changed:<br>> ----- Method: Process>>debug:title: (in category 'debugging') -----<br>> debug: context title: title<br>> "Open debugger on self with context shown on top"<br>> <br>> + ^ self debug: context title: title full: false<br>> - self debug: context title: title full: false.<br>> !<br>><br>> Item was changed:<br>> ----- Method: Process>>debug:title:full: (in category 'debugging') -----<br>> debug: context title: title full: bool<br>> <br>> + ^ self<br>> - self<br>> debug: context<br>> title: title<br>> full: bool<br>> contents: nil!<br>><br>> Item was changed:<br>> ----- Method: Process>>debug:title:full:contents: (in category 'debugging') -----<br>> debug: context title: title full: bool contents: contents<br>> "Open debugger on self with context shown on top"<br>><br>> | topCtxt |<br>> topCtxt := self isActiveProcess ifTrue: [thisContext] ifFalse: [self suspendedContext].<br>> (topCtxt hasContext: context) ifFalse: [^ self error: 'context not in process'].<br>> + ^ ToolSet debugProcess: self context: context label: title contents: contents fullView: bool!<br>> - ToolSet debugProcess: self context: context label: title contents: contents fullView: bool.!<br>><br>> Item was changed:<br>> ----- Method: Process>>debugWithTitle: (in category 'debugging') -----<br>> debugWithTitle: title<br>> - "Open debugger on self"<br>> <br>> + ^ self debugWithTitle: title full: true!<br>> - | context |<br>> - context := self isActiveProcess ifTrue: [thisContext] ifFalse: [self suspendedContext].<br>> - self debug: context title: title full: true.<br>> - !<br>><br>> Item was added:<br>> + ----- Method: Process>>debugWithTitle:full: (in category 'debugging') -----<br>> + debugWithTitle: title full: aBoolean<br>> + <br>> + ^ self debugWithTitle: title full: aBoolean contents: nil!<br>><br>> Item was added:<br>> + ----- Method: Process>>debugWithTitle:full:contents: (in category 'debugging') -----<br>> + debugWithTitle: title full: bool contents: contents<br>> + "Automatically choose the top context."<br>> + <br>> + ^ self<br>> + debug: (self isActiveProcess ifTrue: [thisContext] ifFalse: [self suspendedContext])<br>> + title: title<br>> + full: bool<br>> + contents: contents!<br><br></div></blockquote>
</div></body>