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

Function diagnose_one_relation

src/detector/lock/mod.rs:765–790  ·  view source on GitHub ↗

Find the diagnosis info for relation(a, b), including a's ty & span, b's ty & span, and callchains.

(
    a: &LockGuardId,
    b: &LockGuardId,
    lockguards: &LockGuardMap<'tcx>,
    callgraph: &CallGraph<'tcx>,
    tcx: TyCtxt<'tcx>,
)

Source from the content-addressed store, hash-verified

763 let (caller, callee) = (window[0], window[1]);
764 let caller_instance = match callgraph.index_to_instance(caller).unwrap() {
765 CallGraphNode::WithBody(instance) => instance,
766 n => panic!("CallGraphNode {:?} must own body", n),
767 };
768 let caller_body = tcx.instance_mir(caller_instance.def);
769 let callsites = callgraph.callsites(caller, callee).unwrap();
770 callsites
771 .into_iter()
772 .filter_map(|location| {
773 location
774 .location()
775 .map(|loc| format!("{:?}", caller_body.source_info(loc).span))
776 })
777 .collect::<Vec<_>>()
778 })
779 .collect::<Vec<_>>()
780 })
781 .collect::<Vec<_>>()
782}
783
784// Find the diagnosis info for relation(a, b), including a's ty & span, b's ty & span, and callchains.
785fn diagnose_one_relation<'tcx>(
786 a: &LockGuardId,
787 b: &LockGuardId,
788 lockguards: &LockGuardMap<'tcx>,
789 callgraph: &CallGraph<'tcx>,
790 tcx: TyCtxt<'tcx>,
791) -> DeadlockDiagnosis {
792 let a_info = &lockguards[a];
793 let b_info = &lockguards[b];

Callers 2

detect_deadlockMethod · 0.85
diagnose_doublelockFunction · 0.85

Calls 1

track_callchainsFunction · 0.85

Tested by

no test coverage detected