MCPcopy Create free account
hub / github.com/CodeSentryAI/lockbud / track_callchains

Function track_callchains

src/detector/lock/mod.rs:731–762  ·  view source on GitHub ↗

Find all the callchains: source -> target e.g., for one path: source --|callsites1|--> medium --|callsites2|--> target, first extract callsite locations on edge, namely, [callsites1, callsites2], then map locations to spans [spans1, spans2].

(
    source: InstanceId,
    target: InstanceId,
    callgraph: &CallGraph<'tcx>,
    tcx: TyCtxt<'tcx>,
)

Source from the content-addressed store, hash-verified

729 ApproximateAliasKind::Unknown => DeadlockPossibility::Unknown,
730 },
731 _ => DeadlockPossibility::Unlikely,
732 };
733 (possibility, NotDeadlockReason::TrueDeadlock)
734}
735
736/// Generate doublelock diagnosis.
737fn diagnose_doublelock<'tcx>(
738 a: &LockGuardId,
739 b: &LockGuardId,
740 lockguards: &LockGuardMap<'tcx>,
741 callgraph: &CallGraph<'tcx>,
742 tcx: TyCtxt<'tcx>,
743) -> report::DeadlockDiagnosis {
744 diagnose_one_relation(a, b, lockguards, callgraph, tcx)
745}
746
747/// Find all the callchains: source -> target
748// e.g., for one path: source --|callsites1|--> medium --|callsites2|--> target,
749// first extract callsite locations on edge, namely, [callsites1, callsites2],
750// then map locations to spans [spans1, spans2].
751fn track_callchains<'tcx>(
752 source: InstanceId,
753 target: InstanceId,
754 callgraph: &CallGraph<'tcx>,
755 tcx: TyCtxt<'tcx>,
756) -> Vec<Vec<Vec<String>>> {
757 let paths = callgraph.all_simple_paths(source, target);
758 paths
759 .into_iter()
760 .map(|vec| {
761 vec.windows(2)
762 .map(|window| {
763 let (caller, callee) = (window[0], window[1]);
764 let caller_instance = match callgraph.index_to_instance(caller).unwrap() {
765 CallGraphNode::WithBody(instance) => instance,

Callers 1

diagnose_one_relationFunction · 0.85

Calls 4

all_simple_pathsMethod · 0.80
index_to_instanceMethod · 0.80
callsitesMethod · 0.80
locationMethod · 0.80

Tested by

no test coverage detected