[前][次][番号順一覧][スレッド一覧]

ruby-changes:62394

From: nagachika <ko1@a...>
Date: Sat, 25 Jul 2020 14:17:50 +0900 (JST)
Subject: [ruby-changes:62394] 12391cdbe1 (ruby_2_7): merge revision(s) cbe4f75ef802f13d05f94e42274b65a062bd3666: [Backport #16834]

https://git.ruby-lang.org/ruby.git/commit/?id=12391cdbe1

From 12391cdbe11f3fbeb3b04c30b944139e5bbd9ea6 Mon Sep 17 00:00:00 2001
From: nagachika <nagachika@r...>
Date: Sat, 25 Jul 2020 14:17:35 +0900
Subject: merge revision(s) cbe4f75ef802f13d05f94e42274b65a062bd3666: [Backport
 #16834]

	Fix rb_profile_frame_classpath to handle module singletons

	Right now `SomeClass.method` is properly named, but `SomeModule.method`
	is displayed as `#<Module:0x000055eb5d95adc8>.method` which makes
	profiling annoying.

diff --git a/test/-ext-/debug/test_profile_frames.rb b/test/-ext-/debug/test_profile_frames.rb
index 5ea5060..0335267 100644
--- a/test/-ext-/debug/test_profile_frames.rb
+++ b/test/-ext-/debug/test_profile_frames.rb
@@ -3,6 +3,16 @@ require 'test/unit' https://github.com/ruby/ruby/blob/trunk/test/-ext-/debug/test_profile_frames.rb#L3
 require '-test-/debug'
 
 class SampleClassForTestProfileFrames
+  class << self
+    attr_accessor :sample4
+  end
+
+  self.sample4 = Module.new do
+    def self.corge(block)
+      Sample2.new.baz(block)
+    end
+  end
+
   class Sample2
     def baz(block)
       instance_eval "def zab(block) block.call end"
@@ -10,8 +20,16 @@ class SampleClassForTestProfileFrames https://github.com/ruby/ruby/blob/trunk/test/-ext-/debug/test_profile_frames.rb#L20
     end
   end
 
+  module Sample3
+    class << self
+      def qux(block)
+        SampleClassForTestProfileFrames.sample4.corge(block)
+      end
+    end
+  end
+
   def self.bar(block)
-    Sample2.new.baz(block)
+    Sample3.qux(block)
   end
 
   def foo(block)
@@ -29,6 +47,8 @@ class TestProfileFrames < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/debug/test_profile_frames.rb#L47
       "test_profile_frames",
       "zab",
       "baz",
+      "corge",
+      "qux",
       "bar",
       "foo",
       "test_profile_frames",
@@ -37,6 +57,8 @@ class TestProfileFrames < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/debug/test_profile_frames.rb#L57
       "test_profile_frames",
       "zab",
       "baz",
+      "corge",
+      "qux",
       "bar",
       "foo",
       "test_profile_frames",
@@ -45,6 +67,8 @@ class TestProfileFrames < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/debug/test_profile_frames.rb#L67
       "TestProfileFrames#test_profile_frames",
       "#{obj.inspect}.zab",
       "SampleClassForTestProfileFrames::Sample2#baz",
+      "#{SampleClassForTestProfileFrames.sample4.inspect}.corge",
+      "SampleClassForTestProfileFrames::Sample3.qux",
       "SampleClassForTestProfileFrames.bar",
       "SampleClassForTestProfileFrames#foo",
       "TestProfileFrames#test_profile_frames",
@@ -53,17 +77,21 @@ class TestProfileFrames < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/debug/test_profile_frames.rb#L77
       TestProfileFrames,
       obj,
       SampleClassForTestProfileFrames::Sample2,
+      SampleClassForTestProfileFrames.sample4,
+      SampleClassForTestProfileFrames::Sample3,
       SampleClassForTestProfileFrames, # singleton method
       SampleClassForTestProfileFrames,
       TestProfileFrames,
     ]
     singleton_method_p = [
-      false, true, false, true, false, false, false,
+      false, true, false, true, true, true, false, false, false,
     ]
     method_names = [
       "test_profile_frames",
       "zab",
       "baz",
+      "corge",
+      "qux",
       "bar",
       "foo",
       "test_profile_frames",
@@ -72,14 +100,14 @@ class TestProfileFrames < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/debug/test_profile_frames.rb#L100
       "TestProfileFrames#test_profile_frames",
       "#{obj.inspect}.zab",
       "SampleClassForTestProfileFrames::Sample2#baz",
+      "#{SampleClassForTestProfileFrames.sample4.inspect}.corge",
+      "SampleClassForTestProfileFrames::Sample3.qux",
       "SampleClassForTestProfileFrames.bar",
       "SampleClassForTestProfileFrames#foo",
       "TestProfileFrames#test_profile_frames",
     ]
-    paths = [ file=__FILE__, "(eval)", file, file, file, file ]
-    absolute_paths = [ file, nil, file, file, file, file ]
-
-    # pp frames
+    paths = [ file=__FILE__, "(eval)", file, file, file, file, file, file ]
+    absolute_paths = [ file, nil, file, file, file, file, file, file ]
 
     assert_equal(labels.size, frames.size)
 
diff --git a/version.h b/version.h
index 8a4b3ed..c92be32 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L2
 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
 #define RUBY_VERSION_TEENY 1
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 110
+#define RUBY_PATCHLEVEL 111
 
 #define RUBY_RELEASE_YEAR 2020
 #define RUBY_RELEASE_MONTH 7
diff --git a/vm_backtrace.c b/vm_backtrace.c
index 2c9649a..f6b4e8e 100644
--- a/vm_backtrace.c
+++ b/vm_backtrace.c
@@ -1425,7 +1425,7 @@ rb_profile_frame_classpath(VALUE frame) https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L1425
 	}
 	else if (FL_TEST(klass, FL_SINGLETON)) {
 	    klass = rb_ivar_get(klass, id__attached__);
-	    if (!RB_TYPE_P(klass, T_CLASS))
+	    if (!RB_TYPE_P(klass, T_CLASS) && !RB_TYPE_P(klass, T_MODULE))
 		return rb_sprintf("#<%s:%p>", rb_class2name(rb_obj_class(klass)), (void*)klass);
 	}
 	return rb_class_path(klass);
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]