Class: RubyMemcheck::ValgrindError

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

Constant Summary collapse

SUPPRESSION_NOT_CONFIGURED_ERROR_MSG =
"Please enable suppressions by configuring with valgrind_generate_suppressions set to true"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration, loaded_binaries, error) ⇒ ValgrindError

Returns a new instance of ValgrindError.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ruby_memcheck/valgrind_error.rb', line 10

def initialize(configuration, loaded_binaries, error)
  @kind = error.at_xpath("kind").content
  @msg =
    if kind_leak?
      error.at_xpath("xwhat/text").content
    else
      error.at_xpath("what").content
    end
  @stack = Stack.new(configuration, loaded_binaries, error.at_xpath("stack"))
  @configuration = configuration

  suppression_node = error.at_xpath("suppression")
  if configuration.valgrind_generate_suppressions?
    @suppression = Suppression.new(configuration, suppression_node)
  elsif suppression_node
    raise SUPPRESSION_NOT_CONFIGURED_ERROR_MSG
  end
end

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind.



8
9
10
# File 'lib/ruby_memcheck/valgrind_error.rb', line 8

def kind
  @kind
end

#msgObject (readonly)

Returns the value of attribute msg.



8
9
10
# File 'lib/ruby_memcheck/valgrind_error.rb', line 8

def msg
  @msg
end

#stackObject (readonly)

Returns the value of attribute stack.



8
9
10
# File 'lib/ruby_memcheck/valgrind_error.rb', line 8

def stack
  @stack
end

#suppressionObject (readonly)

Returns the value of attribute suppression.



8
9
10
# File 'lib/ruby_memcheck/valgrind_error.rb', line 8

def suppression
  @suppression
end

Instance Method Details

#skip?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/ruby_memcheck/valgrind_error.rb', line 29

def skip?
  should_filter? && stack.skip?
end

#to_sObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ruby_memcheck/valgrind_error.rb', line 33

def to_s
  str = StringIO.new
  str << "#{msg}\n"
  stack.frames.each do |frame|
    str << if frame.in_binary?
      " *#{frame}\n"
    else
      "  #{frame}\n"
    end
  end
  str << suppression.to_s if suppression
  str.string
end