Process the function calls from the Xdebug trace file
553760
protected function processFunctionCalls()
    {
        $returnStack = array();
        if (!file_exists($this->_traceFile . '.xt') || ($handle = fopen($this->_traceFile . '.xt', 'r')) === false) {
            return;
        }

        // See http://xdebug.org/docs/all_settings#trace_format
        // Note : classes are specified as 'class <classname>'
        while ($dataLine = fgetcsv($handle, null, "\t")) {
            if (is_numeric($dataLine[0])) {
                $minimumLevel = $dataLine[0];
                break;
            }
        }
        while ($dataLine = fgetcsv($handle, null, "\t")) {
            // For convenience and readability
            $tracedataLevel = $dataLine[0];
            if (!is_numeric($tracedataLevel)) { // We've reached the end of the trace file
                break;
            }
            if ($tracedataLevel > $minimumLevel + $this->_depth) { // We don't analyze this deep
                continue;
            }

            $tracedataIsReturn = $dataLine[2];
            if (isset($dataLine[5])) {
                $tracedataFunctionName = $dataLine[5];
                $splitClass = explode('->', $tracedataFunctionName);
                if (count($splitClass) > 1) { // It's a method
                    foreach ($this->_ignoredClassNames as $classname) {
                        if (strpos($splitClass[0], $classname) !== false) {
                            continue 2;
                        }
                    }
                    foreach ($this->_ignoredFunctions as $functionname) {
                        if (strpos($splitClass[1], $functionname) !== false) {
                            continue 2;
                        }
                    }
                } else {
                    foreach ($this->_ignoredFunctions as $functionname) {
                        if (strpos($splitClass[0], $functionname) !== false) {
                            continue 2;
                        }
                    }
                }
            } else {
                $tracedataFunctionName = '';
            }
            if (isset($dataLine[6])) {
                $tracedataUserDefined = $dataLine[6];
            } else {
                $tracedataUserDefined = '';
            }
            if (isset($dataLine[7])) {
                $tracedataIncludeFilename = $dataLine[7];
            } else {
                $tracedataIncludeFilename = '';
            }
            if (isset($dataLine[8])) {
                $tracedataFilename = $dataLine[8];
                foreach ($this->_ignoredFileNames as $filename) {
                    if (strpos($tracedataFilename, $filename) !== false) {
                        continue 2;
                    }
                }
            } else {
                $tracedataFilename = '';
            }
            if (isset($dataLine[9])) {
                $tracedataLinenumber = $dataLine[9];
            } else {
                $tracedataLinenumber = '';
            }

            if ($tracedataIsReturn == 0) { // It's a function/method call
				if (strpos($tracedataFunctionName, '{closure:') !== false) {
                    continue;
                }


                preg_match(
                '/(?P<classOrFunction>\w+){0,1}(?:\:\:|->){0,1}(?P<method>\w+){0,1}/',
                $tracedataFunctionName,
                $functionCall
                );

                $docBlock = false; // getDocComment will return false if no docblock is present
                if (!isset($functionCall['method']) && function_exists($functionCall['classOrFunction'])) { // It's a function
                    $calledFunction = $functionCall['classOrFunction'];
                    $func = new ReflectionFunction($functionCall['classOrFunction']);
                    $docBlock = $func->getDocComment();
                    $numberOfParameters = $func->getNumberOfParameters();
                    $functionParameters = $func->getParameters();
                } elseif (isset($functionCall['method']) && method_exists($functionCall['classOrFunction'], $functionCall['method'])) { // It's a method
                    $calledFunction = $functionCall['classOrFunction'] . '->' . $functionCall['method'];
                    $method = new ReflectionMethod($functionCall['classOrFunction'], $functionCall['method']);
                    $docBlock = $method->getDocComment();
                    $numberOfParameters = $method->getNumberOfParameters();
                    $functionParameters = $method->getParameters();
                } // else it's an internal function, which we're unable to verify at this point

                if ($docBlock !== false) {
                    $foundReturn = false;

                    preg_match_all('/\s*\*\s*@(?P<tag>phpconsistent-ignore)/', $docBlock, $noTypeCheck, PREG_SET_ORDER); // Check if @phpconsistent-ignore was in docblock
                    if (count($noTypeCheck) == 0) {
                        // Main docblock parameter and return type loop
                        preg_match_all('/\s*\*\s*@(?P<tag>param|return)\s+(?P<type>\S+)\s+(?P<paramName>\$?\w+)?/', $docBlock, $docBlockVars, PREG_SET_ORDER);
                        $documentedParameters = 0;
                        $docblockParams = array();
                        for ($cntDocBlockTag = 0; $cntDocBlockTag < count($docBlockVars); $cntDocBlockTag++) {
                            if ($docBlockVars[$cntDocBlockTag]['tag'] == "param") {
								$documentedParameters++;
								if (isset($docBlockVars[$cntDocBlockTag]['paramName'])) {
									$docblockParams[] = $docBlockVars[$cntDocBlockTag]['paramName'];
								} else {
									$docblockParams[] = '';
								}
								if (isset($dataLine[11 + $cntDocBlockTag])) { // Was the call made with this parameter ?
									$foundMatch = $this->compareTypes($dataLine[11 + $cntDocBlockTag], $docBlockVars[$cntDocBlockTag]['type']);

									if ($foundMatch === false) {
										$this->addParamTypeFailure(
											$tracedataFilename,
											$tracedataLinenumber,
											$calledFunction,
											($cntDocBlockTag + 1),
											$docBlockVars[$cntDocBlockTag]['paramName'],
											$docBlockVars[$cntDocBlockTag][2],
											$dataLine[11 + $cntDocBlockTag]
										);
									}
								}
                            } else { // Put the expected return type on the stack for later use
                                $returnStack[] = array(
                                    'fileName'        => $tracedataFilename,
                                    'fileLine'        => $tracedataLinenumber,
                                    'calledFunction'  => $calledFunction,
                                    'parameterNumber' => null,
                                    'parameterName'   => null,
                                    'expectedType'    => $docBlockVars[$cntDocBlockTag]['type'],
                                    'calledType'      => null,
                                    'noTypeCheck'     => 0
                                );
                                $foundReturn = true;
                            }
                        }
                    }

                    if ($numberOfParameters != $documentedParameters) {
                        $this->addParamCountMismatchFailure($tracedataFilename, $tracedataLinenumber, $calledFunction, $documentedParameters, $numberOfParameters);
                    }
                    for ($cntDocBlockParam = 0; $cntDocBlockParam < count($docblockParams); $cntDocBlockParam++) {
                        if (!isset($functionParameters[$cntDocBlockParam])) {
							$this->addParamMissingFailure($tracedataFilename, $tracedataLinenumber, $calledFunction, $cntDocBlockParam, $docblockParams[$cntDocBlockParam]);
						} elseif ($docblockParams[$cntDocBlockParam] != '$' . $functionParameters[$cntDocBlockParam]->getName()) {
                            $this->addParamNameMismatchFailure($tracedataFilename, $tracedataLinenumber, $calledFunction, $cntDocBlockParam, $docblockParams[$cntDocBlockParam], '$' . $functionParameters[$cntDocBlockParam]->getName());
                        }

                    }

                    if ($foundReturn === false) { // Put this function/method call on the stack
                        $returnStack[] = array(
                            'fileName'        => $tracedataFilename,
                            'fileLine'        => $tracedataLinenumber,
                            'calledFunction'  => $calledFunction,
                            'parameterNumber' => null,
                            'parameterName'   => null,
                            'expectedType'    => null,
                            'calledType'      => null,
                            'noTypeCheck'     => count($noTypeCheck)
                        );
                    }
                } else {
                    $returnStack[] = array(
                        'fileName'        => $tracedataFilename,
                        'fileLine'        => $tracedataLinenumber,
                        'calledFunction'  => $calledFunction,
                        'parameterNumber' => null,
                        'parameterName'   => null,
                        'expectedType'    => null,
                        'calledType'      => null,
                        'noTypeCheck'     => 1
                    );
                }
            } else { // It's a return
                // If this isn't set, we have a version of Xdebug that hasn't been patched for Xdebug bug #416
                // Requires Xdebug with code after https://github.com/xdebug/xdebug/pull/79
                if ($tracedataFunctionName != '') {

                    $returnPop = array_pop($returnStack);

                    if ($returnPop['noTypeCheck'] == 0 && $returnPop['expectedType'] != '') {
                        preg_match('/(?P<type>\w+)\s?(?P<class>\w+)?/', $tracedataFunctionName, $returnTypes);
                        if (preg_match('/^\'.*/', $tracedataFunctionName) > 0) { // Strings are not extracted with the above regular expression, but ALWAYS start with a quote in Xdebug trace output
                            $returnPop['calledType'] = 'string';
                        } elseif ($returnTypes['type'] == 'NULL') {
                            $returnPop['calledType'] = 'null';
                        } elseif ($returnTypes['type'] == 'class') {
                            $returnPop['calledType'] = 'class ' . $returnTypes['class'];
                        } elseif ($returnTypes['type'] == 'TRUE' || $returnTypes['type'] == 'FALSE') {
                            $returnPop['calledType'] = 'bool';
                        } elseif ($returnTypes['type'] == 'array') {
                            $returnPop['calledType'] = 'array';
                        } elseif (is_numeric($returnTypes['type'])) {
                            $returnPop['calledType'] = 'int';
                        } else {
                            $returnPop['calledType'] = 'unknown';
                        }
                        if (!$this->compareTypes($returnType, $returnPop['expectedType'])) {
                            $this->addParamTypeFailure($returnPop['fileName'], $returnPop['fileLine'], $returnPop['calledFunction'], null, null, $returnPop['expectedType'], $returnPop['calledType']);
                        }
                    }
                }
            }
        }
        fclose($handle);
    }
