summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-06 13:42:32 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-06 13:42:32 +0000
commit5ac990e83eb4399b38542d788622c8069c7c4192 ()
tree3eaf556c26f92948bd2e1bd0c55ff3ef08b2010d
parent586e018c739d50be00bb7d750907d53009a0229b (diff)
`script_compiled` TracePoint event [Feature #15287]
* vm_trace.c: add `script_compiled` event. This event invoked after script compiling and before evaluating compiled script. Also the following methods are added: `TracePoint#compiled_instruction_sequence` method to get compiled `RubyVM::InstructionSequence` instance. `TracePoint#compiled_eval_script` method to get compiled script (String) by *eval methods (return nil if compiling by file). * vm_trace.c (tracepoint_attr_raised_exception): git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--include/ruby/ruby.h1
-rw-r--r--iseq.h1
-rw-r--r--load.c4
-rw-r--r--vm_eval.c2
-rw-r--r--vm_trace.c80
5 files changed, 87 insertions, 1 deletions
@@ -2216,6 +2216,7 @@ int ruby_native_thread_p(void);
#define RUBY_EVENT_THREAD_BEGIN 0x0400
#define RUBY_EVENT_THREAD_END 0x0800
#define RUBY_EVENT_FIBER_SWITCH 0x1000
#define RUBY_EVENT_TRACEPOINT_ALL 0xffff
/* special events */
@@ -152,6 +152,7 @@ VALUE rb_iseq_ibf_load_extra_data(VALUE str);
void rb_iseq_init_trace(rb_iseq_t *iseq);
int rb_iseq_add_local_tracepoint_recursively(const rb_iseq_t *iseq, rb_event_flag_t turnon_events, VALUE tpval, unsigned int target_line);
int rb_iseq_remove_local_tracepoint_recursively(const rb_iseq_t *iseq, VALUE tpval);
#if VM_INSN_INFO_TABLE_IMPL == 2
unsigned int *rb_iseq_insns_info_decode_positions(const struct rb_iseq_constant_body *body);
@@ -8,6 +8,7 @@
#include "dln.h"
#include "eval_intern.h"
#include "probes.h"
static VALUE ruby_dln_librefs;
@@ -566,7 +567,6 @@ rb_provide(const char *feature)
}
NORETURN(static void load_failed(VALUE));
-const rb_iseq_t *rb_iseq_load_iseq(VALUE fname);
static int
rb_load_internal0(rb_execution_context_t *ec, VALUE fname, int wrap)
@@ -608,6 +608,8 @@ rb_load_internal0(rb_execution_context_t *ec, VALUE fname, int wrap)
fname, rb_realpath_internal(Qnil, fname, 1), NULL);
rb_ast_dispose(ast);
}
rb_iseq_eval(iseq);
}
EC_POP_TAG();
@@ -1293,6 +1293,8 @@ eval_make_iseq(VALUE src, VALUE fname, int line, const rb_binding_t *bind,
printf("%s\n", StringValuePtr(disasm));
}
return iseq;
}
@@ -629,6 +629,7 @@ get_event_id(rb_event_flag_t event)
C(thread_begin, THREAD_BEGIN);
C(thread_end, THREAD_END);
C(fiber_switch, FIBER_SWITCH);
#undef C
default:
return 0;
@@ -763,6 +764,9 @@ symbol2event_flag(VALUE v)
C(thread_begin, THREAD_BEGIN);
C(thread_end, THREAD_END);
C(fiber_switch, FIBER_SWITCH);
C(a_call, A_CALL);
C(a_return, A_RETURN);
#undef C
@@ -880,6 +884,7 @@ rb_tracearg_parameters(rb_trace_arg_t *trace_arg)
case RUBY_EVENT_LINE:
case RUBY_EVENT_CLASS:
case RUBY_EVENT_END:
rb_raise(rb_eRuntimeError, "not supported by this event");
break;
}
@@ -958,6 +963,57 @@ rb_tracearg_raised_exception(rb_trace_arg_t *trace_arg)
}
VALUE
rb_tracearg_object(rb_trace_arg_t *trace_arg)
{
if (trace_arg->event & (RUBY_INTERNAL_EVENT_NEWOBJ | RUBY_INTERNAL_EVENT_FREEOBJ)) {
@@ -1107,6 +1163,28 @@ tracepoint_attr_raised_exception(VALUE tpval)
return rb_tracearg_raised_exception(get_trace_arg());
}
static void
tp_call_trace(VALUE tpval, rb_trace_arg_t *trace_arg)
{
@@ -1740,6 +1818,8 @@ Init_vm_trace(void)
rb_define_method(rb_cTracePoint, "self", tracepoint_attr_self, 0);
rb_define_method(rb_cTracePoint, "return_value", tracepoint_attr_return_value, 0);
rb_define_method(rb_cTracePoint, "raised_exception", tracepoint_attr_raised_exception, 0);
rb_define_singleton_method(rb_cTracePoint, "stat", tracepoint_stat_s, 0);
}