ssoroka-bleak_house 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,123 @@
1
+ Index: Makefile.in
2
+ ===================================================================
3
+ --- Makefile.in (revision 6439)
4
+ +++ Makefile.in (working copy)
5
+ @@ -34,7 +34,7 @@
6
+
7
+ empty =
8
+ OUTFLAG = @OUTFLAG@$(empty)
9
+ -CFLAGS = @CFLAGS@ @XCFLAGS@ @ARCH_FLAG@
10
+ +CFLAGS = @CFLAGS@ @XCFLAGS@ @ARCH_FLAG@ @VALGRIND_CFLAGS@
11
+ CPPFLAGS = -I. -I$(srcdir) @CPPFLAGS@
12
+ LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
13
+ EXTLDFLAGS =
14
+ Index: configure.in
15
+ ===================================================================
16
+ --- configure.in (revision 6439)
17
+ +++ configure.in (working copy)
18
+ @@ -895,6 +895,22 @@
19
+ fi
20
+ fi
21
+
22
+ +AC_ARG_ENABLE(valgrind,
23
+ + [ --enable-valgrind use valgrind support],
24
+ + [want_valgrind=$enableval], [want_valgrind=auto])
25
+ +
26
+ +if test x"$want_valgrind" != xno; then
27
+ + AC_CHECK_HEADERS(valgrind/memcheck.h, have_valgrind=yes, have_valgrind=no)
28
+ + if test x"$have_valgrind" = xyes; then
29
+ + AC_DEFINE(HAVE_VALGRIND)
30
+ + VALGRIND_CFLAGS="";
31
+ + elif test x"$want_valgrind" = xyes -a x"$have_valgrind" = xno; then
32
+ + AC_MSG_ERROR(valgrind support requested but valgrind not found)
33
+ + else
34
+ + VALGRIND_CFLAGS="";
35
+ + fi
36
+ +fi
37
+ +
38
+ dnl default value for $KANJI
39
+ DEFAULT_KCODE="KCODE_NONE"
40
+
41
+ @@ -1504,6 +1520,7 @@
42
+ esac
43
+
44
+ AC_SUBST(XCFLAGS)dnl
45
+ +AC_SUBST(VALGRIND_CFLAGS)dnl
46
+ AC_SUBST(XLDFLAGS)dnl
47
+ AC_SUBST(LIBRUBY_LDSHARED)
48
+ AC_SUBST(LIBRUBY_DLDFLAGS)
49
+ Index: eval.c
50
+ ===================================================================
51
+ --- eval.c (revision 6439)
52
+ +++ eval.c (working copy)
53
+ @@ -28,6 +28,12 @@
54
+ #define EXIT_FAILURE 1
55
+ #endif
56
+
57
+ +#ifdef HAVE_VALGRIND
58
+ +#include <valgrind/memcheck.h>
59
+ +#else
60
+ +#define VALGRIND_MAKE_MEM_DEFINED(p, n) /* empty */
61
+ +#endif
62
+ +
63
+ #include <stdio.h>
64
+
65
+ #include "st.h"
66
+ @@ -5225,6 +5231,9 @@
67
+ int pcall;
68
+ {
69
+ ruby_current_node = lhs;
70
+ +
71
+ + VALGRIND_MAKE_MEM_DEFINED(&val, sizeof(val));
72
+ +
73
+ if (val == Qundef) {
74
+ rb_warning("assigning void value");
75
+ val = Qnil;
76
+ Index: gc.c
77
+ ===================================================================
78
+ --- gc.c (revision 6439)
79
+ +++ gc.c (working copy)
80
+ @@ -30,6 +30,12 @@
81
+ #include <sys/resource.h>
82
+ #endif
83
+
84
+ +#ifdef HAVE_VALGRIND
85
+ +#include <valgrind/memcheck.h>
86
+ +#else
87
+ +#define VALGRIND_MAKE_MEM_DEFINED(p, n) /* empty */
88
+ +#endif
89
+ +
90
+ #if defined _WIN32 || defined __CYGWIN__
91
+ #include <windows.h>
92
+ #endif
93
+ @@ -93,6 +99,9 @@
94
+ {
95
+ void *mem;
96
+
97
+ + VALGRIND_MAKE_MEM_DEFINED(&malloc_increase, sizeof(malloc_increase));
98
+ + VALGRIND_MAKE_MEM_DEFINED(&malloc_limit, sizeof(malloc_limit));
99
+ +
100
+ if (size < 0) {
101
+ rb_raise(rb_eNoMemError, "negative allocation size (or too big)");
102
+ }
103
+ @@ -623,6 +632,9 @@
104
+ register long n;
105
+ {
106
+ VALUE v;
107
+ +
108
+ + VALGRIND_MAKE_MEM_DEFINED(x, sizeof(*x) * n);
109
+ +
110
+ while (n--) {
111
+ v = *x;
112
+ if (is_pointer_to_heap((void *)v)) {
113
+ @@ -713,7 +725,10 @@
114
+ {
115
+ register RVALUE *obj;
116
+
117
+ + VALGRIND_MAKE_MEM_DEFINED(&ptr, sizeof(ptr));
118
+ obj = RANY(ptr);
119
+ + VALGRIND_MAKE_MEM_DEFINED(obj, sizeof(*obj));
120
+ +
121
+ if (rb_special_const_p(ptr)) return; /* special const not marked */
122
+ if (obj->as.basic.flags == 0) return; /* free cell */
123
+ if (obj->as.basic.flags & FL_MARK) return; /* already marked */
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'dike'
5
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + "/../../lib")
6
+ require 'bleak_house'
7
+
8
+ Dike.logfactory("/tmp")
9
+ if ARGV[0]
10
+ Dike.finger
11
+ exec('cat /tmp/0')
12
+ else
13
+ BleakHouse.snapshot("/tmp/0")
14
+ exec("#{$LOAD_PATH.first}/../bin/bleak /tmp/0")
15
+ end
16
+
@@ -0,0 +1,6 @@
1
+
2
+ require 'test/unit'
3
+ require 'open-uri'
4
+
5
+ HERE = File.expand_path(File.dirname(__FILE__))
6
+ $LOAD_PATH << HERE
@@ -0,0 +1,52 @@
1
+
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + "/../../lib")
3
+
4
+ ENV['NO_EXIT_HANDLER'] = "1"
5
+
6
+ require 'rubygems'
7
+ require 'echoe'
8
+ require 'test/unit'
9
+ require 'bleak_house'
10
+
11
+ class BleakHouseTest < Test::Unit::TestCase
12
+
13
+ # Match the default hook filename, for convenience
14
+ FILE = "/tmp/bleak.#{Process.pid}.0.dump"
15
+
16
+ def setup
17
+ File.delete FILE rescue nil
18
+ end
19
+
20
+ def test_snapshot
21
+ symbol_count = Symbol.all_symbols.size
22
+ BleakHouse.snapshot(FILE)
23
+ assert File.exist?(FILE)
24
+ assert BleakHouse.heaps_used > 0
25
+ assert BleakHouse.heaps_length > 0
26
+ end
27
+
28
+ def test_exception
29
+ assert_raises(RuntimeError) do
30
+ BleakHouse.snapshot("/")
31
+ end
32
+ end
33
+
34
+ def test_analyze
35
+ BleakHouse.snapshot(FILE)
36
+ Dir.chdir(File.dirname(__FILE__) + "/../../bin") do
37
+ output = `./bleak #{FILE}`.split("\n")
38
+ # require 'ruby-debug/debugger'
39
+ assert_match(/top 20 most common/, output[0])
40
+ assert_match(/free heap/, output[3])
41
+ assert_match(/\d+ __null__:__null__:__node__/, output[4])
42
+ end
43
+ end
44
+
45
+ def test_signal
46
+ Echoe.silence do
47
+ system("kill -s SIGUSR2 #{Process.pid}")
48
+ end
49
+ assert File.exist?(FILE)
50
+ end
51
+
52
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ssoroka-bleak_house
3
+ version: !ruby/object:Gem::Version
4
+ version: 4.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Evan Weaver
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-12-01 00:00:00 -08:00
13
+ default_executable: bleak
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: echoe
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ version:
24
+ description: A library for finding memory leaks.
25
+ email: ""
26
+ executables:
27
+ - bleak
28
+ extensions:
29
+ - ext/extconf.rb
30
+ extra_rdoc_files:
31
+ - CHANGELOG
32
+ - ext/snapshot.c
33
+ - lib/bleak_house/analyzer.rb
34
+ - lib/bleak_house/hook.rb
35
+ - lib/bleak_house.rb
36
+ - LICENSE
37
+ - LICENSE_BSD
38
+ - README
39
+ - TODO
40
+ files:
41
+ - bin/bleak
42
+ - bleak_house.gemspec
43
+ - CHANGELOG
44
+ - ext/build_ruby.rb
45
+ - ext/build_snapshot.rb
46
+ - ext/extconf.rb
47
+ - ext/snapshot.c
48
+ - ext/snapshot.h
49
+ - lib/bleak_house/analyzer.rb
50
+ - lib/bleak_house/hook.rb
51
+ - lib/bleak_house.rb
52
+ - LICENSE
53
+ - LICENSE_BSD
54
+ - Manifest
55
+ - Rakefile
56
+ - README
57
+ - ruby/configure.patch
58
+ - ruby/gc.patch
59
+ - ruby/ruby-1.8.6-p230.tar.bz2
60
+ - ruby/valgrind.patch
61
+ - test/benchmark/bench.rb
62
+ - test/test_helper.rb
63
+ - test/unit/test_bleak_house.rb
64
+ - TODO
65
+ has_rdoc: true
66
+ homepage: http://blog.evanweaver.com/files/doc/fauna/bleak_house/
67
+ post_install_message:
68
+ rdoc_options:
69
+ - --line-numbers
70
+ - --inline-source
71
+ - --title
72
+ - Bleak_house
73
+ - --main
74
+ - README
75
+ require_paths:
76
+ - lib
77
+ - ext
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: "0"
83
+ version:
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "1.2"
89
+ version:
90
+ requirements: []
91
+
92
+ rubyforge_project: fauna
93
+ rubygems_version: 1.2.0
94
+ signing_key:
95
+ specification_version: 2
96
+ summary: A library for finding memory leaks.
97
+ test_files:
98
+ - test/test_helper.rb
99
+ - test/unit/test_bleak_house.rb