mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
fix return event and opt_invokebuiltin_delegate_leave (#3256)
If :return event is specified for a opt_invokebuiltin_delegate_leave and leave combination, the instructions should be opt_invokebuiltin_delegate trace_return instructions. To make it, opt_invokebuiltin_delegate_leave instruction will be changed to opt_invokebuiltin_delegate even if it is not an event target instruction.
This commit is contained in:
parent
289a28e68f
commit
8070cb56db
Notes:
git
2020-06-26 10:22:20 +09:00
Merged-By: ko1 <ko1@atdot.net>
2 changed files with 10 additions and 8 deletions
17
iseq.c
17
iseq.c
|
@ -3125,17 +3125,20 @@ rb_vm_encoded_insn_data_table_init(void)
|
|||
encoded_insn_data = st_init_numtable_with_size(VM_INSTRUCTION_SIZE / 2);
|
||||
|
||||
for (insn = 0; insn < VM_INSTRUCTION_SIZE/2; insn++) {
|
||||
int traced_insn = (int)insn;
|
||||
if (traced_insn == BIN(opt_invokebuiltin_delegate_leave)) {
|
||||
traced_insn = BIN(opt_invokebuiltin_delegate); // to dispatch :return from leave
|
||||
}
|
||||
st_data_t key1 = (st_data_t)INSN_CODE(insn);
|
||||
st_data_t key2 = (st_data_t)INSN_CODE((st_data_t)traced_insn + VM_INSTRUCTION_SIZE/2);
|
||||
st_data_t key2 = (st_data_t)INSN_CODE(insn + VM_INSTRUCTION_SIZE/2);
|
||||
|
||||
insn_data[insn].insn = (int)insn;
|
||||
insn_data[insn].insn_len = insn_len(insn);
|
||||
insn_data[insn].notrace_encoded_insn = (void *) key1;
|
||||
insn_data[insn].trace_encoded_insn = (void *) key2;
|
||||
|
||||
if (insn != BIN(opt_invokebuiltin_delegate_leave)) {
|
||||
insn_data[insn].notrace_encoded_insn = (void *) key1;
|
||||
insn_data[insn].trace_encoded_insn = (void *) key2;
|
||||
}
|
||||
else {
|
||||
insn_data[insn].notrace_encoded_insn = (void *) INSN_CODE(BIN(opt_invokebuiltin_delegate));
|
||||
insn_data[insn].trace_encoded_insn = (void *) INSN_CODE(BIN(opt_invokebuiltin_delegate) + VM_INSTRUCTION_SIZE/2);
|
||||
}
|
||||
|
||||
st_add_direct(encoded_insn_data, key1, (st_data_t)&insn_data[insn]);
|
||||
st_add_direct(encoded_insn_data, key2, (st_data_t)&insn_data[insn]);
|
||||
|
|
|
@ -2299,7 +2299,6 @@ class TestSetTraceFunc < Test::Unit::TestCase
|
|||
assert_match /^0000 opt_invokebuiltin_delegate_leave /, out
|
||||
|
||||
event = eval(EnvUtil.invoke_ruby(['-e', <<~'EOS'], '', true).first)
|
||||
set_trace_func(proc {}); set_trace_func(nil) # Is it okay that this is required?
|
||||
TracePoint.new(:return) do |tp|
|
||||
p [tp.event, tp.method_id]
|
||||
end.enable do
|
||||
|
|
Loading…
Reference in a new issue