diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-07-01 16:55:30 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-07-01 16:55:30 +0000 |
commit | 5874de95e8df1d051001cf53614c1d245c1ac5ae (patch) | |
tree | 3bd25f3a413a1637a826552181c1568b3bbeb9c0 /insns.def | |
parent | 498324c5d3cd08c2c306a4f91e3a11b7fda22835 (diff) |
* Add coverage measurement constant COVERAGE__. This constant is not
for casual use. Usage: (1) assign {} to COVERAGE__, (2) require or
load Ruby source file, and (3) COVERAGE__["sourcefilepath"] will
return an array whose elements represent number of executions per
line of source code.
* vm_core.h: add field of coverage array to iseq.
* iseq.c (prepare_iseq_build): ditto.
* insns.def (trace): update coverage array.
* parse.y (coverage): create and initialize coverage array.
* compile.h (ADD_TRACE): add trace instruction to update covearge
array.
* thread.c (clear_coverage): delete coverage array when forking.
Otherwise, double count of coverage may occur.
* lib/coverage.rb: sample coverage measurement tool.
* error.c: distinguish explicitly between parse_in_eval and
mild_compile_error.
* load.c: ditto.
* vm_eval.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'insns.def')
-rw-r--r-- | insns.def | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -847,11 +847,21 @@ defined */ DEFINE_INSN trace -(rb_num_t nf) +(rb_num_t nf, VALUE coverage) () () { rb_event_flag_t flag = nf; + if (coverage) { + long line = rb_sourceline() - 1; + if (RARRAY_PTR(coverage)[line] == Qnil) { + rb_bug("bug"); + } + long count = FIX2LONG(RARRAY_PTR(coverage)[line]) + 1; + if (POSFIXABLE(count)) { + RARRAY_PTR(coverage)[line] = LONG2FIX(count); + } + } EXEC_EVENT_HOOK(th, flag, GET_SELF(), 0, 0 /* TODO: id, klass */); } |