From a937111319299a5af1390496329410d89fcb6ef8 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Tue, 27 Sep 2011 17:11:21 +0000 Subject: speedup and lower mem usage for traces --- it_debug.class | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'it_debug.class') diff --git a/it_debug.class b/it_debug.class index 0b14cc7..3c05992 100644 --- a/it_debug.class +++ b/it_debug.class @@ -59,7 +59,7 @@ function debug($text, $level = 0) function srcline($stackoffs = 0) { - $stack = debug_backtrace(); + $stack = debug_backtrace(@constant('DEBUG_BACKTRACE_IGNORE_ARGS')); $line = $stack[1 + $stackoffs]['line']; $file = $stack[1 + $stackoffs]['file']; @@ -158,7 +158,7 @@ function dump($args) } if ($GLOBALS['debug_indent']) - $r = str_repeat(" ", count(debug_backtrace())-3) . $r; + $r = str_repeat(" ", count(debug_backtrace(@constant('DEBUG_BACKTRACE_IGNORE_ARGS')))-3) . $r; # not it_html::Q(); we dont wanna load it_html in ultraclassloader debugging $title = htmlspecialchars(it_debug::backtrace(array('skiplevels' => 1))); @@ -182,23 +182,18 @@ function backtrace($p = array()) $p += array('levels' => 0, 'skiplevels'=> 0, 'skipfiles' => "###"); - if (function_exists('memory_get_usage') && (memory_get_usage() > 50000000)) - $result = array("[mem usage too high]"); - else + foreach (array_slice(debug_backtrace(@constant('DEBUG_BACKTRACE_IGNORE_ARGS')), $p['skiplevels'] + 1) as $call) { - foreach (array_slice(debug_backtrace(), $p['skiplevels'] + 1) as $call) + if (($fn = $call['file']) && !it::match($p['skipfiles'], $call['file'])) { - if (($fn = $call['file']) && !it::match($p['skipfiles'], $call['file'])) - { - if (!it::match('\.class', $call['file']) && file_get_contents($call['file'], null, null, 0, 2) == "#!") - $call['line']++; # fix bug in php error line reporting + if (!it::match('\.class', $call['file']) && file_get_contents($call['file'], null, null, 0, 2) == "#!") + $call['line']++; # fix bug in php error line reporting - $fn = (it::match('auto_prepend', $fn) ? basename(dirname(dirname($fn))) . "/" : "") . basename($fn); - $result[] = $fn . ":" . $call['line']; + $fn = (it::match('auto_prepend', $fn) ? basename(dirname(dirname($fn))) . "/" : "") . basename($fn); + $result[] = $fn . ":" . $call['line']; - if (--$p['levels'] == 0) - break; - } + if (--$p['levels'] == 0) + break; } } -- cgit v1.2.3