@@ -644,6 +644,14 @@ Return the MethodInstance `mi` of the caller in the selected stackframe in `itri
644644"""
645645callerinstance (itrig:: InferenceTrigger ) = itrig. callerframes[end ]. linfo
646646
647+ function callermodule (itrig:: InferenceTrigger )
648+ if ! isempty (itrig. callerframes)
649+ m = callerinstance (itrig). def
650+ return isa (m, Module) ? m : m. module
651+ end
652+ return nothing
653+ end
654+
647655# Select the next (caller) frame that's a Julia (as opposed to C) frame; returns the stackframe and its index in bt, or nothing
648656function next_julia_frame (bt, idx, Δ= 1 ; methodinstanceonly:: Bool = true , methodonly:: Bool = true )
649657 while 1 <= idx+ Δ <= length (bt)
@@ -856,6 +864,8 @@ Cthulhu.specTypes(itrig::InferenceTrigger) = Cthulhu.specTypes(Cthulhu.instance(
856864Cthulhu. backedges (itrig:: InferenceTrigger ) = (itrig. callerframes,)
857865Cthulhu. nextnode (itrig:: InferenceTrigger , edge) = (ret = callingframe (itrig); return isempty (ret. callerframes) ? nothing : ret)
858866
867+ filtermod (mod:: Module , itrigs:: AbstractVector{InferenceTrigger} ) = filter (== (mod) ∘ callermodule, itrigs)
868+
859869# ## inference trigger trees
860870# good for organizing into "events"
861871
@@ -1010,6 +1020,10 @@ function accumulate_by_source(itrigs::AbstractVector{InferenceTrigger})
10101020 return sort ([LocationTrigger (loc, itrigs_loc) for ((loc, _), itrigs_loc) in cs]; by= loctrig-> length (loctrig. itrigs))
10111021end
10121022
1023+ filtermod (mod:: Module , loctrigs:: AbstractVector{LocationTrigger} ) = filter (loctrigs) do loctrig
1024+ any (== (mod) ∘ callermodule, loctrig. itrigs)
1025+ end
1026+
10131027function linetable_match (linetable:: Vector{Core.LineInfoNode} , sffile:: String , sffunc:: String , sfline:: Int )
10141028 idxs = Int[]
10151029 for (idx, line) in enumerate (linetable)
0 commit comments