1083510
private static function buildTraceStep( $trace, $i, $j, $breakMode = 0 )
	{
		if( $j == 0 )
			if( isset( $trace['function'] ) )
				if( in_array( $trace['function'], array( "eval", "throwException" ) ) )		//  Exception was thrown using throwException
					return "";

		$indent		= " ";
		$break		= "";
		if( $breakMode == 2 )
		{
			$indent		= str_repeat( "&nbsp;", 2 + strlen( $j ) );
			$break		= "<br/>".$indent;
		}
		if( $breakMode == 3 )
		{
			$break		= "";#_2_<br/>";
		}
		$funcBreak	= $break;
		if( $breakMode == 1 )
			$funcBreak	= "<br/>";

		$content	= "#$j ";
		if( isset( $trace["file"] ) )
			$content	.= self::trimRootPath( $trace["file"] )."(".$trace["line"]."): ".$funcBreak;
		if( array_key_exists( "class", $trace ) && array_key_exists( "type", $trace ) )
			$content	.= $indent.$trace["class"].$trace["type"];
		if( array_key_exists( "function", $trace ) )
		{
			$content	.= $trace["function"]."(";
			if( array_key_exists( "args", $trace ) )
			{
				if( count( $trace['args'] ) )
				{
					$argList	= array();
					foreach( $trace["args"] as $argument )
					{
						$type	= ucFirst( gettype( $argument ) );
						$string	= self::convertArgumentToString( $argument, $breakMode );
						$argList[]	= $type.": ".$string;
					}
					$argBreak	= $breakMode ? $break.$indent.$indent : " ";
					$arguments	= implode( ",".$argBreak, $argList );
					if( $breakMode == 3 )
					{
						$arguments	= self::blockquote( implode( ",<br/>", $argList ) );
					}
					$content	.= $argBreak.$arguments.$break;
				}
			}
			$content	.= ")<br/>";
		}
		return $content;
	}
