debase 0.0.8 → 0.0.9

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
  SHA1:
3
- metadata.gz: 06e75fc48a88bfcfad884d59e6050959aa4cdb7c
4
- data.tar.gz: af560cc09d27d0576772ff203c3e70c780f25c7c
3
+ metadata.gz: 5e1f349a8be36f5bca030bd34053fd274bba4d4b
4
+ data.tar.gz: 55640ac48553198c7ed8757daa00eed34502b7ee
5
5
  SHA512:
6
- metadata.gz: dba74eaed514dc5e96c5264b09f9dd1b20c3e36ab1d283dd22ef7a621dcf4c0b58f3ef1c48f78db89e243eda997b068d2026f5ef8c0548489dcdb8d5101965f4
7
- data.tar.gz: 92b07150601593a8f34012a3f625cc2739f70978fd38cae398e63295ae7c372d4a3fdb1c7c6c04db29e23bc4c4df6f0f5178386bca2b7668f8422bb3bfb69ca1
6
+ metadata.gz: cbc596bb922eab7aec32817e8f0f0a15625863867f8b3e3dd2dbbd2b19159ad1c238773451c8b6b8e7bc810f505f988ae60037115c96c470336513c7164d5114
7
+ data.tar.gz: dcf31c84ca5ca5cb7d1030aeac41258a5f61bd82c526b8fbb22fbbb9e4610fbb2815f755befbe2e587d0c6bd087e156c9692453cb4c55d37475823ccc83f4fc4
@@ -297,7 +297,9 @@ process_raise_event(VALUE trace_point, void *data)
297
297
  Data_Get_Struct(context_object, debug_context_t, context);
298
298
  if (!check_start_processing(context, rb_thread_current())) return;
299
299
 
