ruby-debug-ide 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,7 @@ module Debugger
18
18
  end
19
19
  commands << klass
20
20
  end
21
-
21
+
22
22
  def load_commands
23
23
  dir = File.dirname(__FILE__)
24
24
  Dir[File.join(dir, 'commands', '*')].each do |file|
@@ -42,15 +42,15 @@ module Debugger
42
42
  @options ||= {}
43
43
  end
44
44
  end
45
-
45
+
46
46
  def initialize(state, printer)
47
47
  @state, @printer = state, printer
48
48
  end
49
-
49
+
50
50
  def match(input)
51
51
  @match = regexp.match(input)
52
52
  end
53
-
53
+
54
54
  protected
55
55
 
56
56
  def method_missing(meth, *args, &block)
@@ -60,24 +60,46 @@ module Debugger
60
60
  super
61
61
  end
62
62
  end
63
-
63
+
64
64
  def print(*args)
65
65
  @state.print(*args)
66
66
  end
67
-
67
+
68
68
  def confirm(msg)
69
69
  @state.confirm(msg) == 'y'
70
70
  end
71
-
71
+
72
+ # see Timeout::timeout, the difference is that we must use a DebugThread
73
+ # because every other thread would be halted when the event hook is reached
74
+ # in ruby-debug.c
75
+ def timeout(sec)
76
+ return yield if sec == nil or sec.zero?
77
+ raise ThreadError, "timeout within critical session" if Thread.critical
78
+ begin
79
+ x = Thread.current
80
+ y = DebugThread.start {
81
+ sleep sec
82
+ x.raise StandardError, "Timeout: evaluation took longer than #{sec} seconds." if x.alive?
83
+ }
84
+ yield sec
85
+ ensure
86
+ y.kill if y and y.alive?
87
+ end
88
+ end
89
+
72
90
  def debug_eval(str, b = get_binding)
73
91
  begin
74
- val = eval(str, b)
92
+ max_time = 10
93
+ @printer.print_debug("Evaluating with timeout after %i sec", max_time)
94
+ timeout(max_time) do
95
+ eval(str, b)
96
+ end
75
97
  rescue StandardError, ScriptError => e
76
98
  @printer.print_exception(e, @state.binding)
77
99
  throw :debug_error
78
100
  end
79
101
  end
80
-
102
+
81
103
  def debug_silent_eval(str)
82
104
  begin
83
105
  eval(str, get_binding)
@@ -85,7 +107,7 @@ module Debugger
85
107
  nil
86
108
  end
87
109
  end
88
-
110
+
89
111
  def hbinding(hash)
90
112
  code = hash.keys.map{|k| "#{k} = hash['#{k}']"}.join(';') + ';binding'
91
113
  if obj = @state.context.frame_self(@state.frame_pos)
@@ -95,16 +117,16 @@ module Debugger
95
117
  end
96
118
  end
97
119
  private :hbinding
98
-
120
+
99
121
  def get_binding
100
122
  binding = @state.context.frame_binding(@state.frame_pos)
101
123
  binding || hbinding(@state.context.frame_locals(@state.frame_pos))
102
124
  end
103
-
125
+
104
126
  def line_at(file, line)
105
127
  Debugger.line_at(file, line)
106
128
  end
107
-
129
+
108
130
  def get_context(thnum)
109
131
  Debugger.contexts.find{|c| c.thnum == thnum}
110
132
  end
@@ -7,10 +7,8 @@ module Debugger
7
7
  end
8
8
 
9
9
  def execute
10
- if confirm("Really quit? (y/n) ")
11
- Debugger.save_history if Debugger.respond_to? :save_history
12
- exit! # exit -> exit!: No graceful way to stop threads...
13
- end
10
+ @printer.print_debug("Exiting debugger.")
11
+ exit! # exit -> exit!: No graceful way to stop threads...
14
12
  end
15
13
 
16
14
  class << self
@@ -27,7 +27,6 @@ module Debugger
27
27
  cmd.execute
28
28
  else
29
29
  process_context_commands(input)
30
- #@printer.print_msg "Unknown command"
31
30
  end
32
31
  end
33
32
  end
@@ -53,7 +52,6 @@ module Debugger
53
52
  s.file = file
54
53
  s.line = line
55
54
  s.binding = context.frame_binding(0)
56
- s.display = display
57
55
  s.interface = @interface
58
56
  s.commands = event_cmds
59
57
  end
@@ -98,7 +96,7 @@ module Debugger
98
96
  end
99
97
  class State # :nodoc:
100
98
  attr_accessor :context, :file, :line, :binding
101
- attr_accessor :frame_pos, :previous_line, :display
99
+ attr_accessor :frame_pos, :previous_line
102
100
  attr_accessor :interface, :commands
103
101
 
104
102
  def initialize
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: ruby-debug-ide
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.3
7
- date: 2007-04-30 13:24:43 +02:00
6
+ version: 0.1.4
7
+ date: 2007-05-01 14:07:48 +02:00
8
8
  summary: IDE interface for ruby-debug.
9
9
  require_paths:
10
10
  - lib
@@ -35,11 +35,11 @@ files:
35
35
  - lib/ruby-debug.rb
36
36
  - lib/ruby-debug/commands
37
37
  - lib/ruby-debug/command.rb
38
- - lib/ruby-debug/processor.rb
39
38
  - lib/ruby-debug/event_processor.rb
40
39
  - lib/ruby-debug/interface.rb
41
40
  - lib/ruby-debug/xml_printer.rb
42
41
  - lib/ruby-debug/printers.rb
42
+ - lib/ruby-debug/processor.rb
43
43
  - lib/ruby-debug/commands/load.rb
44
44
  - lib/ruby-debug/commands/control.rb
45
45
  - lib/ruby-debug/commands/breakpoints.rb
@@ -70,5 +70,5 @@ dependencies:
70
70
  requirements:
71
71
  - - "="
72
72
  - !ruby/object:Gem::Version
73
- version: 0.9.2
73
+ version: 0.9.3
74
74
  version: