function ddebug_backtrace

Same name in other branches
  1. 7.x-1.x devel.module \ddebug_backtrace()
  2. 8.x-1.x devel.module \ddebug_backtrace()
  3. 4.x devel.module \ddebug_backtrace()
  4. 5.x devel.module \ddebug_backtrace()

Print the function call stack.

1 call to ddebug_backtrace()
backtrace_error_handler in ./devel.module
Display backtrace showing the route of calls to the current error.

File

./devel.module, line 1944

Code

function ddebug_backtrace($pop = 0) {
    if (user_access('access devel information')) {
        $backtrace = debug_backtrace();
        while ($pop-- > 0) {
            array_shift($backtrace);
        }
        $counter = count($backtrace);
        $clip = strlen(realpath('.')) + 1;
        $nbsp = " ";
        // Show message if error_level is ERROR_REPORTING_DISPLAY_SOME or higher.
        // (This is Drupal's error_level, which is different from $error_level,
        // and we purposely ignore the difference between _SOME and _ALL,
        // see #970688!)
        if (variable_get('error_level', 1) >= 1) {
            while (!empty($backtrace)) {
                $call = array();
                if (isset($backtrace[0]['file'])) {
                    $call['file'] = substr($backtrace[0]['file'], $clip) . ':' . $backtrace[0]['line'];
                }
                if (isset($backtrace[1])) {
                    if (isset($backtrace[1]['class'])) {
                        $function = $backtrace[1]['class'] . $backtrace[1]['type'] . $backtrace[1]['function'] . '()';
                    }
                    else {
                        $function = $backtrace[1]['function'] . '()';
                    }
                    $backtrace[1] += array(
                        'args' => array(),
                    );
                    $call['args'] = $backtrace[1]['args'];
                }
                else {
                    $function = 'main()';
                    $call['args'] = $_GET;
                }
                $nicetrace[($counter <= 10 ? $nbsp : '') . --$counter . ': ' . $function] = $call;
                array_shift($backtrace);
            }
            krumo($nicetrace);
        }
    }
}