diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-28 03:36:34 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-28 03:36:34 +0000 |
commit | 7453c53b08655e9d17c0419716ffad1c41663b6d (patch) | |
tree | 34faa4463885e66c869a5590f5908f649323506c /test/objspace | |
parent | b0e7ec8c9a06fa975cff864107af1e1c0780f19f (diff) | |
download | ruby-7453c53b08655e9d17c0419716ffad1c41663b6d.tar.gz |
* ext/objspace/object_tracing.c: fix a bug reported at
"[ruby-core:55182] [ruby-trunk - Bug #8456][Open] Sugfault in Ruby Head"
Care about the case TracePoint#path #=> `nil'.
* ext/objspace/object_tracing.c: add two new methods:
* ObjectSpace.allocation_class_path(o)
* ObjectSpace.allocation_method_id(o)
They are not useful for Object.new because they are always
"Class" and :new.
To trace more useful information, we need to maintain call-tree
using call/return hooks, which is implemented by
ll-prof <http://sunagae.net/wiki/doku.php?id=software:llprof>
* test/objspace/test_objspace.rb: add a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/objspace')
-rw-r--r-- | test/objspace/test_objspace.rb | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index 11e69bd7e8..c95670592d 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -112,18 +112,31 @@ class TestObjSpace < Test::Unit::TestCase def test_traceobject o0 = Object.new ObjectSpace.trace_object_allocations{ - o1 = Object.new; line1 = __LINE__ - o2 = "a"+"b" ; line2 = __LINE__ - o3 = [1, 2] ; line3 = __LINE__ + o1 = Object.new; line1 = __LINE__; c1 = GC.count + o2 = "xyzzy" ; line2 = __LINE__; c2 = GC.count + o3 = [1, 2] ; line3 = __LINE__; c3 = GC.count assert_equal(nil, ObjectSpace.allocation_sourcefile(o0)) assert_equal(nil, ObjectSpace.allocation_sourceline(o0)) - assert_equal(__FILE__, ObjectSpace.allocation_sourcefile(o1)) + assert_equal(nil, ObjectSpace.allocation_generation(o0)) + assert_equal(line1, ObjectSpace.allocation_sourceline(o1)) + assert_equal(__FILE__, ObjectSpace.allocation_sourcefile(o1)) + assert_equal(c1, ObjectSpace.allocation_generation(o1)) + assert_equal(Class.name, ObjectSpace.allocation_class_path(o1)) + assert_equal(:new, ObjectSpace.allocation_method_id(o1)) + assert_equal(__FILE__, ObjectSpace.allocation_sourcefile(o2)) assert_equal(line2, ObjectSpace.allocation_sourceline(o2)) + assert_equal(c2, ObjectSpace.allocation_generation(o2)) + assert_equal(self.class.name, ObjectSpace.allocation_class_path(o2)) + assert_equal(__method__, ObjectSpace.allocation_method_id(o2)) + assert_equal(__FILE__, ObjectSpace.allocation_sourcefile(o3)) assert_equal(line3, ObjectSpace.allocation_sourceline(o3)) + assert_equal(c3, ObjectSpace.allocation_generation(o3)) + assert_equal(self.class.name, ObjectSpace.allocation_class_path(o3)) + assert_equal(__method__, ObjectSpace.allocation_method_id(o3)) } end end |