rhomobile-debug 1.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/CHANGELOG +5 -1
  2. data/lib/debugger.rb +57 -9
  3. metadata +4 -3
data/CHANGELOG CHANGED
@@ -1,2 +1,6 @@
1
- ## 1.0
1
+ ## 1.0.1
2
+ * Fix issue with Windows 7 and Ruby 1.8.7
3
+ * Add support for RhoSync debug
4
+
5
+ ## 1.0.0
2
6
  * RhoStudio customization to support debugger
data/lib/debugger.rb CHANGED
@@ -13,6 +13,8 @@ def debug_read_cmd(io,wait)
13
13
  cmd = io.read_nonblock(4096)
14
14
  $_cmd << cmd if cmd !~ /^\s*$/
15
15
  end
16
+
17
+ #$_s.write("get data from front end" + $_cmd.to_s + "\n")
16
18
  rescue
17
19
  # puts $!.inspect
18
20
  end
@@ -35,6 +37,8 @@ def execute_cmd(cmd, advanced)
35
37
  end
36
38
 
37
39
  def get_variables(scope)
40
+ #$_s.write("get_variables start\n")
41
+
38
42
  if (scope =~ /^GVARS/)
39
43
  cmd = "global_variables"
40
44
  prefix = ""
@@ -66,6 +70,7 @@ def get_variables(scope)
66
70
  begin
67
71
  result = eval(v,$_binding).inspect
68
72
  rescue Exception => exc
73
+ $_s.write("get var exception\n")
69
74
  result = "#{$!}".inspect
70
75
  end
71
76
  $_s.write("V:#{vartype}:#{v}:#{result}\n")
@@ -81,9 +86,12 @@ def log_command(cmd)
81
86
  end
82
87
 
83
88
  def debug_handle_cmd(inline)
89
+ #$_s.write("start of debug_handle_cmd wait=" + inline.to_s + "\n")
90
+
84
91
  cmd = $_cmd.match(/^([^\n\r]*)([\n\r]+|$)/)[0]
85
92
  processed = false
86
93
  wait = inline
94
+
87
95
  if cmd != ""
88
96
  if cmd =~/^CONNECTED/
89
97
  log_command(cmd)
@@ -117,6 +125,7 @@ def debug_handle_cmd(inline)
117
125
  puts "[Debugger] Breakpoints disabled"
118
126
  processed = true
119
127
  elsif inline and (cmd =~ /^STEPOVER/)
128
+ $_s.write("STEPOVER start\n")
120
129
  log_command(cmd)
121
130
  $_step = 2
122
131
  $_step_level = $_call_stack
@@ -168,9 +177,11 @@ def debug_handle_cmd(inline)
168
177
  elsif inline and (cmd =~ /^EVL?:/)
169
178
  log_command(cmd)
170
179
  processed = true
180
+ puts "[Debugger] Calc evaluation..."
171
181
  execute_cmd cmd.sub(/^EVL?:/,""), (cmd =~ /^EVL:/ ? true : false)
172
- elsif inline and (cmd =~ /^[GLCI]VARS/)
182
+ elsif inline and (cmd =~ /^[GLCI]VARS/)
173
183
  log_command(cmd)
184
+ puts "[Debugger] Get variables..."
174
185
  get_variables cmd
175
186
  processed = true
176
187
  elsif inline
@@ -179,10 +190,14 @@ def debug_handle_cmd(inline)
179
190
  processed = true
180
191
  end
181
192
  end
193
+
182
194
  if processed
183
195
  $_cmd = $_cmd.sub(/^([^\n\r]*)([\n\r]+(.*)|)$/, "\\3")
184
196
  $_wait = wait if inline
185
197
  end
198
+
199
+ #$_s.write("end of debug_handle_cmd wait=" + $_wait.to_s + "cmd=" + cmd + "\n")
200
+
186
201
  processed
187
202
  end
188
203
 
