{@inheritdoc}

@see <a href="http://php.net/manual/en/function.debug-backtrace.php">debug_backtrace()</a>
for information on how to get a stack trace within this method.
4308
public function throwException(
        $message,
        $code,
        $connectionErrorNumber = null,
        $httpStatusCode = null,
        $previousException = null
    ) {
        throw new PhpCapException(
            $message,
            $code,
            $connectionErrorNumber,
            $httpStatusCode,
            $previousException
        );
    }
702153
public function get_debug_backtrace( $unset = [] ) {
		$backtrace = debug_backtrace();
		foreach ( $backtrace as $k => $v ) {
			// 大量のデータになりがちな object と args を削除や編集
			unset( $backtrace[ $k ]['object'] );
			if ( ! empty( $backtrace[ $k ]['args'] ) ) {
				$backtrace[ $k ]['args'] = $this->parse_backtrace_args( $backtrace[ $k ]['args'] );
			} else {
				unset( $backtrace[ $k ]['args'] );
			}
			if ( ! empty( $unset ) ) {
				foreach ( $v as $key => $value ) {
					if ( in_array( $key, $unset ) ) {
						unset( $backtrace[ $k ][ $key ] );
					}
				}
			}
		}

		return $backtrace;
	}
1208496
private static function getHTMLBackTrace($backtrace)
    {
        $str = '';

        foreach ($backtrace as $step) {
            if ($step['function'] != 'getHTMLBackTrace' && $step['function'] != 'handle_error') {
                $str .= '<tr><td style="border-bottom: 1px solid #EEEEEE">';
                $str .= ((isset($step['class'])) ? htmlspecialchars($step['class'], ENT_NOQUOTES, 'UTF-8') : '').
                ((isset($step['type'])) ? htmlspecialchars($step['type'], ENT_NOQUOTES, 'UTF-8') : '').htmlspecialchars($step['function'], ENT_NOQUOTES, 'UTF-8').'(';

                if (is_array($step['args'])) {
                    $drawn = false;
                    $params = '';
                    foreach ($step['args'] as $param) {
                        $params .= self::getPhpVariableAsText($param);
                        //$params .= var_export($param, true);
                        $params .= ', ';
                        $drawn = true;
                    }
                    $str .= htmlspecialchars($params, ENT_NOQUOTES, 'UTF-8');
                    if ($drawn == true) {
                        $str = substr($str, 0, strlen($str) - 2);
                    }
                }
                $str .= ')';
                $str .= '</td><td style="border-bottom: 1px solid #EEEEEE">';
                $str .= ((isset($step['file'])) ? htmlspecialchars(self::displayFile($step['file']), ENT_NOQUOTES, 'UTF-8') : '');
                $str .= '</td><td style="border-bottom: 1px solid #EEEEEE">';
                $str .= ((isset($step['line'])) ? $step['line'] : '');
                $str .= '</td></tr>';
            }
        }

        return $str;
    }
1373080
protected static function findSource()
    {
        $source = '';
        $trace = debug_backtrace(PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : false);
        foreach ($trace as $row) {
            if (isset($row['file']) === false) {
                continue;
            }

            if (isset($row['function']) === true && strpos($row['function'], 'call_user_func') === 0) {
                continue;
            }

            if (isset($row['class']) === true && (
                is_subclass_of($row['class'], '\Tracy\IBarPanel') === true ||
                strpos(str_replace('/', '\\', $row['file']), 'Illuminate\\') !== false
            )) {
                continue;
            }

            $source = [$row['file'], (int) $row['line']];
        }

        return $source;
    }
591017
public static function caller ( )
	{
		$backtrace = V(debug_backtrace());

		foreach ($backtrace as $line) {
			$line = A($line);

			if ($line->class === 'Bacon\Log') continue;

			return A([
				'class'  => $line->class,
				'file'   => $line->file,
				'method' => $line->function,
				'object' => $line->object
			]);
		}

		/*
		if (isset($backtrace[2]['class'])) {
			return $backtrace[2]['class'];
		} elseif (isset($backtrace[2]['file'])) {
			return $backtrace[2]['file'];
		} else {
			return $backtrace[0]['file'];
		}
		 */
	}
1096943
def backtrace(exc, level_meth = :error)
      return unless show_backtraces
      send(level_meth, "#{exc.class.class_name}: #{exc.message}")
      send(level_meth, "Stack trace:" +
        exc.backtrace[0..5].map {|x| "\n\t#{x}" }.join + "\n")
    end
1251073
protected function getCalleeClass()
    {

        if (PHP_VERSION_ID < 50205)
            $backtrace = debug_backtrace();
        else
            $backtrace = debug_backtrace(false);

        foreach ( $backtrace as $bt ) {
            // Making sure the class we're getting out of the backtrace is not a logger
            if (!is_a($this, $bt['class']) && strpos($bt['class'], 'Logger') === false) {
                return $bt['class'];
            }
        }

        return '';
    }
