ruby-debug-ide 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +0 -0
- data/bin/rdebug-ide +74 -0
- data/lib/ruby-debug.rb +128 -0
- data/lib/ruby-debug/command.rb +114 -0
- data/lib/ruby-debug/commands/breakpoints.rb +126 -0
- data/lib/ruby-debug/commands/catchpoint.rb +40 -0
- data/lib/ruby-debug/commands/control.rb +127 -0
- data/lib/ruby-debug/commands/eval.rb +64 -0
- data/lib/ruby-debug/commands/frame.rb +161 -0
- data/lib/ruby-debug/commands/inspect.rb +24 -0
- data/lib/ruby-debug/commands/load.rb +18 -0
- data/lib/ruby-debug/commands/stepping.rb +105 -0
- data/lib/ruby-debug/commands/threads.rb +153 -0
- data/lib/ruby-debug/commands/variables.rb +123 -0
- data/lib/ruby-debug/event_processor.rb +45 -0
- data/lib/ruby-debug/interface.rb +118 -0
- data/lib/ruby-debug/printers.rb +2 -0
- data/lib/ruby-debug/processor.rb +155 -0
- data/lib/ruby-debug/xml_printer.rb +237 -0
- metadata +74 -0
@@ -0,0 +1,237 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
|
4
|
+
module Debugger
|
5
|
+
class XmlPrinter # :nodoc:
|
6
|
+
attr_accessor :interface
|
7
|
+
|
8
|
+
def initialize(interface)
|
9
|
+
@interface = interface
|
10
|
+
end
|
11
|
+
|
12
|
+
def print_msg(*args)
|
13
|
+
msg, *args = args
|
14
|
+
xml_message = CGI.escapeHTML(msg % args)
|
15
|
+
print "<message>#{xml_message}</message>\n"
|
16
|
+
end
|
17
|
+
|
18
|
+
def print_error(*args)
|
19
|
+
print_element("error") do
|
20
|
+
msg, *args = args
|
21
|
+
print CGI.escapeHTML(msg % args)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def print_debug(*args)
|
26
|
+
if Debugger.is_debug
|
27
|
+
$stdout.printf(*args)
|
28
|
+
$stdout.printf("\n")
|
29
|
+
$stdout.flush
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def print_frames(context, cur_idx)
|
34
|
+
print_element("frames") do
|
35
|
+
(0...context.stack_size).each do |idx|
|
36
|
+
print_frame(context, idx, cur_idx)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def print_current_frame(context, frame_pos)
|
42
|
+
print_debug "Selected frame no #{frame_pos}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def print_frame(context, idx, cur_idx)
|
46
|
+
print "<frame no=\"%s\" file=\"%s\" line=\"%s\" #{'current="true" ' if idx == cur_idx}/>\n",
|
47
|
+
idx, context.frame_file(idx), context.frame_line(idx)
|
48
|
+
end
|
49
|
+
|
50
|
+
def print_contexts(contexts)
|
51
|
+
print_element("threads") do
|
52
|
+
contexts.each do |c|
|
53
|
+
print_context(c) unless c.ignored?
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def print_context(context)
|
59
|
+
current = 'current="yes"' if context.thread == Thread.current
|
60
|
+
print "<thread id=\"%s\" status=\"%s\" #{current}/>\n", context.thnum, context.thread.status
|
61
|
+
end
|
62
|
+
|
63
|
+
def print_variables(vars, kind)
|
64
|
+
print_element("variables") do
|
65
|
+
# print self at top position
|
66
|
+
print_variable('self', yield('self'), kind) if vars.include?('self')
|
67
|
+
vars.sort.each do |v|
|
68
|
+
print_variable(v, yield(v), kind) unless v == 'self'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def print_array(array)
|
74
|
+
print_element("variables") do
|
75
|
+
index = 0
|
76
|
+
array.each { |e|
|
77
|
+
print_variable('[' + index.to_s + ']', e, 'instance')
|
78
|
+
index += 1
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def print_hash(hash)
|
84
|
+
print_element("variables") do
|
85
|
+
hash.keys.each { | k |
|
86
|
+
if k.class.name == "String"
|
87
|
+
name = '\'' + k + '\''
|
88
|
+
else
|
89
|
+
name = k.to_s
|
90
|
+
end
|
91
|
+
print_variable(name, hash[k], 'instance')
|
92
|
+
}
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def print_variable(name, value, kind)
|
97
|
+
if value == nil then
|
98
|
+
print("<variable name=\"%s\" kind=\"%s\"/>\n", CGI.escapeHTML(name), kind)
|
99
|
+
return
|
100
|
+
end
|
101
|
+
if Array === value || Hash === value
|
102
|
+
has_children = !value.empty?
|
103
|
+
unless has_children
|
104
|
+
value_str = "Empty #{value.class}"
|
105
|
+
else
|
106
|
+
value_str = "#{value.class} (#{value.size} element(s))"
|
107
|
+
end
|
108
|
+
else
|
109
|
+
has_children = !value.instance_variables.empty? || !value.class.class_variables.empty?
|
110
|
+
value_str = value.to_s
|
111
|
+
if value_str =~ /^\"(.*)"$/
|
112
|
+
value_str = $1
|
113
|
+
end
|
114
|
+
end
|
115
|
+
print("<variable name=\"%s\" kind=\"%s\" value=\"%s\" type=\"%s\" hasChildren=\"%s\" objectId=\"%#+x\"/>\n",
|
116
|
+
CGI.escapeHTML(name), kind, CGI.escapeHTML(value_str), value.class, has_children, value.object_id)
|
117
|
+
end
|
118
|
+
|
119
|
+
def print_breakpoints(breakpoints)
|
120
|
+
print_element 'breakpoints' do
|
121
|
+
breakpoints.sort_by{|b| b.id }.each do |b|
|
122
|
+
print "<breakpoint n=\"%d\" file=\"%s\" line=\"%s\" />\n", b.id, b.source, b.pos.to_s
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def print_breakpoint_added(b)
|
128
|
+
print "<breakpointAdded no=\"%s\" location=\"%s:%s\"/>", b.id, b.source, b.pos
|
129
|
+
end
|
130
|
+
|
131
|
+
def print_breakpoint_deleted(b)
|
132
|
+
print "<breakpointDeleted no=\"%s\"/>", b.id
|
133
|
+
end
|
134
|
+
|
135
|
+
def print_expressions(exps)
|
136
|
+
print_element "expressions" do
|
137
|
+
exps.each_with_index do |(exp, value), idx|
|
138
|
+
print_expression(exp, value, idx+1)
|
139
|
+
end
|
140
|
+
end unless exps.empty?
|
141
|
+
end
|
142
|
+
|
143
|
+
def print_expression(exp, value, idx)
|
144
|
+
print "<dispay name=\"%s\" value=\"%s\" no=\"%d\" />\n", exp, value, idx
|
145
|
+
end
|
146
|
+
|
147
|
+
def print_eval(exp, value)
|
148
|
+
print "<eval expression=\"%s\" value=\"%s\" />\n", CGI.escapeHTML(exp), value
|
149
|
+
end
|
150
|
+
|
151
|
+
def print_pp(exp, value)
|
152
|
+
print value
|
153
|
+
end
|
154
|
+
|
155
|
+
def print_list(b, e, file, line)
|
156
|
+
print "[%d, %d] in %s\n", b, e, file
|
157
|
+
if lines = Debugger.source_for(file)
|
158
|
+
n = 0
|
159
|
+
b.upto(e) do |n|
|
160
|
+
if n > 0 && lines[n-1]
|
161
|
+
if n == line
|
162
|
+
print "=> %d %s\n", n, lines[n-1].chomp
|
163
|
+
else
|
164
|
+
print " %d %s\n", n, lines[n-1].chomp
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
else
|
169
|
+
print "No sourcefile available for %s\n", file
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def print_methods(methods)
|
174
|
+
print_element "methods" do
|
175
|
+
methods.each do |method|
|
176
|
+
print "<method name=\"%s\" />\n", method
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
# Events
|
182
|
+
|
183
|
+
def print_breakpoint(n, breakpoint)
|
184
|
+
print("<breakpoint file=\"%s\" line=\"%s\" threadId=\"%d\"/>\n",
|
185
|
+
breakpoint.source, breakpoint.pos, Debugger.current_context.thnum)
|
186
|
+
end
|
187
|
+
|
188
|
+
def print_catchpoint(exception)
|
189
|
+
context = Debugger.current_context
|
190
|
+
print("<exception file=\"%s\" line=\"%s\" type=\"%s\" message=\"%s\" threadId=\"%d\"/>\n",
|
191
|
+
context.frame_file(0), context.frame_line(0), exception.class, CGI.escapeHTML(exception.to_s), context.thnum)
|
192
|
+
end
|
193
|
+
|
194
|
+
def print_trace(context, file, line)
|
195
|
+
print "<trace file=\"%s\" line=\"%s\" threadId=\"%d\" />\n", file, line, context.thnum
|
196
|
+
end
|
197
|
+
|
198
|
+
def print_at_line(file, line)
|
199
|
+
print "<suspended file=\"%s\" line=\"%s\" threadId=\"%d\" frames=\"%d\"/>\n",
|
200
|
+
file, line, Debugger.current_context.thnum, Debugger.current_context.stack_size
|
201
|
+
end
|
202
|
+
|
203
|
+
def print_exception(exception, binding)
|
204
|
+
print "<processingException type=\"%s\" message=\"%s\"/>\n",
|
205
|
+
exception.class, CGI.escapeHTML(exception.to_s)
|
206
|
+
end
|
207
|
+
|
208
|
+
def print_inspect(eval_result)
|
209
|
+
print_element("variables") do
|
210
|
+
print_variable("eval_result", eval_result, 'locale')
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def print_load_result(file, exception=nil)
|
215
|
+
if exception then
|
216
|
+
print("<loadResult file=\"%s\" exceptionType=\"%s\" exceptionMessage=\"%s\"/>", file, exception.class, CGI.escapeHTML(exception.to_s))
|
217
|
+
else
|
218
|
+
print("<loadResult file=\"%s\" status=\"OK\"/>", file)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
private
|
222
|
+
|
223
|
+
def print(*params)
|
224
|
+
print_debug(*params)
|
225
|
+
@interface.print(*params)
|
226
|
+
end
|
227
|
+
|
228
|
+
def print_element(name)
|
229
|
+
print("<#{name}>\n")
|
230
|
+
begin
|
231
|
+
yield
|
232
|
+
ensure
|
233
|
+
print("</#{name}>\n")
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: ruby-debug-ide
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.1.2
|
7
|
+
date: 2007-04-12 16:06:05 +02:00
|
8
|
+
summary: IDE interface for ruby-debug.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: rubyeclipse-dev-list@sourceforge.net
|
12
|
+
homepage: http://rubyforge.org/projects/ruby-commons/
|
13
|
+
rubyforge_project: ruby-debug-commons
|
14
|
+
description: An interface which glues ruby-debug to IDEs like Eclipse (RDT) and NetBeans.
|
15
|
+
autorequire: ruby-debug-base
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.8.2
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Markus Barchfeld, Martin Krauskopf
|
31
|
+
files:
|
32
|
+
- README
|
33
|
+
- bin/rdebug-ide
|
34
|
+
- lib/ruby-debug
|
35
|
+
- lib/ruby-debug.rb
|
36
|
+
- lib/ruby-debug/commands
|
37
|
+
- lib/ruby-debug/command.rb
|
38
|
+
- lib/ruby-debug/processor.rb
|
39
|
+
- lib/ruby-debug/event_processor.rb
|
40
|
+
- lib/ruby-debug/interface.rb
|
41
|
+
- lib/ruby-debug/xml_printer.rb
|
42
|
+
- lib/ruby-debug/printers.rb
|
43
|
+
- lib/ruby-debug/commands/load.rb
|
44
|
+
- lib/ruby-debug/commands/control.rb
|
45
|
+
- lib/ruby-debug/commands/breakpoints.rb
|
46
|
+
- lib/ruby-debug/commands/inspect.rb
|
47
|
+
- lib/ruby-debug/commands/eval.rb
|
48
|
+
- lib/ruby-debug/commands/variables.rb
|
49
|
+
- lib/ruby-debug/commands/stepping.rb
|
50
|
+
- lib/ruby-debug/commands/frame.rb
|
51
|
+
- lib/ruby-debug/commands/threads.rb
|
52
|
+
- lib/ruby-debug/commands/catchpoint.rb
|
53
|
+
test_files: []
|
54
|
+
|
55
|
+
rdoc_options: []
|
56
|
+
|
57
|
+
extra_rdoc_files: []
|
58
|
+
|
59
|
+
executables:
|
60
|
+
- rdebug-ide
|
61
|
+
extensions: []
|
62
|
+
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
dependencies:
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: ruby-debug-base
|
68
|
+
version_requirement:
|
69
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 0.9.2
|
74
|
+
version:
|