Skip to content

Commit

Permalink
* eval.c, node.h, thread.c, yarvcore.[ch], eval_intern.h:
Browse files Browse the repository at this point in the history
  support set_trace_func (incomplete.  id and klass
  don't be passed).  And support Thread#set_trace_func
  which hook only specified thread and Thread#add_trace_func
  which add new trace func instead of replace old one.
  C level API was modified.  See thread.c (logic) and
  yarvcore.h (data structures).
* vm.c, vm_macro.def: add hook points.
* compile.c, insns.def: fix "trace" instruction.
* iseq.c, vm_macro.h: add compile option "trace_instruction".
* test/ruby/test_settracefunc.rb: hook "c-return" of set_trace_func.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
ko1 committed Apr 19, 2007
1 parent 2dd91fa commit a738943
Show file tree
Hide file tree
Showing 15 changed files with 472 additions and 313 deletions.
18 changes: 18 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
Thu Apr 19 18:37:49 2007 Koichi Sasada <[email protected]>

* eval.c, node.h, thread.c, yarvcore.[ch], eval_intern.h:
support set_trace_func (incomplete. id and klass
don't be passed). And support Thread#set_trace_func
which hook only specified thread and Thread#add_trace_func
which add new trace func instead of replace old one.
C level API was modified. See thread.c (logic) and
yarvcore.h (data structures).

* vm.c, vm_macro.def: add hook points.

* compile.c, insns.def: fix "trace" instruction.

* iseq.c, vm_macro.h: add compile option "trace_instruction".

* test/ruby/test_settracefunc.rb: hook "c-return" of set_trace_func.

Thu Apr 19 17:46:36 2007 Koichi Sasada <[email protected]>

* lib/optparse.rb: fix to override conv proc.
Expand Down
18 changes: 17 additions & 1 deletion compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,19 @@ rb_iseq_compile(VALUE self, NODE *node)
ADD_CATCH_ENTRY(CATCH_TYPE_NEXT, start, end, 0, end);
}
else {
COMPILE(ret, "scoped node", node->nd_body);
if (iseq->type == ISEQ_TYPE_CLASS) {
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_CLASS);
COMPILE(ret, "scoped node", node->nd_body);
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_END);
}
else if (iseq->type == ISEQ_TYPE_METHOD) {
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_CALL);
COMPILE(ret, "scoped node", node->nd_body);
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_RETURN);
}
else {
COMPILE(ret, "scoped node", node->nd_body);
}
}
}
else {
Expand Down Expand Up @@ -2433,6 +2445,10 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)

type = nd_type(node);

if (node->flags & NODE_NEWLINE) {
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_LINE);
}

switch (type) {

case NODE_METHOD:{
Expand Down
5 changes: 5 additions & 0 deletions compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ r_value(VALUE value)
new_insn_send(iseq, line, \
(VALUE)id, (VALUE)argc, (VALUE)block, (VALUE)flag))

#define ADD_TRACE(seq, line, event) \
if (iseq->compile_data->option->trace_instruction) { \
ADD_INSN1(seq, line, trace, INT2FIX(event)); \
}

/* add label */
#define ADD_LABEL(seq, label) \
ADD_ELEM(seq, (LINK_ELEMENT *)label)
Expand Down
Loading

0 comments on commit a738943

Please sign in to comment.