Fixed GCC compile warning
Ported hook on debug_print_backtrace()

This also fixes problems with the limit parameter.
Fallback for invalid SAPI packet header