Extend debug functionality

Change-Id: I4448e569f11338cde859feecac25407889fc0cca
Reviewed-on: http://review.couchbase.org/24076
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>