Skip to content

Commit

Permalink
Stacks prior to start time are not tracked.
Browse files Browse the repository at this point in the history
  • Loading branch information
alpaca-tc committed Apr 22, 2024
1 parent 7ee3530 commit 8809591
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/diver_down/trace/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def build_trace_point
end

# `caller_location` is nil if it is filtered by target_files
caller_location = find_neast_caller_location
caller_location = find_neast_caller_location(call_stack.stack_size)

if caller_location
pushed = true
Expand All @@ -113,11 +113,19 @@ def build_trace_point
end
end

def find_neast_caller_location
return caller_locations(2, 2)[0] if @target_file_set.nil?
def find_neast_caller_location(stack_size)
excluded_frame_size = 1 # Ignore neast caller because it is stack of #find_neast_caller_location.
finished_frame_size = excluded_frame_size + stack_size + 1
frame_pos = 1

# If @target_file_set is nil, return the caller location.
return caller_locations(excluded_frame_size + 1, excluded_frame_size + 1)[0] if @target_file_set.nil?

Thread.each_caller_location do
break if finished_frame_size < frame_pos
return _1 if @target_file_set.include?(_1.path)

frame_pos += 1
end

nil
Expand Down

0 comments on commit 8809591

Please sign in to comment.