Am I missing something? Does this TODO imply that the event hook
mechanism isn't supposed to work yet?
The hook works fine, it just doesn't pass in the id and klass variables.
You can get them pretty easily, though
(ruby_current_thread->cfp->iseq->defined_method_id and
ruby_current_thread->cfp->iseq->klass).
Mark
Mark
> Ryan Davis 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?
>>
>>
>>
>>
>
> The hook works fine, it just doesn't pass in the id and klass
> variables. [...]
No... "works fine" for me means "compatible" and this definitely
isn't. My event_hook gem has had to go through a lot of convolutions
just to compile and now it turns out that it is going to need even
more to work as it did before.
> The hook works fine, it just doesn't pass in the id and klass
> variables. You can get them pretty easily, though
> (ruby_current_thread->cfp->iseq->defined_method_id and
> ruby_current_thread->cfp->iseq->klass).
Neither ruby_current_thread nor rb_thread_t are defined as public, so
I don't see how this is possible (and safe/maintainable). They appear
to be in the private vm_core.h at the base of trunk/1_9.
It seems to me that the TODO that I pointed out needs to be finished
for event_hook to be usable.
Koichi, are there any plans for this?
No. ruby-debug19(-base) relies on your ruby_core_source gem... I don't
think that a hack of that magnitude qualifies as "working fairly
well". I'd rather write code that works out of the box with the
version of ruby I'm using.
Further, I don't think your solution is safe. Is there any guarantee
that threads won't switch between the time that the event is generated
and the event_hook is called? There is a LOT of mechanism in there
and I can't wade through that question (and don't trust it as a result).
To answer your thread switching concern: there's one method between the
VM executing the bytecode in vm_exec_core() and my hook
(exec_event_hooks). It doesn't touch ruby_current_thread. Not much
mechanism at all; it seems very safe to me, and I have spent hours and
hours debugging the VM. Also, as a side note, the debugger suspends all
running threads. It's conceivable to me that there are potential race
conditions that might cause problems, though.
Further, in practice, I am not getting any bug reports of segfaults
under the debugger that I have not already attributed to other issues;
and all such problems are fixed. If you're not comfortable with the
induction, fine, but to me, that means something.
Sorry for my late response. I'm processing over 2000 unread message on
ruby-core and I find this post now.
I want to provide stack frame traversing "C" API that you can access
frame information such as RECEIVER, CALLEE METHOD NAME, and so on. In
our laboratory, prototype was finished (for memory profiler, that
Soh-san posted).
Is this enough for your use?
--
// SASADA Koichi at atdot dot net