300
+ update_stack_size(context);
300
301
  if (catchpoint_hit_count(catchpoints, rb_errinfo(), &exception_name) != Qnil) {
302
+ rb_ensure(start_inspector, context_object, stop_inspector, Qnil);
301
303
  tp = TRACE_POINT;
302
304
  path = rb_tracearg_path(tp);
303
305
  lineno = rb_tracearg_lineno(tp);
data/ext/extconf.rb CHANGED
@@ -1,3 +1,11 @@
1
+ if defined?(RUBY_ENGINE) && 'rbx' == RUBY_ENGINE
2
+ # create dummy Makefile to indicate success
3
+ f = File.open(File.join(File.dirname(__FILE__), "Makefile"), "w")
4
+ f.write("all:\n\techo all\ninstall:\n\techo installed\n")
5
+ f.close
6
+ return
7
+ end
8
+
1
9
  # autodetect ruby headers
2
10
  unless ARGV.any? {|arg| arg.include?('--with-ruby-include') }
3
11
  require 'rbconfig'
data/lib/debase.rb CHANGED
@@ -1,4 +1,8 @@
1
- require "debase_internals"
1
+ if defined?(RUBY_ENGINE) && 'rbx' == RUBY_ENGINE
2
+ require 'debase/rbx'
3
+ else
4
+ require "debase_internals"
5
+ end
2
6
  require "debase/version"
3
7
  require "debase/context"
4
8
 
data/lib/debase/rbx.rb ADDED
@@ -0,0 +1,102 @@
1
+ require 'debase/rbx/breakpoint'
2
+ require 'debase/rbx/context'
3
+ require 'debase/rbx/monkey'
4
+
5
+ module Debase
6
+ class << self
7
+ attr_reader :breakpoints, :current_context
8
+
9
+ def setup_tracepoints
10
+ return nil unless @catchpoints.nil?
11
+ @contexts = {}
12
+ @catchpoints = {}
13
+ @breakpoints = []
14
+ Rubinius::CodeLoader.compiled_hook.add proc { |script|
15
+ @breakpoints.each { | b |
16
+ if (b.source == script.file_path)
17
+ exec, ip = script.compiled_code.locate_line(b.pos)
18
+ if exec
19
+ exec.set_breakpoint ip, b
20
+ end
21
+ end
22
+ }
23
+ }
24
+ spinup_thread
25
+ Thread.current.set_debugger_thread @thread
26
+ self
27
+ end
28
+
29
+ def remove_tracepoints
30
+ end
31
+
32
+ def prepare_context(thread=Thread.current)
33
+ cleanup_contexts
34
+ @contexts[thread] ||= Context.new(thread)
35
+ end
36
+
37
+ def cleanup_contexts
38
+ @contexts.delete_if { |key, value| !key.alive? }
39
+ end
40
+
41
+ def contexts
42
+ @contexts.values
43
+ end
44
+
45
+ def debug_load(file, stop=false, incremental_start=true)
46
+ setup_tracepoints
47
+ prepare_context
48
+ begin
49
+ load file
50
+ nil
51
+ rescue Exception => e
52
+ e
53
+ end
54
+ end
55
+
56
+ def started?
57
+ !@thread.nil?
58
+ end
59
+
60
+ def listen
61
+ channel = nil
62
+ while true
63
+ channel << true if channel
64
+ # Wait for someone to stop
65
+ bp, thread, channel, locs = @local_channel.receive
66
+
67
+ if bp
68
+ context = prepare_context(thread)
69
+ @current_context = context
70
+ context.fill_frame_info(locs)
71
+ context.at_breakpoint(bp)
72
+ context.at_line(locs.first.file, locs.first.line)
73
+ puts "resuming execution"
74
+ context.clear_frame_info
75
+ @current_context = nil
76
+ end
77
+ end
78
+ end
79
+
80
+ def spinup_thread
81
+ return if @thread
82
+
83
+ @local_channel = Rubinius::Channel.new
84
+
85
+ @thread = DebugThread.new do
86
+ begin
87
+ listen
88
+ rescue Exception => e
89
+ puts e
90
+ e.render("Listening")
91
+ end
92
+ end
93
+
94
+ @thread.setup_control!(@local_channel)
95
+ end
96
+ end
97
+
98
+ class DebugThread < Thread
99
+ def set_debugger_thread
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,16 @@
1
+ module Debase
2
+ class Breakpoint
3
+ @@global_id = 1
4
+
5
+ attr_accessor :source, :pos
6
+ attr_reader :id
7
+
8
+ def initialize(file, line, expr=nil)
9
+ @source = file
10
+ @pos = line
11
+ @expr = expr
12
+ @id = @@global_id
13
+ @@global_id = @@global_id + 1
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,58 @@
1
+ require 'debase/rbx/frame'
2
+
3
+ module Debase
4
+ class Context
5
+ @@max_thread_num = 1
6
+ attr_reader :thread, :thnum
7
+
8
+ def initialize(thread)
9
+ @thread = thread
10
+ @thnum = @@max_thread_num
11
+ @@max_thread_num = @@max_thread_num + 1
12
+ end
13
+
14
+ def frame_file(frame=0)
15
+ @frames[frame].file
16
+ end
17
+
18
+ def frame_line(frame=0)
19
+ @frames[frame].line
20
+ end
21
+
22
+ def frame_binding(frame=0)
23
+ @frames[frame].binding
24
+ end
25
+
26
+ def frame_self(frame=0)
27
+ @frames[frame].self
28
+ end
29
+
30
+ def stack_size
31
+ @frames.size
32
+ end
33
+
34
+ def fill_frame_info(locations)
35
+ @frames = []
36
+ locations.each do |loc|
37
+ @frames << Frame.new(loc)
38
+ end
39
+ @frames
40
+ end
41
+
42
+ def clear_frame_info
43
+ @frames = nil
44
+ end
45
+
46
+ def stop_reason
47
+ :breakpoint
48
+ end
49
+
50
+ def ignored?
51
+ thread.is_a? DebugThread
52
+ end
53
+
54
+ def dead?
55
+ !@thread.alive?
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,23 @@
1
+ module Debase
2
+ class Frame
3
+ def initialize(location)
4
+ @location = location
5
+ end
6
+
7
+ def binding
8
+ @binding ||= Binding.setup(@location.variables, @location.method, @location.constant_scope)
9
+ end
10
+
11
+ def line
12
+ @location.line
13
+ end
14
+
15
+ def file
16
+ @location.file
17
+ end
18
+
19
+ def self
20
+ @location.receiver
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,13 @@
1
+ class Object
2
+ # todo: remove me, I'm here only for debugging
3
+ def method_missing(name, *args)
4
+ puts "#{self.class}.#{name}"
5
+ super(name, args)
6
+ end
7
+ end
8
+
9
+ module Rubinius
10
+ class Location
11
+ attr_reader :receiver
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Debase
2
- VERSION = "0.0.8" unless defined? VERSION
2
+ VERSION = "0.0.9" unless defined? VERSION
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Ushakov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-26 00:00:00.000000000 Z
11
+ date: 2013-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debugger-ruby_core_source
@@ -81,6 +81,11 @@ files:
81
81
  - ext/locker.c
82
82
  - lib/debase.rb
83
83
  - lib/debase/context.rb
84
+ - lib/debase/rbx.rb
85
+ - lib/debase/rbx/breakpoint.rb
86
+ - lib/debase/rbx/context.rb
87
+ - lib/debase/rbx/frame.rb
88
+ - lib/debase/rbx/monkey.rb
84
89
  - lib/debase/version.rb
85
90
  - test/example/a/example.rb
86
91
  - test/example/at-exit.rb
@@ -125,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
130
  version: '0'
126
131
  requirements: []
127
132
  rubyforge_project: debase
128
- rubygems_version: 2.0.3
133
+ rubygems_version: 2.1.11
129
134
  signing_key:
130
135
  specification_version: 4
131
136
  summary: debase is a fast implementation of the standard Ruby debugger debug.rb for