1186824
public static function stacktrace( $stack = null, $withPre = false )
	{
		if ( is_null( $stack ) )
			$stack = debug_backtrace();
		$output = $withPre ? '<pre>' : '';

		$stackLen = count( $stack );
		for ( $i = 1; $i < $stackLen; $i++ )
		{
			$entry = $stack[$i];

			$func = $entry['function'] . '(';
			$argsLen = count( $entry['args'] );

			for ( $j = 0; $j < $argsLen; $j++ )
			{
				$my_entry = $entry['args'][$j];

				if ( is_string( $my_entry ) )
					$func .= $my_entry;

				if ( $j < $argsLen - 1 )
					$func .= ', ';
			}
			$func .= ')';

			$entry_file = 'NO_FILE';

			if ( array_key_exists( 'file', $entry ) )
				$entry_file = $entry['file'];

			$entry_line = 'NO_LINE';

			if ( array_key_exists( 'line', $entry ) )
				$entry_line = $entry['line'];

			$output .= $entry_file . ':' . $entry_line . ' - ' . $func . PHP_EOL;
		}

		if ( $withPre )
			$output .= $output . '</pre>';

		return $output;
	}
761427
public static function inspect()
	{
		$backtrace = debug_backtrace();

		// If being called from within, show the file above in the backtrack
		if (strpos($backtrace[0]['file'], 'core/classes/debug.php') !== false)
		{
			$callee = $backtrace[1];
			$label = \Inflector::humanize($backtrace[1]['function']);
		}
		else
		{
			$callee = $backtrace[0];
			$label = 'Debug';
		}

		$arguments = func_get_args();
		$total_arguments = count($arguments);

		$callee['file'] = \Fuel::clean_path($callee['file']);

		if ( ! static::$js_displayed)
		{
			echo <<<JS
<script type="text/javascript">function fuel_debug_toggle(a){if(document.getElementById){if(document.getElementById(a).style.display=="none"){document.getElementById(a).style.display="block"}else{document.getElementById(a).style.display="none"}}else{if(document.layers){if(document.id.display=="none"){document.id.display="block"}else{document.id.display="none"}}else{if(document.all.id.style.display=="none"){document.all.id.style.display="block"}else{document.all.id.style.display="none"}}}};</script>
JS;
			static::$js_displayed = true;
		}
		echo '<div class="fuelphp-inspect" style="font-size: 13px;background: #EEE !important; border:1px solid #666; color: #000 !important; padding:10px;">';
		echo '<h1 style="border-bottom: 1px solid #CCC; padding: 0 0 5px 0; margin: 0 0 5px 0; font: bold 120% sans-serif;">'.$callee['file'].' @ line: '.$callee['line'].'</h1>';
		echo '<pre style="overflow:auto;font-size:100%;">';
		$i = 0;
		foreach ($arguments as $argument)
		{
			echo '<strong>'.$label.' #'.(++$i).' of '.$total_arguments.'</strong>:<br />';
				echo static::format('...', $argument);
			echo '<br />';
		}

		echo "</pre>";
		echo "</div>";
	}
1185439
public function debugGet() {
		$aResult = $this->_coll()->findOne([static::$_mKey => $this->_mID]);
		unset($aResult[static::$_mKey]);
		return $aResult;
	}
287184
public function backtrace($sh = null, $backtrace = null)
    {
        $output = '<div class="atk-box-small atk-table atk-table-zebra">';
        $output .= "<table>\n";
        $output .= "<tr><th align='right'>File</th><th>Object Name</th><th>Stack Trace</th><th>Help</th></tr>";
        if (!isset($backtrace)) {
            $backtrace = debug_backtrace();
        }
        $sh -= 2;

        $n = 0;
        foreach ($backtrace as $bt) {
            ++$n;
            $args = '';
            if (!isset($bt['args'])) {
                continue;
            }
            foreach ($bt['args'] as $a) {
                if (!empty($args)) {
                    $args .= ', ';
                }
                switch (gettype($a)) {
                    case 'integer':
                    case 'double':
                        $args .= $a;
                        break;
                    case 'string':
                        $a = htmlspecialchars(substr($a, 0, 128)).((strlen($a) > 128) ? '...' : '');
                        $args .= "\"$a\"";
                        break;
                    case 'array':
                        $args .= 'Array('.count($a).')';
                        break;
                    case 'object':
                        $args .= 'Object('.get_class($a).')';
                        break;
                    case 'resource':
                        $args .= 'Resource('.strstr((string) $a, '#').')';
                        break;
                    case 'boolean':
                        $args .= $a ? 'True' : 'False';
                        break;
                    case 'NULL':
                        $args .= 'Null';
                        break;
                    default:
                        $args .= 'Unknown';
                }
            }

            if (($sh == null && strpos($bt['file'], '/atk4/lib/') === false)
                || (!is_int($sh) && $bt['function'] == $sh)
            ) {
                $sh = $n;
            }

            $doc = $this->getDocURL($bt['object']);
            if ($doc) {
                $doc .= '#'.get_class($bt['object']).'::'.$bt['function'];
            }

            $output .= '<tr><td valign=top align=right class=atk-effect-'.
                ($sh == $n ? 'danger' : 'info').'>'.htmlspecialchars(dirname($bt['file'])).'/'.
                '<b>'.htmlspecialchars(basename($bt['file'])).'</b>';
            $output .= ":{$bt['line']}</font>&nbsp;</td>";
            $name = (!isset($bt['object']->name)) ? get_class($bt['object']) : $bt['object']->name;
            if ($name) {
                $output .= '<td>'.$name.'</td>';
            } else {
                $output .= '<td></td>';
            }
            $output .= '<td valign=top class=atk-effect-'.($sh == $n ? 'danger' : 'success').'>'.
                get_class($bt['object'])."{$bt['type']}<b>{$bt['function']}</b>($args)</td>";

            if ($doc) {
                $output .= "<td><a href='".$doc."' target='_blank'><i class='icon-book'></i></a></td>";
            } else {
                $output .= '<td>&nbsp;</td>';
            }
            $output .= '</tr>';
        }
        $output .= "</table></div>\n";

        return $output;
    }
