[Vm-dev] Cog and #commonSend are getting me crazy :(

stephane ducasse stephane.ducasse at gmail.com
Fri Apr 29 08:33:37 UTC 2011


Mariano can you document that somewhere :)

On Apr 28, 2011, at 11:59 PM, Mariano Martinez Peck wrote:

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



More information about the Vm-dev mailing list