Module: DEBUGGER__::DAP_TraceInspector::Custom_ThreadClient

Defined in:
lib/debug/dap_custom/traceInspector.rb

Instance Method Summary collapse

Instance Method Details

#custom_dap_request_rdbgTraceInspector(req) ⇒ Object



276
277
278
279
280
281
282
283
284
# File 'lib/debug/dap_custom/traceInspector.rb', line 276

def custom_dap_request_rdbgTraceInspector(req)
  cmd = req.dig('arguments', 'command')
  case cmd
  when 'record'
    process_record_cmd(req)
  else
    raise "Unknown command #{cmd}"
  end
end

#process_record_cmd(req) ⇒ Object



286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/debug/dap_custom/traceInspector.rb', line 286

def process_record_cmd(req)
  cmd = req.dig('arguments', 'subCommand')
  case cmd
  when 'enable'
    size = req.dig('arguments', 'maxLogSize')
    @recorder = Custom_Recorder.new max_log_size: size
    @recorder.enable
    event! :protocol_result, :rdbgTraceInspector, req
  when 'disable'
    if @recorder&.enabled?
      @recorder.disable
    end
    @recorder = nil
    event! :protocol_result, :rdbgTraceInspector, req
  when 'collect'
    logs = []
    log_index = nil
    trace_cnt = 0
    unless @recorder.nil?
      log_index = @recorder.log_index
      @recorder.log.each{|frames|
        crt_frame = frames[0]
        log = {
          name: crt_frame.name,
          location: {
            path: crt_frame.location.path,
            line: crt_frame.location.lineno,
          },
          depth: crt_frame.frame_depth
        }
        if params = crt_frame.iseq_parameters_info
          log[:parameters] = params
        end
        if return_str = crt_frame.return_str
          log[:returnValue] = return_str
        end
        logs << log
      }
      trace_cnt = @recorder.dropped_trace_cnt
      @recorder.dropped_trace_cnt = 0
    end
    event! :protocol_result, :rdbgTraceInspector, req, logs: logs, stoppedIndex: log_index, dropped_trace_cnt: trace_cnt
  else
    raise "Unknown command #{cmd}"
  end
end