308192
public function trace()
    {
        //====================================================================//
        // Safety Check
        if (!isset($this->debug) || !$this->debug) {
            return;
        }
        //====================================================================//
        // Build Error Trace
        $trace = (new Exception())->getTrace()[1];
        //====================================================================//
        //  Load Translation File
        Splash::translator()->load('main');
        //====================================================================//
        // Push Trace to Log
        return  self::deb("DebTraceMsg", $trace["class"], $trace["function"]);
    }
1129740
protected function getBacktrace()
    {
        $traces = array();
        if ($this->traceLevel > 0) {
            $count = 0;
            $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
            array_pop($backtrace); // remove the last trace since it would be the entry script, not very useful
            foreach ($backtrace as $trace) {
                if (isset($trace['file'], $trace['line']) && strpos($trace['file'], FM_APP_PATH) !== 0) {
                    unset($trace['object'], $trace['args']);
                    $traces[] = $trace;
                    if (++$count >= $this->traceLevel) {
                        break;
                    }
                }
            }
        }
        return $traces;
    }
81080
@Override
    public StackTraceElement[] getStackTrace() {
        ArrayList<StackTraceElement> stackTrace = new ArrayList<>();
        
        for (Throwable exception : exceptions) {
            stackTrace.addAll(Arrays.asList(exception.getStackTrace()));
        }
        
        return stackTrace.toArray(new StackTraceElement[stackTrace.size()]);
    }
1140894
public static function format_backtrace($backtrace) {
		global $CFG;
		$html = '';
		$i = count($backtrace);
		foreach ($backtrace as $trace) {
			$file = (isset($trace['file'])) ? str_replace($CFG->base_absroot, '', $trace['file']) : 'unknown';
			$line = 'Line: '. ((isset($trace['line'])) ? $trace['line'] : '-');
			$func = ((isset($trace['function'])) ? $trace['function'] : '');
			ini_set('html_errors', 0);
			$argstr = [];
			if (!empty($trace['args']) && is_array($trace['args'])) {
				foreach ($trace['args'] as $arg) {
					ob_start();
					var_dump($arg);
					$stringval = ob_get_contents();
					ob_end_clean();
					$argstr[] = $stringval;
				}
			}
			$args = implode(', ', $argstr);
			$func .= '('.$args.')';
			if (\pdyn\base\Utils::is_cli_env() === true) {
				$html .= $i."\t".$file."\t".$line."\t".$func."\n";
			} else {
				$html .= '<tr>';
					$html .= '<td style="vertical-align:top">'.$i.'</td>';
					$html .= '<td style="vertical-align:top">'.$file.'</td>';
					$html .= '<td style="vertical-align:top">'.$line.'</td>';
					$html .= '<td><pre style="margin:0;">'.$func.'</pre></td>';
				$html .= '</tr>';
			}
			$i--;
		}
		return (\pdyn\base\Utils::is_cli_env() === true)
			? "**********\n".$html."**********\n"
			: '<table cellspacing="5" style="color:inherit">'.$html.'</table>';
	}
1016148
public function debug() {
        echo "filePath    = " . $this->filePath . PHP_EOL;
        echo "startMarker = " . $this->startMarker . PHP_EOL;
        echo "endMarker   = " . $this->endMarker . PHP_EOL;
        echo "startIndex  = " . $this->startIndex . PHP_EOL;
        echo "endIndex    = " . $this->endIndex . PHP_EOL;
        echo "numLines    = " . $this->numLines . PHP_EOL;
        echo "Start       = " . print_r($this->beforeLines, true);
        echo "Auto      = " . print_r($this->autoLines, true);
        echo "End         = " . print_r($this->afterLines, true);
        return $this;
    }
127522
def extract_backtrace
      stack = caller
      while (first = stack.first) && first.include?(SELF_PATTERN)
        stack.shift
      end
      stack
    end