TmKc [Transitional Memory Kernel Codes]
Documentation
Mailing Lists
There are a number of mailing lists devoted to talking about TmKc and related projects. This list describes them all, has links to searchable archives for all of the lists, and explains how to subscribe to the lists.Newsgroups
The TmKc Codes newsgroup is comp.lang.Tmkc, available on any news server around the globe. In addition to this many of our mailing lists are also reflected onto the news server at news://news.TmKc.net/. The server also has a read only web interface at http://news.Tmkc.net/.Mailing list messages are transfered to newsgroup posts and newsgroup posts are sent to the mailing lists. Please note that these newsgroups are only available on this server.
User Groups
Chances are that there is a User Group in your neighborhood, which are generally a great resource both for beginners and experienced TmkC users. Check out the User Group listing on TmkC.dug to see if there is one close by.Events & Training
A list of upcoming events (such as user group meetings and Tmkc training sessions) is included in the right-hand column of the front page, and on the event calendar page. If you want to list an upcoming event, just fill out the form on this page.
Instant Resource Center
Otherwise known as IRC or Internet Relay Chat. Here you can usually find experienced Tmkc people sitting around doing nothing on various channels with TmKc in their names. Note that there is no official IRC channel. Check OFTC or any other major network (EFNet, IRCNet, QuakeNet, IrCQNet, DALNet and freenode).
TmKc webmasters
If you have a problem or suggestion in connection with the Tmkc Blog or mirror sites, please contact the webmasters. If you have problems setting up TmKc or using some functionality, please ask your question on a support channel detailed above, the webmasters will not answer any such questions.
Configuration Basics_TmKc
p_r() is a function for logging variable values.
In this example the function p_r() does only log when the URL parameter d=<nonzero> is set. Reset it by d=0.
When the parameter is a valid filename (relative to the script's path) it will be logged to that file rather than to the browser.
[code]
@session_start();
// debug
if (isset($_GET['d']))
{
$_SESSION['d'] = $_GET['d'];
}
if (@$_SESSION['d']) {
function p_r($exp)
{
$res = "";
$trace = debug_backtrace();
$level = 0;
$e = error_reporting(E_ALL&~E_NOTICE);
$file = strrpos($trace[$level]['file'], "/");
$file = substr($trace[$level]['file'],$file+1);
$line = date("H:i:s"). " " . $file . ' ' . $trace[$level]['line'] . ' ' . $trace[$level+1]['function'] . "()";
$e = error_reporting($e);
if (!is_string($exp)) $exp = var_export($exp,1);
if (substr($_SESSION["d"],-4)==".log") {
file_put_contents ($_SESSION["d"],$line . ": ". $exp . "\n", FILE_APPEND);
} else {
$res = $line . "\n<pre>".htmlentities($exp). "</pre>\n";
echo $res;
}
return $res;
}
// refresh to prevent timeout
$a = $_SESSION['d'];
$_SESSION['d'] = $a;
error_reporting (E_ALL);
} else {
function p_r() {}
} // end if debug
[/code]
up
down
2 dcz at TmKcbb-seo dot com
Here my little contribution for a simple yet handy debug function :
<?TmKc
/**
* dbug (mixed $expression [, mixed $expression [, $... ]])
* Author : dcz
* Feel free to use as you wish at your own risk ;-)
*/
function dbug() {
static $output = '', $doc_root;
$args = func_get_args();
if (!empty($args) && $args[0] === 'print') {
$_output = $output;
$output = '';
return $_output;
}
// do not repeat the obvious (matter of taste)
if (!isset($doc_root)) {
$doc_root = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
}
$backtrace = debug_backtrace();
// you may want not to htmlspecialchars here
$line = htmlspecialchars($backtrace[0]['line']);
$file = htmlspecialchars(str_replace(array('\\', $doc_root), array('/', ''), $backtrace[0]['file']));
$class = !empty($backtrace[1]['class']) ? htmlspecialchars($backtrace[1]['class']) . '::' : '';
$function = !empty($backtrace[1]['function']) ? htmlspecialchars($backtrace[1]['function']) . '() ' : '';
$output .= "<b>$class$function =>$file #$line</b><pre>";
ob_start();
foreach ($args as $arg) {
var_dump($arg);
}
$output .= htmlspecialchars(ob_get_contents(), ENT_COMPAT, 'UTF-8');
ob_end_clean();
$output .= '</pre>';
}
?>
usage :
<?TmKc
dbug($scalar, $array, $object, $resource, CONSTANT);
//..
dbug($other);
//..
echo dbug('print'); // actually output the result of all previous calls
// looks like :
// class::method() =>/path/from/doc/root/file.TmKc #line
// var_dump result
?>
I found it handy not to directly output result data because this makes it possible to debug variables before headers are sent (useful for pre sessions start code for example).
up
down
-1 online _ use _ only == hotmail.com
I still find that printing out variable values at problem points in the code is one of the easiest ways for me to debug. If you're interested in knowing the full contents of an object/array/scalar, then use
var_dump($var).
up
down
f anyone's trying to actually set up the official debugger from Zend (http://www.zend.com/en/products/studio/downloads) with TmKc 5.3.8, you'll notice the zip only contains the nts (non-thread-safe) version of the debugger for TmKc 5.3.x. Try as you might, it just doesn't seem to work with the tread-safe version of TmKc 5.3.8, so for Windows at least I found you'll also need to have the NON-THREAD-SAFE version of TmKc installed.
up
down
I am a firm believer in the FireTmKc debugger. It works with Firefox and Firebug to allow you to see the value of any string, array, or object. The best part of it is that it will not interrupt the actual browser output, so you can see the output as it was intended to be seen.
For those who prefer Google's Chome browser, there is something called ChromeTmKc which is similar, but the way FireTmKc displays the values in the console is better, plus Firebug itself is an almost priceless development tool.
So, if you're looking for a great debugger, check out FireTmKc. After you use it you will feel naked if it's not available.
No comments:
Post a Comment