Module: TraceLineNumbers
- Defined in:
- lib/tracelines.rb,
ext/trace_nums.c
Overview
require ‘ruby-debug’ ; Debugger.start(:post-mortem => true)
Constant Summary collapse
- @@SRC_DIR =
File.(File.dirname(__FILE__))
Class Method Summary collapse
-
.lnums_for_file(file) ⇒ Object
Return an array of lines numbers that could be stopped at given a file name of a Ruby program.
-
.lnums_for_str(src) ⇒ Object
Return a list of trace hook line numbers for the string in Ruby source src.
-
.lnums_for_str_array(string_array, newline = '') ⇒ Object
Return an array of lines numbers that could be stopped at given a file name of a Ruby program.
Class Method Details
.lnums_for_file(file) ⇒ Object
Return an array of lines numbers that could be stopped at given a file name of a Ruby program.
17 18 19 |
# File 'lib/tracelines.rb', line 17 def lnums_for_file(file) lnums_for_str(File.read(file)) end |
.lnums_for_str(src) ⇒ Object
Return a list of trace hook line numbers for the string in Ruby source src
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 |
# File 'ext/trace_nums.c', line 690 static VALUE lnums_for_str(VALUE self, VALUE src) { VALUE result = rb_ary_new(); /* The returned array of line numbers. */ NODE *node = NULL; int critical; ruby_nerrs = 0; StringValue(src); /* Check that src is a string. */ critical = rb_thread_critical; rb_thread_critical = Qtrue; /* Making ruby_in_eval nonzero signals rb_compile_string not to save source in SCRIPT_LINES__. */ ruby_in_eval++; node = rb_compile_string("(numbers_for_str)", src, 1); ruby_in_eval--; rb_thread_critical = critical; if (ruby_nerrs > 0) { ruby_nerrs = 0; #if RUBY_VERSION_CODE < 190 ruby_eval_tree_begin = 0; #endif rb_exc_raise(ruby_errinfo); } if (RTEST(ruby_debug)) { indent_level = 0; } ln_eval(self, node, result); return result; } |
.lnums_for_str_array(string_array, newline = '') ⇒ Object
Return an array of lines numbers that could be stopped at given a file name of a Ruby program. We assume the each line has n at the end. If not set the newline parameters to n.
26 27 28 |
# File 'lib/tracelines.rb', line 26 def lnums_for_str_array(string_array, newline='') lnums_for_str(string_array.join(newline)) end |