Support for parametrized locks in deadlock detector

Backported from bitcoin commit 908037fe16843aa354f63af8f14804821aaf70f1