270781
function () {
        var prefix = 'DEBUG';
        this.output(prefix, prefix.blue, Array.prototype.slice.call(arguments));
    }
336699
public function analyze()
    {
        if (!file_exists($this->_traceFile)) {
            return false;
        }
        $this->processFunctionCalls();
        unlink($this->_traceFile);
        if (file_exists($this->_traceFile . '.xt')) {
            unlink($this->_traceFile . '.xt');
        }

        if (count($this->_failures) > 0) {
            return $this->_failures;
        } else {
		    return array();
		}
    }
1196383
protected function getTrace($e)
    {
        $traces = $e->getTrace();

        // Get trace from xdebug if enabled, failure exceptions only trace to the shutdown handler by default
        if (!$e instanceof \ErrorException) {
            return $traces;
        }

        if (!Misc::isLevelFatal($e->getSeverity())) {
            return $traces;
        }

        if (!extension_loaded('xdebug') || !xdebug_is_enabled()) {
            return [];
        }

        // Use xdebug to get the full stack trace and remove the shutdown handler stack trace
        $stack = array_reverse(xdebug_get_function_stack());
        $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
        $traces = array_diff_key($stack, $trace);

        return $traces;
    }
1360065
public static function trace()
    {
        if (!self::$enabled_mode) {
            return 0;
        }

        Utils::normalizeAliases(self::$aliases);

        $args = \func_get_args();

        $call_info = self::getCallInfo(self::$aliases, \debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), \count($args));

        $statics = self::getStatics();

        if (\in_array('~', $call_info['modifiers'], true)) {
            $statics['enabled_mode'] = self::MODE_TEXT;
        }

        $kintstance = self::createFromStatics($statics);
        if (!$kintstance) {
            // Should never happen
            return 0; // @codeCoverageIgnore
        }

        if (\in_array('-', $call_info['modifiers'], true)) {
            while (\ob_get_level()) {
                \ob_end_clean();
            }
        }

        $kintstance->setStatesFromStatics($statics);
        $kintstance->setStatesFromCallInfo($call_info);

        $trimmed_trace = array();
        $trace = \debug_backtrace(true);

        foreach ($trace as $frame) {
            if (Utils::traceFrameIsListed($frame, self::$aliases)) {
                $trimmed_trace = array();
            }

            $trimmed_trace[] = $frame;
        }

        $output = $kintstance->dumpAll(
            array($trimmed_trace),
            array(BasicObject::blank('Kint\\Kint::trace()', 'debug_backtrace(true)'))
        );

        if (self::$return || \in_array('@', $call_info['modifiers'], true)) {
            return $output;
        }

        echo $output;

        if (\in_array('-', $call_info['modifiers'], true)) {
            \flush(); // @codeCoverageIgnore
        }

        return 0;
    }