@@ -192,15 +207,24 @@ $_tracefunc = lambda{|event, file, line, id, bind, classname|
192
207
  $_classname = classname;
193
208
  $_methodname = id;
194
209
  file = file.to_s.gsub('\\', '/')
210
+
195
211
  if file[0, $_app_path.length] == $_app_path
212
+
196
213
  if event =~ /^line/
197
214
 
198
215
  unhandled = true
199
216
  step_stop = ($_step > 0) and (($_step_level < 0) or ($_call_stack <= $_step_level))
217
+
218
+ a = step_stop.to_s
219
+ #$_s.write('[Debugger][2] file = ' + file.to_s + ' step = ' + a.to_s + "\n")
220
+
200
221
  if (step_stop or ($_breakpoints_enabled and (not $_breakpoint.empty?)))
201
222
  filename = file[$_app_path.length, file.length-$_app_path.length]
223
+
202
224
  ln = line.to_i.to_s
203
225
  if (step_stop or ($_breakpoints_enabled and ($_breakpoint.has_key?(filename + ':' + ln))))
226
+ #$_s.write('[Debugger][3] step = ' + file.to_s + ' line = ' + line.to_s + "\n")
227
+
204
228
  fn = filename.gsub(/:/, '|')
205
229
  cl = classname.to_s.gsub(/:/,'#')
206
230
  $_s.write((step_stop ? DEBUGGER_STEP_TYPE[$_step-1] : "BP") + ":#{fn}:#{ln}:#{cl}:#{id}\n")
@@ -208,14 +232,25 @@ $_tracefunc = lambda{|event, file, line, id, bind, classname|
208
232
  $_step = 0
209
233
  $_step_level = -1
210
234
 
235
+ #$_s.write("start waiting\n")
236
+
237
+ puts ">> " + ENV["APP_TYPE"].to_s
238
+
211
239
  $_wait = true
212
240
  while $_wait
213
241
  while debug_handle_cmd(true) do end
214
- if System::get_property('main_window_closed')
215
- $_wait = false
242
+
243
+ if ENV["APP_TYPE"] == "rhodes"
244
+ if System::get_property('main_window_closed')
245
+ $_wait = false
246
+ end
216
247
  end
217
- sleep if $_wait
248
+
249
+ sleep(0.1) if $_wait
218
250
  end
251
+
252
+ #$_s.write("end waiting\n")
253
+
219
254
  unhandled = false
220
255
  end
221
256
  end
@@ -242,13 +277,22 @@ $_s = nil
242
277
 
243
278
  begin
244
279
  puts "[Debugger] Opening connection"
245
- debug_host = (Rho::RhoConfig.debug_host.nil? or Rho::RhoConfig.debug_host == "") ? '127.0.0.1' : Rho::RhoConfig.debug_host
246
- debug_port = (Rho::RhoConfig.debug_port.nil? or Rho::RhoConfig.debug_port == "") ? 9000 : Rho::RhoConfig.debug_port
280
+ debug_host_env = ENV['RHOHOST']
281
+ debug_port_env = ENV['RHOPORT']
282
+ debug_path_env = ENV['ROOT_PATH']
283
+
284
+ debug_host = (debug_host_env.nil? or debug_host_env == "") ? '127.0.0.1' : debug_host_env
285
+ debug_port = (debug_port_env.nil? or debug_port_env == "") ? 9000 : debug_port_env
286
+
287
+ puts "host=" + debug_host_env.to_s
288
+ puts "port=" + debug_port_env.to_s
289
+ puts "path=" + debug_path_env.to_s
290
+
247
291
  $_s = timeout(30) { TCPSocket.open(debug_host, debug_port) }
248
292
 
249
293
  puts "[Debugger] Connected: " + $_s.to_s
250
- $_s.write("CONNECT\n")
251
-
294
+ $_s.write("CONNECT\nHOST=" + debug_host.to_s + "\nPORT=" + debug_port.to_s + "\n")
295
+
252
296
  $_breakpoint = Hash.new
253
297
  $_breakpoints_enabled = true
254
298
  $_step = 0
@@ -256,7 +300,10 @@ begin
256
300
  $_call_stack = 0
257
301
  $_resumed = false
258
302
  $_cmd = ""
259
- $_app_path = File.join(Rho::RhoApplication::get_base_app_path(), 'app/').gsub('\\', '/')
303
+ $_app_path = ""
304
+
305
+ $_app_path = (debug_path_env.nil? or debug_path_env == "") ? "" : debug_path_env
306
+ $_s.write("DEBUG PATH=" + $_app_path.to_s + "\n")
260
307
 
261
308
  at_exit {
262
309
  $_s.write("QUIT\n") if (not $_s.nil?)
@@ -269,6 +316,7 @@ begin
269
316
  debug_read_cmd($_s,true)
270
317
  while debug_handle_cmd(false) do end
271
318
  if ($_cmd !~ /^\s*$/) and (Thread.main.stop?)
319
+ $_s.write("[manage thread] set wait = true\n")
272
320
  $_wait = true
273
321
  Thread.main.wakeup
274
322
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhomobile-debug
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- version: "1.0"
9
+ - 1
10
+ version: 1.0.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Rhomobile
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-06-30 00:00:00 -07:00
18
+ date: 2011-07-04 00:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies: []
20
21