diff options
author | Koichi Sasada <[email protected]> | 2022-10-17 17:50:42 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2022-10-20 17:38:28 +0900 |
commit | e35c528d721d209ed8531b10b46c2ac725ea7bf5 (patch) | |
tree | 7a5fe3d73461b9e628f04226dedfffe8632a5438 /vm_backtrace.c | |
parent | 7563604fb868d87057733f52d780d841fc1ab6bb (diff) |
push dummy frame for loading process
This patch pushes dummy frames when loading code for the
profiling purpose.
The following methods push a dummy frame:
* `Kernel#require`
* `Kernel#load`
* `RubyVM::InstructionSequence.compile_file`
* `RubyVM::InstructionSequence.load_from_binary`
https://bugs.ruby-lang.org/issues/18559
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6572
Diffstat (limited to 'vm_backtrace.c')
-rw-r--r-- | vm_backtrace.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/vm_backtrace.c b/vm_backtrace.c index 3aae59bf68..12157ef707 100644 --- a/vm_backtrace.c +++ b/vm_backtrace.c @@ -37,10 +37,8 @@ inline static int calc_pos(const rb_iseq_t *iseq, const VALUE *pc, int *lineno, int *node_id) { VM_ASSERT(iseq); - VM_ASSERT(ISEQ_BODY(iseq)); - VM_ASSERT(ISEQ_BODY(iseq)->iseq_encoded); - VM_ASSERT(ISEQ_BODY(iseq)->iseq_size); - if (! pc) { + + if (pc == NULL) { if (ISEQ_BODY(iseq)->type == ISEQ_TYPE_TOP) { VM_ASSERT(! ISEQ_BODY(iseq)->local_table); VM_ASSERT(! ISEQ_BODY(iseq)->local_table_size); @@ -53,6 +51,10 @@ calc_pos(const rb_iseq_t *iseq, const VALUE *pc, int *lineno, int *node_id) return 1; } else { + VM_ASSERT(ISEQ_BODY(iseq)); + VM_ASSERT(ISEQ_BODY(iseq)->iseq_encoded); + VM_ASSERT(ISEQ_BODY(iseq)->iseq_size); + ptrdiff_t n = pc - ISEQ_BODY(iseq)->iseq_encoded; VM_ASSERT(n <= ISEQ_BODY(iseq)->iseq_size); VM_ASSERT(n >= 0); @@ -1557,7 +1559,7 @@ rb_profile_frames(int start, int limit, VALUE *buff, int *lines) end_cfp = RUBY_VM_NEXT_CONTROL_FRAME(end_cfp); for (i=0; i<limit && cfp != end_cfp;) { - if (VM_FRAME_RUBYFRAME_P(cfp)) { + if (VM_FRAME_RUBYFRAME_P(cfp) && cfp->pc != 0) { if (start > 0) { start--; continue; |