blab 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91cbcb0ecff4366f95c0039e94952f5e364d538ecc588060bf33c40262dd4ad4
4
- data.tar.gz: e47c8a122f138859de18c66c095d62caf326a613ac1c4bcfd3c5fc5e2358ec8e
3
+ metadata.gz: 48035d0e66390d19e010b00b0dc407d73fa165f31579797fc45e595f364f9e8f
4
+ data.tar.gz: 274213a7a6c78bab28acc1d94236492faca32d10ed5a6de0d85be6090ecdbb14
5
5
  SHA512:
6
- metadata.gz: 9af0cfe4d8f881ba10d4d7297a6fe280d871bdedae5302e27e6b824db9ccd460d264d77a9c3c8d23ca4f3aefb97e8d31ace9b85cfbc21bb2b2b5c7ac3f207925
7
- data.tar.gz: 308c1b8edee335be6cd588c8aa59f2266a18a529db07c188a6b89ab1f707d288d50294762c011f6d714aa75077a1fd48f26d2b97cc679eaec4e8bca1d8bf9c73
6
+ metadata.gz: a194885665d8987407b7254421069f44e18185ad73c1767d5d5eb39e8ce2b7bbf2d73d7540ded79347e50d078378206584800dbc35b4910c3e86e274944c6aac
7
+ data.tar.gz: f2e63e5c913c9a32b7c70a07f9e8facada8d2b257fc28669c2c8ea77d2a55bb08f9a2e60d98df87ba308329c69c5e99be66a649c9114c77c2f281a0ce216b9d9
data/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
 
4
4
  A debugging tool.
5
5
 
