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.
If you are interested, read his answer here:
http://forum.world.st/Cog-and-commonSend-are-getting-me-crazy-td3480836.html
And yes, his code is similar to yours:
CoInterpreter >> compilationBreak: selectorOop point: selectorLength
<api>
<cmacro: '(sel, len) do { \
if ((len) == breakSelectorLength \
&& !strncmp((char *)((sel) + BaseHeaderSize), breakSelector, breakSelectorLength)) { \
suppressHeartbeatFlag = 1; \
compilationBreakpointFor(sel); \
} \
} while (0)'>
| i |
breakSelectorLength = selectorLength ifTrue:
[i := breakSelectorLength.
[i > 0] whileTrue:
[(self byteAt: selectorOop + i + BaseHeaderSize - 1) = (breakSelector at: i) asInteger
ifTrue: [(i := i - 1) = 0 ifTrue:
[self compilationBreakpointFor: selectorOop]]
ifFalse: [i := 0]]]