Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../opt/alt/ruby32/share/ruby
File: objspace.rb
# frozen_string_literal: true
[0] Fix | Delete
[1] Fix | Delete
require 'objspace.so'
[2] Fix | Delete
[3] Fix | Delete
module ObjectSpace
[4] Fix | Delete
class << self
[5] Fix | Delete
private :_dump
[6] Fix | Delete
private :_dump_all
[7] Fix | Delete
private :_dump_shapes
[8] Fix | Delete
end
[9] Fix | Delete
[10] Fix | Delete
module_function
[11] Fix | Delete
[12] Fix | Delete
# call-seq:
[13] Fix | Delete
# ObjectSpace.dump(obj[, output: :string]) -> "{ ... }"
[14] Fix | Delete
# ObjectSpace.dump(obj, output: :file) -> #<File:/tmp/rubyobj20131125-88733-1xkfmpv.json>
[15] Fix | Delete
# ObjectSpace.dump(obj, output: :stdout) -> nil
[16] Fix | Delete
#
[17] Fix | Delete
# Dump the contents of a ruby object as JSON.
[18] Fix | Delete
#
[19] Fix | Delete
# This method is only expected to work with C Ruby.
[20] Fix | Delete
# This is an experimental method and is subject to change.
[21] Fix | Delete
# In particular, the function signature and output format are
[22] Fix | Delete
# not guaranteed to be compatible in future versions of ruby.
[23] Fix | Delete
def dump(obj, output: :string)
[24] Fix | Delete
out = case output
[25] Fix | Delete
when :file, nil
[26] Fix | Delete
require 'tempfile'
[27] Fix | Delete
Tempfile.create(%w(rubyobj .json))
[28] Fix | Delete
when :stdout
[29] Fix | Delete
STDOUT
[30] Fix | Delete
when :string
[31] Fix | Delete
+''
[32] Fix | Delete
when IO
[33] Fix | Delete
output
[34] Fix | Delete
else
[35] Fix | Delete
raise ArgumentError, "wrong output option: #{output.inspect}"
[36] Fix | Delete
end
[37] Fix | Delete
[38] Fix | Delete
ret = _dump(obj, out)
[39] Fix | Delete
return nil if output == :stdout
[40] Fix | Delete
ret
[41] Fix | Delete
end
[42] Fix | Delete
[43] Fix | Delete
[44] Fix | Delete
# call-seq:
[45] Fix | Delete
# ObjectSpace.dump_all([output: :file]) -> #<File:/tmp/rubyheap20131125-88469-laoj3v.json>
[46] Fix | Delete
# ObjectSpace.dump_all(output: :stdout) -> nil
[47] Fix | Delete
# ObjectSpace.dump_all(output: :string) -> "{...}\n{...}\n..."
[48] Fix | Delete
# ObjectSpace.dump_all(output: File.open('heap.json','w')) -> #<File:heap.json>
[49] Fix | Delete
# ObjectSpace.dump_all(output: :string, since: 42) -> "{...}\n{...}\n..."
[50] Fix | Delete
#
[51] Fix | Delete
# Dump the contents of the ruby heap as JSON.
[52] Fix | Delete
#
[53] Fix | Delete
# _full_ must be a boolean. If true all heap slots are dumped including the empty ones (T_NONE).
[54] Fix | Delete
#
[55] Fix | Delete
# _since_ must be a non-negative integer or +nil+.
[56] Fix | Delete
#
[57] Fix | Delete
# If _since_ is a positive integer, only objects of that generation and
[58] Fix | Delete
# newer generations are dumped. The current generation can be accessed using
[59] Fix | Delete
# GC::count. Objects that were allocated without object allocation tracing enabled
[60] Fix | Delete
# are ignored. See ::trace_object_allocations for more information and
[61] Fix | Delete
# examples.
[62] Fix | Delete
#
[63] Fix | Delete
# If _since_ is omitted or is +nil+, all objects are dumped.
[64] Fix | Delete
#
[65] Fix | Delete
# _shapes_ must be a boolean or a non-negative integer.
[66] Fix | Delete
#
[67] Fix | Delete
# If _shapes_ is a positive integer, only shapes newer than the provided
[68] Fix | Delete
# shape id are dumped. The current shape_id can be accessed using <tt>RubyVM.stat(:next_shape_id)</tt>.
[69] Fix | Delete
#
[70] Fix | Delete
# If _shapes_ is +false+, no shapes are dumped.
[71] Fix | Delete
#
[72] Fix | Delete
# To only dump objects allocated past a certain point you can combine _since_ and _shapes_:
[73] Fix | Delete
# ObjectSpace.trace_object_allocations
[74] Fix | Delete
# GC.start
[75] Fix | Delete
# gc_generation = GC.count
[76] Fix | Delete
# shape_generation = RubyVM.stat(:next_shape_id)
[77] Fix | Delete
# call_method_to_instrument
[78] Fix | Delete
# ObjectSpace.dump_all(since: gc_generation, shapes: shape_generation)
[79] Fix | Delete
#
[80] Fix | Delete
# This method is only expected to work with C Ruby.
[81] Fix | Delete
# This is an experimental method and is subject to change.
[82] Fix | Delete
# In particular, the function signature and output format are
[83] Fix | Delete
# not guaranteed to be compatible in future versions of ruby.
[84] Fix | Delete
def dump_all(output: :file, full: false, since: nil, shapes: true)
[85] Fix | Delete
out = case output
[86] Fix | Delete
when :file, nil
[87] Fix | Delete
require 'tempfile'
[88] Fix | Delete
Tempfile.create(%w(rubyheap .json))
[89] Fix | Delete
when :stdout
[90] Fix | Delete
STDOUT
[91] Fix | Delete
when :string
[92] Fix | Delete
+''
[93] Fix | Delete
when IO
[94] Fix | Delete
output
[95] Fix | Delete
else
[96] Fix | Delete
raise ArgumentError, "wrong output option: #{output.inspect}"
[97] Fix | Delete
end
[98] Fix | Delete
[99] Fix | Delete
shapes = 0 if shapes == true
[100] Fix | Delete
ret = _dump_all(out, full, since, shapes)
[101] Fix | Delete
return nil if output == :stdout
[102] Fix | Delete
ret
[103] Fix | Delete
end
[104] Fix | Delete
[105] Fix | Delete
# call-seq:
[106] Fix | Delete
# ObjectSpace.dump_shapes([output: :file]) -> #<File:/tmp/rubyshapes20131125-88469-laoj3v.json>
[107] Fix | Delete
# ObjectSpace.dump_shapes(output: :stdout) -> nil
[108] Fix | Delete
# ObjectSpace.dump_shapes(output: :string) -> "{...}\n{...}\n..."
[109] Fix | Delete
# ObjectSpace.dump_shapes(output: File.open('shapes.json','w')) -> #<File:shapes.json>
[110] Fix | Delete
# ObjectSpace.dump_all(output: :string, since: 42) -> "{...}\n{...}\n..."
[111] Fix | Delete
#
[112] Fix | Delete
# Dump the contents of the ruby shape tree as JSON.
[113] Fix | Delete
#
[114] Fix | Delete
# If _shapes_ is a positive integer, only shapes newer than the provided
[115] Fix | Delete
# shape id are dumped. The current shape_id can be accessed using <tt>RubyVM.stat(:next_shape_id)</tt>.
[116] Fix | Delete
#
[117] Fix | Delete
# This method is only expected to work with C Ruby.
[118] Fix | Delete
# This is an experimental method and is subject to change.
[119] Fix | Delete
# In particular, the function signature and output format are
[120] Fix | Delete
# not guaranteed to be compatible in future versions of ruby.
[121] Fix | Delete
def dump_shapes(output: :file, since: 0)
[122] Fix | Delete
out = case output
[123] Fix | Delete
when :file, nil
[124] Fix | Delete
require 'tempfile'
[125] Fix | Delete
Tempfile.create(%w(rubyshapes .json))
[126] Fix | Delete
when :stdout
[127] Fix | Delete
STDOUT
[128] Fix | Delete
when :string
[129] Fix | Delete
+''
[130] Fix | Delete
when IO
[131] Fix | Delete
output
[132] Fix | Delete
else
[133] Fix | Delete
raise ArgumentError, "wrong output option: #{output.inspect}"
[134] Fix | Delete
end
[135] Fix | Delete
[136] Fix | Delete
ret = _dump_shapes(out, since)
[137] Fix | Delete
return nil if output == :stdout
[138] Fix | Delete
ret
[139] Fix | Delete
end
[140] Fix | Delete
end
[141] Fix | Delete
[142] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function