1152426
def timed_do_fn(f):
    """"""
    def wrap(callable, *args, **kwargs):
        global _debug_id

        # get a description of the function that called us
        st = traceback.extract_stack(limit=2)
        file, line, name, _ = st[0]

        # and its locals
        frame = inspect.currentframe()
        locals = frame.f_locals

        # invent a unique ID for the description
        id, _debug_id = _debug_id, _debug_id + 1

        descr = "%s-%08x" % (name, id)

        start_time = time.time()
        log.msg("%s - before ('%s' line %d)" % (descr, file, line))
        for name in locals:
            if name in ('self', 'thd'):
                continue
            log.msg("%s -   %s = %r" % (descr, name, locals[name]))

        # wrap the callable to log the begin and end of the actual thread
        # function
        def callable_wrap(*args, **kargs):
            log.msg("%s - thd start" % (descr,))
            try:
                return callable(*args, **kwargs)
            finally:
                log.msg("%s - thd end" % (descr,))
        d = f(callable_wrap, *args, **kwargs)

        @d.addBoth
        def after(x):
            end_time = time.time()
            elapsed = (end_time - start_time) * 1000
            log.msg("%s - after (%0.2f ms elapsed)" % (descr, elapsed))
            return x
        return d
    wrap.__name__ = f.__name__
    wrap.__doc__ = f.__doc__
    return wrap
396615
def handle_debug_backtrace(self, call_id, payload):
        """"""
        frames = payload["frames"]
        fd, path = tempfile.mkstemp('.json', text=True, dir=self.tmp_diff_folder)
        tmpfile = os.fdopen(fd, 'w')

        tmpfile.write(json.dumps(frames, indent=2))
        opts = {'readonly': True, 'bufhidden': 'wipe',
                'buflisted': False, 'swapfile': False}
        self.editor.split_window(path, size=20, bufopts=opts)
        tmpfile.close()
108255
public function render() {
        if (!$this->_enableXDebugOverlay) {
            ini_set('xdebug.overload_var_dump', 'off');
        }
        $debuggerCount = count($this->_debuggers);
        $this->setName(str_replace('{count}', '{' . $debuggerCount . '}', self::NAME));
        parent::render();
    }
