Skip to content

Commit

Permalink
revert #746
Browse files Browse the repository at this point in the history
fix #799
  • Loading branch information
ko1 committed Nov 25, 2022
1 parent fe270d4 commit 3e3f374
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 37 deletions.
29 changes: 0 additions & 29 deletions ext/debug/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,42 +89,13 @@ capture_frames(VALUE self, VALUE skip_path_prefix)
return rb_debug_inspector_open(di_body, (void *)skip_path_prefix);
}

#ifdef RB_PROFILE_FRAMES_HAS_C_FRAMES
#define BUFF_SIZE 4096

static VALUE
frame_depth(VALUE self)
{
static VALUE buff[BUFF_SIZE];
static int lines[BUFF_SIZE];

int size = rb_profile_frames(0, BUFF_SIZE, buff, lines);

// If the buffer is full, there might be more frames.
// Fall back to rb_make_backtrace to get them all.
if (size >= BUFF_SIZE) {
VALUE bt = rb_make_backtrace();
size = RARRAY_LEN(bt);
return INT2FIX(size);
}

// rb_profile_frames will return one extra frame
// https://bugs.ruby-lang.org/issues/18907
#ifdef RB_PROFILE_FRAMES_HAS_EXTRA_FRAME
return INT2FIX(size - 1);
#else
return INT2FIX(size);
#endif
}
#else
static VALUE
frame_depth(VALUE self)
{
// TODO: more efficient API
VALUE bt = rb_make_backtrace();
return INT2FIX(RARRAY_LEN(bt));
}
#endif

// iseq

Expand Down
8 changes: 0 additions & 8 deletions ext/debug/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
$defs << '-DHAVE_RB_ISEQ_PARAMETERS'
$defs << '-DHAVE_RB_ISEQ_CODE_LOCATION'

if RUBY_VERSION >= '3.0.0'
$defs << '-DRB_PROFILE_FRAMES_HAS_C_FRAMES'

if RUBY_VERSION < '3.2.0'
$defs << '-DRB_PROFILE_FRAMES_HAS_EXTRA_FRAME'
end
end

if RUBY_VERSION >= '3.1.0'
$defs << '-DHAVE_RB_ISEQ_TYPE'
end
Expand Down

0 comments on commit 3e3f374

Please sign in to comment.