rcov 0.8.1.2.0 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/BLURB +2 -40
 - data/LICENSE +2 -5
 - data/Rakefile +32 -106
 - data/THANKS +14 -0
 - data/bin/rcov +277 -1090
 - data/doc/readme_for_api.markdown +22 -0
 - data/doc/readme_for_emacs.markdown +52 -0
 - data/doc/readme_for_rake.markdown +51 -0
 - data/doc/readme_for_vim.markdown +34 -0
 - data/{rcov.el → editor-extensions/rcov.el} +0 -0
 - data/{rcov.vim → editor-extensions/rcov.vim} +0 -0
 - data/ext/rcovrt/1.8/callsite.c +216 -0
 - data/ext/rcovrt/1.8/rcovrt.c +287 -0
 - data/ext/rcovrt/1.9/callsite.c +234 -0
 - data/ext/rcovrt/1.9/rcovrt.c +264 -0
 - data/ext/rcovrt/extconf.rb +12 -2
 - data/lib/rcov.rb +13 -968
 - data/lib/rcov/call_site_analyzer.rb +225 -0
 - data/lib/rcov/code_coverage_analyzer.rb +268 -0
 - data/lib/rcov/coverage_info.rb +36 -0
 - data/lib/rcov/differential_analyzer.rb +116 -0
 - data/lib/rcov/file_statistics.rb +334 -0
 - data/lib/rcov/formatters.rb +13 -0
 - data/lib/rcov/formatters/base_formatter.rb +173 -0
 - data/lib/rcov/formatters/failure_report.rb +15 -0
 - data/lib/rcov/formatters/full_text_report.rb +48 -0
 - data/lib/rcov/formatters/html_coverage.rb +274 -0
 - data/lib/rcov/formatters/html_erb_template.rb +62 -0
 - data/lib/rcov/formatters/text_coverage_diff.rb +193 -0
 - data/lib/rcov/formatters/text_report.rb +32 -0
 - data/lib/rcov/formatters/text_summary.rb +11 -0
 - data/lib/rcov/lowlevel.rb +16 -17
 - data/lib/rcov/rcovtask.rb +21 -22
 - data/lib/rcov/templates/detail.html.erb +64 -0
 - data/lib/rcov/templates/index.html.erb +93 -0
 - data/lib/rcov/templates/jquery-1.3.2.min.js +19 -0
 - data/lib/rcov/templates/jquery.tablesorter.min.js +15 -0
 - data/lib/rcov/templates/print.css +12 -0
 - data/lib/rcov/templates/rcov.js +42 -0
 - data/lib/rcov/templates/screen.css +270 -0
 - data/lib/rcov/version.rb +5 -8
 - data/setup.rb +5 -2
 - data/test/{sample_01.rb → assets/sample_01.rb} +0 -0
 - data/test/{sample_02.rb → assets/sample_02.rb} +0 -0
 - data/test/{sample_03.rb → assets/sample_03.rb} +0 -0
 - data/test/{sample_04.rb → assets/sample_04.rb} +0 -0
 - data/test/{sample_05-new.rb → assets/sample_05-new.rb} +0 -0
 - data/test/{sample_05-old.rb → assets/sample_05-old.rb} +0 -0
 - data/test/{sample_05.rb → assets/sample_05.rb} +0 -0
 - data/test/{test_CallSiteAnalyzer.rb → call_site_analyzer_test.rb} +57 -81
 - data/test/{test_CodeCoverageAnalyzer.rb → code_coverage_analyzer_test.rb} +71 -35
 - data/test/{test_FileStatistics.rb → file_statistics_test.rb} +34 -36
 - data/test/{test_functional.rb → functional_test.rb} +21 -35
 - metadata +91 -69
 - data/CHANGES +0 -177
 - data/LEGAL +0 -36
 - data/README.API +0 -42
 - data/README.emacs +0 -64
 - data/README.en +0 -130
 - data/README.rake +0 -62
 - data/README.rant +0 -68
 - data/README.vim +0 -47
 - data/Rantfile +0 -76
 - data/ext/rcovrt/callsite.c +0 -242
 - data/ext/rcovrt/rcovrt.c +0 -329
 - data/lib/rcov/rant.rb +0 -87
 - data/lib/rcov/report.rb +0 -1236
 - data/mingw-rbconfig.rb +0 -174
 
| 
         @@ -0,0 +1,234 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #include <ruby.h>
         
     | 
| 
      
 2 
     | 
    
         
            +
            #include <ruby/st.h>
         
     | 
| 
      
 3 
     | 
    
         
            +
            #include <stdlib.h>
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            #define DEBUG 0
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            static char callsite_hook_set_p;
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            typedef struct {
         
     | 
| 
      
 10 
     | 
    
         
            +
              const char *sourcefile;
         
     | 
| 
      
 11 
     | 
    
         
            +
              unsigned int sourceline;
         
     | 
| 
      
 12 
     | 
    
         
            +
              VALUE curr_meth;
         
     | 
| 
      
 13 
     | 
    
         
            +
            } type_def_site;       
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            static VALUE caller_info = 0;
         
     | 
