Skip to content

Commit 8d2207f

Browse files
authored
Merge pull request #77 from ViugiNick/master
comment version-specific test
2 parents 30ea5a1 + f067294 commit 8d2207f

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

ext/debase_internals.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,35 @@ call_at_line(debug_context_t *context, char *file, int line, VALUE context_objec
313313
rb_funcall(context_object, idAtLine, 2, rb_str_new2(file), INT2FIX(line));
314314
}
315315

316+
int count_stack_size() {
317+
rb_thread_t *thread = ruby_current_thread;
318+
rb_control_frame_t *last_cfp = TH_CFP(thread);
319+
rb_control_frame_t *start_cfp = RUBY_VM_END_CONTROL_FRAME(TH_INFO(thread));
320+
rb_control_frame_t *cfp;
321+
322+
ptrdiff_t size, i;
323+
324+
start_cfp =
325+
RUBY_VM_NEXT_CONTROL_FRAME(
326+
RUBY_VM_NEXT_CONTROL_FRAME(start_cfp)); /* skip top frames */
327+
328+
if (start_cfp < last_cfp) {
329+
size = 0;
330+
}
331+
else {
332+
size = start_cfp - last_cfp + 1;
333+
}
334+
335+
int stack_size = 0;
336+
for (i=0, cfp = start_cfp; i<size; i++, cfp = RUBY_VM_NEXT_CONTROL_FRAME(cfp)) {
337+
if (cfp->iseq && cfp->pc) {
338+
stack_size++;
339+
}
340+
}
341+
342+
return stack_size;
343+
}
344+
316345
static void
317346
process_line_event(VALUE trace_point, void *data)
318347
{
@@ -343,7 +372,8 @@ process_line_event(VALUE trace_point, void *data)
343372
print_event(tp, context);
344373

345374
if(context->init_stack_size == -1) {
346-
context->init_stack_size = context->stack_size;
375+
context->stack_size = count_stack_size();
376+
context->init_stack_size = context->stack_size;
347377
}
348378

349379
if (context->thread_pause) {

lib/debase/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Debase
2-
VERSION = "0.2.4" unless defined? VERSION
2+
VERSION = "0.2.5" unless defined? VERSION
33
end

0 commit comments

Comments
 (0)