556945
function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
    {
        $params = $functionParameters;
        switch ( $functionName )
        {
            case $this->BlockName:
            {
                $viewMode = "full";
                $name = $currentNamespace;
                // Read ini file
                $toolbarIni = eZINI::instance( "toolbar.ini" );

                if ( isset( $functionParameters["view"] ) )
                {
                    $viewMode = $tpl->elementValue( $functionParameters["view"], $rootNamespace, $currentNamespace, $functionPlacement );
                }

                if ( isset( $functionParameters["name"] ) )
                {
                    reset( $params );
                    $whatParamsShouldBeUnset = array();
                    $whatParamsShouldBeReplaced = array();
                    while ( ( $key = key( $params ) ) !== null )
                    {
                        $item =& $params[$key];
                        switch ( $key )
                        {
                            case "name":
                            case "view":
                                break;

                            default:
                            {
                                if ( !$tpl->hasVariable( $key, $name ) )
                                {
                                    $whatParamsShouldBeUnset[] = $key; // Tpl vars should be removed after including
                                }
                                else
                                {
                                    $whatParamsShouldBeReplaced[$key] = $tpl->variable( $key, $name ); // Tpl vars should be replaced after including
                                }

                                $item_value = $tpl->elementValue( $item, $rootNamespace, $currentNamespace, $functionPlacement );
                                $tpl->setVariable( $key, $item_value, $name );
                            } break;
                        }
                        next( $params );
                    }
                    $toolbarPosition = $tpl->elementValue( $functionParameters["name"], $rootNamespace, $currentNamespace, $functionPlacement );
                    $definedVariables = array();
                    $toolbarName = "Toolbar_" . $toolbarPosition;
                    $toolArray = $toolbarIni->variable( $toolbarName, 'Tool' );

                    if ( !is_array( $toolArray ) )
                        $toolArray = array();

                    $actionParameters = array();
                    foreach ( array_keys( $toolArray ) as $toolKey )
                    {
                        $definedVariables = array();
                        $tool = $toolArray[$toolKey];
                        $placement = $toolKey + 1;
                        if ( $toolbarIni->hasGroup( "Tool_" . $tool ) )
                        {
                            $actionParameters = $toolbarIni->group( "Tool_" . $tool );
                        }
                        if ( $toolbarIni->hasGroup( "Tool_" . $toolbarPosition . "_" . $tool . "_" . $placement ) )
                        {
                            $actionParameters = array_merge( $actionParameters, $toolbarIni->group( "Tool_" . $toolbarPosition . "_" . $tool . "_" . $placement ) );
                        }
                        foreach ( array_keys( $actionParameters ) as $key )
                        {
                            $itemValue = $actionParameters[$key];
                            $tpl->setVariable( $key, $itemValue, $name );
                            $definedVariables[] = $key;
                        }
                        $toolIDValue =  "Tool_" . $toolbarPosition . "_" . $tool . "_" . $placement;
                        $tpl->setVariable( "tool_id", $toolIDValue, $name );
                        $definedVariables[] = "tool_id";
                        $toolOffset = $placement;
                        $tpl->setVariable( "offset", $toolOffset, $name );
                        $definedVariables[] = "offset";
                        $uri = "design:toolbar/$viewMode/$tool.tpl";

                        if ( $placement == 1 )
                        {
                            if ( count( $toolArray ) == 1 )
                            {
                                $tpl->setVariable( "first", true );
                                $tpl->setVariable( "last", true );
                                $tpl->setVariable( "placement", "last" );
                                $definedVariables[] = "first";
                                $definedVariables[] = "last";
                                $definedVariables[] = "placement";
                            }
                            else
                            {
                                $tpl->setVariable( "first", true );
                                $tpl->setVariable( "last", false );
                                $tpl->setVariable( "placement", "first" );
                                $definedVariables[] = "first";
                                $definedVariables[] = "last";
                                $definedVariables[] = "placement";
                            }
                        }
                        else if ( $placement == count( $toolArray ) )
                        {
                            $tpl->setVariable( "first", false );
                            $tpl->setVariable( "last", true );
                            $tpl->setVariable( "placement", "last" );
                            $definedVariables[] = "first";
                            $definedVariables[] = "last";
                            $definedVariables[] = "placement";
                        }
                        else
                        {
                            $tpl->setVariable( "first", false );
                            $tpl->setVariable( "last",  false );
                            $tpl->setVariable( "placement", "" );
                            $definedVariables[] = "placement";
                        }
                        $tpl->processURI( $uri, true, $extraParameters, $textElements, $name, $name );
                        // unset var
                        foreach ( $whatParamsShouldBeUnset as $key )
                        {
                            $tpl->unsetVariable( $key, $name );
                        }
                        // replace var
                        foreach ( $whatParamsShouldBeReplaced as $key => $item_value )
                        {
                            $tpl->setVariable( $key, $item_value, $name );
                        }
                    }
                }
            }
        }
    }
