<br><br><div class="gmail_quote">On Sat, Apr 30, 2011 at 4:23 AM, Yoshiki Ohshima <span dir="ltr"><<a href="mailto:yoshiki@vpri.org" target="_blank">yoshiki@vpri.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
At Thu, 28 Apr 2011 12:22:33 +0200,<br>
<div><div></div><div>Mariano Martinez Peck wrote:<br>
><br>
> Hi. Suppose I am doing something in #commonSend:<br>
><br>
> 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 internalFindNewMethod.<br>
> self internalExecuteNewMethod.<br>
> self fetchNextBytecode<br>
><br>
> and somewhere there I want to do something like this:<br>
><br>
> (messageSelector = '#foo') ifTrue: [ self print: 'the message foo was called'; cr ].<br>
><br>
> messageSelector is the instVar of Interpreter and it is already in the stack.<br>
><br>
> Of course, the part that doesn't work is (messageSelector = '#foo')<br>
> I tried several things but I don't find how to do it.<br>
<br>
</div></div> Perhaps something along the line of:<br>
<br>
(self cCode: 'stSizeOf(messageSelector) == sizeOf('foo') && (strncmp(firstIndexableField(messageSelector), 'foo',<br>
sizeOf('foo')) == 0)) ifTrue: [self print: 'the message foo was called': cr].<br>
<br>
(Not tested this particualr one, but have done similar thing<br>
before. This assumes that messageSelector is always a Symbol, which<br>
may not be the case for you...)<br>
<font color="#888888"><br></font></blockquote><div><br>Thanks Yoshiki. After I sent this mail, and with a help of a friend, I was also trying to do something similar to that. Just by coincidense, Eliot answered me in another thread, a way to solve this in Cog, and it is using the command line argument -breaksel. With such parameter you can send a seletor as an argument, put a breakpoint with gdb, and the VM will stop in a place. It is not EXACTLY the same as what I was asking, but it is useful.<br>
<br>If you are interested, read his answer here: <a href="http://forum.world.st/Cog-and-commonSend-are-getting-me-crazy-td3480836.html">http://forum.world.st/Cog-and-commonSend-are-getting-me-crazy-td3480836.html</a><br>
<br>And yes, his code is similar to yours:<br><br>CoInterpreter >> compilationBreak: selectorOop point: selectorLength<br> <api><br> <cmacro: '(sel, len) do { \<br> if ((len) == breakSelectorLength \<br>
&& !strncmp((char *)((sel) + BaseHeaderSize), breakSelector, breakSelectorLength)) { \<br> suppressHeartbeatFlag = 1; \<br> compilationBreakpointFor(sel); \<br> } \<br>} while (0)'><br>
| i |<br> breakSelectorLength = selectorLength ifTrue:<br> [i := breakSelectorLength.<br> [i > 0] whileTrue:<br> [(self byteAt: selectorOop + i + BaseHeaderSize - 1) = (breakSelector at: i) asInteger<br>
ifTrue: [(i := i - 1) = 0 ifTrue:<br> [self compilationBreakpointFor: selectorOop]]<br> ifFalse: [i := 0]]]<br></div></div><br clear="all"><br>Once again, thanks for your help.<br>
<br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br><br>