Putting these settings in /etc/php/7.2/apache/php.ini did the job:
[XDebug] xdebug.profiler_enable = 1 xdebug.profiler_output_dir = /tmp/xdebug xdebug.profiler_output_name = cachegrind.out.%p.%u.%H.%R.xt
The cachegrind files are now written to /tmp/xdebug.