From e001f70760918bd9a107d9056808d14b4fcd6b1c Mon Sep 17 00:00:00 2001 From: Robin Johnson Date: Sun, 2 Feb 2003 08:17:00 +0000 Subject: [PATCH] DBG extension! --- ChangeLog | 7 +++ Documentation.html | 43 ++++++++++++++++- config.inc.php3 | 9 ++++ footer.inc.php3 | 21 ++++++++- libraries/dbg/profiling.php3 | 89 ++++++++++++++++++++++++++++++++++++ libraries/dbg/setup.php3 | 31 +++++++++++++ 6 files changed, 197 insertions(+), 3 deletions(-) create mode 100644 libraries/dbg/profiling.php3 create mode 100644 libraries/dbg/setup.php3 diff --git a/ChangeLog b/ChangeLog index e5b9c8fc8..3416aa9f8 100755 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,13 @@ $Source$ gave their lives for the people of Earth. --- * Documentation.html: Removed a bit of duplication in [7.4] and the Developers section + * libraries/dbg: New directory for DBG code + * libraries/dbg/setup.php3: + - DBG initialization code, including module support + * libraries/dbg/profiling.php3: Profiling code + * lang/*: New strings added for DBG extension + * config.inc.php3: config options for DBG, off by default + * footer.inc.php3: DBG profiling output 2003-02-01 Michal Cihar * Documentati-on.*, translators.html, docs.css: New documentation layout. diff --git a/Documentation.html b/Documentation.html index f164c6ab8..e9a27149b 100755 --- a/Documentation.html +++ b/Documentation.html @@ -1400,6 +1400,36 @@ $cfg['PmaAbsoluteUri'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'

+
$cfg['DBG']['enable'] boolean
+
+ DEVELOPERS ONLY!
+ Enable the DBG extension for debugging phpMyAdmin. Required for profiling + the code. +
+ For help in setting up your system to this, see the + Developers section. +
+ +
$cfg['DBG']['profile']['enable'] boolean
+
+ DEVELOPERS ONLY!
+ Enable profiling support for phpMyAdmin. This will append a chunk of data + to the end of every page displayed in the main window with profiling + statistics for that page.
+ You may need need to increase the maximum execution time for this to + complete successfully. +
+ +
$cfg['DBG']['profile']['threshold'] float (units in milliseconds)
+
+ DEVELOPERS ONLY!
+ When profiling data is displayed, this variable controls the threshold of + display for any profiling data, based on the average time each time has + taken. If it is over the threshold it is displayed, otherwise it is not + displayed. This takes a value in milliseconds. In most cases you don't need + to edit this. +
+
$cfg['ColumnTypes'] array
All possible types of a MySQL column. In most cases you don't need to @@ -2578,7 +2608,7 @@ $cfg['PmaAbsoluteUri'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' please try to keep your code as simple as possible: beginners are using phpMyAdmin as an example application.
As far as possible, we want the scripts to be XHTML1.0 and CSS2 - compliant on one hand, they fit + compliant on one hand, they fit the PEAR coding standards on the other hand. Please pay attention to this. @@ -2594,6 +2624,17 @@ $cfg['PmaAbsoluteUri'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
  • If you want to be really helpful, write an entry for the ChangeLog.
  • +
  • + The DBG extension (PHP + Debugger DBG) is now supported by phpMyAdmin for developers to + better debug and profile their code.
    + Please see the $cfg['DBG']* configuration options for more + information.
    + This is in memorium of the Space Shuttle Columbia (STS-107) which was + lost during its re-entry into Earth's atmosphere and in memory of the + brave men and women who gave their lives for the people of Earth. +
  • + diff --git a/config.inc.php3 b/config.inc.php3 index 02629d88b..df67c1dfa 100755 --- a/config.inc.php3 +++ b/config.inc.php3 @@ -417,6 +417,15 @@ $cfg['SQLValidator']['use'] = FALSE; // Make the SQL Validator available $cfg['SQLValidator']['username'] = ''; // If you have a custom username, specify it here (defaults to anonymous) $cfg['SQLValidator']['password'] = ''; // Password for username +/** + * Developers ONLY! + * To use the following, please install the DBG extension from http://dd.cron.ru/dbg/ + */ +$cfg['DBG']['enable'] = FALSE; // Make the DBG stuff available +$cfg['DBG']['profile']['enable'] = FALSE; // Produce profiling results of PHP +$cfg['DBG']['profile']['threshold'] = 0.5; // Threshold of long running code to display + // Anything below the threshold is not displayed + /** * MySQL settings diff --git a/footer.inc.php3 b/footer.inc.php3 index 5acad815e..029ea4fd0 100755 --- a/footer.inc.php3 +++ b/footer.inc.php3 @@ -21,11 +21,28 @@ if (isset($GLOBALS['userlink']) && $GLOBALS['userlink']) { diff --git a/libraries/dbg/profiling.php3 b/libraries/dbg/profiling.php3 new file mode 100644 index 000000000..a546caebb --- /dev/null +++ b/libraries/dbg/profiling.php3 @@ -0,0 +1,89 @@ + + */ + + dbg_get_profiler_results(&$dbg_prof_results); + + echo '
    ' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n"; + foreach ($dbg_prof_results['line_no'] as $idx => $line_no) { + $mod_no = $dbg_prof_results['mod_no'][$idx]; + dbg_get_module_name($mod_no, &$mod_name); + + //if (strpos("!".$mod_name, 'dbg.php') > 0) continue; + + $hit_cnt = $dbg_prof_results['hit_count'][$idx]; + + $time_sum = $dbg_prof_results['tm_sum'][$idx] * 1000; + $time_avg_hit = $time_sum / $hit_cnt; + $time_min = $dbg_prof_results['tm_min'][$idx] * 1000; + $time_max = $dbg_prof_results['tm_max'][$idx] * 1000; + + $time_sum = sprintf('%.3f', $time_sum); + $time_avg_hit = sprintf('%.3f', $time_avg_hit); + $time_min = sprintf('%.3f', $time_min); + $time_max = sprintf('%.3f', $time_max); + + dbg_get_source_context($mod_no, $line_no, &$ctx_id); + + //use a default context name if needed + if (dbg_get_context_name($ctx_id, &$ctx_name) + && strcmp($ctx_name,'') == 0) { + $ctx_name = "::main"; + } + + $bk = "#ffffff"; + if (($idx & 1) == 0) + $bk = "#e0e0e0"; + + if($time_avg_hit > $GLOBALS['cfg']['DBG']['profile']['threshold'] ) { + echo '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . "\n"; + } + } + echo "
    ' . $GLOBALS['strDBGModule'] . '' . $GLOBALS['strDBGLine'] . '' . $GLOBALS['strDBGHits'] . '' . $GLOBALS['strDBGTimePerHitMs'] . '' . $GLOBALS['strDBGTotalTimeMs'] . '' . $GLOBALS['strDBGMinTimeMs'] . '' . $GLOBALS['strDBGMinTimeMs'] . '' . $GLOBALS['strDBGContextID'] . '' . $GLOBALS['strDBGContext'] . '
    ' . $mod_name . '' . $line_no . '' . $hit_cnt . '' . $time_avg_hit . '' . $time_sum . '' . $time_min . '' . $time_max . '' . $ctx_id . '' . $ctx_name . '
    "; + } + } +} + +?> diff --git a/libraries/dbg/setup.php3 b/libraries/dbg/setup.php3 new file mode 100644 index 000000000..88bbbcb17 --- /dev/null +++ b/libraries/dbg/setup.php3 @@ -0,0 +1,31 @@ += 40000 && !@ini_get('safe_mode') && @ini_get('enable_dl')) + && @function_exists('dl')) { + $extension = 'dbg'; + if (PMA_IS_WINDOWS) { + $suffix = '.dll'; + } else { + $suffix = '.so'; + } + if (!@extension_loaded($extension)) { + @dl($extension . $suffix); + } + if (!@extension_loaded($extension)) { + echo $strCantLoadDBG . '
    ' . "\n" + . '' . $GLOBALS['strDocu'] . '' . "\n"; + exit(); + } + $GLOBALS['DBG'] = true; + } // end load mysql extension + } +} + +?>