<br><br><div class="gmail_quote">On Sat, Apr 30, 2011 at 4:23 AM, Yoshiki Ohshima <span dir="ltr">&lt;<a href="mailto:yoshiki@vpri.org" target="_blank">yoshiki@vpri.org</a>&gt;</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>
&gt;<br>
&gt; Hi. Suppose I am doing something in #commonSend:<br>
&gt;<br>
&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 internalFindNewMethod.<br>
&gt; self internalExecuteNewMethod.<br>
&gt; self fetchNextBytecode<br>
&gt;<br>
&gt; and somewhere there I want to do something like this:<br>
&gt;<br>
&gt; (messageSelector = &#39;#foo&#39;) ifTrue: [ self print: &#39;the message foo was called&#39;; cr ].<br>
&gt;<br>
&gt; messageSelector is the instVar of Interpreter and it is already in the stack.<br>
&gt;<br>
&gt; Of course, the part that doesn&#39;t work is (messageSelector = &#39;#foo&#39;)<br>
&gt; I tried several things but I don&#39;t find how to do it.<br>
<br>
</div></div>  Perhaps something along the line of:<br>
<br>
  (self cCode: &#39;stSizeOf(messageSelector) == sizeOf(&#39;foo&#39;) &amp;&amp; (strncmp(firstIndexableField(messageSelector), &#39;foo&#39;,<br>
     sizeOf(&#39;foo&#39;)) == 0)) ifTrue: [self print: &#39;the message foo was called&#39;: 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 &gt;&gt;  compilationBreak: selectorOop point: selectorLength<br>    &lt;api&gt;<br>    &lt;cmacro: &#39;(sel, len) do { \<br>    if ((len) == breakSelectorLength \<br>
     &amp;&amp; !strncmp((char *)((sel) + BaseHeaderSize), breakSelector, breakSelectorLength)) { \<br>        suppressHeartbeatFlag = 1; \<br>        compilationBreakpointFor(sel); \<br>    } \<br>} while (0)&#39;&gt;<br>
    | i |<br>    breakSelectorLength = selectorLength ifTrue:<br>        [i := breakSelectorLength.<br>         [i &gt; 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>