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
1
require 'objspace.so'
2

  
3
module Kernel
4
  define_method(:p) do |*objs|
5
    objs.each do |obj|
6
      file = ObjectSpace.allocation_sourcefile(obj)
7
      line = ObjectSpace.allocation_sourceline(obj)
8
      if file
9
        puts "#{ obj.inspect } @ #{ file }:#{ line }"
10
      else
11
        puts obj.inspect
12
      end
13
    end
14
  end
15
end
16

  
17
ObjectSpace.trace_object_allocations_start
18

  
19
warn "objspace/trace is enabled"