aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-09 00:21:51 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-09 00:21:51 +0000
commitb753b9606e6329c62d385512ea173171c7c07146 (patch)
treef61b8818e59fe469f837f751d24c1e7e03e0b5d8
parent21e858e518c4cec31f4c56caa37682db38bac6a3 (diff)
downloadruby-b753b9606e6329c62d385512ea173171c7c07146.tar.gz
* include/ruby/debug.h,
vm_backtrace.c (rb_profile_frame_full_label): add new C API rb_profile_frame_full_label() which returns label with qualified method name. Note that in future version of Ruby label() may return same return value of full_label(). * ext/-test-/debug/profile_frames.c, test/-ext-/debug/test_profile_frames.rb: fix a test for this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog13
-rw-r--r--ext/-test-/debug/profile_frames.c1
-rw-r--r--include/ruby/debug.h1
-rw-r--r--test/-ext-/debug/test_profile_frames.rb12
-rw-r--r--vm_backtrace.c19
5 files changed, 45 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index e0055c7d41..512428878d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Wed Oct 9 09:18:14 2013 Koichi Sasada <ko1@atdot.net>
+
+ * include/ruby/debug.h,
+ vm_backtrace.c (rb_profile_frame_full_label): add new C API
+ rb_profile_frame_full_label() which returns label with
+ qualified method name.
+ Note that in future version of Ruby label() may return
+ same return value of full_label().
+
+ * ext/-test-/debug/profile_frames.c,
+ test/-ext-/debug/test_profile_frames.rb: fix a test for this change.
+
+
Wed Oct 9 00:55:51 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* load.c (load_lock): display backtrace to $stderr at circular
diff --git a/ext/-test-/debug/profile_frames.c b/ext/-test-/debug/profile_frames.c
index 5d9501046c..1656ff7d4b 100644
--- a/ext/-test-/debug/profile_frames.c
+++ b/ext/-test-/debug/profile_frames.c
@@ -23,6 +23,7 @@ profile_frames(VALUE self, VALUE start_v, VALUE num_v)
rb_ary_push(ary, rb_profile_frame_absolute_path(buff[i]));
rb_ary_push(ary, rb_profile_frame_label(buff[i]));
rb_ary_push(ary, rb_profile_frame_base_label(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_full_label(buff[i]));
rb_ary_push(ary, rb_profile_frame_first_lineno(buff[i]));
rb_ary_push(ary, rb_profile_frame_classpath(buff[i]));
rb_ary_push(ary, rb_profile_frame_singleton_method_p(buff[i]));
diff --git a/include/ruby/debug.h b/include/ruby/debug.h
index add719545f..9bfc9b9a83 100644
--- a/include/ruby/debug.h
+++ b/include/ruby/debug.h
@@ -31,6 +31,7 @@ VALUE rb_profile_frame_path(VALUE frame);
VALUE rb_profile_frame_absolute_path(VALUE frame);
VALUE rb_profile_frame_label(VALUE frame);
VALUE rb_profile_frame_base_label(VALUE frame);
+VALUE rb_profile_frame_full_label(VALUE frame);
VALUE rb_profile_frame_first_lineno(VALUE frame);
VALUE rb_profile_frame_classpath(VALUE frame);
VALUE rb_profile_frame_singleton_method_p(VALUE frame);
diff --git a/test/-ext-/debug/test_profile_frames.rb b/test/-ext-/debug/test_profile_frames.rb
index 410c2fbe11..7c00aa066b 100644
--- a/test/-ext-/debug/test_profile_frames.rb
+++ b/test/-ext-/debug/test_profile_frames.rb
@@ -37,6 +37,13 @@ class TestProfileFrames < Test::Unit::TestCase
"foo",
"test_profile_frames",
]
+ full_labels = [
+ "block (2 levels) in TestProfileFrames#test_profile_frames",
+ "SampleClassForTestProfileFrames::Sample2#baz",
+ "SampleClassForTestProfileFrames.bar",
+ "SampleClassForTestProfileFrames#foo",
+ "block in TestProfileFrames#test_profile_frames",
+ ]
classes = [
TestProfileFrames,
SampleClassForTestProfileFrames::Sample2,
@@ -62,15 +69,18 @@ class TestProfileFrames < Test::Unit::TestCase
"TestProfileFrames#test_profile_frames",
]
+ # pp frames
+
assert_equal(labels.size, frames.size)
- frames.each.with_index{|(path, absolute_path, label, base_label, first_lineno,
+ frames.each.with_index{|(path, absolute_path, label, base_label, full_label, first_lineno,
classpath, singleton_p, method_name, qualified_method_name), i|
err_msg = "#{i}th frame"
assert_equal(__FILE__, path, err_msg)
assert_equal(__FILE__, absolute_path, err_msg)
assert_equal(labels[i], label, err_msg)
assert_equal(base_labels[i], base_label, err_msg)
+ assert_equal(full_labels[i], full_label, err_msg)
assert_equal(classes[i].to_s, classpath, err_msg)
assert_equal(singleton_method_p[i], singleton_p, err_msg)
assert_equal(methdo_names[i], method_name, err_msg)
diff --git a/vm_backtrace.c b/vm_backtrace.c
index 1f2e8c3f19..74a9df2ed0 100644
--- a/vm_backtrace.c
+++ b/vm_backtrace.c
@@ -1343,3 +1343,22 @@ rb_profile_frame_qualified_method_name(VALUE frame)
return Qnil;
}
}
+
+VALUE
+rb_profile_frame_full_label(VALUE frame)
+{
+ VALUE label = rb_profile_frame_label(frame);
+ VALUE base_label = rb_profile_frame_base_label(frame);
+ VALUE qualified_method_name = rb_profile_frame_qualified_method_name(frame);
+
+ if (NIL_P(qualified_method_name) || base_label == qualified_method_name) {
+ return label;
+ }
+ else {
+ long label_length = RSTRING_LEN(label);
+ long base_label_length = RSTRING_LEN(base_label);
+ VALUE prefix = rb_str_new(RSTRING_PTR(label), label_length - base_label_length);
+
+ return rb_sprintf("%"PRIsVALUE"%"PRIsVALUE, prefix, qualified_method_name);
+ }
+}