ruby-debug-ide19 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +75 -0
- data/ChangeLog +465 -0
- data/ChangeLog.archive +1073 -0
- data/MIT-LICENSE +24 -0
- data/Rakefile +110 -0
- data/bin/rdebug-ide +88 -0
- data/ext/mkrf_conf.rb +28 -0
- data/lib/ruby-debug-ide.rb +172 -0
- data/lib/ruby-debug/command.rb +169 -0
- data/lib/ruby-debug/commands/breakpoints.rb +129 -0
- data/lib/ruby-debug/commands/catchpoint.rb +52 -0
- data/lib/ruby-debug/commands/condition.rb +51 -0
- data/lib/ruby-debug/commands/control.rb +129 -0
- data/lib/ruby-debug/commands/enable.rb +203 -0
- data/lib/ruby-debug/commands/eval.rb +64 -0
- data/lib/ruby-debug/commands/frame.rb +155 -0
- data/lib/ruby-debug/commands/inspect.rb +24 -0
- data/lib/ruby-debug/commands/jump.rb +73 -0
- data/lib/ruby-debug/commands/load.rb +18 -0
- data/lib/ruby-debug/commands/stepping.rb +108 -0
- data/lib/ruby-debug/commands/threads.rb +153 -0
- data/lib/ruby-debug/commands/variables.rb +136 -0
- data/lib/ruby-debug/event_processor.rb +74 -0
- data/lib/ruby-debug/helper.rb +33 -0
- data/lib/ruby-debug/interface.rb +39 -0
- data/lib/ruby-debug/printers.rb +2 -0
- data/lib/ruby-debug/processor.rb +152 -0
- data/lib/ruby-debug/xml_printer.rb +268 -0
- data/test/rd_basic_test.rb +10 -0
- data/test/rd_catchpoint_test.rb +20 -0
- data/test/rd_condition_test.rb +11 -0
- data/test/rd_enable_disable_test.rb +43 -0
- data/test/rd_inspect_test.rb +11 -0
- data/test/rd_stepping_breakpoints_test.rb +36 -0
- data/test/rd_test_base.rb +44 -0
- data/test/rd_threads_and_frames_test.rb +11 -0
- data/test/rd_variables_test.rb +11 -0
- data/test/ruby-debug/xml_printer_test.rb +105 -0
- metadata +103 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
module Debugger
|
2
|
+
class EvalCommand < Command # :nodoc:
|
3
|
+
#self.control = true
|
4
|
+
|
5
|
+
def match(input)
|
6
|
+
@input = input
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def regexp
|
11
|
+
/^\s*(p|e(?:val)?)\s+/
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute
|
15
|
+
expr = @match ? @match.post_match : @input
|
16
|
+
binding = @state.context ? get_binding : TOPLEVEL_BINDING
|
17
|
+
print_eval expr, debug_eval(expr, binding).inspect
|
18
|
+
end
|
19
|
+
|
20
|
+
class << self
|
21
|
+
def help_command
|
22
|
+
%w|p eval|
|
23
|
+
end
|
24
|
+
|
25
|
+
def help(cmd)
|
26
|
+
if cmd == 'p'
|
27
|
+
%{
|
28
|
+
p expression\tevaluate expression and print its value
|
29
|
+
}
|
30
|
+
else
|
31
|
+
%{
|
32
|
+
e[val] expression\tevaluate expression and print its value,
|
33
|
+
\t\t\talias for p.
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class PPCommand < Command # :nodoc:
|
41
|
+
def regexp
|
42
|
+
/^\s*pp\s+/
|
43
|
+
end
|
44
|
+
|
45
|
+
def execute
|
46
|
+
exp = @match.post_match
|
47
|
+
out = StringIO.new
|
48
|
+
PP.pp(debug_eval(exp), out) rescue out.puts $!.message
|
49
|
+
print_pp out.string
|
50
|
+
end
|
51
|
+
|
52
|
+
class << self
|
53
|
+
def help_command
|
54
|
+
'pp'
|
55
|
+
end
|
56
|
+
|
57
|
+
def help(cmd)
|
58
|
+
%{
|
59
|
+
pp expression\tevaluate expression and print its value
|
60
|
+
}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
module Debugger
|
2
|
+
|
3
|
+
module FrameFunctions # :nodoc:
|
4
|
+
|
5
|
+
def adjust_frame(frame_pos, absolute)
|
6
|
+
if absolute
|
7
|
+
if frame_pos < 0
|
8
|
+
abs_frame_pos = @state.context.stack_size + frame_pos
|
9
|
+
else
|
10
|
+
abs_frame_pos = frame_pos - 1
|
11
|
+
end
|
12
|
+
else
|
13
|
+
abs_frame_pos = @state.frame_pos + frame_pos
|
14
|
+
end
|
15
|
+
|
16
|
+
if abs_frame_pos >= @state.context.stack_size then
|
17
|
+
print_error "Adjusting would put us beyond the oldest (initial) frame.\n"
|
18
|
+
return
|
19
|
+
elsif abs_frame_pos < 0 then
|
20
|
+
print_error "Adjusting would put us beyond the newest (innermost) frame.\n"
|
21
|
+
return
|
22
|
+
end
|
23
|
+
if @state.frame_pos != abs_frame_pos then
|
24
|
+
@state.previous_line = nil
|
25
|
+
@state.frame_pos = abs_frame_pos
|
26
|
+
end
|
27
|
+
@state.file = @state.context.frame_file(@state.frame_pos)
|
28
|
+
@state.line = @state.context.frame_line(@state.frame_pos)
|
29
|
+
|
30
|
+
print_current_frame(@state.frame_pos)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
class WhereCommand < Command # :nodoc:
|
36
|
+
def regexp
|
37
|
+
/^\s*(?:w(?:here)?|bt|backtrace)$/
|
38
|
+
end
|
39
|
+
|
40
|
+
def execute
|
41
|
+
print_frames(@state.context, @state.frame_pos)
|
42
|
+
end
|
43
|
+
|
44
|
+
class << self
|
45
|
+
def help_command
|
46
|
+
%w|where backtrace|
|
47
|
+
end
|
48
|
+
|
49
|
+
def help(cmd)
|
50
|
+
if cmd == 'where'
|
51
|
+
%{
|
52
|
+
w[here]\tdisplay frames
|
53
|
+
}
|
54
|
+
else
|
55
|
+
%{
|
56
|
+
bt|backtrace\t\talias for where
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
class UpCommand < Command # :nodoc:
|
64
|
+
include FrameFunctions
|
65
|
+
def regexp
|
66
|
+
/^\s* u(?:p)? (?:\s+(.*))? .*$/x
|
67
|
+
end
|
68
|
+
|
69
|
+
def execute
|
70
|
+
unless @match[1]
|
71
|
+
pos = 1
|
72
|
+
else
|
73
|
+
pos = get_int(@match[1], "Up")
|
74
|
+
return unless pos
|
75
|
+
end
|
76
|
+
adjust_frame(pos, false)
|
77
|
+
end
|
78
|
+
|
79
|
+
class << self
|
80
|
+
def help_command
|
81
|
+
'up'
|
82
|
+
end
|
83
|
+
|
84
|
+
def help(cmd)
|
85
|
+
%{
|
86
|
+
up[count]\tmove to higher frame
|
87
|
+
}
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
class DownCommand < Command # :nodoc:
|
93
|
+
include FrameFunctions
|
94
|
+
def regexp
|
95
|
+
/^\s* down (?:\s+(.*))? .*$/x
|
96
|
+
end
|
97
|
+
|
98
|
+
def execute
|
99
|
+
if not @match[1]
|
100
|
+
pos = 1
|
101
|
+
else
|
102
|
+
pos = get_int(@match[1], "Down")
|
103
|
+
return unless pos
|
104
|
+
end
|
105
|
+
adjust_frame(-pos, false)
|
106
|
+
end
|
107
|
+
|
108
|
+
class << self
|
109
|
+
def help_command
|
110
|
+
'down'
|
111
|
+
end
|
112
|
+
|
113
|
+
def help(cmd)
|
114
|
+
%{
|
115
|
+
down[count]\tmove to lower frame
|
116
|
+
}
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
class FrameCommand < Command # :nodoc:
|
122
|
+
include FrameFunctions
|
123
|
+
def regexp
|
124
|
+
/^\s* f(?:rame)? (?:\s+ (.*))? \s*$/x
|
125
|
+
end
|
126
|
+
|
127
|
+
def execute
|
128
|
+
if not @match[1]
|
129
|
+
print "Missing a frame number argument.\n"
|
130
|
+
return
|
131
|
+
else
|
132
|
+
pos = get_int(@match[1], "Frame")
|
133
|
+
return unless pos
|
134
|
+
end
|
135
|
+
adjust_frame(pos, true)
|
136
|
+
end
|
137
|
+
|
138
|
+
class << self
|
139
|
+
def help_command
|
140
|
+
'frame'
|
141
|
+
end
|
142
|
+
|
143
|
+
def help(cmd)
|
144
|
+
%{
|
145
|
+
f[rame] frame-number
|
146
|
+
Move the current frame to the specified frame number.
|
147
|
+
|
148
|
+
A negative number indicates position from the other end. So
|
149
|
+
'frame -1' moves to the oldest frame, and 'frame 0' moves to
|
150
|
+
the newest frame.
|
151
|
+
}
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Debugger
|
2
|
+
|
3
|
+
class InspectCommand < Command
|
4
|
+
# reference inspection results in order to save them from the GC
|
5
|
+
@@references = []
|
6
|
+
def self.reference_result(result)
|
7
|
+
@@references << result
|
8
|
+
end
|
9
|
+
def self.clear_references
|
10
|
+
@@references = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def regexp
|
14
|
+
/^\s*v(?:ar)?\s+inspect\s+/
|
15
|
+
end
|
16
|
+
#
|
17
|
+
def execute
|
18
|
+
obj = debug_eval(@match.post_match)
|
19
|
+
InspectCommand.reference_result(obj)
|
20
|
+
@printer.print_inspect(obj)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Debugger
|
2
|
+
|
3
|
+
# Implements debugger "jump" command
|
4
|
+
class JumpCommand < Command
|
5
|
+
self.allow_in_control = true
|
6
|
+
|
7
|
+
def numeric?(object)
|
8
|
+
true if Float(object) rescue false
|
9
|
+
end
|
10
|
+
|
11
|
+
def regexp
|
12
|
+
/ ^\s*
|
13
|
+
j(?:ump)? \s*
|
14
|
+
(?:\s+(\S+))?\s*
|
15
|
+
(?:\s+(\S+))?\s*
|
16
|
+
$
|
17
|
+
/ix
|
18
|
+
end
|
19
|
+
|
20
|
+
def execute
|
21
|
+
if RUBY_VERSION < "1.9"
|
22
|
+
print_msg "Not implemented"
|
23
|
+
return
|
24
|
+
end
|
25
|
+
if !@match[1]
|
26
|
+
print_msg "\"jump\" must be followed by a line number"
|
27
|
+
return
|
28
|
+
end
|
29
|
+
if !numeric?(@match[1])
|
30
|
+
print_msg "Bad line number: " + @match[1]
|
31
|
+
return
|
32
|
+
end
|
33
|
+
line = @match[1].to_i
|
34
|
+
line = @state.context.frame_line(0) + line if @match[1][0] == '+' or @match[1][0] == '-'
|
35
|
+
if line == @state.context.frame_line(0)
|
36
|
+
return
|
37
|
+
end
|
38
|
+
file = @match[2]
|
39
|
+
file = @state.context.frame_file(file.to_i) if numeric?(file)
|
40
|
+
file = @state.context.frame_file(0) if !file
|
41
|
+
case @state.context.jump(line, file)
|
42
|
+
when 0
|
43
|
+
@state.proceed
|
44
|
+
return
|
45
|
+
when 1
|
46
|
+
print_msg "Not possible to jump from here"
|
47
|
+
when 2
|
48
|
+
print_msg "Couldn't find debugged frame"
|
49
|
+
when 3
|
50
|
+
print_msg "Couldn't find active code at " + file + ":" + line.to_s
|
51
|
+
else
|
52
|
+
print_msg "Unknown error occurred"
|
53
|
+
end
|
54
|
+
@printer.print_at_line(@state.context, @state.context.frame_file, @state.context.frame_line)
|
55
|
+
end
|
56
|
+
|
57
|
+
class << self
|
58
|
+
def help_command
|
59
|
+
%w[jump]
|
60
|
+
end
|
61
|
+
|
62
|
+
def help(cmd)
|
63
|
+
%{
|
64
|
+
j[ump] line\tjump to line number (absolute)
|
65
|
+
j[ump] -line\tjump back to line (relative)
|
66
|
+
j[ump] +line\tjump ahead to line (relative)
|
67
|
+
|
68
|
+
Change the next line of code to be executed.
|
69
|
+
}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Debugger
|
2
|
+
class LoadCommand < Command
|
3
|
+
def regexp
|
4
|
+
/^\s*load\s+/
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute
|
8
|
+
fileName = @match.post_match
|
9
|
+
@printer.print_debug("loading file: %s", fileName)
|
10
|
+
begin
|
11
|
+
load fileName
|
12
|
+
@printer.print_load_result(fileName)
|
13
|
+
rescue Exception => error
|
14
|
+
@printer.print_load_result(fileName, error)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module Debugger
|
2
|
+
class NextCommand < Command # :nodoc:
|
3
|
+
self.need_context = true
|
4
|
+
|
5
|
+
def regexp
|
6
|
+
/^\s*n(?:ext)?([+-])?(?:\s+(\d+))?$/
|
7
|
+
end
|
8
|
+
|
9
|
+
def execute
|
10
|
+
force = @match[1] == '+'
|
11
|
+
steps = @match[2] ? @match[2].to_i : 1
|
12
|
+
@state.context.step_over steps, @state.frame_pos, force
|
13
|
+
@state.proceed
|
14
|
+
end
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def help_command
|
18
|
+
'next'
|
19
|
+
end
|
20
|
+
|
21
|
+
def help(cmd)
|
22
|
+
%{
|
23
|
+
n[ext][+][ nnn]\tstep over once or nnn times,
|
24
|
+
\t\t'+' forces to move to another line
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class StepCommand < Command # :nodoc:
|
31
|
+
self.need_context = true
|
32
|
+
|
33
|
+
def regexp
|
34
|
+
/^\s*s(?:tep)?([+-])?(?:\s+(\d+))?$/
|
35
|
+
end
|
36
|
+
|
37
|
+
def execute
|
38
|
+
force = @match[1] == '+'
|
39
|
+
steps = @match[2] ? @match[2].to_i : 1
|
40
|
+
@state.context.step(steps, force)
|
41
|
+
@state.proceed
|
42
|
+
end
|
43
|
+
|
44
|
+
class << self
|
45
|
+
def help_command
|
46
|
+
'step'
|
47
|
+
end
|
48
|
+
|
49
|
+
def help(cmd)
|
50
|
+
%{
|
51
|
+
s[tep][ nnn]\tstep (into methods) once or nnn times
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class FinishCommand < Command # :nodoc:
|
58
|
+
self.need_context = true
|
59
|
+
|
60
|
+
def regexp
|
61
|
+
/^\s*fin(?:ish)?$/
|
62
|
+
end
|
63
|
+
|
64
|
+
def execute
|
65
|
+
if @state.frame_pos == @state.context.stack_size - 1
|
66
|
+
print_msg "\"finish\" not meaningful in the outermost frame."
|
67
|
+
else
|
68
|
+
@state.context.stop_frame = @state.frame_pos
|
69
|
+
@state.frame_pos = 0
|
70
|
+
@state.proceed
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class << self
|
75
|
+
def help_command
|
76
|
+
'finish'
|
77
|
+
end
|
78
|
+
|
79
|
+
def help(cmd)
|
80
|
+
%{
|
81
|
+
fin[ish]\treturn to outer frame
|
82
|
+
}
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
class ContinueCommand < Command # :nodoc:
|
88
|
+
def regexp
|
89
|
+
/^\s*c(?:ont)?$/
|
90
|
+
end
|
91
|
+
|
92
|
+
def execute
|
93
|
+
@state.proceed
|
94
|
+
end
|
95
|
+
|
96
|
+
class << self
|
97
|
+
def help_command
|
98
|
+
'cont'
|
99
|
+
end
|
100
|
+
|
101
|
+
def help(cmd)
|
102
|
+
%{
|
103
|
+
c[ont]\trun until program ends or hit breakpoint
|
104
|
+
}
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|