<br><br><div class="gmail_quote">On Fri, Apr 29, 2011 at 4:31 AM, Luc Fabresse <span dir="ltr">&lt;<a href="mailto:luc.fabresse@gmail.com">luc.fabresse@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
 <br>yes clearly.<br>some doc on tools and hints for VM debugging.<br>It is particularly hard and interesting ;-)<br></blockquote><div><br></div><div>If you want to find out what there is to document then at the external level do this:</div>
<div><br></div><div>Cog.app/Contents/MacOS/Croquet -?</div><div>unknown option: -?</div><div>Usage: Fast.app/Contents/MacOS/Croquet [&lt;option&gt;...] [&lt;imageName&gt; [&lt;argument&gt;...]]</div><div>       Fast.app/Contents/MacOS/Croquet [&lt;option&gt;...] -- [&lt;argument&gt;...]</div>
<div><br></div><div>Common &lt;option&gt;s:</div><div>  -help                 print this help message, then exit</div><div>  -memory &lt;size&gt;[mk]    use fixed heap size (added to image size)</div><div>  -eden &lt;size&gt;[mk]      set eden memory to bytes</div>
<div>  -stackpages num       use n stack pages</div><div>  -breaksel selector    set breakpoint on send of selector</div><div>  -codesize &lt;size&gt;[mk]  set machine code memory to bytes</div><div>  -sendtrace[=num]      enable send tracing (optionally to a specific value)</div>
<div>  -tracestores          enable store tracing (assert check stores)</div><div>  -cogmaxlits &lt;n&gt;       set max number of literals for methods compiled to machine code</div><div>  -cogminjumps &lt;n&gt;      set min number of backward jumps for interpreted methods to be considered for compilation to machine code</div>
<div>  -pathenc &lt;enc&gt;        set encoding for pathnames (default: macintosh)</div><div>  -headless             run in headless (no window) mode (default: false)</div><div><br></div><div>Notes:</div><div>  &lt;imageName&gt; defaults to `Squeak.image&#39;.</div>
<div>  If `-memory&#39; is not specified then the heap will grow dynamically.</div><div>  &lt;argument&gt;s are ignored, but are processed by the Squeak image.</div><div>  The first &lt;argument&gt; normally names a Squeak `script&#39; to execute.</div>
<div>  Precede &lt;arguments&gt; by `--&#39; to use default image. </div><div><br></div><div>In particular &quot;-breaksel selector&quot;, &quot;-sendtrace[=num]&quot; &amp; &quot;-tracestores&quot; are interesting for debugging.</div>
<div><br></div><div>Inside the system you would need to document all the various facilities for debugging; the print methods in the interpreters, the break-pointing facilities in the CogVMSimulator et al.  There&#39;s a lot there.  I can of courser help and I have workspaces with various versions of it.  But this isn&#39;t going to be easy to document fully, not least because it changes as needs require.</div>
<div><br></div><div>best</div><div>Eliot</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br clear="all">#Luc<br>
<br><br><div class="gmail_quote">2011/4/29 stephane ducasse <span dir="ltr">&lt;<a href="mailto:stephane.ducasse@gmail.com" target="_blank">stephane.ducasse@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
Mariano can you document that somewhere :)<br>
<br>
On Apr 28, 2011, at 11:59 PM, Mariano Martinez Peck wrote:<br>
<br>
&gt; Hi Eliot. Thanks for answering. Your answer was EXTREMELY useful. Not only because it helped me to solve the problem I was having, but also because I discovered a wonderful tool.<br>
&gt;<br>
&gt; You are smart :)  I like the solution. So, if I understood correctly, I can put a breakpoint in the function warning() with &quot;break warning&quot;. With the -breaksel  parameter you set an instVar with the selector name and size. Then after, anywhere I can send  #compilationBreak: selectorOop point: selectorLength   and that will magically check whether the selectorOop is the one I passes with -breaksel and if true, it will call warning, who has a breakpoint, hence, I can debug :)   AWESOME!!!!   Now with CMake I can even generate a xcode project and debug it :)  (I don&#39;t know why attaching gdb from Xcode crash the vm).<br>


&gt;<br>
&gt; One little comment....I have an error using Cocoa VM builds because sqMacUnixCommandLineInterface.c  is only for /platforms/MacOS   and not for /platforms/IOS/<br>
&gt; I am not sure how this should be integrated in Cocoa branch.<br>
&gt;<br>
&gt; Thanks Eliot, I like having a kind of #haltIf: in the vm :)<br>
&gt;<br>
&gt; Mariano<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Apr 28, 2011 at 7:00 PM, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Mariano,<br>
&gt;<br>
&gt;     here&#39;s a hint.  Look at the command-line argument breaksel and see where it is used.  This will call warning whenever a specific message is sent.  e.g.<br>
&gt;<br>
&gt; McStalker.macbuild$ gdb Debug.app/<br>
&gt; GNU gdb 6.3.50-20050815 (Apple version gdb-1515) (Sat Jan 15 08:33:48 UTC 2011)<br>
&gt; Copyright 2004 Free Software Foundation, Inc.<br>
&gt; GDB is free software, covered by the GNU General Public License, and you are<br>
&gt; welcome to change it and/or distribute copies of it under certain conditions.<br>
&gt; Type &quot;show copying&quot; to see the conditions.<br>
&gt; There is absolutely no warranty for GDB.  Type &quot;show warranty&quot; for details.<br>
&gt; This GDB was configured as &quot;x86_64-apple-darwin&quot;...Reading symbols for shared libraries ................ done<br>
&gt;<br>
&gt; (gdb) break warning<br>
&gt; Breakpoint 1 at 0x105e2b: file /Users/eliot/Cog/oscogvm/macbuild/../src/vm/gcc3x-cointerp.c, line 39.<br>
&gt; (gdb) run -breaksel initialize ~/Squeak/Squeak4.2/trunk4.2.image<br>
&gt; Starting program: /Users/eliot/Cog/oscogvm/macbuild/Debug.app/Contents/MacOS/Croquet -breaksel initialize ~/Squeak/Squeak4.2/trunk4.2.image<br>
&gt; Reading symbols for shared libraries .+++++++++++++++..................................................................................... done<br>
&gt; Reading symbols for shared libraries . done<br>
&gt;<br>
&gt; Breakpoint 1, warning (s=0x16487c &quot;send breakpoint (heartbeat suppressed)&quot;) at /Users/eliot/Cog/oscogvm/macbuild/../src/vm/gcc3x-cointerp.c:39<br>
&gt; 39              printf(&quot;\n%s\n&quot;, s);<br>
&gt; (gdb) where 5<br>
&gt; #0  warning (s=0x16487c &quot;send breakpoint (heartbeat suppressed)&quot;) at /Users/eliot/Cog/oscogvm/macbuild/../src/vm/gcc3x-cointerp.c:39<br>
&gt; #1  0x0010b490 in interpret () at /Users/eliot/Cog/oscogvm/macbuild/../src/vm/gcc3x-cointerp.c:4747<br>
&gt; #2  0x0011d521 in enterSmalltalkExecutiveImplementation () at /Users/eliot/Cog/oscogvm/macbuild/../src/vm/gcc3x-cointerp.c:14103<br>
&gt; #3  0x00124bc7 in initStackPagesAndInterpret () at /Users/eliot/Cog/oscogvm/macbuild/../src/vm/gcc3x-cointerp.c:17731<br>
&gt; #4  0x00105ec9 in interpret () at /Users/eliot/Cog/oscogvm/macbuild/../src/vm/gcc3x-cointerp.c:1933<br>
&gt; (More stack frames follow...)<br>
&gt;<br>
&gt; On Thu, Apr 28, 2011 at 5:26 AM, Mariano Martinez Peck &lt;<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Hi Eliot. I am fighting since several hours with something in Cog and I cannot realize it. I am blind.<br>
&gt;<br>
&gt; I need to intercept all messages sent to an object. I have already done this for Interpreter VM and for StackVM. Now,  I am trying latest CogMTVM, and there is something I am not sying...I have this test:<br>
&gt;<br>
&gt; testBlah<br>
&gt;<br>
&gt;     ClassWith1Var new fooLong.<br>
&gt;     ClassWith1Var new fooLong.<br>
&gt;     ClassWith1Var new fooLong.<br>
&gt;<br>
&gt;<br>
&gt; ClassWith1Var &gt;&gt; fooLong<br>
&gt;     | aaa |<br>
&gt;     Object new.<br>
&gt;     self foo.<br>
&gt;<br>
&gt;<br>
&gt; Now, I modified<br>
&gt;<br>
&gt; CoInterpreter &gt;&gt; commonSend<br>
&gt;     &quot;Send a message, starting lookup with the receiver&#39;s class.&quot;<br>
&gt;     &quot;Assume: messageSelector and argumentCount have been set, and that<br>
&gt;     the receiver and arguments have been pushed onto the stack,&quot;<br>
&gt;     &quot;Note: This method is inlined into the interpreter dispatch loop.&quot;<br>
&gt;     &lt;sharedCodeNamed: &#39;commonSend&#39; inCase: 131&gt;<br>
&gt;     self sendBreak: messageSelector + BaseHeaderSize<br>
&gt;         point: (objectMemory lengthOf: messageSelector)<br>
&gt;         receiver: (self internalStackValue: argumentCount).<br>
&gt;     cogit recordSendTrace ifTrue:<br>
&gt;         [self recordTrace: lkupClass thing: messageSelector source: TraceIsFromInterpreter].<br>
&gt;     self internalFindNewMethod.<br>
&gt;     self print: &#39;called: &#39;; printStringOf: messageSelector; cr.<br>
&gt;     self internalExecuteNewMethod.<br>
&gt;     self fetchNextBytecode<br>
&gt;<br>
&gt;<br>
&gt; And when running the VM from gdb, &#39;called: fooLong&#39;  doesn&#39;t appear at all!!!  why ?<br>
&gt; In addition, it appears &#39;called: foo&#39; which is correct because #fooLong sends #foo<br>
&gt; but it appears only ONCE.<br>
&gt;<br>
&gt; #fooLong as I can see is not a quick return method but instead it goes by #sendLiteralSelector0ArgsBytecode. But the same happens if I put the print in that method... (which makes sense).<br>
&gt; I tried with a StackVM and the same....so it seems that #fooLong is going by another place than #commonSend.<br>
&gt;<br>
&gt; As far as I understand, there is nothing related with PIC or Jitt. In any of those cases, as what I can see, the #commonSend is called anyways.<br>
&gt;<br>
&gt; So...I am completly lost.<br>
&gt;<br>
&gt; Thanks in advance for any help.<br>
&gt;<br>
&gt; --<br>
&gt; Mariano<br>
&gt; <a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Mariano<br>
&gt; <a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
&gt;<br>
<br>
</blockquote></div><br>
<br></blockquote></div><br>