In MINIT:
/* Replace error handler callback with our own */
xdebug_old_error_cb = zend_error_cb;
xdebug_new_error_cb = xdebug_error_cb;
In MSHUTDOWN:
zend_error_cb = xdebug_old_error_cb;
xdebug_error_cb:
/* Error callback for formatting stack traces */
void xdebug_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args)
{
...
}