class DEBUGGER__::DAP_TraceInspector::MultiTracer
def append log
def append log if @log.size >= @max_log_size @dropped_trace_cnt += 1 @log.shift end @log << log end
def call_identifier_str tp
def call_identifier_str tp if tp.defined_class minfo(tp) else "block" end end
def call_trace_log tp, return_str: nil, params: nil
def call_trace_log tp, return_str: nil, params: nil log = { depth: DEBUGGER__.frame_depth, name: call_identifier_str(tp), threadId: Thread.current.instance_variable_get(:@__thread_client_id), location: { path: tp.path, line: tp.lineno } } log[:returnValue] = return_str if return_str log[:parameters] = params if params && params.size > 0 log end
def initialize ui, evts, trace_params, max_log_size: nil, **kw
def initialize ui, evts, trace_params, max_log_size: nil, **kw @evts = evts @log = [] @trace_params = trace_params if max_log_size @max_log_size = max_log_size else @max_log_size = 50000 end @dropped_trace_cnt = 0 super(ui, **kw) @type = 'multi' @name = 'TraceInspector' end
def line_trace_log tp
def line_trace_log tp { depth: DEBUGGER__.frame_depth, threadId: Thread.current.instance_variable_get(:@__thread_client_id), location: { path: tp.path, line: tp.lineno } } end
def parameters_info tp
def parameters_info tp b = tp.binding tp.parameters.map{|_type, name| begin { name: name, value: DEBUGGER__.safe_inspect(b.local_variable_get(name), short: true, max_length: 4096) } rescue NameError, TypeError nil end }.compact end
def setup
def setup @tracer = TracePoint.new(*@evts){|tp| next if skip?(tp) case tp.event when :call, :c_call, :b_call if @trace_params params = parameters_info tp end append(call_trace_log(tp, params: params)) when :return, :c_return, :b_return return_str = DEBUGGER__.safe_inspect(tp.return_value, short: true, max_length: 4096) append(call_trace_log(tp, return_str: return_str)) when :line append(line_trace_log(tp)) end } end
def skip? tp
def skip? tp super || !@evts.include?(tp.event) end
def skip_with_pattern?(tp)
def skip_with_pattern?(tp) super && !tp.method_id&.match?(@pattern) end