295103
def debug(func):
    
    @wraps(func)
    def wrapped(*args, **kwargs):
        arg = repr(args) + ' ' + repr(kwargs)
        sys.stdout.write('Entering ' + func.__name__ + arg + '\n')
        try:
            result = func(*args, **kwargs)
        except:
            sys.stdout.write('Traceback caught:\n')
            sys.stdout.write(format_exception(*sys.exc_info()))
            raise
        arg = repr(result)
        sys.stdout.write('Leaving ' + func.__name__ + '(): ' + arg + '\n')
        return result
    return wrapped
129044
function(opts = {}) {
  if (opts.handleUncaughtExceptions == null) {
    opts.handleUncaughtExceptions = true;
  }
  if (opts.structuredStackTrace == null) {
    opts.structuredStackTrace = false;
  }
  if (opts.handleUncaughtExceptions) {
    process.on('uncaughtException', function(err) {
      prettyPrint(err, {
        colorize: process.stdout.isTTY
      });
      return process.exit(1);
    });
  }
  return Error.prepareStackTrace = function(err, stack) {
    var _stack, frame;
    _stack = (function() {
      var i, len, results;
      results = [];
      for (i = 0, len = stack.length; i < len; i++) {
        frame = stack[i];
        results.push(wrap(err, frame));
      }
      return results;
    })();
    if (opts.structuredStackTrace) {
      err.structuredStackTrace = structured(err, stack);
    }
    return err + ((function() {
      var i, len, results;
      results = [];
      for (i = 0, len = _stack.length; i < len; i++) {
        frame = _stack[i];
        results.push('\n    at ' + frame);
      }
      return results;
    })()).join('');
  };
}
1004567
def trace(f):
    
    @functools.wraps(f)
    def decorator(*args, **kwargs):
        print 'Calling ' + f.func_name + ' in ' + str(args[0])
        return f(*args, **kwargs)
    return decorator
578696
def tracer(frame, event, arg):
    
    global func_count_max
    global func_count
    global trace_filter
    global time_filter
    global call_stack
    global func_time
    global func_time_max

    if event == 'call':
        keep = True
        code = frame.f_code

        # Stores all the parts of a human readable name of the current call.
        full_name_list = []

        # Work out the module name
        module = inspect.getmodule(code)
        if module:
            module_name = module.__name__
            module_path = module.__file__
            if not settings['include_stdlib'] \
                and is_module_stdlib(module_path):
                keep = False
            if module_name == '__main__':
                module_name = ''
        else:
            module_name = ''
        if module_name:
            full_name_list.append(module_name)

        # Work out the class name.
        try:
            class_name = frame.f_locals['self'].__class__.__name__
            full_name_list.append(class_name)
        except (KeyError, AttributeError):
            class_name = ''

        # Work out the current function or method
        func_name = code.co_name
        if func_name == '?':
            func_name = '__main__'
        full_name_list.append(func_name)

        # Create a readable representation of the current call
        full_name = '.'.join(full_name_list)

        # Load the trace filter, if any. 'keep' determines if we should ignore
        # this call
        if keep and trace_filter:
            keep = trace_filter(call_stack, module_name, class_name,
                func_name, full_name)

        # Store the call information
        if keep:

            if call_stack:
                fr = call_stack[-1]
            else:
                fr = None
            if fr not in call_dict:
                call_dict[fr] = {}
            if full_name not in call_dict[fr]:
                call_dict[fr][full_name] = 0
            call_dict[fr][full_name] += 1

            if full_name not in func_count:
                func_count[full_name] = 0
            func_count[full_name] += 1
            if func_count[full_name] > func_count_max:
                func_count_max = func_count[full_name]

            call_stack.append(full_name)
            call_stack_timer.append(time.time())

        else:
            call_stack.append('')
            call_stack_timer.append(None)

    if event == 'return':
        if call_stack:
            full_name = call_stack.pop(-1)
            if call_stack_timer:
                t = call_stack_timer.pop(-1)
            else:
                t = None
            if t and time_filter(stack=call_stack, full_name=full_name):
                if full_name not in func_time:
                    func_time[full_name] = 0
                call_time = (time.time() - t)
                func_time[full_name] += call_time
                if func_time[full_name] > func_time_max:
                    func_time_max = func_time[full_name]

    return tracer