6
- The gem allows to trace local variables and memory usage for Ruby code (MRI 2.6+). \
7
- It's extremely experemental and is intended for use in a development environment only. \
6
+ The gem allows to trace local variables and memory usage for Ruby code. \
7
+ It's intended for use in a development environment only. \
8
8
  Blab is inspired by [PySnooper](https://github.com/cool-RR/PySnooper).
9
9
 
10
10
 
@@ -44,16 +44,13 @@ The output to STDOUT:
44
44
 
45
45
  ```
46
46
  Var......... str="cbaaabb"
47
- 18:17:26.042 call test/support/test.rb:46 13463552 blab def longest_rep(str)
48
- 18:17:26.042 line test/support/test.rb:47 13508608 max = str.chars.chunk(&:itself).map(&:last).max_by(&:size)
47
+ 18:17:26.042 call test/support/test.rb:46 blab def longest_rep(str)
48
+ 18:17:26.042 line test/support/test.rb:47 max = str.chars.chunk(&:itself).map(&:last).max_by(&:size)
49
49
  Var......... max=["a", "a", "a"]
50
- 18:17:26.043 line test/support/test.rb:48 13516800 max ? [max[0], max.size] : ["", 0]
51
- 18:17:26.043 return test/support/test.rb:49 13516800 end
50
+ 18:17:26.043 line test/support/test.rb:48 max ? [max[0], max.size] : ["", 0]
51
+ 18:17:26.043 return test/support/test.rb:49 end
52
52
  ```
53
53
 
54
- The output is configurable. Within the example the 4th item in a table is `ru_maxss` - a memory amount used by the Ruby process. The value is in bytes on Mac OS X (Darwin), but in kilobytes on BSD and Linux. In the example it's in bytes and is roughly 13MB total.
55
- Note, that blab itself adds some overhead, and the program'll take lesser memory running without it.
56
-
57
54
  The gem allows to wrap only a piece of code in a block:
58
55
 
59
56
  ```ruby
@@ -82,20 +79,20 @@ The output:
82
79
  ```
83
80
  Var......... a=["Bored", "Curious"]
84
81
  Var......... b=["cat", "frog"]
85
- 18:38:15.188 line test/support/test.rb:54 13770752 a << "Insane"
86
- 18:38:15.188 line test/support/test.rb:55 13807616 shuffle(b)
82
+ 18:38:15.188 line test/support/test.rb:54 a << "Insane"
83
+ 18:38:15.188 line test/support/test.rb:55 shuffle(b)
87
84
  Var......... arr=["cat", "frog"]
88
- 18:38:15.188 call test/support/test.rb:45 13807616 def shuffle(arr)
89
- 18:38:15.189 line test/support/test.rb:46 13807616 for n in 0...arr.size
85
+ 18:38:15.188 call test/support/test.rb:45 def shuffle(arr)
86
+ 18:38:15.189 line test/support/test.rb:46 for n in 0...arr.size
90
87
  Var......... n=0
91
- 18:38:15.189 line test/support/test.rb:47 13811712 targ = n + rand(arr.size - n)
88
+ 18:38:15.189 line test/support/test.rb:47 targ = n + rand(arr.size - n)
92
89
  Var......... targ=0
93
- 18:38:15.189 line test/support/test.rb:48 13811712 arr[n], arr[targ] = arr[targ], arr[n] if n != targ
90
+ 18:38:15.189 line test/support/test.rb:48 arr[n], arr[targ] = arr[targ], arr[n] if n != targ
94
91
  Var......... n=1
95
- 18:38:15.189 line test/support/test.rb:47 13811712 targ = n + rand(arr.size - n)
92
+ 18:38:15.189 line test/support/test.rb:47 targ = n + rand(arr.size - n)
96
93
  Var......... targ=1
97
- 18:38:15.189 line test/support/test.rb:48 13811712 arr[n], arr[targ] = arr[targ], arr[n] if n != targ
98
- 18:38:15.189 return test/support/test.rb:50 13811712 end
94
+ 18:38:15.189 line test/support/test.rb:48 arr[n], arr[targ] = arr[targ], arr[n] if n != targ
95
+ 18:38:15.189 return test/support/test.rb:50 end
99
96
  ```
100
97
 
101
98
  ## Configuration
@@ -140,7 +137,6 @@ output_order = [
140
137
  { type: :file_lines, order: 3, width: 30 },
141
138
  { type: :class_name, order: 4, width: 10 },
142
139
  { type: :method_name, order: 5, width: 12 },
143
- { type: :ru_maxss, order: 6, width: 12 },
144
140
  { type: :code_lines, order: 7, width: 120 }
145
141
  ]
146
142
 
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../ext/blab_trace"
4
3
  require_relative "blab/config"
5
4
  require_relative "blab/formatter"
6
5
  require_relative "blab/printer"
@@ -12,12 +11,12 @@ module Blab
12
11
  base.define_singleton_method(:blab) do |name|
13
12
  old_m = self.instance_method(name)
14
13
 
15
- base.send(:define_method, name) do |*args|
14
+ self.send(:define_method, name) do |*args|
16
15
  begin
17
- blab_trace(Blab::Tracer.trace)
16
+ set_trace_func(Blab::Tracer.trace)
18
17
  old_m.bind(self).call(*args)
19
18
  ensure
20
- blab_trace(nil)
19
+ set_trace_func(nil)
21
20
  Blab::Tracer.reset
22
21
  end
23
22
  end
@@ -25,10 +24,10 @@ module Blab
25
24
 
26
25
  def with_blab
27
26
  begin
28
- blab_trace(Blab::Tracer.trace)
27
+ set_trace_func(Blab::Tracer.trace)
29
28
  yield
30
29
  ensure
31
- blab_trace(nil)
30
+ set_trace_func(nil)
32
31
  Blab::Tracer.reset
33
32
  end
34
33
  end
@@ -14,7 +14,6 @@ module Blab
14
14
  { type: :file_lines, order: 3, width: 50 },
15
15
  #{ type: :class_name, order: 4, width: 10 },
16
16
  #{ type: :method_name, order: 5, width: 12 },
17
- { type: :ru_maxss, order: 4, width: 12 },
18
17
  { type: :code_lines, order: 5, width: 120 }
19
18
  ].freeze
20
19
 
@@ -38,8 +37,12 @@ module Blab
38
37
  @log_output ||= STDOUT
39
38
  end
40
39
 
40
+ def output_order
41
+ @output_order ||= DEFAULT_OUTPUT
42
+ end
43
+
41
44
  def output_config
42
- @output_config ||= (@output_order || DEFAULT_OUTPUT).sort_by { |h| h[:order] }.map! { |h| [h[:type], h[:width]] }
45
+ @output_config ||= output_order.sort_by { |h| h[:order] }.map! { |h| [h[:type], h[:width]] }
43
46
  end
44
47
 
45
48
  def datetime_format
@@ -14,8 +14,7 @@ module Blab
14
14
  :class_name,
15
15
  :event,
16
16
  :method_name,
17
- :time,
18
- :ru_maxss
17
+ :time
19
18
  ].freeze
20
19
 
21
20
  attr_reader :config, :logger
@@ -13,7 +13,7 @@ module Blab
13
13
  end
14
14
 
15
15
  def trace
16
- proc do |event, file, line, method_name, context, class_name, ru_maxss|
16
+ proc do |event, file, line, method_name, context, class_name|
17
17
  next if file =~ FILE_NAME
18
18
  next if skip_c_calls? && C_CALLS.include?(event)
19
19
  next if original_scope_only? && !original_scope?(file, method_name, class_name)
@@ -36,9 +36,7 @@ module Blab
36
36
  file: file,
37
37
  line: line,
38
38
  method_name: method_name.to_s,
39
- class_name: class_name.to_s,
40
- # ru_maxss is in bytes on Mac OS X (Darwin), but in kilobytes on BSD and Linux
41
- ru_maxss: ru_maxss.to_s
39
+ class_name: class_name.to_s
42
40
  )
43
41
  end
44
42
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blab
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "minitest/autorun"
4
+ require "blab"
5
+
6
+ class SimpleTest
7
+ def sum(a, b)
8
+ with_blab { a + b }
9
+ end
10
+
11
+ blab def diff(a, b)
12
+ a - b
13
+ end
14
+ end
15
+
16
+ class TestBlab < Minitest::Test
17
+ def setup
18
+ @simple_test = SimpleTest.new
19
+ end
20
+
21
+ def test_sum
22
+ out, err = capture_subprocess_io do
23
+ @simple_test.sum(1, 2)
24
+ end
25
+ assert_equal err, ""
26
+ assert_match(/with_blab { a \+ b }/, out)
27
+ end
28
+
29
+ def test_diff
30
+ out, err = capture_subprocess_io do
31
+ @simple_test.diff(2, 1)
32
+ end
33
+ assert_equal err, ""
34
+ assert_match(/a - b/, out)
35
+ end
36
+ end
@@ -12,7 +12,6 @@ class TestPrinter < Minitest::Test
12
12
  [:file_lines, 50],
13
13
  [:class_name, 12],
14
14
  [:method_name, 12],
15
- [:ru_maxss, 12],
16
15
  [:code_lines, 120]
17
16
  ]
18
17
  @printer = Blab::Printer.new(@config, @logger)
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yulia Oletskaya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-20 00:00:00.000000000 Z
11
+ date: 2019-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: debase-ruby_core_source
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.10'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.10'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: minitest
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -41,19 +27,11 @@ dependencies:
41
27
  description: A debugging tool
42
28
  email: yulia.oletskaya@gmail.com
43
29
  executables: []
44
- extensions:
45
- - ext/extconf.rb
30
+ extensions: []
46
31
  extra_rdoc_files: []
47
32
  files:
48
33
  - LICENSE
49
34
  - README.md
50
- - ext/Makefile
51
- - ext/blab_trace.bundle
52
- - ext/blab_trace.c
53
- - ext/blab_trace.o
54
- - ext/extconf.h
55
- - ext/extconf.rb
56
- - ext/mkmf.log
57
35
  - lib/blab.rb
58
36
  - lib/blab/config.rb
59
37
  - lib/blab/formatter.rb
@@ -61,6 +39,7 @@ files:
61
39
  - lib/blab/tracer.rb
62
40
  - lib/blab/version.rb
63
41
  - test/support/test.rb
42
+ - test/test_blab.rb
64
43
  - test/test_formatter.rb
65
44
  - test/test_printer.rb
66
45
  homepage: http://rubygems.org/gems/blab
@@ -87,6 +66,7 @@ signing_key:
87
66
  specification_version: 4
88
67
  summary: Blab
89
68
  test_files:
69
+ - test/test_blab.rb
90
70
  - test/test_formatter.rb
91
71
  - test/test_printer.rb
92
72
  - test/support/test.rb
@@ -1,266 +0,0 @@
1
-
2
- SHELL = /bin/sh
3
-
4
- # V=0 quiet, V=1 verbose. other values don't work.
5
- V = 0
6
- Q1 = $(V:1=)
7
- Q = $(Q1:0=@)
8
- ECHO1 = $(V:1=@ :)
9
- ECHO = $(ECHO1:0=@ echo)
10
- NULLCMD = :
11
-
12
- #### Start of system configuration section. ####
13
-
14
- srcdir = .
15
- topdir = /Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0
16
- hdrdir = $(topdir)
17
- arch_hdrdir = /Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0/x86_64-darwin16
18
- PATH_SEPARATOR = :
19
- VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
20
- prefix = $(DESTDIR)/Users/july/.rbenv/versions/2.6.0
21
- rubysitearchprefix = $(rubylibprefix)/$(sitearch)
22
- rubyarchprefix = $(rubylibprefix)/$(arch)
23
- rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
24
- exec_prefix = $(prefix)
25
- vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
26
- sitearchhdrdir = $(sitehdrdir)/$(sitearch)
27
- rubyarchhdrdir = $(rubyhdrdir)/$(arch)
28
- vendorhdrdir = $(rubyhdrdir)/vendor_ruby
29
- sitehdrdir = $(rubyhdrdir)/site_ruby
30
- rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
31
- vendorarchdir = $(vendorlibdir)/$(sitearch)
32
- vendorlibdir = $(vendordir)/$(ruby_version)
33
- vendordir = $(rubylibprefix)/vendor_ruby
34
- sitearchdir = $(sitelibdir)/$(sitearch)
35
- sitelibdir = $(sitedir)/$(ruby_version)
36
- sitedir = $(rubylibprefix)/site_ruby
37
- rubyarchdir = $(rubylibdir)/$(arch)
38
- rubylibdir = $(rubylibprefix)/$(ruby_version)
39
- sitearchincludedir = $(includedir)/$(sitearch)
40
- archincludedir = $(includedir)/$(arch)
41
- sitearchlibdir = $(libdir)/$(sitearch)
42
- archlibdir = $(libdir)/$(arch)
43
- ridir = $(datarootdir)/$(RI_BASE_NAME)
44
- mandir = $(datarootdir)/man
45
- localedir = $(datarootdir)/locale
46
- libdir = $(exec_prefix)/lib
47
- psdir = $(docdir)
48
- pdfdir = $(docdir)
49
- dvidir = $(docdir)
50
- htmldir = $(docdir)
51
- infodir = $(datarootdir)/info
52
- docdir = $(datarootdir)/doc/$(PACKAGE)
53
- oldincludedir = $(SDKROOT)/usr/include
54
- includedir = $(prefix)/include
55
- localstatedir = $(prefix)/var
56
- sharedstatedir = $(prefix)/com
57
- sysconfdir = $(prefix)/etc
58
- datadir = $(datarootdir)
59
- datarootdir = $(prefix)/share
60
- libexecdir = $(exec_prefix)/libexec
61
- sbindir = $(exec_prefix)/sbin
62
- bindir = $(exec_prefix)/bin
63
- archdir = $(rubyarchdir)
64
-
65
-
66
- CC_WRAPPER =
67
- CC = clang
68
- CXX = clang++
69
- LIBRUBY = $(LIBRUBY_A)
70
- LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
71
- LIBRUBYARG_SHARED =
72
- LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static -framework Security -framework Foundation $(MAINLIBS)
73
- empty =
74
- OUTFLAG = -o $(empty)
75
- COUTFLAG = -o $(empty)
76
- CSRCFLAG = $(empty)
77
-
78
- RUBY_EXTCONF_H =
79
- cflags = $(optflags) $(debugflags) $(warnflags)
80
- cxxflags = $(optflags) $(debugflags) $(warnflags)
81
- optflags = -O3
82
- debugflags = -ggdb3
83
- warnflags = -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens
84
- cppflags =
85
- CCDLFLAGS = -fno-common
86
- CFLAGS = $(CCDLFLAGS) $(cflags) -pipe $(ARCH_FLAG)
87
- INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
88
- DEFS =
89
- CPPFLAGS = -DHAVE_VM_CORE_H -DHAVE_ISEQ_H -I/Users/july/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/debase-ruby_core_source-0.10.4/lib/debase/ruby_core_source/ruby-2.6.0-p0
90
- CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
91
- ldflags = -L. -L/Users/july/.rbenv/versions/2.6.0/lib -fstack-protector-strong -L/usr/local/lib
92
- dldflags = -L/Users/july/.rbenv/versions/2.6.0/lib -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress
93
- ARCH_FLAG =
94
- DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
95
- LDSHARED = $(CC) -dynamic -bundle
96
- LDSHAREDXX = $(CXX) -dynamic -bundle
97
- AR = libtool -static
98
- EXEEXT =
99
-
100
- RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
101
- RUBY_SO_NAME = ruby.2.6
102
- RUBYW_INSTALL_NAME =
103
- RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
104
- RUBYW_BASE_NAME = rubyw
105
- RUBY_BASE_NAME = ruby
106
-
107
- arch = x86_64-darwin16
108
- sitearch = $(arch)
109
- ruby_version = 2.6.0
110
- ruby = $(bindir)/$(RUBY_BASE_NAME)
111
- RUBY = $(ruby)
112
- ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
113
-
114
- RM = rm -f
115
- RM_RF = $(RUBY) -run -e rm -- -rf
116
- RMDIRS = rmdir -p
117
- MAKEDIRS = mkdir -p
118
- INSTALL = /usr/bin/install -c
119
- INSTALL_PROG = $(INSTALL) -m 0755
120
- INSTALL_DATA = $(INSTALL) -m 644
121
- COPY = cp
122
- TOUCH = exit >
123
-
124
- #### End of system configuration section. ####
125
-
126
- preload =
127
- libpath = . $(libdir)
128
- LIBPATH = -L. -L$(libdir)
129
- DEFFILE =
130
-
131
- CLEANFILES = mkmf.log
132
- DISTCLEANFILES =
133
- DISTCLEANDIRS =
134
-
135
- extout =
136
- extout_prefix =
137
- target_prefix =
138
- LOCAL_LIBS =
139
- LIBS =
140
- ORIG_SRCS = blab_trace.c
141
- SRCS = $(ORIG_SRCS)
142
- OBJS = blab_trace.o
143
- HDRS = $(srcdir)/extconf.h
144
- LOCAL_HDRS =
145
- TARGET = blab_trace
146
- TARGET_NAME = blab_trace
147
- TARGET_ENTRY = Init_$(TARGET_NAME)
148
- DLLIB = $(TARGET).bundle
149
- EXTSTATIC =
150
- STATIC_LIB =
151
-
152
- TIMESTAMP_DIR = .
153
- BINDIR = $(bindir)
154
- RUBYCOMMONDIR = $(sitedir)$(target_prefix)
155
- RUBYLIBDIR = $(sitelibdir)$(target_prefix)
156
- RUBYARCHDIR = $(sitearchdir)$(target_prefix)
157
- HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
158
- ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
159
- TARGET_SO_DIR =
160
- TARGET_SO = $(TARGET_SO_DIR)$(DLLIB)
161
- CLEANLIBS = $(TARGET_SO)
162
- CLEANOBJS = *.o *.bak
163
-
164
- all: $(DLLIB)
165
- static: $(STATIC_LIB)
166
- .PHONY: all install static install-so install-rb
167
- .PHONY: clean clean-so clean-static clean-rb
168
-
169
- clean-static::
170
- clean-rb-default::
171
- clean-rb::
172
- clean-so::
173
- clean: clean-so clean-static clean-rb-default clean-rb
174
- -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
175
-
176
- distclean-rb-default::
177
- distclean-rb::
178
- distclean-so::
179
- distclean-static::
180
- distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
181
- -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
182
- -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
183
- -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
184
-
185
- realclean: distclean
186
- install: install-so install-rb
187
-
188
- install-so: $(DLLIB) $(TIMESTAMP_DIR)/.sitearchdir.time
189
- $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
190
- clean-static::
191
- -$(Q)$(RM) $(STATIC_LIB)
192
- install-rb: pre-install-rb do-install-rb install-rb-default
193
- install-rb-default: pre-install-rb-default do-install-rb-default
194
- pre-install-rb: Makefile
195
- pre-install-rb-default: Makefile
196
- do-install-rb:
197
- do-install-rb-default:
198
- pre-install-rb-default:
199
- @$(NULLCMD)
200
- $(TIMESTAMP_DIR)/.sitearchdir.time:
201
- $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
202
- $(Q) $(TOUCH) $@
203
-
204
- site-install: site-install-so site-install-rb
205
- site-install-so: install-so
206
- site-install-rb: install-rb
207
-
208
- .SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
209
-
210
- .cc.o:
211
- $(ECHO) compiling $(<)
212
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
213
-
214
- .cc.S:
215
- $(ECHO) translating $(<)
216
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
217
-
218
- .mm.o:
219
- $(ECHO) compiling $(<)
220
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
221
-
222
- .mm.S:
223
- $(ECHO) translating $(<)
224
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
225
-
226
- .cxx.o:
227
- $(ECHO) compiling $(<)
228
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
229
-
230
- .cxx.S:
231
- $(ECHO) translating $(<)
232
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
233
-
234
- .cpp.o:
235
- $(ECHO) compiling $(<)
236
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
237
-
238
- .cpp.S:
239
- $(ECHO) translating $(<)
240
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
241
-
242
- .c.o:
243
- $(ECHO) compiling $(<)
244
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
245
-
246
- .c.S:
247
- $(ECHO) translating $(<)
248
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
249
-
250
- .m.o:
251
- $(ECHO) compiling $(<)
252
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
253
-
254
- .m.S:
255
- $(ECHO) translating $(<)
256
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
257
-
258
- $(TARGET_SO): $(OBJS) Makefile
259
- $(ECHO) linking shared-object $(DLLIB)
260
- -$(Q)$(RM) $(@)
261
- $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
262
- $(Q) $(POSTLINK)
263
-
264
-
265
-
266
- $(OBJS): $(HDRS) $(ruby_headers)
Binary file
@@ -1,186 +0,0 @@
1
- #include "extconf.h"
2
-
3
- #define TRUE 1
4
- #define FALSE 0
5
-
6
- PUREFUNC(static rb_callable_method_entry_t *check_method_entry(VALUE obj, int can_be_svar));
7
- static rb_callable_method_entry_t *check_method_entry(VALUE obj, int can_be_svar)
8
- {
9
- if (obj == Qfalse) return NULL;
10
-
11
- #if VM_CHECK_MODE > 0
12
- if (!RB_TYPE_P(obj, T_IMEMO)) rb_bug("check_method_entry: unknown type: %s", rb_obj_info(obj));
13
- #endif
14
-
15
- switch (imemo_type(obj)) {
16
- case imemo_ment:
17
- return (rb_callable_method_entry_t *)obj;
18
- case imemo_cref:
19
- return NULL;
20
- case imemo_svar:
21
- if (can_be_svar) {
22
- return check_method_entry(((struct vm_svar *)obj)->cref_or_me, FALSE);
23
- }
24
- default:
25
- #if VM_CHECK_MODE > 0
26
- rb_bug("check_method_entry: svar should not be there:");
27
- #endif
28
- return NULL;
29
- }
30
- }
31
-
32
- MJIT_STATIC const rb_callable_method_entry_t *rb_vm_frame_method_entry(const rb_control_frame_t *cfp)
33
- {
34
- const VALUE *ep = cfp->ep;
35
- rb_callable_method_entry_t *me;
36
-
37
- while (!VM_ENV_LOCAL_P(ep)) {
38
- if ((me = check_method_entry(ep[VM_ENV_DATA_INDEX_ME_CREF], FALSE)) != NULL) return me;
39
- ep = VM_ENV_PREV_EP(ep);
40
- }
41
-
42
- return check_method_entry(ep[VM_ENV_DATA_INDEX_ME_CREF], TRUE);
43
- }
44
-
45
-
46
- int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, ID *called_idp, VALUE *klassp)
47
- {
48
- const rb_callable_method_entry_t *me = rb_vm_frame_method_entry(cfp);
49
-
50
- if (me) {
51
- if (idp) *idp = me->def->original_id;
52
- if (called_idp) *called_idp = me->called_id;
53
- if (klassp) *klassp = me->owner;
54
- return TRUE;
55
- }
56
- else {
57
- return FALSE;
58
- }
59
- }
60
-
61
- int rb_ec_frame_method_id_and_class(const rb_execution_context_t *ec, ID *idp, ID *called_idp, VALUE *klassp)
62
- {
63
- return rb_vm_control_frame_id_and_class(ec->cfp, idp, called_idp, klassp);
64
- }
65
-
66
- inline static int calc_lineno(const rb_iseq_t *iseq, const VALUE *pc)
67
- {
68
- size_t pos = (size_t)(pc - iseq->body->iseq_encoded);
69
- if (LIKELY(pos)) {
70
- /* use pos-1 because PC points next instruction at the beginning of instruction */
71
- pos--;
72
- }
73
- return rb_iseq_line_no(iseq, pos);
74
- }
75
-
76
- int rb_vm_get_sourceline(const rb_control_frame_t *cfp)
77
- {
78
- if (VM_FRAME_RUBYFRAME_P(cfp) && cfp->iseq) {
79
- const rb_iseq_t *iseq = cfp->iseq;
80
- int line = calc_lineno(iseq, cfp->pc);
81
- if (line != 0) {
82
- return line;
83
- }
84
- else {
85
- return FIX2INT(rb_iseq_first_lineno(iseq));
86
- }
87
- }
88
- else {
89
- return 0;
90
- }
91
- }
92
-
93
- static const char * get_event_name(rb_event_flag_t event)
94
- {
95
- switch (event) {
96
- case RUBY_EVENT_LINE: return "line";
97
- case RUBY_EVENT_CLASS: return "class";
98
- case RUBY_EVENT_END: return "end";
99
- case RUBY_EVENT_CALL: return "call";
100
- case RUBY_EVENT_RETURN: return "return";
101
- case RUBY_EVENT_C_CALL: return "c-call";
102
- case RUBY_EVENT_C_RETURN: return "c-return";
103
- case RUBY_EVENT_RAISE: return "raise";
104
- default: return "unknown";
105
- }
106
- }
107
-
108
- static void get_path_and_lineno(const rb_execution_context_t *ec, const rb_control_frame_t *cfp, rb_event_flag_t event, VALUE *pathp, int *linep)
109
- {
110
- cfp = rb_vm_get_ruby_level_next_cfp(ec, cfp);
111
-
112
- if (cfp) {
113
- const rb_iseq_t *iseq = cfp->iseq;
114
- *pathp = rb_iseq_path(iseq);
115
-
116
- if (event & (RUBY_EVENT_CLASS | RUBY_EVENT_CALL | RUBY_EVENT_B_CALL)) {
117
- *linep = FIX2INT(rb_iseq_first_lineno(iseq));
118
- }
119
- else {
120
- *linep = rb_vm_get_sourceline(cfp);
121
- }
122
- }
123
- else {
124
- *pathp = Qnil;
125
- *linep = 0;
126
- }
127
- }
128
-
129
- static void blab_trace_func(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klass)
130
- {
131
- int line;
132
- VALUE filename;
133
- VALUE eventname = rb_str_new2(get_event_name(event));
134
- VALUE argv[7];
135
- const rb_execution_context_t *ec = GET_EC();
136
-
137
- // RUSAGE_SELF/RUSAGE_CHILDREN/RUSAGE_THREAD
138
- struct rusage r_usage;
139
- getrusage(RUSAGE_SELF, &r_usage);
140
-
141
- get_path_and_lineno(ec, ec->cfp, event, &filename, &line);
142
-
143
- if (!klass) {
144
- rb_ec_frame_method_id_and_class(ec, &id, 0, &klass);
145
- }
146
-
147
- if (klass) {
148
- if (RB_TYPE_P(klass, T_ICLASS)) {
149
- klass = RBASIC(klass)->klass;
150
- }
151
- else if (FL_TEST(klass, FL_SINGLETON)) {
152
- klass = rb_ivar_get(klass, id__attached__);
153
- }
154
- }
155
-
156
- argv[0] = eventname;
157
- argv[1] = filename;
158
- argv[2] = INT2FIX(line);
159
- argv[3] = id ? ID2SYM(id) : Qnil;
160
- argv[4] = (self && (filename != Qnil)) ? rb_binding_new() : Qnil;
161
- argv[5] = klass ? klass : Qnil;
162
- argv[6] = INT2FIX(r_usage.ru_maxrss); // maximum resident set size
163
-
164
- rb_proc_call_with_block(proc, 7, argv, Qnil);
165
- }
166
-
167
- static VALUE rb_blab_trace(VALUE obj, VALUE trace)
168
- {
169
- rb_remove_event_hook(blab_trace_func);
170
-
171
- if (NIL_P(trace)) {
172
- return Qnil;
173
- }
174
-
175
- if (!rb_obj_is_proc(trace)) {
176
- rb_raise(rb_eTypeError, "trace_func needs to be Proc");
177
- }
178
-
179
- rb_add_event_hook(blab_trace_func, RUBY_EVENT_ALL, trace);
180
- return trace;
181
- }
182
-
183
- void Init_blab_trace()
184
- {
185
- rb_define_global_function("blab_trace", rb_blab_trace, 1);
186
- }
Binary file
@@ -1,9 +0,0 @@
1
- #ifndef EXTCONF_H
2
- #define EXTCONF_H 1
3
-
4
- #include <ruby.h>
5
- #include <vm_core.h>
6
- #include <iseq.h>
7
- #include <sys/resource.h>
8
-
9
- #endif
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "mkmf"
4
- require "debase/ruby_core_source"
5
-
6
- if RUBY_VERSION < "2.6"
7
- STDERR.print("Ruby version must be 2.6 or older\n")
8
- exit(1)
9
- end
10
-
11
- hdrs = proc { have_header("vm_core.h") and have_header("iseq.h") }
12
-
13
- if !Debase::RubyCoreSource::create_makefile_with_core(hdrs, "blab_trace")
14
- exit(1)
15
- end
@@ -1,86 +0,0 @@
1
- have_header: checking for vm_core.h... -------------------- no
2
-
3
- "clang -o conftest -I/Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0/x86_64-darwin16 -I/Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0/ruby/backward -I/Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0 -I. -I/Users/july/.rbenv/versions/2.6.0/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -pipe conftest.c -L. -L/Users/july/.rbenv/versions/2.6.0/lib -L. -L/Users/july/.rbenv/versions/2.6.0/lib -fstack-protector-strong -L/usr/local/lib -lruby.2.6-static -framework Security -framework Foundation -lpthread -lgmp -ldl -lobjc "
4
- checked program was:
5
- /* begin */
6
- 1: #include "ruby.h"
7
- 2:
8
- 3: int main(int argc, char **argv)
9
- 4: {
10
- 5: return 0;
11
- 6: }
12
- /* end */
13
-
14
- "clang -E -I/Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0/x86_64-darwin16 -I/Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0/ruby/backward -I/Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0 -I. -I/Users/july/.rbenv/versions/2.6.0/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -pipe conftest.c -o conftest.i"
15
- conftest.c:3:10: fatal error: 'vm_core.h' file not found
16
- #include <vm_core.h>
17
- ^~~~~~~~~~~
18
- 1 error generated.
19
- checked program was:
20
- /* begin */
21
- 1: #include "ruby.h"
22
- 2:
23
- 3: #include <vm_core.h>
24
- /* end */
25
-
26
- --------------------
27
-
28
- have_header: checking for vm_core.h... -------------------- no
29
-
30
- "clang -E -I/Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0/x86_64-darwin16 -I/Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0/ruby/backward -I/Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0 -I. -I/Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0/ruby-2.6.0-p0 -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -pipe conftest.c -o conftest.i"
31
- conftest.c:3:10: fatal error: 'vm_core.h' file not found
32
- #include <vm_core.h>
33
- ^~~~~~~~~~~
34
- 1 error generated.
35
- checked program was:
36
- /* begin */
37
- 1: #include "ruby.h"
38
- 2:
39
- 3: #include <vm_core.h>
40
- /* end */
41
-
42
- --------------------
43
-
44
- have_header: checking for vm_core.h... -------------------- yes
45
-
46
- "clang -E -I/Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0/x86_64-darwin16 -I/Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0/ruby/backward -I/Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0 -I. -I/Users/july/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/debase-ruby_core_source-0.10.4/lib/debase/ruby_core_source/ruby-2.6.0-p0 -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -pipe conftest.c -o conftest.i"
47
- In file included from conftest.c:3:
48
- In file included from /Users/july/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/debase-ruby_core_source-0.10.4/lib/debase/ruby_core_source/ruby-2.6.0-p0/vm_core.h:75:
49
- In file included from /Users/july/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/debase-ruby_core_source-0.10.4/lib/debase/ruby_core_source/ruby-2.6.0-p0/method.h:14:
50
- /Users/july/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/debase-ruby_core_source-0.10.4/lib/debase/ruby_core_source/ruby-2.6.0-p0/internal.h:125:10: warning: '__msan_allocated_memory' macro redefined [-Wmacro-redefined]
51
- # define __msan_allocated_memory(x, y)
52
- ^
53
- /Library/Developer/CommandLineTools/usr/lib/clang/9.0.0/include/sanitizer/msan_interface.h:113:9: note: previous definition is here
54
- #define __msan_allocated_memory(data, size)
55
- ^
56
- In file included from conftest.c:3:
57
- In file included from /Users/july/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/debase-ruby_core_source-0.10.4/lib/debase/ruby_core_source/ruby-2.6.0-p0/vm_core.h:75:
58
- In file included from /Users/july/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/debase-ruby_core_source-0.10.4/lib/debase/ruby_core_source/ruby-2.6.0-p0/method.h:14:
59
- /Users/july/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/debase-ruby_core_source-0.10.4/lib/debase/ruby_core_source/ruby-2.6.0-p0/internal.h:127:10: warning: '__msan_unpoison' macro redefined [-Wmacro-redefined]
60
- # define __msan_unpoison(x, y)
61
- ^
62
- /Library/Developer/CommandLineTools/usr/lib/clang/9.0.0/include/sanitizer/msan_interface.h:112:9: note: previous definition is here
63
- #define __msan_unpoison(a, size)
64
- ^
65
- 2 warnings generated.
66
- checked program was:
67
- /* begin */
68
- 1: #include "ruby.h"
69
- 2:
70
- 3: #include <vm_core.h>
71
- /* end */
72
-
73
- --------------------
74
-
75
- have_header: checking for iseq.h... -------------------- yes
76
-
77
- "clang -E -I/Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0/x86_64-darwin16 -I/Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0/ruby/backward -I/Users/july/.rbenv/versions/2.6.0/include/ruby-2.6.0 -I. -I/Users/july/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/debase-ruby_core_source-0.10.4/lib/debase/ruby_core_source/ruby-2.6.0-p0 -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -pipe conftest.c -o conftest.i"
78
- checked program was:
79
- /* begin */
80
- 1: #include "ruby.h"
81
- 2:
82
- 3: #include <iseq.h>
83
- /* end */
84
-
85
- --------------------
86
-