lib/diver_down/trace/session.rb in diver_down-0.0.1.alpha16 vs lib/diver_down/trace/session.rb in diver_down-0.0.1.alpha17
- old
+ new
@@ -36,17 +36,19 @@
end
private
def build_trace_point
- call_stack = DiverDown::Trace::CallStack.new
+ call_stacks = {}
TracePoint.new(*DiverDown::Trace::Tracer.trace_events) do |tp|
# Skip the trace of the library itself
next if tp.path&.start_with?(DiverDown::LIB_DIR)
next if TracePoint == tp.defined_class
+ call_stack = call_stacks[Thread.current] ||= DiverDown::Trace::CallStack.new
+
case tp.event
when :b_call
call_stack.push
when :b_return
call_stack.pop
@@ -62,12 +64,15 @@
unless mod
call_stack.push
next
end
- if !@ignored_method_ids.nil? && @ignored_method_ids.ignored?(mod, DiverDown::Helper.module?(tp.self), tp.method_id)
- # If this method is ignored, the call stack is ignored until the method returns.
- call_stack.push(ignored: true)
+ ignored = @ignored_method_ids.ignored(mod, DiverDown::Helper.module?(tp.self), tp.method_id) if @ignored_method_ids
+
+ if ignored
+ # If ignored is :all, the call stack is ignored until the method returns.
+ # If ignored is :single, the call stack is ignored only current call.
+ call_stack.push(ignored: ignored == :all)
next
end
source_name = normalize_module_name(mod, tp)