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
Defined Under Namespace
Classes: ValgrindHelper
Constant Summary collapse
- VERSION =
:nodoc:
"1.2.0"
Instance Attribute Summary collapse
-
#gdb_options ⇒ Object
Optional: Used to add flags to GDB.
-
#valgrind_options ⇒ Object
Optional: Used to add flags to valgrind.
Instance Method Summary collapse
-
#define_debugging_tasks ⇒ Object
:nodoc:.
- #hoe_debugging_check_for_suppression_file(options) ⇒ Object
- #hoe_debugging_command ⇒ Object
- #hoe_debugging_make_test_cmd ⇒ Object
- #hoe_debugging_ruby ⇒ Object
- #hoe_debugging_run_valgrind(command, cmdline_options = []) ⇒ Object
- #hoe_debugging_valgrind_helper ⇒ Object
-
#initialize_debugging ⇒ Object
:nodoc:.
Instance Attribute Details
#gdb_options ⇒ Object
Optional: Used to add flags to GDB. [default: []]
18 19 20 |
# File 'lib/hoe/debugging.rb', line 18 def end |
#valgrind_options ⇒ Object
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 end |
Instance Method Details
#define_debugging_tasks ⇒ Object
:nodoc:
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/hoe/debugging.rb', line 71 def define_debugging_tasks #:nodoc: desc "Run the test suite under GDB." task "test:gdb" do sh "gdb #{gdb_options.join ' '} --args #{hoe_debugging_command}" end desc "Run the test suite under Valgrind." task "test:valgrind" do vopts = hoe_debugging_check_for_suppression_file vopts hoe_debugging_run_valgrind hoe_debugging_command, vopts end desc "Run the test suite under Valgrind with memory-fill." task "test:valgrind:mem" do vopts = + ["--freelist-vol=100000000", "--malloc-fill=6D", "--free-fill=66"] hoe_debugging_check_for_suppression_file vopts hoe_debugging_run_valgrind hoe_debugging_command, vopts end desc "Run the test suite under Valgrind with memory-zero." task "test:valgrind:mem0" do vopts = + ["--freelist-vol=100000000", "--malloc-fill=00", "--free-fill=00"] hoe_debugging_check_for_suppression_file vopts hoe_debugging_run_valgrind hoe_debugging_command, vopts end desc "Generate a valgrind suppression file for your test suite." task "test:valgrind:suppression" do vopts = + ["--gen-suppressions=all"] Tempfile.open "hoe_debugging_valgrind_suppression_log" do |logfile| hoe_debugging_run_valgrind "#{hoe_debugging_ruby} #{hoe_debugging_make_test_cmd} 2> #{logfile.path}", vopts hoe_debugging_valgrind_helper.save_suppressions_from logfile.path end end end |
#hoe_debugging_check_for_suppression_file(options) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/hoe/debugging.rb', line 60 def hoe_debugging_check_for_suppression_file if suppression_file = hoe_debugging_valgrind_helper.matching_suppression_file puts "NOTICE: using valgrind suppressions in #{suppression_file.inspect}" << "--suppressions=#{suppression_file}" end end |
#hoe_debugging_command ⇒ Object
52 53 54 |
# File 'lib/hoe/debugging.rb', line 52 def hoe_debugging_command "#{hoe_debugging_ruby} #{hoe_debugging_make_test_cmd}" end |
#hoe_debugging_make_test_cmd ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/hoe/debugging.rb', line 41 def hoe_debugging_make_test_cmd cmd = [] if File.directory? "spec" cmd << "-S rspec" cmd << (ENV['FILTER'] || ENV['TESTOPTS']) else cmd << make_test_cmd end cmd.join(' ') end |
#hoe_debugging_ruby ⇒ Object
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(RbConfig::CONFIG["bindir"], (RbConfig::CONFIG["RUBY_INSTALL_NAME"] + RbConfig::CONFIG["EXEEXT"])) end |
#hoe_debugging_run_valgrind(command, cmdline_options = []) ⇒ Object
56 57 58 |
# File 'lib/hoe/debugging.rb', line 56 def hoe_debugging_run_valgrind command, =[] sh "valgrind #{cmdline_options.join(' ')} #{command}" end |
#hoe_debugging_valgrind_helper ⇒ Object
67 68 69 |
# File 'lib/hoe/debugging.rb', line 67 def hoe_debugging_valgrind_helper @valgrind_helper ||= ValgrindHelper.new name end |
#initialize_debugging ⇒ Object
:nodoc:
27 28 29 30 31 32 33 34 |
# File 'lib/hoe/debugging.rb', line 27 def initialize_debugging #:nodoc: self. = [] self. = ["--num-callers=50", "--error-limit=no", "--partial-loads-ok=yes", "--undef-value-errors=no"] end |