1228701
def debug_callback(event, *args, **kwds):
    '''
    '''
    l = ['event %s' % (event.type,)]
    if args:
        l.extend(map(str, args))
    if kwds:
        l.extend(sorted('%s=%s' % t for t in kwds.items()))
    print('Debug callback (%s)' % ', '.join(l))
644448
function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
    {
        if ( count( $functionParameters ) == 0 || !count( $functionParameters['condition'] ) )
        {
            eZDebug::writeError( "Not enough arguments passed to 'if' function." );
            return;
        }

        $ifValue = $tpl->elementValue( $functionParameters['condition'], $rootNamespace, $currentNamespace, $functionPlacement );

        $show        = $ifValue; // whether to show the child being currently processing
        $showWasTrue = $show;    // true if $show has been assigned 'true' value at least once in the current {if}...{/if} block.
        $foundElse   = false;    // true if 'else' has been met once in the current {if}...{/if} block.

        if ( !is_array( $functionChildren ) )
        {
            return;
        }
        foreach ( $functionChildren as $key => $child )
        {
            $childType = $child[0];

            // parse 'elseif', 'else' functions
            if ( $childType == eZTemplate::NODE_FUNCTION )
            {
                $childFunctionName      =& $child[2];
                $childFunctionArgs      =& $child[3];
                $childFunctionPlacement =& $child[4];

                if ( $childFunctionName == 'else' )
                {
                    if ( $foundElse  )
                    {
                        eZDebug::writeError( "Duplicated 'else'" );
                        $show = false;
                        continue;
                    }

                    $show = !$showWasTrue;
                    $foundElse = true;
                    continue;
                }
                elseif ( $childFunctionName == 'elseif' )
                {
                    if ( $foundElse  )
                    {
                        eZDebug::writeError( "There should be no more 'elseif' after 'else'" );
                        $show = false;
                        continue;
                    }

                    if ( !isset( $childFunctionArgs['condition'] ) || !count( $childFunctionArgs['condition'] ) ) // no arguments passes to 'elseif' (should not happen)
                        $elseifValue = false;
                    else
                        $elseifValue = $tpl->elementValue( $childFunctionArgs['condition'], $rootNamespace, $currentNamespace, $functionPlacement );

                    if ( !$showWasTrue && $elseifValue )
                        $show = $showWasTrue = true;
                    else
                        $show = false;
                    continue;
                }
                elseif ( $childFunctionName == 'break' )
                {
                    if ( !$show )
                            continue;
                    return array( 'breakFunctionFound' => 1 );
                }
                elseif ( $childFunctionName == 'continue' )
                {
                    if ( !$show )
                            continue;
                    return array( 'continueFunctionFound' => 1 );
                }
                elseif ( $childFunctionName == 'skip' )
                {
                    if ( !$show )
                            continue;
                    return array( 'skipFunctionFound' => 1 );
                }
            }

            if ( $show )
            {
                $rslt = $tpl->processNode( $child, $textElements, $rootNamespace, $currentNamespace );

                // handle 'break', 'continue' and 'skip'
                if ( is_array( $rslt ) && ( array_key_exists( 'breakFunctionFound', $rslt ) ||
                                            array_key_exists( 'continueFunctionFound', $rslt )  ||
                                            array_key_exists( 'skipFunctionFound', $rslt ) ) )
                {
                    return $rslt;
                }
            }
        }
    }
289251
public static function debugTrail() {
		$trail = debug_backtrace();
		$trail = array_reverse($trail);
		array_pop($trail);

		$path = array();
		foreach ($trail as $dat) {
			$pathFragment = $dat['class'] . $dat['type'] . $dat['function'];
				// add the path of the included file
			if (in_array($dat['function'], array('require', 'include', 'require_once', 'include_once'))) {
				$pathFragment .= '(' . substr($dat['args'][0], strlen(PATH_site)) . '),' . substr($dat['file'], strlen(PATH_site));
			}
			$path[] = $pathFragment . '#' . $dat['line'];
		}

		return implode(' // ', $path);
	}