Class: RubyMemcheck::Frame

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_memcheck/frame.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration, loaded_binaries, frame_xml) ⇒ Frame

Returns a new instance of Frame.



7
8
9
10
11
12
13
14
15
16
# File 'lib/ruby_memcheck/frame.rb', line 7

def initialize(configuration, loaded_binaries, frame_xml)
  @configuration = configuration
  @loaded_binaries = loaded_binaries

  @fn = frame_xml.at_xpath("fn")&.content
  @obj = frame_xml.at_xpath("obj")&.content
  # file and line may not be available
  @file = frame_xml.at_xpath("file")&.content
  @line = frame_xml.at_xpath("line")&.content
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



5
6
7
# File 'lib/ruby_memcheck/frame.rb', line 5

def configuration
  @configuration
end

#fileObject (readonly)

Returns the value of attribute file.



5
6
7
# File 'lib/ruby_memcheck/frame.rb', line 5

def file
  @file
end

#fnObject (readonly)

Returns the value of attribute fn.



5
6
7
# File 'lib/ruby_memcheck/frame.rb', line 5

def fn
  @fn
end

#lineObject (readonly)

Returns the value of attribute line.



5
6
7
# File 'lib/ruby_memcheck/frame.rb', line 5

def line
  @line
end

#loaded_binariesObject (readonly)

Returns the value of attribute loaded_binaries.



5
6
7
# File 'lib/ruby_memcheck/frame.rb', line 5

def loaded_binaries
  @loaded_binaries
end

#objObject (readonly)

Returns the value of attribute obj.



5
6
7
# File 'lib/ruby_memcheck/frame.rb', line 5

def obj
  @obj
end

Instance Method Details

#binary_init_func?Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
# File 'lib/ruby_memcheck/frame.rb', line 32

def binary_init_func?
  return false unless in_binary?

  binary_name = File.basename(obj, ".*")
  fn == "Init_#{binary_name}"
end

#in_binary?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
# File 'lib/ruby_memcheck/frame.rb', line 26

def in_binary?
  return false unless obj

  loaded_binaries.include?(obj)
end

#in_ruby?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
# File 'lib/ruby_memcheck/frame.rb', line 18

def in_ruby?
  return false unless obj

  obj == configuration.ruby ||
    # Hack to fix Ruby built with --enabled-shared
    File.basename(obj) == "libruby.so.#{RUBY_VERSION}"
end

#to_sObject



39
40
41
42
43
44
45
46
47
# File 'lib/ruby_memcheck/frame.rb', line 39

def to_s
  if file
    "#{fn} (#{file}:#{line})"
  elsif fn
    "#{fn} (at #{obj})"
  else
    "<unknown stack frame>"
  end
end