debug 1.0.0.rc2 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -153,8 +153,8 @@ module DEBUGGER__
153
153
  when 'setFunctionBreakpoints'
154
154
  send_response req
155
155
  when 'setExceptionBreakpoints'
156
- filters = args.dig('filterOptions').map{|bp_info|
157
- case bp_info.dig('filterId')
156
+ process_filter = ->(filter_id) {
157
+ case filter_id
158
158
  when 'any'
159
159
  bp = SESSION.add_catch_breakpoint 'Exception'
160
160
  when 'RuntimeError'
@@ -163,17 +163,26 @@ module DEBUGGER__
163
163
  bp = nil
164
164
  end
165
165
  {
166
- verifiled: bp ? true : false,
166
+ verified: bp ? true : false,
167
167
  message: bp.inspect,
168
168
  }
169
169
  }
170
+
171
+ filters = args.fetch('filters').map {|filter_id|
172
+ process_filter.call(filter_id)
173
+ }
174
+
175
+ filters += args.fetch('filterOptions', {}).map{|bp_info|
176
+ process_filter.call(bp_info.dig('filterId'))
177
+ }
178
+
170
179
  send_response req, breakpoints: filters
171
180
  when 'configurationDone'
172
181
  send_response req
173
182
  @q_msg << 'continue'
174
183
  when 'attach'
175
184
  send_response req
176
- Process.kill(:SIGINT, Process.pid)
185
+ Process.kill(:SIGURG, Process.pid)
177
186
  when 'disconnect'
178
187
  send_response req
179
188
  @q_msg << 'continue'
@@ -196,7 +205,7 @@ module DEBUGGER__
196
205
  exit
197
206
  when 'pause'
198
207
  send_response req
199
- Process.kill(:SIGINT, Process.pid)
208
+ Process.kill(:SIGURG, Process.pid)
200
209
  when 'reverseContinue'
201
210
  send_response req,
202
211
  success: false, message: 'cancelled',
@@ -247,7 +256,7 @@ module DEBUGGER__
247
256
  def event type, *args
248
257
  case type
249
258
  when :suspend_bp
250
- _i, bp = *args
259
+ _i, bp, tid = *args
251
260
  if bp.kind_of?(CatchBreakpoint)
252
261
  reason = 'exception'
253
262
  text = bp.description
@@ -259,24 +268,26 @@ module DEBUGGER__
259
268
  send_event 'stopped', reason: reason,
260
269
  description: text,
261
270
  text: text,
262
- threadId: 1,
271
+ threadId: tid,
263
272
  allThreadsStopped: true
264
273
  when :suspend_trap
274
+ _sig, tid = *args
265
275
  send_event 'stopped', reason: 'pause',
266
- threadId: 1,
276
+ threadId: tid,
267
277
  allThreadsStopped: true
268
278
  when :suspended
279
+ tid, = *args
269
280
  send_event 'stopped', reason: 'step',
270
- threadId: 1,
281
+ threadId: tid,
271
282
  allThreadsStopped: true
272
283
  end
273
284
  end
274
285
  end
275
286
 
276
287
  class Session
277
- def find_tc id
288
+ def find_waiting_tc id
278
289
  @th_clients.each{|th, tc|
279
- return tc if tc.id == id
290
+ return tc if tc.id == id && tc.waiting?
280
291
  }
281
292
  return nil
282
293
  end
@@ -297,7 +308,7 @@ module DEBUGGER__
297
308
 
298
309
  when 'stackTrace'
299
310
  tid = req.dig('arguments', 'threadId')
300
- if tc = find_tc(tid)
311
+ if tc = find_waiting_tc(tid)
301
312
  tc << [:dap, :backtrace, req]
302
313
  else
303
314
  fail_response req
@@ -306,7 +317,7 @@ module DEBUGGER__
306
317
  frame_id = req.dig('arguments', 'frameId')
307
318
  if @frame_map[frame_id]
308
319
  tid, fid = @frame_map[frame_id]
309
- if tc = find_tc(tid)
320
+ if tc = find_waiting_tc(tid)
310
321
  tc << [:dap, :scopes, req, fid]
311
322
  else
312
323
  fail_response req
@@ -339,7 +350,7 @@ module DEBUGGER__
339
350
  frame_id = ref[1]
340
351
  tid, fid = @frame_map[frame_id]
341
352
 
342
- if tc = find_tc(tid)
353
+ if tc = find_waiting_tc(tid)
343
354
  tc << [:dap, :scope, req, fid]
344
355
  else
345
356
  fail_response req
@@ -348,13 +359,13 @@ module DEBUGGER__
348
359
  when :variable
349
360
  tid, vid = ref[1], ref[2]
350
361
 
351
- if tc = find_tc(tid)
362
+ if tc = find_waiting_tc(tid)
352
363
  tc << [:dap, :variable, req, vid]
353
364
  else
354
365
  fail_response req
355
366
  end
356
367
  else
357
- raise "Uknown type: #{ref.inspect}"
368
+ raise "Unknown type: #{ref.inspect}"
358
369
  end
359
370
  else
360
371
  fail_response req
@@ -364,7 +375,7 @@ module DEBUGGER__
364
375
  if @frame_map[frame_id]
365
376
  tid, fid = @frame_map[frame_id]
366
377
  expr = req.dig('arguments', 'expression')
367
- if tc = find_tc(tid)
378
+ if tc = find_waiting_tc(tid)
368
379
  tc << [:dap, :evaluate, req, fid, expr]
369
380
  else
370
381
  fail_response req
@@ -471,7 +482,7 @@ module DEBUGGER__
471
482
  fid = args.shift
472
483
  frame = @target_frames[fid]
473
484
 
474
- lnum =
485
+ lnum =
475
486
  if frame.binding
476
487
  frame.binding.local_variables.size
477
488
  elsif vars = frame.local_variables
@@ -580,7 +591,7 @@ module DEBUGGER__
580
591
  end
581
592
  event! :dap_result, :evaluate, req, tid: self.id, **evaluate_result(result)
582
593
  else
583
- raise "Unkown req: #{args.inspect}"
594
+ raise "Unknown req: #{args.inspect}"
584
595
  end
585
596
  end
586
597