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,
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@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
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@gmail.comwrote:
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@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 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@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@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
yes clearly. some doc on tools and hints for VM debugging. It is particularly hard and interesting ;-)
#Luc
2011/4/29 stephane ducasse stephane.ducasse@gmail.com
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@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
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@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
On Fri, Apr 29, 2011 at 4:31 AM, Luc Fabresse luc.fabresse@gmail.comwrote:
yes clearly. some doc on tools and hints for VM debugging. It is particularly hard and interesting ;-)
If you want to find out what there is to document then at the external level do this:
Cog.app/Contents/MacOS/Croquet -? unknown option: -? Usage: Fast.app/Contents/MacOS/Croquet [<option>...] [<imageName> [<argument>...]] Fast.app/Contents/MacOS/Croquet [<option>...] -- [<argument>...]
Common <option>s: -help print this help message, then exit -memory <size>[mk] use fixed heap size (added to image size) -eden <size>[mk] set eden memory to bytes -stackpages num use n stack pages -breaksel selector set breakpoint on send of selector -codesize <size>[mk] set machine code memory to bytes -sendtrace[=num] enable send tracing (optionally to a specific value) -tracestores enable store tracing (assert check stores) -cogmaxlits <n> set max number of literals for methods compiled to machine code -cogminjumps <n> set min number of backward jumps for interpreted methods to be considered for compilation to machine code -pathenc <enc> set encoding for pathnames (default: macintosh) -headless run in headless (no window) mode (default: false)
Notes: <imageName> defaults to `Squeak.image'. If `-memory' is not specified then the heap will grow dynamically. <argument>s are ignored, but are processed by the Squeak image. The first <argument> normally names a Squeak `script' to execute. Precede <arguments> by `--' to use default image.
In particular "-breaksel selector", "-sendtrace[=num]" & "-tracestores" are interesting for debugging.
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.
best Eliot
#Luc
2011/4/29 stephane ducasse stephane.ducasse@gmail.com
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@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@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
http://code.google.com/p/cog/issues/detail?id=39
On Fri, Apr 29, 2011 at 7:19 PM, Eliot Miranda eliot.miranda@gmail.comwrote:
On Fri, Apr 29, 2011 at 4:31 AM, Luc Fabresse luc.fabresse@gmail.comwrote:
yes clearly. some doc on tools and hints for VM debugging. It is particularly hard and interesting ;-)
If you want to find out what there is to document then at the external level do this:
Cog.app/Contents/MacOS/Croquet -? unknown option: -? Usage: Fast.app/Contents/MacOS/Croquet [<option>...] [<imageName> [<argument>...]] Fast.app/Contents/MacOS/Croquet [<option>...] -- [<argument>...]
Common <option>s: -help print this help message, then exit -memory <size>[mk] use fixed heap size (added to image size) -eden <size>[mk] set eden memory to bytes -stackpages num use n stack pages -breaksel selector set breakpoint on send of selector -codesize <size>[mk] set machine code memory to bytes -sendtrace[=num] enable send tracing (optionally to a specific value) -tracestores enable store tracing (assert check stores) -cogmaxlits <n> set max number of literals for methods compiled to machine code -cogminjumps <n> set min number of backward jumps for interpreted methods to be considered for compilation to machine code -pathenc <enc> set encoding for pathnames (default: macintosh) -headless run in headless (no window) mode (default: false)
Notes: <imageName> defaults to `Squeak.image'. If `-memory' is not specified then the heap will grow dynamically. <argument>s are ignored, but are processed by the Squeak image. The first <argument> normally names a Squeak `script' to execute. Precede <arguments> by `--' to use default image.
In particular "-breaksel selector", "-sendtrace[=num]" & "-tracestores" are interesting for debugging.
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.
best Eliot
#Luc
2011/4/29 stephane ducasse stephane.ducasse@gmail.com
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@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@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
vm-dev@lists.squeakfoundation.org