aboutsummaryrefslogtreecommitdiffstats
path: root/ext/coverage
Commit message (Collapse)AuthorAgeFilesLines
* Update dependenciesNobuyoshi Nakada2019-11-181-17/+0
|
* Revert https://github.com/ruby/ruby/pull/2486卜部昌平2019-10-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commits: 10d6a3aca7 8ba48c1b85 fba8627dc1 dd883de5ba 6c6a25feca 167e6b48f1 7cb96d41a5 3207979278 595b3c4fdd 1521f7cf89 c11c5e69ac cf33608203 3632a812c0 f56506be0d 86427a3219 . The reason for the revert is that we observe ABA problem around inline method cache. When a cache misshits, we search for a method entry. And if the entry is identical to what was cached before, we reuse the cache. But the commits we are reverting here introduced situations where a method entry is freed, then the identical memory region is used for another method entry. An inline method cache cannot detect that ABA. Here is a code that reproduce such situation: ```ruby require 'prime' class << Integer alias org_sqrt sqrt def sqrt(n) raise end GC.stress = true Prime.each(7*37){} rescue nil # <- Here we populate CC class << Object.new; end # These adjacent remove-then-alias maneuver # frees a method entry, then immediately # reuses it for another. remove_method :sqrt alias sqrt org_sqrt end Prime.each(7*37).to_a # <- SEGV ```
* refactor constify most of rb_method_entry_t卜部昌平2019-09-301-1/+1
| | | | | | | | | | | Now that we have eliminated most destructive operations over the rb_method_entry_t / rb_callable_method_entry_t, let's make them mostly immutabe and mark them const. One exception is rb_export_method(), which destructively modifies visibilities of method entries. I have left that operation as is because I suspect that destructiveness is the nature of that function.
* Split RUBY_ASSERT and so on under include/rubyNobuyoshi Nakada2019-07-141-0/+1
|
* * expand tabs.git2019-07-031-1/+1
|
* Use rb_ident_hash_new instead of rb_hash_new_compare_by_idNobuyoshi Nakada2019-07-031-1/+1
| | | | The latter is same as the former, removed the duplicate function.
* Removed moving toplevel header since r12501nobu2019-02-081-2/+2
| | | | | | | Moving public headers was 12-years ago, no depend files would expect ruby.h in the top source directory now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/coverage/lib/coverage.rb (Coverage.line_stub): use only line eventsmame2018-12-201-1/+1
| | | | | | | | It wrongly used all linenos of ISeq#trace_points which includes not only line events but also call, return, and other events. So, the result included some linenos that can not be covered at all by line coverage. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2018-10-201-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/coverage/: add the oneshot modemame2018-10-202-12/+63
| | | | | | | | | | | | This patch introduces "oneshot_lines" mode for `Coverage.start`, which checks "whether each line was executed at least once or not", instead of "how many times each line was executed". A hook for each line is fired at most once, and after it is fired, the hook flag was removed; it runs with zero overhead. See [Feature #15022] in detail. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* update dependenciesnobu2018-01-091-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/coverage/coverage.c: remove COVERAGE_EXPERIMENTAL_MODEmame2017-12-121-8/+1
| | | | | | A NEWS entry is also added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/coverage/coverage.c: method coverage has column info. of method def.mame2017-12-051-2/+5
| | | | | | | | This change makes method coverage result have not only first lineno of method defintion, but also code range (i.e. first lineno, first column, last lineno, and last column). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_core.h (rb_iseq_locatoin_t): add a field `code_range`mame2017-12-051-1/+1
| | | | | | | This change makes each ISeq keep NODE's code range. This information is needed for method coverage. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revamp method coverage to support define_methodmame2017-12-051-21/+74
| | | | | | | | | | | | | | Traditionally, method coverage measurement was implemented by inserting `trace2` instruction to the head of method iseq. So, it just measured methods defined by `def` keyword. This commit drastically changes the measuring mechanism of method coverage; at `RUBY_EVENT_CALL`, it keeps a hash from rb_method_entry_t* to runs (i.e., it counts the runs per method entry), and at `Coverage.result`, it creates the result hash by enumerating all `rb_method_entry_t*` objects (by `ObjectSpace.each_object`). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add a last location to branch coverageyui-knk2017-11-161-8/+12
| | | | | | | | | | | | | | | * compile.c (DECL_BRANCH_BASE, ADD_TRACE_BRANCH_COVERAGE): Add a last location to arguments. * compile.c (compile_if, compile_case, compile_case2, compile_loop, iseq_compile_each0): Pass a last location to macros. * ext/coverage/coverage.c (branch_coverage): Add a last location to a return value. * test/coverage/test_coverage.rb: Follow-up these changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add column numbers to branch coverageyui-knk2017-10-221-4/+6
| | | | | | | | | | | | | | | * compile.c (DECL_BRANCH_BASE, ADD_TRACE_BRANCH_COVERAGE): Add column to arguments. * compile.c (compile_if, compile_case, compile_when, compile_loop, iseq_compile_each0): Pass column numbers to macros. * ext/coverage/coverage.c (branch_coverage): Add column numbers to a return value. * test/coverage/test_coverage.rb: Follow-up these changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/coverage/coverage.c (rb_coverage_start): Ensure `opt` is a hashyui-knk2017-09-151-0/+2
| | | | | | | | Ensure `opt` is a hash before using `rb_hash_lookup` to `opt`. This will prevent SEGV when an inappropriate object (i.e. an array) is passed to `opt`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/coverage/coverage.c: use long instead of int for coverage site idmame2017-09-141-5/+7
| | | | | | | | Coverage generates unique ID numbers for each branch and each method. Use long instead of int for the IDs. I don't want to see 2^32 branches and methods in one file, but just in case... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/coverage/coverage.c (method_coverage): `id` was used uninitializedmame2017-09-141-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add method coveragemame2017-09-141-1/+17
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Removed needless operator.hsbt2017-09-141-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add branch coverage for if statementmame2017-09-141-1/+26
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/coverage/coverage.c: Fix the condition for non-experimental modemame2017-09-141-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [EXPERIMENTAL] Extend the API of `Coverage.start` and `result`mame2017-09-141-8/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | The old API: Coverage.start load "foo.rb" p Coverage.result #=> {"foo.rb" => [1, 2, nil]} The new API: ENV["COVERAGE_EXPERIMENTAL_MODE"] = "true" Coverage.start(lines: true) load "foo.rb" p Coverage.result #=> {"foo.rb" => {:lines => [1, 2, nil]}} This new API allows us to add other measuring target types. Notes: * To keep compatibility, the old interface is still remained; passing no optional argument makes `Coverage.result` return the old format. * This feature is still experimental. So, to enable the new API, the environment variable `COVERAGE_EXPERIMENTAL_MODE` must be set. I plan to activate this feature by Ruby 2.5. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Refactor the internal data format for coverage measurementmame2017-09-031-4/+7
| | | | | | | | | | | To prepare new measuring targets: branch and method coverages. So far, iseq->coverage was an array of counts executed for line coverage. Now, it is a three-element array for each measuring target, whose first element is an array for line coverage. The second element is planned for branch coverage, and the third will be for method coverage. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/coverage/coverage.c: add Coverage.enabled?mame2017-09-011-0/+15
| | | | | | | | * ext/coverage/coverage.c (rb_coverage_running): add to quickly check if coverage is enabled. patched by Burke Libbey <burke AT libbey.me> in [ruby-core:81726]. [Feature #13667] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby tool/update-deps --fixshyouhei2017-03-221-0/+1
| | | | | | | | | | | | | | Onigumo 6 (r57045) introduced new onigumo.h header file, which is required from quite much everywhere. This commit adds necessary dependencies. Note: ruby/oniguruma.h now includes onigumo.h, ruby/io.h includes oniguruma.h, ruby/encoding.h also includes oniguruma.h, and internal.h includes encoding.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Update dependencies.akr2016-04-111-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/coverage/coverage.c: Fully reset coverage to not persist global state.eregon2016-04-061-20/+5
| | | | | | | | | | It was returning old file coverages as empty arrays to the user. [ruby-core:74596] [Bug #12220] * ext/coverage/coverage.c (rb_coverages): remove unused static state. * thread.c: Moved and renamed coverage_clear_result_i to reset_coverage_i. * test/coverage/test_coverage.rb: improve precision of tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread.c (update_coverage): Do not track coverage in loaded fileseregon2016-03-311-0/+1
| | | | | | | after Coverage.result. Avoids out-of-bounds access. [Bug #12237] * ext/coverage/coverage.c (coverage_clear_result_i): document. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_core.h: use RUBY_ASSERTnobu2016-01-221-0/+1
| | | | | | * vm_core.h (VM_ASSERT): use RUBY_ASSERT instead of rb_bug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* handle ext/ as r53141naruse2015-12-161-0/+1
| | | | | | | | g -L frozen_string_literal ext/**/*.rb|xargs ruby -Ka -e'ARGV.each{|fn|puts fn;open(fn,"r+"){|f|s=f.read.sub(/\A(#!.*\n)?(#.*coding.*\n)?/,"\\&# frozen_string_literal: false\n");f.rewind;f.write s}}' git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/coverage/coverage.c: Remove extension from require argument.hsbt2015-04-121-2/+2
| | | | | | [ci skip][fix GH-870] Patch by @yui-knk git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* coverage.c: suppress a warningnobu2015-02-131-1/+1
| | | | | | | * ext/coverage/coverage.c (coverage_clear_result_i): use local variable coverage. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/coverage/coverage.c: Add Coverage.peek_result. Allows you totenderlove2015-02-131-7/+30
| | | | | | | | | capture coverage information without stopping the coverage tool. [ruby-core:67940] [Feature #10816] * test/coverage/test_coverage.rb: test for change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Update dependencies.akr2014-12-191-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Update dependency.akr2014-11-211-0/+20
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Dependencies updated.akr2014-11-181-2/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Include ruby.h and ruby/encoding.h to beakr2014-11-151-0/+2
| | | | | | | | includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Mark auogenerated part.akr2014-11-151-0/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * common.mk: Remove comments in Dependency lines.akr2014-11-151-4/+4
| | | | | | | | | | | | Notified by usa. * enc/depend: Ditto. * ext/**/depend: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * tool/update-deps: Extend to fix dependencies.akr2014-11-151-0/+4
| | | | | | | | | | | | * common.mk: Dependencies updated by tool/update-deps. * enc/depend: Ditto. * ext/**/depend: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/openssl/depend: remove dependency from internal headers.ko12014-05-141-1/+1
| | | | | | | | | | | | | | | | | | | [Feature #9612] * ext/openssl/ossl.c (ossl_fips_mode_set): ditto. * ext/coverage/depend: ditto. * include/ruby/thread_native.h: added. This header file only provides wrapper functions to control native threads. These wrapper functions are used by MRI implementation. * vm_core.h: use include/ruby/thread_native.h. * thread.c: ditto. * thread_pthread.h: ditto. * thread_win32.h: ditto. * thread_native.h: removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * common.mk, ext/objspace/depend, ext/coverage/depend,akr2013-10-281-1/+3
| | | | | | | ext/-test-/debug/depend, ext/date/depend: Update dependencies. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h: constify RBasic::klass and addko12013-05-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RBASIC_CLASS(obj) macro which returns a class of `obj'. This change is a part of RGENGC branch [ruby-trunk - Feature #8339]. * object.c: add new function rb_obj_reveal(). This function reveal interal (hidden) object by rb_obj_hide(). Note that do not change class before and after hiding. Only permitted example is: klass = RBASIC_CLASS(obj); rb_obj_hide(obj); .... rb_obj_reveal(obj, klass); TODO: API design. rb_obj_reveal() should be replaced with others. TODO: modify constified variables using cast may be harmful for compiler's analysis and optimizaton. Any idea to prohibt inserting RBasic::klass directly? If rename RBasic::klass and force to use RBASIC_CLASS(obj), then all codes such as `RBASIC(obj)->klass' will be compilation error. Is it acceptable? (We have similar experience at Ruby 1.9, for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)". * internal.h: add some macros. * RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal object. * RBASIC_SET_CLASS(obj, cls) set RBasic::klass. * RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS without write barrier (planned). * RCLASS_SET_SUPER(a, b) set super class of a. * array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c, file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c, parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c, string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c: Use above macros and functions to access RBasic::klass. * ext/coverage/coverage.c, ext/readline/readline.c, ext/socket/ancdata.c, ext/socket/init.c, * ext/zlib/zlib.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/coverage/depend: fix id.h place as r40283.naruse2013-04-152-1/+2
| | | | | | * ext/coverage/extconf.rb: add topdir and topsrcdir to VPATH. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/-test-/debug/depend: New file.akr2013-04-141-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * ext/-test-/exception/depend: Ditto. * ext/-test-/printf/depend: Ditto. * ext/-test-/string/depend: Ditto. * ext/coverage/depend: Ditto. * ext/io/console/depend: Ditto. * ext/io/nonblock/depend: Ditto. * ext/io/wait/depend: Ditto. * ext/openssl/depend: Ditto. * ext/pathname/depend: Ditto. * ext/psych/depend: Ditto. * ext/zlib/depend: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/coverage/coverage.c (Init_coverage): Change list format anddrbrain2011-10-101-5/+7
| | | | | | | | describe Coverage.result output. Patch by Sylvain Daubert. [Ruby 1.9 - Bug #5428] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/coverage/coverage.c: resurrect r32071 + add GC guard fornagachika2011-07-041-9/+18
| | | | | | | | | rb_coverages. [ruby-core:37352] [Bug #4927] [ruby-core:36539] [Feature #4796] * test/coverage/test_coverage.rb resurrect r32071. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e