--001636d34f707900a80474b36995
Content-Type: text/plain; charset=ISO-2022-JP
Content-Transfer-Encoding: 7bit

The event hook definitely works.

The TODO relates I think to setting *id* and *klass* which I what 1.8 does.

*begin long discussion which most may want to ignore:**
*
That said, in my view I don't believe it necessary to ever fill this out.
Instead what I'd rather see is the event hook call interface *simplified*.

Right now it is a trace function call looks like:
  *trace_function(event, file, line, id, bind, klass)
*
What I've been using in an experimental debugger is:
   *trace_function(event, frame, argl)
*
From *frame* you can figure out *file*, *line*, *id*, *bind* and so on. I
was thinking that in the replacement call *arg* would be a placeholder for
any event where it may be desirable to pass more information. For example
the return value in a function or perhaps exception information in a raise.
I think this is how Python does it in their trace hook.

(Right now the way I up a value about to be returned is by just retrieving
the value from the VM stack which is very YARV specific).

As for *file* and *line*, I find this a little weird. The intent clearly is
to indicate a source position of where you are at when the event triggers.
But even though there are two (unnecessary in my opinion) parameters, it
still falls short of being specific and general.

"file" sometimes might not be a file if say you are running the
internal_prelude in a require ;-)
So I use a notion of a  "container" which is a two part thing: one part is
something like a locator ("file") and the other the object in which that
locator lives. Many times the locator is a "file" inside say a filesystem,
but it could be a string variable passed to *eval* or
*RubyVM::InstructionSequenceCompile.
*

So here it may be helpful say in a debugger or trace hook routine to know
not only the position of the text inside that variable but perhaps the
location of the eval. That way you could set the frame to be the context of
the eval on the call stack and pick up the full source text of the eval
which by the way doesn't appear in SCRIPT_LINES__.

In Python where packages can be bundled inside "egg" files and sometimes
compressed,  you might want to indicate that "file" is not in a filesystem
but inside this bundled file.

And as for "line", well, in the general case I think one wants again a
two-part thing: both a start position and and end position which would be a
starting "line" offset and a character offset within that and then an ending
line and an ending-line character offset. Right now I don't believe Ruby
will ever allow a compilation to start in one container (or "file") and end
in another, so repeating the "file" part on the end is not needed.

However in the presence of optimization, it is conceivable that instructions
or source code fragments from different "lines" get combined. So in fact
there may be *several* sets of positions for say a given VM instruction or
stopping place.  So what I have here is an unstructured array of
"positions", each position being in general a two part thingy, but for now I
just have a single Fixnum "line".

Some of these thoughts I have documented in
http://github.com/rocky/rb-threadframe/blob/master/threadframe.rd which is
in need of update.

On Tue, Sep 29, 2009 at 3:21 AM, Ryan Davis <ryand-ruby / zenspider.com>wrote:

> /**
>>  @c setting
>>  @e trace
>>  @j trace Ѥ̿ᡣ
>>  */
>> DEFINE_INSN
>> trace
>> (rb_num_t nf)
>> ()
>> ()
>> {
>>    rb_event_flag_t flag  rb_event_flag_t)nf;
>>
>>    EXEC_EVENT_HOOK(th, flag, GET_SELF(), 0, 0 /* TODO: id, klass */);
>> }
>>
>
> Am I missing something? Does this TODO imply that the event hook mechanism
> isn't supposed to work yet?
>
>
>

--001636d34f707900a80474b36995
Content-Type: text/html; charset=ISO-2022-JP
Content-Transfer-Encoding: base64

VGhlIGV2ZW50IGhvb2sgZGVmaW5pdGVseSB3b3Jrcy4gPGJyPjxicj5UaGUgVE9ETyByZWxhdGVz
IEkgdGhpbmsgdG8gc2V0dGluZyA8aT5pZDwvaT4gYW5kIDxpPmtsYXNzPC9pPiB3aGljaCBJIHdo
YXQgMS44IGRvZXMuIDxicj48YnI+PGI+YmVnaW4gbG9uZyBkaXNjdXNzaW9uIHdoaWNoIG1vc3Qg
bWF5IHdhbnQgdG8gaWdub3JlOjwvYj48aT48YnI+PC9pPjxicj5UaGF0IHNhaWQsIGluIG15IHZp
ZXcgSSBkb24mIzM5O3QgYmVsaWV2ZSBpdCBuZWNlc3NhcnkgdG8gZXZlciBmaWxsIHRoaXMgb3V0
LiBJbnN0ZWFkIHdoYXQgSSYjMzk7ZCByYXRoZXIgc2VlIGlzIHRoZSBldmVudCBob29rIGNhbGwg
aW50ZXJmYWNlIDxpPnNpbXBsaWZpZWQ8L2k+Ljxicj4KPGJyPlJpZ2h0IG5vdyBpdCBpcyBhIHRy
YWNlIGZ1bmN0aW9uIGNhbGwgbG9va3MgbGlrZTogPGJyPiZuYnNwOyA8aT50cmFjZV9mdW5jdGlv
bihldmVudCwgZmlsZSwgbGluZSwgaWQsIGJpbmQsIGt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