KDebug support

As asked by @XVilka here's the working code which implements enough KD protocol to be useful.
Up for review and not ready to merge yet.