2009년 5월 23일 토요일

xdebug sample

<?

/*
xdebug 1.3.2

xdebug_get_function_stack
xdebug_call_class
xdebug_call_function
xdebug_call_file
xdebug_call_line
xdebug_var_dump
xdebug_enable
xdebug_disable
xdebug_is_enabled
xdebug_start_trace
xdebug_stop_trace
xdebug_get_function_trace
xdebug_dump_function_trace
xdebug_time_index
xdebug_start_code_coverage
xdebug_stop_code_coverage
xdebug_get_code_coverage
xdebug_start_profiling
xdebug_stop_profiling
xdebug_dump_function_profile
xdebug_get_function_profile
xdebug_dump_superglobals


xdebug.auto_profile   Off
xdebug.auto_profile_mode 0
xdebug.auto_trace   Off
xdebug.collect_params  Off
xdebug.default_enable  On
xdebug.dump.COOKIE
xdebug.dump.ENV
xdebug.dump.FILES
xdebug.dump.GET
xdebug.dump.POST
xdebug.dump.REQUEST
xdebug.dump.SERVER
xdebug.dump.SESSION
xdebug.dump_once   On
xdebug.dump_undefined  Off
xdebug.manual_url   http://www.php.net http://www.php.net
xdebug.max_nesting_level 64
xdebug.output_dir   /tmp

xdebug.remote_enable  Off
xdebug.remote_handler  gdb
xdebug.remote_host   localhost
xdebug.remote_mode   req
xdebug.remote_port   17869
*/

ini_set("xdebug.auto_profile", 1);
ini_set("xdebug.auto_profile_mode", 1);
ini_set("xdebug.max_nesting_level", 64);

function xdebug_start()
{
 xdebug_load();

 if(!xdebug_is_enabled())
  xdebug_enable();

 xdebug_start_profiling();
}

function xdebug_stop()
{
 xdebug_dump_function_profile(4);
 xdebug_stop_profiling();
}

/*******************************************************************************
* php.ini - extension_dir=./ 으로 설정되어 있어..--;
*******************************************************************************/
function xdebug_load()
{
 $module = "/usr/local/lib/php/extensions/no-debug-non-zts-20020429/xdebug.so";

 $dir[e]  = ini_get("extension_dir");
 $dir[u]  = dirname($_SERVER[PATH_TRANSLATED]) . "/";
 $dir[ut] = preg_replace(";[^/]+;", "..", $dir[u]);
 
 if(preg_match(";^/;", $dir[e]))
  $dir[e] = preg_replace(";[^/]+;", "..", $dir[e]);
 else
  $dir[e] = "";

 if(preg_match(";^/;", $module))
 {
  if(!$dir[e])
   $file = $dir[ut] . $module;
  else
   $file = $dir[e] . $module;
 }
 else
 {
  if(!$dir[e])
   $file = $module;
     else
   $file = $dir[e] . $dir[u] . $module;
 }

 if(is_file($file))
 {
  $ext = str_replace(".so", "", basename($file));
     if(!extension_loaded($ext))
   @dl($file);
 }

 if(!extension_loaded($ext))
  echo $file . " load fail!!";
}

?>

댓글 없음:

댓글 쓰기