Project

General

Profile

Feature #17762 ยป objspace-trace.patch

mame (Yusuke Endoh), 03/30/2021 02:49 PM

View differences:

ext/objspace/lib/objspace/trace.rb
require 'objspace.so'
module Kernel
define_method(:p) do |*objs|
objs.each do |obj|
file = ObjectSpace.allocation_sourcefile(obj)
line = ObjectSpace.allocation_sourceline(obj)
if file
puts "#{ obj.inspect } @ #{ file }:#{ line }"
else
puts obj.inspect
end
end
end
end
ObjectSpace.trace_object_allocations_start
warn "objspace/trace is enabled"
    (1-1/1)