diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-06-18 07:55:45 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-06-18 07:55:45 +0000 |
commit | 942a54302de5bfa4665960947c403e1c0b6831ad (patch) | |
tree | 2a4be7c58259a21f0a3f04ca76ea2ee1774d00f5 /parse.y | |
parent | 31345380ac41f8b830104ea41b4b52e1e2b094a8 (diff) | |
download | ruby-942a54302de5bfa4665960947c403e1c0b6831ad.tar.gz |
* parse.y (yycompile): disable trace while creating ruby_debug_lines.
[ruby-talk:253586]
* thread.c (ruby_suppress_tracing): new function to call a function
with suppressing trace.
* lib/debug.rb, lib/tracer.rb: for YARV.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 37 |
1 files changed, 23 insertions, 14 deletions
@@ -4584,26 +4584,35 @@ parser_yyerror(struct parser_params *parser, const char *msg) static void parser_prepare(struct parser_params *parser); #ifndef RIPPER +VALUE ruby_suppress_tracing(VALUE (*func)(ANYARGS), VALUE arg); + +static VALUE +debug_lines(VALUE f) +{ + if (rb_const_defined_at(rb_cObject, rb_intern("SCRIPT_LINES__"))) { + VALUE hash = rb_const_get_at(rb_cObject, rb_intern("SCRIPT_LINES__")); + if (TYPE(hash) == T_HASH) { + VALUE fname = rb_str_new2((const char *)f); + VALUE lines = rb_hash_aref(hash, fname); + if (NIL_P(lines)) { + lines = rb_ary_new(); + rb_hash_aset(hash, fname, lines); + } + return lines; + } + } + return 0; +} + static NODE* yycompile(struct parser_params *parser, const char *f, int line) { int n; const char *kcode_save; - if (!compile_for_eval && rb_safe_level() == 0 && - rb_const_defined(rb_cObject, rb_intern("SCRIPT_LINES__"))) { - VALUE hash, fname; - - hash = rb_const_get(rb_cObject, rb_intern("SCRIPT_LINES__")); - if (TYPE(hash) == T_HASH) { - fname = rb_str_new2(f); - ruby_debug_lines = rb_hash_aref(hash, fname); - if (NIL_P(ruby_debug_lines)) { - ruby_debug_lines = rb_ary_new(); - rb_hash_aset(hash, fname, ruby_debug_lines); - } - } - if (line > 1) { + if (!compile_for_eval && rb_safe_level() == 0) { + ruby_debug_lines = ruby_suppress_tracing(debug_lines, (VALUE)f); + if (ruby_debug_lines && line > 1) { VALUE str = rb_str_new(0,0); n = line - 1; do { |