Class: DEBUGGER__::DAP_TraceInspector::MultiTracer
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::DEBUGGER__::Tracer
|
|
Instance Chain:
|
|
Inherits: |
DEBUGGER__::Tracer
|
Defined in: | lib/debug/dap_custom/traceInspector.rb |
Class Method Summary
::DEBUGGER__::Tracer
- Inherited
Instance Attribute Summary
Instance Method Summary
- #append(log)
- #call_identifier_str(tp)
- #call_trace_log(tp, return_str: nil, params: nil)
- #line_trace_log(tp)
- #parameters_info(tp)
- #setup
- #skip?(tp) ⇒ Boolean
- #skip_with_pattern?(tp) ⇒ Boolean
::DEBUGGER__::Tracer
- Inherited
#colorize, #description, #disable, #enable, #header, #minfo, #out, #skip?, #skip_with_pattern?, #to_s |
::DEBUGGER__::Color
- Included
#color_pp | See additional method definition at line 50. |
#colored_inspect, | |
#colorize | See additional method definition at line 36. |
#colorize_blue, | |
#colorize_code | See additional method definition at line 79. |
#colorize_cyan, #colorize_dim, #colorize_magenta, | |
#irb_colorize | See additional method definition at line 27. |
#with_inspection_error_guard |
::DEBUGGER__::SkipPathHelper
- Included
Constructor Details
.new(ui, evts, trace_params, max_log_size: nil, **kw) ⇒ MultiTracer
# File 'lib/debug/dap_custom/traceInspector.rb', line 4
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
Instance Attribute Details
#dropped_trace_cnt (rw)
[ GitHub ]# File 'lib/debug/dap_custom/traceInspector.rb', line 19
attr_accessor :dropped_trace_cnt
#log (readonly)
[ GitHub ]# File 'lib/debug/dap_custom/traceInspector.rb', line 20
attr_reader :log
Instance Method Details
#append(log)
[ GitHub ]#call_identifier_str(tp)
[ GitHub ]# File 'lib/debug/dap_custom/traceInspector.rb', line 52
def call_identifier_str tp if tp.defined_class minfo(tp) else "block" end end
#call_trace_log(tp, return_str: nil, params: nil)
[ GitHub ]# File 'lib/debug/dap_custom/traceInspector.rb', line 68
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
#line_trace_log(tp)
[ GitHub ]# File 'lib/debug/dap_custom/traceInspector.rb', line 83
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
#parameters_info(tp)
[ GitHub ]# File 'lib/debug/dap_custom/traceInspector.rb', line 41
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
#setup
[ GitHub ]# File 'lib/debug/dap_custom/traceInspector.rb', line 22
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
#skip?(tp) ⇒ Boolean
# File 'lib/debug/dap_custom/traceInspector.rb', line 94
def skip? tp super || !@evts.include?(tp.event) end
#skip_with_pattern?(tp) ⇒ Boolean
# File 'lib/debug/dap_custom/traceInspector.rb', line 98
def skip_with_pattern?(tp) super && !tp.method_id&.match?(@pattern) end