Module: Hoe::Debugging

Defined in:
lib/hoe/debugging.rb

Overview

Whee, stuff to help when your codes are b0rked. Tasks provided:

  • test:gdb

  • test:valgrind

  • test:valgrind:mem

  • test:valgrind:mem0

Constant Summary collapse

VERSION =

:nodoc:

"1.0.4"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gdb_optionsObject

Optional: Used to add flags to GDB. [default: []]



18
19
20
# File 'lib/hoe/debugging.rb', line 18

def gdb_options
  @gdb_options
end

#valgrind_optionsObject

Optional: Used to add flags to valgrind. [default: %w(--num-callers=50 --error-limit=no --partial-loads-ok=yes --undef-value-errors=no)]



25
26
27
# File 'lib/hoe/debugging.rb', line 25

def valgrind_options
  @valgrind_options
end

Instance Method Details

#define_debugging_tasksObject

:nodoc:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/hoe/debugging.rb', line 51

def define_debugging_tasks #:nodoc:
  desc "Run the test suite under GDB."
  task "test:gdb" do
    sh "gdb #{gdb_options.join ' '} --args #{hoe_debugging_ruby} #{hoe_debugging_make_test_cmd}"
  end

  desc "Run the test suite under Valgrind."
  task "test:valgrind" do
    sh "valgrind #{valgrind_options.join ' '} #{hoe_debugging_ruby} #{hoe_debugging_make_test_cmd}"
  end

  desc "Run the test suite under Valgrind with memory-fill."
  task "test:valgrind:mem" do
    sh "valgrind #{valgrind_options.join ' '} " +
      "--freelist-vol=100000000 --malloc-fill=6D --free-fill=66 " +
      "#{hoe_debugging_ruby} #{hoe_debugging_make_test_cmd}"
  end

  desc "Run the test suite under Valgrind with memory-zero."
  task "test:valgrind:mem0" do
    sh "valgrind #{valgrind_options.join ' '} " +
      "--freelist-vol=100000000 --malloc-fill=00 --free-fill=00 " +
      "#{hoe_debugging_ruby} #{hoe_debugging_make_test_cmd}"
  end
end

#hoe_debugging_make_test_cmdObject



41
42
43
44
45
46
47
48
49
# File 'lib/hoe/debugging.rb', line 41

def hoe_debugging_make_test_cmd
  cmd = []
  if File.directory? "spec"
    cmd << "-S rspec"
  else
    cmd << make_test_cmd
  end
  cmd.join(' ')
end

#hoe_debugging_rubyObject



36
37
38
39
# File 'lib/hoe/debugging.rb', line 36

def hoe_debugging_ruby
  # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/151376
  @ruby ||= File.join(Config::CONFIG["bindir"], (Config::CONFIG["RUBY_INSTALL_NAME"] + Config::CONFIG["EXEEXT"]))
end

#initialize_debuggingObject

:nodoc:



27
28
29
30
31
32
33
34
# File 'lib/hoe/debugging.rb', line 27

def initialize_debugging #:nodoc:
  self.gdb_options = []

  self.valgrind_options = ["--num-callers=50",
                           "--error-limit=no",
                           "--partial-loads-ok=yes",
                           "--undef-value-errors=no"]
end