| 
      
 16 
     | 
    
         
            +
            static VALUE method_def_site_info = 0;
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            static int caller_stack_len = 1;
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            static VALUE record_callsite_info(VALUE args) {
         
     | 
| 
      
 21 
     | 
    
         
            +
              VALUE caller_ary;
         
     | 
| 
      
 22 
     | 
    
         
            +
              VALUE curr_meth;
         
     | 
| 
      
 23 
     | 
    
         
            +
              VALUE count_hash;
         
     | 
| 
      
 24 
     | 
    
         
            +
              VALUE count;
         
     | 
| 
      
 25 
     | 
    
         
            +
              VALUE *pargs = (VALUE *)args;
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              caller_ary = pargs[0];
         
     | 
| 
      
 28 
     | 
    
         
            +
              curr_meth = pargs[1];
         
     | 
| 
      
 29 
     | 
    
         
            +
              count_hash = rb_hash_aref(caller_info, curr_meth);
         
     | 
| 
      
 30 
     | 
    
         
            +
              
         
     | 
| 
      
 31 
     | 
    
         
            +
              if(TYPE(count_hash) != T_HASH) { 
         
     | 
| 
      
 32 
     | 
    
         
            +
                /* Qnil, anything else should be impossible unless somebody's been
         
     | 
| 
      
 33 
     | 
    
         
            +
                 * messing with ObjectSpace */
         
     | 
| 
      
 34 
     | 
    
         
            +
                count_hash = rb_hash_new();
         
     | 
| 
      
 35 
     | 
    
         
            +
                rb_hash_aset(caller_info, curr_meth, count_hash);
         
     | 
| 
      
 36 
     | 
    
         
            +
              }
         
     | 
| 
      
 37 
     | 
    
         
            +
              
         
     | 
| 
      
 38 
     | 
    
         
            +
              count = rb_hash_aref(count_hash, caller_ary);
         
     | 
| 
      
 39 
     | 
    
         
            +
              
         
     | 
| 
      
 40 
     | 
    
         
            +
              if(count == Qnil) 
         
     | 
| 
      
 41 
     | 
    
         
            +
                count = INT2FIX(0);
         
     | 
| 
      
 42 
     | 
    
         
            +
              
         
     | 
| 
      
 43 
     | 
    
         
            +
              count = INT2FIX(FIX2UINT(count) + 1);
         
     | 
| 
      
 44 
     | 
    
         
            +
              rb_hash_aset(count_hash, caller_ary, count);
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              if(DEBUG == 1)
         
     | 
| 
      
 47 
     | 
    
         
            +
                printf("CALLSITE: %s -> %s   %d\n", RSTRING_PTR(rb_inspect(curr_meth)), RSTRING_PTR(rb_inspect(caller_ary)), FIX2INT(count));
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              return Qnil;
         
     | 
| 
      
 50 
     | 
    
         
            +
            }
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            static VALUE record_method_def_site(VALUE args) {
         
     | 
| 
      
 53 
     | 
    
         
            +
              type_def_site *pargs = (type_def_site *)args;
         
     | 
| 
      
 54 
     | 
    
         
            +
              VALUE def_site_info;
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              if( RTEST(rb_hash_aref(method_def_site_info, pargs->curr_meth)) )
         
     | 
| 
      
 57 
     | 
    
         
            +
                return Qnil;
         
     | 
| 
      
 58 
     | 
    
         
            +
              
         
     | 
| 
      
 59 
     | 
    
         
            +
              def_site_info = rb_ary_new();
         
     | 
| 
      
 60 
     | 
    
         
            +
              rb_ary_push(def_site_info, rb_str_new2(pargs->sourcefile));
         
     | 
| 
      
 61 
     | 
    
         
            +
              rb_ary_push(def_site_info, INT2NUM(pargs->sourceline+1));
         
     | 
| 
      
 62 
     | 
    
         
            +
              rb_hash_aset(method_def_site_info, pargs->curr_meth, def_site_info);
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
              if(DEBUG == 1)
         
     | 
| 
      
 65 
     | 
    
         
            +
                printf("DEFSITE: %s:%d  for %s\n", pargs->sourcefile, pargs->sourceline+1, RSTRING_PTR(rb_inspect(pargs->curr_meth)));
         
     | 
| 
      
 66 
     | 
    
         
            +
              
         
     | 
| 
      
 67 
     | 
    
         
            +
              return Qnil;
         
     | 
| 
      
 68 
     | 
    
         
            +
            }
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            static VALUE callsite_custom_backtrace(int lev) {
         
     | 
| 
      
 71 
     | 
    
         
            +
              ID id;
         
     | 
| 
      
 72 
     | 
    
         
            +
              VALUE klass;
         
     | 
| 
      
 73 
     | 
    
         
            +
              VALUE klass_path;
         
     | 
| 
      
 74 
     | 
    
         
            +
              VALUE eval_string;
         
     | 
| 
      
 75 
     | 
    
         
            +
              
         
     | 
| 
      
 76 
     | 
    
         
            +
              rb_frame_method_id_and_class(&id, &klass);
         
     | 
| 
      
 77 
     | 
    
         
            +
              
         
     | 
| 
      
 78 
     | 
    
         
            +
              if (id == ID_ALLOCATOR)
         
     | 
| 
      
 79 
     | 
    
         
            +
                return Qnil;
         
     | 
| 
      
 80 
     | 
    
         
            +
              
         
     | 
| 
      
 81 
     | 
    
         
            +
              if (klass) {
         
     | 
| 
      
 82 
     | 
    
         
            +
                if (TYPE(klass) == T_ICLASS) {
         
     | 
| 
      
 83 
     | 
    
         
            +
                  klass = RBASIC(klass)->klass;
         
     | 
| 
      
 84 
     | 
    
         
            +
                }
         
     | 
| 
      
 85 
     | 
    
         
            +
                else if (FL_TEST(klass, FL_SINGLETON)) {
         
     | 
| 
      
 86 
     | 
    
         
            +
                  klass = rb_iv_get(klass, "__attached__");
         
     | 
| 
      
 87 
     | 
    
         
            +
                }
         
     | 
| 
      
 88 
     | 
    
         
            +
              }
         
     | 
| 
      
 89 
     | 
    
         
            +
              // rb_sprintf("\"#<Class:%s>\"", RSTRING_PTR(klass_path))
         
     | 
| 
      
 90 
     | 
    
         
            +
              
         
     | 
| 
      
 91 
     | 
    
         
            +
              /*
         
     | 
| 
      
 92 
     | 
    
         
            +
              klass = class << klass; self end unless klass === eval("self", binding)
         
     | 
| 
      
 93 
     | 
    
         
            +
              */
         
     | 
| 
      
 94 
     | 
    
         
            +
              
         
     | 
| 
      
 95 
     | 
    
         
            +
              klass_path = rb_class_path(klass);
         
     | 
| 
      
 96 
     | 
    
         
            +
              VALUE reciever = rb_funcall(rb_binding_new(), rb_intern("eval"), 1, rb_str_new2("self"));
         
     | 
| 
      
 97 
     | 
    
         
            +
              
         
     | 
| 
      
 98 
     | 
    
         
            +
              if (rb_funcall(klass, rb_intern("=="), 1, reciever) == Qtrue) {
         
     | 
| 
      
 99 
     | 
    
         
            +
                klass_path = rb_sprintf("\"#<Class:%s>\"", RSTRING_PTR(klass_path));
         
     | 
| 
      
 100 
     | 
    
         
            +
                OBJ_FREEZE(klass_path);
         
     | 
| 
      
 101 
     | 
    
         
            +
              }
         
     | 
| 
      
 102 
     | 
    
         
            +
              
         
     | 
| 
      
 103 
     | 
    
         
            +
              eval_string = rb_sprintf("caller[%d, 1].map do |line|\nmd = /^([^:]*)(?::(\\d+)(?::in `(?:block in )?(.*)'))?/.match(line)\nraise \"Bad backtrace format\" unless md\n[%s, md[3] ? md[3].to_sym : nil, md[1], (md[2] || '').to_i]\nend", lev, RSTRING_PTR(klass_path));
         
     | 
| 
      
 104 
     | 
    
         
            +
              return rb_eval_string(RSTRING_PTR(eval_string));
         
     | 
| 
      
 105 
     | 
    
         
            +
            }
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
            static void coverage_event_callsite_hook(rb_event_flag_t event, VALUE node,  VALUE self, ID mid, VALUE klass) {
         
     | 
| 
      
 108 
     | 
    
         
            +
              VALUE caller_ary;
         
     | 
| 
      
 109 
     | 
    
         
            +
              VALUE curr_meth;
         
     | 
| 
      
 110 
     | 
    
         
            +
              VALUE args[2];
         
     | 
| 
      
 111 
     | 
    
         
            +
              int status;
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
              caller_ary = callsite_custom_backtrace(caller_stack_len);
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
              VALUE klass_path;
         
     | 
| 
      
 116 
     | 
    
         
            +
              curr_meth = rb_ary_new();
         
     | 
| 
      
 117 
     | 
    
         
            +
               
         
     | 
| 
      
 118 
     | 
    
         
            +
              rb_frame_method_id_and_class(&mid, &klass);
         
     | 
| 
      
 119 
     | 
    
         
            +
              
         
     | 
| 
      
 120 
     | 
    
         
            +
              if (mid == ID_ALLOCATOR)
         
     | 
| 
      
 121 
     | 
    
         
            +
                return; //Qnil;
         
     | 
| 
      
 122 
     | 
    
         
            +
              if (klass) {
         
     | 
| 
      
 123 
     | 
    
         
            +
                if (TYPE(klass) == T_ICLASS) {
         
     | 
| 
      
 124 
     | 
    
         
            +
                  klass = RBASIC(klass)->klass;
         
     | 
| 
      
 125 
     | 
    
         
            +
                }
         
     | 
| 
      
 126 
     | 
    
         
            +
                else if (FL_TEST(klass, FL_SINGLETON)) {
         
     | 
| 
      
 127 
     | 
    
         
            +
                  klass = rb_iv_get(klass, "__attached__");
         
     | 
| 
      
 128 
     | 
    
         
            +
                }
         
     | 
| 
      
 129 
     | 
    
         
            +
              }
         
     | 
| 
      
 130 
     | 
    
         
            +
              
         
     | 
| 
      
 131 
     | 
    
         
            +
              /*
         
     | 
| 
      
 132 
     | 
    
         
            +
              klass = class << klass; self end unless klass === eval("self", binding)
         
     | 
| 
      
 133 
     | 
    
         
            +
              */
         
     | 
| 
      
 134 
     | 
    
         
            +
              
         
     | 
| 
      
 135 
     | 
    
         
            +
              klass_path = rb_class_path(klass);
         
     | 
| 
      
 136 
     | 
    
         
            +
              VALUE reciever = rb_funcall(rb_binding_new(), rb_intern("eval"), 1, rb_str_new2("self"));
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
              if (rb_funcall(klass, rb_intern("=="), 1, reciever) == Qtrue) {
         
     | 
| 
      
 139 
     | 
    
         
            +
                klass_path = rb_sprintf("#<Class:%s>", RSTRING_PTR(klass_path));
         
     | 
| 
      
 140 
     | 
    
         
            +
                OBJ_FREEZE(klass_path);
         
     | 
| 
      
 141 
     | 
    
         
            +
              }
         
     | 
| 
      
 142 
     | 
    
         
            +
                
         
     | 
| 
      
 143 
     | 
    
         
            +
              rb_ary_push(curr_meth, klass_path);
         
     | 
| 
      
 144 
     | 
    
         
            +
              rb_ary_push(curr_meth, ID2SYM(mid));
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
              args[0] = caller_ary;
         
     | 
| 
      
 147 
     | 
    
         
            +
              args[1] = curr_meth;
         
     | 
| 
      
 148 
     | 
    
         
            +
              rb_protect(record_callsite_info, (VALUE)args, &status);
         
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
              if(!status) {
         
     | 
| 
      
 151 
     | 
    
         
            +
                type_def_site args;
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
                args.sourcefile = rb_sourcefile();
         
     | 
| 
      
 154 
     | 
    
         
            +
                args.sourceline = rb_sourceline();
         
     | 
| 
      
 155 
     | 
    
         
            +
                args.curr_meth = curr_meth;
         
     | 
| 
      
 156 
     | 
    
         
            +
                rb_protect(record_method_def_site, (VALUE)&args, NULL);
         
     | 
| 
      
 157 
     | 
    
         
            +
              }
         
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
      
 159 
     | 
    
         
            +
              if(status)
         
     | 
| 
      
 160 
     | 
    
         
            +
                rb_gv_set("$!", Qnil);
         
     | 
| 
      
 161 
     | 
    
         
            +
            }
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
            static VALUE cov_install_callsite_hook(VALUE self) {
         
     | 
| 
      
 164 
     | 
    
         
            +
              if(!callsite_hook_set_p) {
         
     | 
| 
      
 165 
     | 
    
         
            +
                if(TYPE(caller_info) != T_HASH)
         
     | 
| 
      
 166 
     | 
    
         
            +
                  caller_info = rb_hash_new();
         
     | 
| 
      
 167 
     | 
    
         
            +
                callsite_hook_set_p = 1;
         
     | 
| 
      
 168 
     | 
    
         
            +
                VALUE something = 0;
         
     | 
| 
      
 169 
     | 
    
         
            +
                rb_add_event_hook(coverage_event_callsite_hook, 
         
     | 
| 
      
 170 
     | 
    
         
            +
                                  RUBY_EVENT_CALL, something);
         
     | 
| 
      
 171 
     | 
    
         
            +
                return Qtrue;
         
     | 
| 
      
 172 
     | 
    
         
            +
              } 
         
     | 
| 
      
 173 
     | 
    
         
            +
              else
         
     | 
| 
      
 174 
     | 
    
         
            +
                return Qfalse;
         
     | 
| 
      
 175 
     | 
    
         
            +
            }
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
            static VALUE cov_remove_callsite_hook(VALUE self) {
         
     | 
| 
      
 178 
     | 
    
         
            +
              if(!callsite_hook_set_p) 
         
     | 
| 
      
 179 
     | 
    
         
            +
                return Qfalse;
         
     | 
| 
      
 180 
     | 
    
         
            +
              else {
         
     | 
| 
      
 181 
     | 
    
         
            +
                rb_remove_event_hook(coverage_event_callsite_hook);
         
     | 
| 
      
 182 
     | 
    
         
            +
                callsite_hook_set_p = 0;
         
     | 
| 
      
 183 
     | 
    
         
            +
                return Qtrue;
         
     | 
| 
      
 184 
     | 
    
         
            +
              }
         
     | 
| 
      
 185 
     | 
    
         
            +
            }
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
            static VALUE cov_generate_callsite_info(VALUE self) {
         
     | 
| 
      
 188 
     | 
    
         
            +
              VALUE ret;
         
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
      
 190 
     | 
    
         
            +
              ret = rb_ary_new();
         
     | 
| 
      
 191 
     | 
    
         
            +
              rb_ary_push(ret, caller_info);
         
     | 
| 
      
 192 
     | 
    
         
            +
              rb_ary_push(ret, method_def_site_info);
         
     | 
| 
      
 193 
     | 
    
         
            +
              return ret;
         
     | 
| 
      
 194 
     | 
    
         
            +
            }
         
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
      
 196 
     | 
    
         
            +
            static VALUE cov_reset_callsite(VALUE self) {
         
     | 
| 
      
 197 
     | 
    
         
            +
              if(callsite_hook_set_p) {
         
     | 
| 
      
 198 
     | 
    
         
            +
                rb_raise(rb_eRuntimeError, "Cannot reset the callsite info in the middle of a traced run.");
         
     | 
| 
      
 199 
     | 
    
         
            +
                return Qnil;
         
     | 
| 
      
 200 
     | 
    
         
            +
              }
         
     | 
| 
      
 201 
     | 
    
         
            +
              
         
     | 
| 
      
 202 
     | 
    
         
            +
              caller_info = rb_hash_new();
         
     | 
| 
      
 203 
     | 
    
         
            +
              method_def_site_info = rb_hash_new();
         
     | 
| 
      
 204 
     | 
    
         
            +
              return Qnil;
         
     | 
| 
      
 205 
     | 
    
         
            +
            }
         
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
      
 207 
     | 
    
         
            +
            void Init_rcov_callsite() {
         
     | 
| 
      
 208 
     | 
    
         
            +
              VALUE mRcov;
         
     | 
| 
      
 209 
     | 
    
         
            +
              VALUE mRCOV__;
         
     | 
| 
      
 210 
     | 
    
         
            +
              ID id_rcov = rb_intern("Rcov");
         
     | 
| 
      
 211 
     | 
    
         
            +
              ID id_coverage__ = rb_intern("RCOV__");
         
     | 
| 
      
 212 
     | 
    
         
            +
              // ID id_script_lines__ = rb_intern("SCRIPT_LINES__");
         
     | 
| 
      
 213 
     | 
    
         
            +
              
         
     | 
| 
      
 214 
     | 
    
         
            +
              if(rb_const_defined(rb_cObject, id_rcov)) 
         
     | 
| 
      
 215 
     | 
    
         
            +
                mRcov = rb_const_get(rb_cObject, id_rcov);
         
     | 
| 
      
 216 
     | 
    
         
            +
              else
         
     | 
| 
      
 217 
     | 
    
         
            +
                mRcov = rb_define_module("Rcov");
         
     | 
| 
      
 218 
     | 
    
         
            +
              
         
     | 
| 
      
 219 
     | 
    
         
            +
              if(rb_const_defined(mRcov, id_coverage__))
         
     | 
| 
      
 220 
     | 
    
         
            +
                mRCOV__ = rb_const_get_at(mRcov, id_coverage__);
         
     | 
| 
      
 221 
     | 
    
         
            +
              else
         
     | 
| 
      
 222 
     | 
    
         
            +
                mRCOV__ = rb_define_module_under(mRcov, "RCOV__");
         
     | 
| 
      
 223 
     | 
    
         
            +
             
     | 
| 
      
 224 
     | 
    
         
            +
              callsite_hook_set_p = 0;
         
     | 
| 
      
 225 
     | 
    
         
            +
              caller_info = rb_hash_new();
         
     | 
| 
      
 226 
     | 
    
         
            +
              method_def_site_info = rb_hash_new();
         
     | 
| 
      
 227 
     | 
    
         
            +
              rb_gc_register_address(&caller_info);
         
     | 
| 
      
 228 
     | 
    
         
            +
              rb_gc_register_address(&method_def_site_info);
         
     | 
| 
      
 229 
     | 
    
         
            +
              
         
     | 
| 
      
 230 
     | 
    
         
            +
              rb_define_singleton_method(mRCOV__, "install_callsite_hook", cov_install_callsite_hook, 0);
         
     | 
| 
      
 231 
     | 
    
         
            +
              rb_define_singleton_method(mRCOV__, "remove_callsite_hook", cov_remove_callsite_hook, 0);
         
     | 
| 
      
 232 
     | 
    
         
            +
              rb_define_singleton_method(mRCOV__, "generate_callsite_info", cov_generate_callsite_info, 0);
         
     | 
| 
      
 233 
     | 
    
         
            +
              rb_define_singleton_method(mRCOV__, "reset_callsite", cov_reset_callsite, 0);
         
     | 
| 
      
 234 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,264 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #include <ruby.h>
         
     | 
| 
      
 2 
     | 
    
         
            +
            #include <ruby/st.h>
         
     | 
| 
      
 3 
     | 
    
         
            +
            #include <stdlib.h>
         
     | 
| 
      
 4 
     | 
    
         
            +
            #include <assert.h>
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            #define COVERAGE_DEBUG_EVENTS 0
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            #define RCOVRT_VERSION_MAJOR 2
         
     | 
| 
      
 9 
     | 
    
         
            +
            #define RCOVRT_VERSION_MINOR 0
         
     | 
| 
      
 10 
     | 
    
         
            +
            #define RCOVRT_VERSION_REV   0
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            static VALUE mRcov;
         
     | 
| 
      
 13 
     | 
    
         
            +
            static VALUE mRCOV__;
         
     | 
| 
      
 14 
     | 
    
         
            +
            static VALUE oSCRIPT_LINES__;
         
     | 
| 
      
 15 
     | 
    
         
            +
            static ID id_cover;
         
     | 
| 
      
 16 
     | 
    
         
            +
            static st_table* coverinfo = 0;
         
     | 
| 
      
 17 
     | 
    
         
            +
            static char coverage_hook_set_p;
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            struct cov_array {
         
     | 
| 
      
 20 
     | 
    
         
            +
              unsigned int len;
         
     | 
| 
      
 21 
     | 
    
         
            +
              unsigned int *ptr;
         
     | 
| 
      
 22 
     | 
    
         
            +
            };
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            static struct cov_array *cached_array = 0;
         
     | 
| 
      
 25 
     | 
    
         
            +
            static char *cached_file = 0; 
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            static struct cov_array * coverage_increase_counter_uncached(char *sourcefile, unsigned int sourceline, char mark_only) {
         
     | 
| 
      
 28 
     | 
    
         
            +
              struct cov_array *carray = NULL;
         
     | 
| 
      
 29 
     | 
    
         
            +
             
         
     | 
| 
      
 30 
     | 
    
         
            +
              if(sourcefile == NULL) {
         
     | 
| 
      
 31 
     | 
    
         
            +
                /* "can't happen", just ignore and avoid segfault */
         
     | 
| 
      
 32 
     | 
    
         
            +
                return NULL;
         
     | 
| 
      
 33 
     | 
    
         
            +
              } 
         
     | 
| 
      
 34 
     | 
    
         
            +
              else if(!st_lookup(coverinfo, (st_data_t)sourcefile, (st_data_t*)&carray)) {
         
     | 
| 
      
 35 
     | 
    
         
            +
                VALUE arr;
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                arr = rb_hash_aref(oSCRIPT_LINES__, rb_str_new2(sourcefile));
         
     | 
| 
      
 38 
     | 
    
         
            +
                if(NIL_P(arr)) 
         
     | 
| 
      
 39 
     | 
    
         
            +
                  return 0;
         
     | 
| 
      
 40 
     | 
    
         
            +
                rb_check_type(arr, T_ARRAY);
         
     | 
| 
      
 41 
     | 
    
         
            +
                carray = calloc(1, sizeof(struct cov_array));
         
     | 
| 
      
 42 
     | 
    
         
            +
                carray->ptr = calloc(RARRAY_LEN(arr), sizeof(unsigned int));
         
     | 
| 
      
 43 
     | 
    
         
            +
                carray->len = RARRAY_LEN(arr);
         
     | 
| 
      
 44 
     | 
    
         
            +
                st_insert(coverinfo, (st_data_t)strdup(sourcefile), (st_data_t) carray);
         
     | 
| 
      
 45 
     | 
    
         
            +
              } 
         
     | 
| 
      
 46 
     | 
    
         
            +
              else {
         
     | 
| 
      
 47 
     | 
    
         
            +
                /* recovered carray, sanity check */
         
     | 
| 
      
 48 
     | 
    
         
            +
                assert(carray && "failed to create valid carray");
         
     | 
| 
      
 49 
     | 
    
         
            +
              }
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              if(mark_only) {
         
     | 
| 
      
 52 
     | 
    
         
            +
                if(!carray->ptr[sourceline])
         
     | 
| 
      
 53 
     | 
    
         
            +
                  carray->ptr[sourceline] = 1;
         
     | 
| 
      
 54 
     | 
    
         
            +
              } 
         
     | 
| 
      
 55 
     | 
    
         
            +
              else {
         
     | 
| 
      
 56 
     | 
    
         
            +
                if (carray && carray->len > sourceline) {
         
     | 
| 
      
 57 
     | 
    
         
            +
                  carray->ptr[sourceline]++;
         
     | 
| 
      
 58 
     | 
    
         
            +
                }
         
     | 
| 
      
 59 
     | 
    
         
            +
              }
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
              return carray;
         
     | 
| 
      
 62 
     | 
    
         
            +
            }
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            static void coverage_mark_caller() {
         
     | 
| 
      
 65 
     | 
    
         
            +
              coverage_increase_counter_uncached(rb_sourcefile(), rb_sourceline(), 1);
         
     | 
| 
      
 66 
     | 
    
         
            +
            }
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            static void coverage_increase_counter_cached(char *sourcefile, int sourceline) {
         
     | 
| 
      
 69 
     | 
    
         
            +
              if(cached_file == sourcefile && cached_array && cached_array->len > sourceline) {
         
     | 
| 
      
 70 
     | 
    
         
            +
                cached_array->ptr[sourceline]++;
         
     | 
| 
      
 71 
     | 
    
         
            +
                return;
         
     | 
| 
      
 72 
     | 
    
         
            +
              }
         
     | 
| 
      
 73 
     | 
    
         
            +
              cached_file = sourcefile;
         
     | 
| 
      
 74 
     | 
    
         
            +
              cached_array = coverage_increase_counter_uncached(sourcefile, sourceline, 0);
         
     | 
| 
      
 75 
     | 
    
         
            +
            }
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
            static void coverage_event_coverage_hook(rb_event_flag_t event, VALUE node, VALUE self, ID mid, VALUE klass) {
         
     | 
| 
      
 78 
     | 
    
         
            +
              char *sourcefile;
         
     | 
| 
      
 79 
     | 
    
         
            +
              unsigned int sourceline;
         
     | 
| 
      
 80 
     | 
    
         
            +
              static unsigned int in_hook = 0;
         
     | 
| 
      
 81 
     | 
    
         
            +
             
         
     | 
| 
      
 82 
     | 
    
         
            +
              if(in_hook) {
         
     | 
| 
      
 83 
     | 
    
         
            +
                return;
         
     | 
| 
      
 84 
     | 
    
         
            +
              }
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
              in_hook++;
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
              #if COVERAGE_DEBUG_EVENTS
         
     | 
| 
      
 89 
     | 
    
         
            +
              do {
         
     | 
| 
      
 90 
     | 
    
         
            +
                int status;
         
     | 
| 
      
 91 
     | 
    
         
            +
                VALUE old_exception;
         
     | 
| 
      
 92 
     | 
    
         
            +
                old_exception = rb_gv_get("$!");
         
     | 
| 
      
 93 
     | 
    
         
            +
                rb_protect(rb_inspect, klass, &status);
         
     | 
| 
      
 94 
     | 
    
         
            +
                if(!status) {
         
     | 
| 
      
 95 
     | 
    
         
            +
                  printf("EVENT: %d %s %s %s %d\n", event,
         
     | 
| 
      
 96 
     | 
    
         
            +
                         klass ? RSTRING(rb_inspect(klass))->ptr : "", 
         
     | 
| 
      
 97 
     | 
    
         
            +
                         mid ? (mid == ID_ALLOCATOR ? "ID_ALLOCATOR" : rb_id2name(mid))
         
     | 
| 
      
 98 
     | 
    
         
            +
                         : "unknown",
         
     | 
| 
      
 99 
     | 
    
         
            +
                         node ? node->nd_file : "", node ? nd_line(node) : 0);
         
     | 
| 
      
 100 
     | 
    
         
            +
                } 
         
     | 
| 
      
 101 
     | 
    
         
            +
                else {
         
     | 
| 
      
 102 
     | 
    
         
            +
                  printf("EVENT: %d %s %s %d\n", event,
         
     | 
| 
      
 103 
     | 
    
         
            +
                         mid ? (mid == ID_ALLOCATOR ? "ID_ALLOCATOR" : rb_id2name(mid)) 
         
     | 
| 
      
 104 
     | 
    
         
            +
                         : "unknown",
         
     | 
| 
      
 105 
     | 
    
         
            +
                         node ? node->nd_file : "", node ? nd_line(node) : 0);
         
     | 
| 
      
 106 
     | 
    
         
            +
                }
         
     | 
| 
      
 107 
     | 
    
         
            +
                rb_gv_set("$!", old_exception);
         
     | 
| 
      
 108 
     | 
    
         
            +
              } while (0); 
         
     | 
| 
      
 109 
     | 
    
         
            +
              #endif
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
              if(event & RUBY_EVENT_C_CALL) {
         
     | 
| 
      
 112 
     | 
    
         
            +
                coverage_mark_caller();
         
     | 
| 
      
 113 
     | 
    
         
            +
              }
         
     | 
| 
      
 114 
     | 
    
         
            +
              if(event & (RUBY_EVENT_C_CALL | RUBY_EVENT_C_RETURN | RUBY_EVENT_CLASS)) {
         
     | 
| 
      
 115 
     | 
    
         
            +
                in_hook--;
         
     | 
| 
      
 116 
     | 
    
         
            +
                return;
         
     | 
| 
      
 117 
     | 
    
         
            +
              }
         
     | 
| 
      
 118 
     | 
    
         
            +
              
         
     | 
| 
      
 119 
     | 
    
         
            +
              sourcefile = rb_sourcefile();
         
     | 
| 
      
 120 
     | 
    
         
            +
              sourceline = rb_sourceline();
         
     | 
| 
      
 121 
     | 
    
         
            +
              
         
     | 
| 
      
 122 
     | 
    
         
            +
              if (0 == sourceline || 0 == sourcefile) {
         
     | 
| 
      
 123 
     | 
    
         
            +
                in_hook--;
         
     | 
| 
      
 124 
     | 
    
         
            +
                return;
         
     | 
| 
      
 125 
     | 
    
         
            +
              }
         
     | 
| 
      
 126 
     | 
    
         
            +
              
         
     | 
| 
      
 127 
     | 
    
         
            +
              coverage_increase_counter_cached(sourcefile, sourceline);
         
     | 
| 
      
 128 
     | 
    
         
            +
              if(event & RUBY_EVENT_CALL)
         
     | 
| 
      
 129 
     | 
    
         
            +
                coverage_mark_caller();
         
     | 
| 
      
 130 
     | 
    
         
            +
              in_hook--;
         
     | 
| 
      
 131 
     | 
    
         
            +
            }
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
            static VALUE cov_install_coverage_hook(VALUE self) {
         
     | 
| 
      
 134 
     | 
    
         
            +
              if(!coverage_hook_set_p) {
         
     | 
| 
      
 135 
     | 
    
         
            +
                if(!coverinfo)
         
     | 
| 
      
 136 
     | 
    
         
            +
                  coverinfo = st_init_strtable();
         
     | 
| 
      
 137 
     | 
    
         
            +
                coverage_hook_set_p = 1;
         
     | 
| 
      
 138 
     | 
    
         
            +
                /* TODO: allow C_CALL too, since it's supported already
         
     | 
| 
      
 139 
     | 
    
         
            +
                 * the overhead is around ~30%, tested on typo */
         
     | 
| 
      
 140 
     | 
    
         
            +
                VALUE holder = 0;
         
     | 
| 
      
 141 
     | 
    
         
            +
                rb_add_event_hook(coverage_event_coverage_hook, 
         
     | 
| 
      
 142 
     | 
    
         
            +
                                  RUBY_EVENT_ALL & ~RUBY_EVENT_C_CALL &
         
     | 
| 
      
 143 
     | 
    
         
            +
                                  ~RUBY_EVENT_C_RETURN & ~RUBY_EVENT_CLASS, holder);
         
     | 
| 
      
 144 
     | 
    
         
            +
                return Qtrue;
         
     | 
| 
      
 145 
     | 
    
         
            +
              }
         
     | 
| 
      
 146 
     | 
    
         
            +
              else
         
     | 
| 
      
 147 
     | 
    
         
            +
                return Qfalse;
         
     | 
| 
      
 148 
     | 
    
         
            +
            }
         
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
            static int populate_cover(st_data_t key, st_data_t value, st_data_t cover) {
         
     | 
| 
      
 151 
     | 
    
         
            +
              VALUE rcover;
         
     | 
| 
      
 152 
     | 
    
         
            +
              VALUE rkey;
         
     | 
| 
      
 153 
     | 
    
         
            +
              VALUE rval;
         
     | 
| 
      
 154 
     | 
    
         
            +
              struct cov_array *carray;
         
     | 
| 
      
 155 
     | 
    
         
            +
              unsigned int i;
         
     | 
| 
      
 156 
     | 
    
         
            +
              
         
     | 
| 
      
 157 
     | 
    
         
            +
              rcover = (VALUE)cover;
         
     | 
| 
      
 158 
     | 
    
         
            +
              carray = (struct cov_array *) value;
         
     | 
| 
      
 159 
     | 
    
         
            +
              rkey = rb_str_new2((char*) key);
         
     | 
| 
      
 160 
     | 
    
         
            +
              rval = rb_ary_new2(carray->len);
         
     | 
| 
      
 161 
     | 
    
         
            +
              for(i = 0; i < carray->len; i++)
         
     | 
| 
      
 162 
     | 
    
         
            +
                rb_ary_push(rval, UINT2NUM(carray->ptr[i]));
         
     | 
| 
      
 163 
     | 
    
         
            +
              
         
     | 
| 
      
 164 
     | 
    
         
            +
              rb_hash_aset(rcover, rkey, rval);
         
     | 
| 
      
 165 
     | 
    
         
            +
              
         
     | 
| 
      
 166 
     | 
    
         
            +
              return ST_CONTINUE;
         
     | 
| 
      
 167 
     | 
    
         
            +
            }
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
      
 169 
     | 
    
         
            +
            static int free_table(st_data_t key, st_data_t value, st_data_t ignored) {
         
     | 
| 
      
 170 
     | 
    
         
            +
              struct cov_array *carray;
         
     | 
| 
      
 171 
     | 
    
         
            +
              
         
     | 
| 
      
 172 
     | 
    
         
            +
              carray = (struct cov_array *) value;
         
     | 
| 
      
 173 
     | 
    
         
            +
              free((char *)key);
         
     | 
| 
      
 174 
     | 
    
         
            +
              free(carray->ptr);
         
     | 
| 
      
 175 
     | 
    
         
            +
              free(carray);
         
     | 
| 
      
 176 
     | 
    
         
            +
              
         
     | 
| 
      
 177 
     | 
    
         
            +
              return ST_CONTINUE;
         
     | 
| 
      
 178 
     | 
    
         
            +
            }
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
            static VALUE cov_remove_coverage_hook(VALUE self) {
         
     | 
| 
      
 181 
     | 
    
         
            +
              if(!coverage_hook_set_p) 
         
     | 
| 
      
 182 
     | 
    
         
            +
                return Qfalse;
         
     | 
| 
      
 183 
     | 
    
         
            +
              else {
         
     | 
| 
      
 184 
     | 
    
         
            +
                rb_remove_event_hook(coverage_event_coverage_hook);
         
     | 
| 
      
 185 
     | 
    
         
            +
                coverage_hook_set_p = 0;
         
     | 
| 
      
 186 
     | 
    
         
            +
                return Qtrue;
         
     | 
| 
      
 187 
     | 
    
         
            +
              }
         
     | 
| 
      
 188 
     | 
    
         
            +
            }
         
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
      
 190 
     | 
    
         
            +
            static VALUE cov_generate_coverage_info(VALUE self) {
         
     | 
| 
      
 191 
     | 
    
         
            +
              VALUE cover;
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
              if(rb_const_defined_at(mRCOV__, id_cover)) {
         
     | 
| 
      
 194 
     | 
    
         
            +
                rb_mod_remove_const(mRCOV__, ID2SYM(id_cover));
         
     | 
| 
      
 195 
     | 
    
         
            +
              }
         
     | 
| 
      
 196 
     | 
    
         
            +
             
     | 
| 
      
 197 
     | 
    
         
            +
              cover = rb_hash_new();
         
     | 
| 
      
 198 
     | 
    
         
            +
              if(coverinfo)
         
     | 
| 
      
 199 
     | 
    
         
            +
                st_foreach(coverinfo, populate_cover, cover);
         
     | 
| 
      
 200 
     | 
    
         
            +
              rb_define_const(mRCOV__, "COVER", cover);
         
     | 
| 
      
 201 
     | 
    
         
            +
             
     | 
| 
      
 202 
     | 
    
         
            +
              return cover;
         
     | 
| 
      
 203 
     | 
    
         
            +
            }
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
            static VALUE cov_reset_coverage(VALUE self) {
         
     | 
| 
      
 206 
     | 
    
         
            +
              if(coverage_hook_set_p) {
         
     | 
| 
      
 207 
     | 
    
         
            +
                rb_raise(rb_eRuntimeError, "Cannot reset the coverage info in the middle of a traced run.");
         
     | 
| 
      
 208 
     | 
    
         
            +
                return Qnil;
         
     | 
| 
      
 209 
     | 
    
         
            +
              }
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
      
 211 
     | 
    
         
            +
              cached_array = 0;
         
     | 
| 
      
 212 
     | 
    
         
            +
              cached_file = 0;
         
     | 
| 
      
 213 
     | 
    
         
            +
              st_foreach(coverinfo, free_table, Qnil); 
         
     | 
| 
      
 214 
     | 
    
         
            +
              st_free_table(coverinfo);
         
     | 
| 
      
 215 
     | 
    
         
            +
              coverinfo = 0;
         
     | 
| 
      
 216 
     | 
    
         
            +
             
     | 
| 
      
 217 
     | 
    
         
            +
              return Qnil;
         
     | 
| 
      
 218 
     | 
    
         
            +
            }
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
            static VALUE cov_ABI(VALUE self) {
         
     | 
| 
      
 221 
     | 
    
         
            +
              VALUE ret;
         
     | 
| 
      
 222 
     | 
    
         
            +
             
     | 
| 
      
 223 
     | 
    
         
            +
              ret = rb_ary_new();
         
     | 
| 
      
 224 
     | 
    
         
            +
              rb_ary_push(ret, INT2FIX(RCOVRT_VERSION_MAJOR));
         
     | 
| 
      
 225 
     | 
    
         
            +
              rb_ary_push(ret, INT2FIX(RCOVRT_VERSION_MINOR));
         
     | 
| 
      
 226 
     | 
    
         
            +
              rb_ary_push(ret, INT2FIX(RCOVRT_VERSION_REV));
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
              return ret;
         
     | 
| 
      
 229 
     | 
    
         
            +
            }
         
     | 
| 
      
 230 
     | 
    
         
            +
             
     | 
| 
      
 231 
     | 
    
         
            +
            void Init_rcovrt() {
         
     | 
| 
      
 232 
     | 
    
         
            +
              ID id_rcov = rb_intern("Rcov");
         
     | 
| 
      
 233 
     | 
    
         
            +
              ID id_coverage__ = rb_intern("RCOV__");
         
     | 
| 
      
 234 
     | 
    
         
            +
              ID id_script_lines__ = rb_intern("SCRIPT_LINES__");
         
     | 
| 
      
 235 
     | 
    
         
            +
              
         
     | 
| 
      
 236 
     | 
    
         
            +
              id_cover = rb_intern("COVER");
         
     | 
| 
      
 237 
     | 
    
         
            +
              
         
     | 
| 
      
 238 
     | 
    
         
            +
              if(rb_const_defined(rb_cObject, id_rcov)) 
         
     | 
| 
      
 239 
     | 
    
         
            +
                mRcov = rb_const_get(rb_cObject, id_rcov);
         
     | 
| 
      
 240 
     | 
    
         
            +
              else
         
     | 
| 
      
 241 
     | 
    
         
            +
                mRcov = rb_define_module("Rcov");
         
     | 
| 
      
 242 
     | 
    
         
            +
              
         
     | 
| 
      
 243 
     | 
    
         
            +
              if(rb_const_defined(mRcov, id_coverage__))
         
     | 
| 
      
 244 
     | 
    
         
            +
                mRCOV__ = rb_const_get_at(mRcov, id_coverage__);
         
     | 
| 
      
 245 
     | 
    
         
            +
              else
         
     | 
| 
      
 246 
     | 
    
         
            +
                mRCOV__ = rb_define_module_under(mRcov, "RCOV__");
         
     | 
| 
      
 247 
     | 
    
         
            +
              
         
     | 
| 
      
 248 
     | 
    
         
            +
              if(rb_const_defined(rb_cObject, id_script_lines__))
         
     | 
| 
      
 249 
     | 
    
         
            +
                oSCRIPT_LINES__ = rb_const_get(rb_cObject, rb_intern("SCRIPT_LINES__"));
         
     | 
| 
      
 250 
     | 
    
         
            +
              else {
         
     | 
| 
      
 251 
     | 
    
         
            +
                oSCRIPT_LINES__ = rb_hash_new();
         
     | 
| 
      
 252 
     | 
    
         
            +
                rb_const_set(rb_cObject, id_script_lines__, oSCRIPT_LINES__);
         
     | 
| 
      
 253 
     | 
    
         
            +
              }
         
     | 
| 
      
 254 
     | 
    
         
            +
              
         
     | 
| 
      
 255 
     | 
    
         
            +
              coverage_hook_set_p = 0;
         
     | 
| 
      
 256 
     | 
    
         
            +
              
         
     | 
| 
      
 257 
     | 
    
         
            +
              rb_define_singleton_method(mRCOV__, "install_coverage_hook", cov_install_coverage_hook, 0);
         
     | 
| 
      
 258 
     | 
    
         
            +
              rb_define_singleton_method(mRCOV__, "remove_coverage_hook", cov_remove_coverage_hook, 0);
         
     | 
| 
      
 259 
     | 
    
         
            +
              rb_define_singleton_method(mRCOV__, "generate_coverage_info", cov_generate_coverage_info, 0);
         
     | 
| 
      
 260 
     | 
    
         
            +
              rb_define_singleton_method(mRCOV__, "reset_coverage", cov_reset_coverage, 0);
         
     | 
| 
      
 261 
     | 
    
         
            +
              rb_define_singleton_method(mRCOV__, "ABI", cov_ABI, 0);
         
     | 
| 
      
 262 
     | 
    
         
            +
              
         
     | 
| 
      
 263 
     | 
    
         
            +
              Init_rcov_callsite();
         
     | 
| 
      
 264 
     | 
    
         
            +
            }
         
     |