How to use dd(debug_backtrace()); for an error debugging?
You can run:

dd(debug_backtrace());


which prints the output to drupal_debug.txt file by default in your temporary folder which can be found in your tmp folder (See: Where Drupal creates temporary files?). You can specify different file, but in Drupal settings related to file system.

The call to dd(debug_backtrace('drupal_debug.txt')); is invalid, since debug_backtrace() accepts int $options, not the file.

Regarding this warning:


  Only 0 of 1 bytes written, possibly out of free disk space in drupal_debug(). Devel was unable to write to /tmp/drupal_debug.txt.


it says you're likely to be out of free disk space on your hard drive. So you should remove this file from your temporary folder at /tmp, then try again.

To make it more light, use the following version:

dd(debug_backtrace(FALSE, 5));


which won't populate all objects (FALSE) and limit number of stack frames returned to 5.

If your function is called too many times, try adding die() or exit(); to avoid multiple calls.

You can also use the following one-liner:

array_walk(debug_backtrace(),create_function('$a,$b','print "&lt;pre&gt;{$a[\'function\']}()(".basename($a[\'file\']).":{$a[\'line\']});&lt;/pre&gt;\\n";'));


which will print even more minimalized version of the backtrace to avoid out-of-space issues.