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, frame_xml) ⇒ Frame

Returns a new instance of Frame.



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

def initialize(configuration, frame_xml)
  @configuration = configuration
  @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

#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

#in_binary?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
# File 'lib/ruby_memcheck/frame.rb', line 22

def in_binary?
  if obj
    File.basename(obj, ".*") == configuration.binary_name
  else
    false
  end
end

#in_ruby?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/ruby_memcheck/frame.rb', line 16

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

#to_sObject



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

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