<br><br><div class="gmail_quote">On Fri, Apr 29, 2011 at 4:31 AM, Luc Fabresse <span dir="ltr"><<a href="mailto:luc.fabresse@gmail.com">luc.fabresse@gmail.com</a>></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 [<option>...] [<imageName> [<argument>...]]</div><div> Fast.app/Contents/MacOS/Croquet [<option>...] -- [<argument>...]</div>
<div><br></div><div>Common <option>s:</div><div> -help print this help message, then exit</div><div> -memory <size>[mk] use fixed heap size (added to image size)</div><div> -eden <size>[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 <size>[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 <n> set max number of literals for methods compiled to machine code</div><div> -cogminjumps <n> set min number of backward jumps for interpreted methods to be considered for compilation to machine code</div>
<div> -pathenc <enc> 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> <imageName> defaults to `Squeak.image'.</div>
<div> If `-memory' is not specified then the heap will grow dynamically.</div><div> <argument>s are ignored, but are processed by the Squeak image.</div><div> The first <argument> normally names a Squeak `script' to execute.</div>
<div> Precede <arguments> by `--' to use default image. </div><div><br></div><div>In particular "-breaksel selector", "-sendtrace[=num]" & "-tracestores" 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's a lot there. I can of courser help and I have workspaces with various versions of it. But this isn'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"><<a href="mailto:stephane.ducasse@gmail.com" target="_blank">stephane.ducasse@gmail.com</a>></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>
> 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>
><br>
> You are smart :) I like the solution. So, if I understood correctly, I can put a breakpoint in the function warning() with "break warning". 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't know why attaching gdb from Xcode crash the vm).<br>
><br>
> 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>
> I am not sure how this should be integrated in Cocoa branch.<br>
><br>
> Thanks Eliot, I like having a kind of #haltIf: in the vm :)<br>
><br>
> Mariano<br>
><br>
><br>
> On Thu, Apr 28, 2011 at 7:00 PM, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>> wrote:<br>
><br>
> Mariano,<br>
><br>
> here'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>
><br>
> McStalker.macbuild$ gdb Debug.app/<br>
> GNU gdb 6.3.50-20050815 (Apple version gdb-1515) (Sat Jan 15 08:33:48 UTC 2011)<br>
> Copyright 2004 Free Software Foundation, Inc.<br>
> GDB is free software, covered by the GNU General Public License, and you are<br>
> welcome to change it and/or distribute copies of it under certain conditions.<br>
> Type "show copying" to see the conditions.<br>
> There is absolutely no warranty for GDB. Type "show warranty" for details.<br>
> This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries ................ done<br>
><br>
> (gdb) break warning<br>
> Breakpoint 1 at 0x105e2b: file /Users/eliot/Cog/oscogvm/macbuild/../src/vm/gcc3x-cointerp.c, line 39.<br>
> (gdb) run -breaksel initialize ~/Squeak/Squeak4.2/trunk4.2.image<br>
> Starting program: /Users/eliot/Cog/oscogvm/macbuild/Debug.app/Contents/MacOS/Croquet -breaksel initialize ~/Squeak/Squeak4.2/trunk4.2.image<br>
> Reading symbols for shared libraries .+++++++++++++++..................................................................................... done<br>
> Reading symbols for shared libraries . done<br>
><br>
> Breakpoint 1, warning (s=0x16487c "send breakpoint (heartbeat suppressed)") at /Users/eliot/Cog/oscogvm/macbuild/../src/vm/gcc3x-cointerp.c:39<br>
> 39 printf("\n%s\n", s);<br>
> (gdb) where 5<br>
> #0 warning (s=0x16487c "send breakpoint (heartbeat suppressed)") at /Users/eliot/Cog/oscogvm/macbuild/../src/vm/gcc3x-cointerp.c:39<br>
> #1 0x0010b490 in interpret () at /Users/eliot/Cog/oscogvm/macbuild/../src/vm/gcc3x-cointerp.c:4747<br>
> #2 0x0011d521 in enterSmalltalkExecutiveImplementation () at /Users/eliot/Cog/oscogvm/macbuild/../src/vm/gcc3x-cointerp.c:14103<br>
> #3 0x00124bc7 in initStackPagesAndInterpret () at /Users/eliot/Cog/oscogvm/macbuild/../src/vm/gcc3x-cointerp.c:17731<br>
> #4 0x00105ec9 in interpret () at /Users/eliot/Cog/oscogvm/macbuild/../src/vm/gcc3x-cointerp.c:1933<br>
> (More stack frames follow...)<br>
><br>
> On Thu, Apr 28, 2011 at 5:26 AM, Mariano Martinez Peck <<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@gmail.com</a>> wrote:<br>
><br>
> Hi Eliot. I am fighting since several hours with something in Cog and I cannot realize it. I am blind.<br>
><br>
> 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>
><br>
> testBlah<br>
><br>
> ClassWith1Var new fooLong.<br>
> ClassWith1Var new fooLong.<br>
> ClassWith1Var new fooLong.<br>
><br>
><br>
> ClassWith1Var >> fooLong<br>
> | aaa |<br>
> Object new.<br>
> self foo.<br>
><br>
><br>
> Now, I modified<br>
><br>
> CoInterpreter >> commonSend<br>
> "Send a message, starting lookup with the receiver's class."<br>
> "Assume: messageSelector and argumentCount have been set, and that<br>
> the receiver and arguments have been pushed onto the stack,"<br>
> "Note: This method is inlined into the interpreter dispatch loop."<br>
> <sharedCodeNamed: 'commonSend' inCase: 131><br>
> self sendBreak: messageSelector + BaseHeaderSize<br>
> point: (objectMemory lengthOf: messageSelector)<br>
> receiver: (self internalStackValue: argumentCount).<br>
> cogit recordSendTrace ifTrue:<br>
> [self recordTrace: lkupClass thing: messageSelector source: TraceIsFromInterpreter].<br>
> self internalFindNewMethod.<br>
> self print: 'called: '; printStringOf: messageSelector; cr.<br>
> self internalExecuteNewMethod.<br>
> self fetchNextBytecode<br>
><br>
><br>
> And when running the VM from gdb, 'called: fooLong' doesn't appear at all!!! why ?<br>
> In addition, it appears 'called: foo' which is correct because #fooLong sends #foo<br>
> but it appears only ONCE.<br>
><br>
> #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>
> I tried with a StackVM and the same....so it seems that #fooLong is going by another place than #commonSend.<br>
><br>
> 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>
><br>
> So...I am completly lost.<br>
><br>
> Thanks in advance for any help.<br>
><br>
> --<br>
> Mariano<br>
> <a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
> --<br>
> Mariano<br>
> <a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
><br>
<br>
</blockquote></div><br>
<br></blockquote></div><br>