You may use xdebug_start_trace()
and xdebug_stop_trace()
XDebug functions to kick off the debugger on demand. Make sure that you've configured XDebug in CLI first (php -i | grep xdebug
).
Then create new one-liner PHP file as follows (e.g. drush_xdebug_start.inc):
<?php xdebug_start_trace();
Then run the drush as:
drush --early=drush_xdebug_startearly="$PWD"/drush_xdebug_start.inc whatever_command_you_need