That would include mortgage debt which is forgiven as a result of foreclosure, as well as debt restructuring, short sale or deed in lieu of foreclosure, so long as the debt is associated with the purchase, building or improvement of your main home and even if that debt is considered recourse debt.
FORBES: You Are Not Alone: R. Kelly Joins Taxpayers Who Have Lost Homes Due To Foreclosure