From 4990f6d16dcc3d5983a994730db362a33c5c5be5 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 15 Sep 2011 14:39:34 +0900 Subject: [PATCH] Revert "use rb_iseq_line_no()." This reverts commit f4b590a22e304100ea29f27d1bbde2ff22984049. --- ext/ruby_debug/ruby_debug.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/ext/ruby_debug/ruby_debug.c b/ext/ruby_debug/ruby_debug.c index f125325..ba59a46 100644 --- a/ext/ruby_debug/ruby_debug.c +++ b/ext/ruby_debug/ruby_debug.c @@ -751,8 +751,28 @@ set_thread_event_flag_i(st_data_t key, st_data_t val, st_data_t flag) static int find_prev_line_start(rb_control_frame_t *cfp) { - const rb_iseq_t *iseq = cfp->iseq; - return rb_iseq_line_no(iseq, cfp->pc - iseq->iseq_encoded - 1); + int i, pos, line_no; + pos = cfp->pc - cfp->iseq->iseq_encoded; + for (i = 0; i < cfp->iseq->insn_info_size; i++) + { + if (cfp->iseq->insn_info_table[i].position != pos) + continue; + + if (i == 0) return(0); // TODO + + pos = -1; + line_no = cfp->iseq->insn_info_table[--i].line_no; + do { + if (cfp->iseq->insn_info_table[i].line_no == line_no) + pos = cfp->iseq->insn_info_table[i].position; + else + break; + i--; + } while (i >= 0); + + return(pos); + } + return(-1); } static rb_control_frame_t *