1. <!---
  2. **
  3. * CF5 Debugging Output
  4. *
  5. * Copyright (c) 2001 Macromedia. All Rights Reserved.
  6. * DO NOT REDISTRIBUTE THIS SOFTWARE IN ANY WAY WITHOUT THE EXPRESSED
  7. * WRITTEN PERMISSION OF MACROMEDIA.
  8. --->
  9. <cfif IsDebugMode()>
  10. <cfsilent>
  11. <cfset startTime = getTickCount()>
  12. <cfscript>
  13.     formEncoding = getEncoding("FORM");
  14.     urlEncoding = getEncoding("URL");
  15.     setEncoding("FORM", formEncoding);
  16.     setEncoding("URL", urlEncoding);
  17. </cfscript>
  18. </cfsilent>
  19. <!--- Localized strings --->
  20. <cfset undefined = "">
  21.     <!--- Use the debugging service to check options --->
  22.     <cftry>
  23.         <cfobject action="CREATE" type="JAVA" class="coldfusion.server.ServiceFactory" name="factory">
  24.         <cfset cfdebugger = factory.getDebuggingService()>
  25.         <cfcatch type="Any"></cfcatch>
  26.     </cftry>
  27.     <!--- Load the debugging service's event table --->
  28.     <cfset qEvents = cfdebugger.getDebugger().getData()>
  29.     <!--- Produce the filtered event queries --->
  30.     <!--- EVENT: Templates --->
  31.     <cftry>
  32.         <cfquery dbType="query" name="cfdebug_templates" debug="false">
  33.             SELECT template, parent, Sum(endTime - StartTime) AS et
  34.             FROM qEvents
  35.             WHERE type = 'Template'
  36.             GROUP BY template, parent
  37.             ORDER BY et DESC
  38.         </cfquery>
  39. <!--- added by Aaron Longnion, 2007-03-24, so we can see the order files ran --->
  40.         <cfquery name="cfdebug_orderedTemplates" dbtype="query" debug="false">
  41.             SELECT
  42.                 line,
  43.                 parent,
  44.                 template
  45.             FROM
  46.              qEvents
  47.             WHERE
  48.              type = 'Template'
  49.             ORDER BY
  50.              starttime DESC
  51.         </cfquery>
  52.         <cfscript>
  53.             if( cfdebug_templates.recordCount eq 1 and len(trim(cfdebug_templates.et)) )
  54.             {
  55.                 querySetCell(cfdebug_templates, "et", "0", 1);
  56.             }
  57.         </cfscript>
  58.         <cfcatch type="Any">
  59.             <cfscript>
  60.                 cfdebug_templates = queryNew('template, parent, et');
  61.             </cfscript>
  62.         </cfcatch>
  63.     </cftry>
  64.     <!--- EVENT: SQL Queries --->
  65.     <cftry>
  66.         <cfquery dbType="query" name="cfdebug_queries" debug="false">
  67.             SELECT *, (endTime - startTime) AS executionTime
  68.             FROM qEvents
  69.             WHERE type = 'SqlQuery'
  70.         </cfquery>
  71.         <cfscript>
  72.             if( cfdebug_queries.recordCount eq 1 and len(trim(cfdebug_queries.executionTime)) )
  73.             {
  74.                 querySetCell(cfdebug_queries, "executionTime", "0", 1);
  75.             }
  76.         </cfscript>
  77.         <cfcatch type="Any">
  78.             <cfscript>
  79.                 cfdebug_queries = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL, et');
  80.             </cfscript>
  81.         </cfcatch>
  82.     </cftry>
  83.     <!--- EVENT: Object Queries --->
  84.     <cftry>
  85.         <cfquery dbType="query" name="cfdebug_cfoql" debug="false">
  86.             SELECT *, (endTime - startTime) AS executionTime
  87.             FROM qEvents
  88.             WHERE type = 'ObjectQuery'
  89.         </cfquery>
  90.         <cfscript>
  91.             if( cfdebug_cfoql.recordCount eq 1 and len(trim(cfdebug_cfoql.executionTime)) )
  92.             {
  93.                 querySetCell(cfdebug_cfoql, "executionTime", "0", 1);
  94.             }
  95.         </cfscript>
  96.         <cfcatch type="Any">
  97.             <cfscript>
  98.                 cfdebug_cfoql = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL');
  99.             </cfscript>
  100.         </cfcatch>
  101.     </cftry>
  102.     <!--- EVENT: Stored Procedures --->
  103.     <cftry>
  104.         <cfquery dbType="query" name="cfdebug_storedproc" debug="false">
  105.             SELECT *, (endTime - startTime) AS executionTime
  106.             FROM qEvents
  107.             WHERE type = 'StoredProcedure'
  108.         </cfquery>
  109.         <cfscript>
  110.             if( cfdebug_storedproc.recordCount eq 1 and len(trim(cfdebug_storedproc.executionTime)) )
  111.             {
  112.                 querySetCell(cfdebug_storedproc, "executionTime", "0", 1);
  113.             }
  114.         </cfscript>
  115.         <cfcatch type="Any">
  116.             <cfscript>
  117.                 cfdebug_storedproc = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL');
  118.             </cfscript>
  119.         </cfcatch>
  120.     </cftry>
  121.     <!--- EVENT: Trace Points --->
  122.     <cftry>
  123.         <cfquery dbType="query" name="cfdebug_trace" debug="false">
  124.             SELECT *
  125.             FROM qEvents
  126.             WHERE type = 'Trace'
  127.         </cfquery>
  128.         <cfcatch type="Any">
  129.             <cfscript>
  130.                 cfdebug_trace = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL');
  131.             </cfscript>
  132.         </cfcatch>
  133.     </cftry>
  134.     <!--- EVENT: CFTimer Points --->
  135.     <cftry>
  136.         <cfquery dbType="query" name="cfdebug_timer" debug="false">
  137.             SELECT *
  138.             FROM qEvents
  139.             WHERE type = 'CFTimer'
  140.         </cfquery>
  141.         <cfcatch type="Any">
  142.             <cfscript>
  143.                 cfdebug_timer = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL');
  144.             </cfscript>
  145.         </cfcatch>
  146.     </cftry>
  147.     <!--- EVENT: Locking Warning Points --->
  148.     <cftry>
  149.         <cfquery dbType="query" name="cfdebug_lock" debug="false">
  150.             SELECT *
  151.             FROM qEvents
  152.             WHERE type = 'LockWarning'
  153.         </cfquery>
  154.         <cfcatch type="Any">
  155.             <cfscript>
  156.                 cfdebug_lock = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL');
  157.             </cfscript>
  158.         </cfcatch>
  159.     </cftry>
  160.     <!--- EVENT: Exceptions --->
  161.     <cftry>
  162.         <cfquery dbType="query" name="cfdebug_ex" debug="false">
  163.             SELECT *
  164.             FROM qEvents
  165.             WHERE type = 'Exception'
  166.         </cfquery>
  167.         <cfcatch type="Any">
  168.             <cfscript>
  169.                 cfdebug_ex = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL');
  170.             </cfscript>
  171.         </cfcatch>
  172.     </cftry>
  173.     <!--- Establish Section Display Flags --->
  174.     <cfparam name="displayDebug" default="false" type="boolean"><!--- ::    display the debug time     :: --->
  175.     <cfparam name="bGeneral" default="false" type="boolean">
  176.     <cfparam name="bFoundExecution" default="false" type="boolean">
  177.     <cfparam name="bFoundTemplates" default="false" type="boolean">
  178.     <cfparam name="bFoundExceptions" default="false" type="boolean">
  179.     <cfparam name="bFoundSQLQueries" default="false" type="boolean">
  180.     <cfparam name="bFoundObjectQueries" default="false" type="boolean">
  181.     <cfparam name="bFoundStoredProc" default="false" type="boolean">
  182.     <cfparam name="bFoundTrace" default="false" type="boolean">
  183.     <cfparam name="bFoundTimer" default="false" type="boolean">
  184.     <cfparam name="bFoundLocking" default="false" type="boolean">
  185.     <cfparam name="bFoundScopeVars" default="false" type="boolean">
  186.     <cftry>
  187.         <cfscript>
  188.             bFoundTemplates = cfdebugger.check("Template");
  189.             if( bFoundTemplates )
  190.             { displayDebug=true; }
  191.             if ( isDefined("cfdebugger.settings.general") and cfdebugger.settings.general )
  192.             { bGeneral = true; displayDebug=true; }
  193.             if (IsDefined("cfdebug_ex") AND cfdebug_ex.recordCount GT 0) { bFoundExceptions = true; displayDebug=true; }
  194.             else { bFoundExceptions = false; }
  195.             if (IsDefined("cfdebug_queries") AND cfdebug_queries.RecordCount GT 0) { bFoundSQLQueries = true; displayDebug=true; }
  196.             else { bFoundSQLQueries = false; }
  197.             if (IsDefined("cfdebug_cfoql") AND cfdebug_cfoql.RecordCount GT 0) { bFoundObjectQueries = true; displayDebug=true; }
  198.             else { bFoundObjectQueries = false; }
  199.             if (IsDefined("cfdebug_storedproc") AND cfdebug_storedproc.RecordCount GT 0) { bFoundStoredProc = true; displayDebug=true; }
  200.             else { bFoundStoredProc = false; }
  201.             if (IsDefined("cfdebug_trace") AND cfdebug_trace.recordCount GT 0) { bFoundTrace = true; displayDebug=true; }
  202.             else { bFoundTrace = false; }
  203.             if (IsDefined("cfdebug_timer") AND cfdebug_timer.recordCount GT 0) { bFoundTimer = true; displayDebug=true; }
  204.             else { bFoundTimer = false; }
  205.             if (IsDefined("cfdebug_lock") AND cfdebug_lock.recordCount GT 0) { bFoundLocking = true; displayDebug=true; }
  206.             else { bFoundLocking = false; }
  207.             if (IsDefined("cfdebugger") AND cfdebugger.check("Variables")) { bFoundScopeVars = true; displayDebug=true; }
  208.             else { bFoundScopeVars = false; }
  209.         </cfscript>
  210.         <cfcatch type="Any"></cfcatch>
  211.     </cftry>
  212. <cfsetting enablecfoutputonly="Yes">
  213. <cfif displayDebug>
  214. <cfoutput>
  215. </td></td></td></th></th></th></tr></tr></tr></table></table></table></a></abbrev></acronym></address></applet></au></b></banner></big></blink></blockquote></bq></caption></center></cite></code></comment></del></dfn></dir></div></div></dl></em></fig></fn></font></form></frame></frameset></h1></h2></h3></h4></h5></h6></head></i></ins></kbd></listing></map></marquee></menu></multicol></nobr></noframes></noscript></note></ol></p></param></person></plaintext></pre></q></s></samp></script></select></small></strike></strong></sub></sup></table></td></textarea></th></title></tr></tt></u></ul></var></wbr></xmp>
  216. <style type="text/css">
  217. .cfdebug
  218. {
  219.     color:black;
  220.     background-color:white;
  221.     font-family:"Times New Roman", Times, serif;
  222.     font-size:small;
  223.     text-align: left;
  224. }
  225. .cfdebuglge
  226. {
  227.     color:black;
  228.     background-color:white;
  229.     font-family:"Times New Roman", Times, serif;
  230.     font-size:medium;
  231. }
  232. a.cfdebuglink {color:blue; background-color:white }
  233. </style>
  234. <table class="cfdebug" bgcolor="white">
  235. <tr>
  236.     <td>
  237. </cfoutput>
  238. </cfif>
  239. <cfif bGeneral>
  240. <cfoutput>
  241.     <cftry>
  242.         <p class="cfdebug"><hr/>
  243.         <b class="cfdebuglge"><a name="cfdebug_top">Debugging Information</a></b>
  244.         <table class="cfdebug">
  245.         <tr>
  246.             <td class="cfdebug" nowrap>#server.coldfusion.productname# #server.coldfusion.productlevel#</td>
  247.             <td class="cfdebug">#server.coldfusion.productversion#</td>
  248.         </tr>
  249.         <tr>
  250.             <td class="cfdebug" nowrap> Template </td>
  251.             <td class="cfdebug">#xmlFormat(CGI.Script_Name)#</td>
  252.         </tr>
  253.         <tr>
  254.             <td class="cfdebug" nowrap> Time Stamp </td>
  255.             <td class="cfdebug">#DateFormat(Now())# #TimeFormat(Now())#</td>
  256.         </tr>
  257.         <tr>
  258.             <td class="cfdebug" nowrap> Locale </td>
  259.             <td class="cfdebug">#GetLocale()#</td>
  260.         </tr>
  261.         <tr>
  262.             <td class="cfdebug" nowrap> User Agent </td>
  263.             <td class="cfdebug">#CGI.HTTP_USER_AGENT#</td>
  264.         </tr>
  265.         <tr>
  266.             <td class="cfdebug" nowrap> Remote IP </td>
  267.             <td class="cfdebug">#CGI.REMOTE_ADDR#</td>
  268.         </tr>
  269.         <tr>
  270.             <td class="cfdebug" nowrap> Host Name </td>
  271.             <td class="cfdebug">#CGI.REMOTE_HOST#</td>
  272.         </tr>
  273.         </table>
  274.         </p>
  275.         <cfcatch type="Any"></cfcatch>
  276.     </cftry>
  277. </cfoutput>
  278. </cfif>
  279. <!--- Template Stack and Executions Times --->
  280. <cfif bFoundTemplates>
  281.     <!--- Total Execution Time of all top level pages --->
  282.     <cfquery dbType="query" name="cfdebug_execution" debug="false">
  283.     SELECT (endTime - startTime) AS executionTime
  284.     FROM qEvents
  285.     WHERE type = 'ExecutionTime'
  286.     </cfquery>
  287.     <!--- ::
  288.         in the case that no execution time is recorded.
  289.         we will add a value of -1 so we know that a problem exists but the template continues to run properly.
  290.         :: --->
  291.     <cfif not cfdebug_execution.recordCount>
  292.         <cfscript>
  293.             queryAddRow(cfdebug_execution);
  294.             querySetCell(cfdebug_execution, "executionTime", "-1");
  295.         </cfscript>
  296.     </cfif>
  297.     <cfquery dbType="query" name="cfdebug_top_level_execution_sum" debug="false">
  298.         SELECT sum(endTime - startTime) AS executionTime
  299.          FROM qEvents
  300.         WHERE type = 'Template' AND parent = ''
  301.     </cfquery>
  302. <!--- File not found will not produce any records when looking for top level pages --->
  303. <cfif cfdebug_top_level_execution_sum.recordCount and len(trim(cfdebug_top_level_execution_sum.executionTime[1])) gt 0>
  304. <cfset time_other = Max(cfdebug_execution.executionTime - val(cfdebug_top_level_execution_sum.executionTime), 0)>
  305. <cfoutput>
  306.             <style type="text/css">
  307. .template
  308. {    color: black;
  309.     font-family: "Times New Roman", Times, serif;
  310.     font-weight: normal; }
  311. .template_overage
  312. {    color: red;
  313.     background-color: white;
  314.     font-family: "Times New Roman", Times, serif;
  315.     font-weight: bold; }
  316. </style>
  317. </cfoutput>
  318. <cfif cfdebugger.settings.template_mode EQ "tree">
  319. <cfset a = arrayNew(1)>
  320. <cfloop query="qEvents">
  321. <cfscript>
  322. // in cannot convert the value "" to a boolean for cachedquery column
  323. // SELECT stacktrace will result in Query Of Queries runtime error.
  324. // Failed to get meta_data for columnqEvents.stacktrace .
  325. // Was told I need to define meta data for debugging event table similar to <cfldap>
  326. if( qEvents.type eq "template" ) {
  327. st = structNew();
  328. st.StackTrace = qEvents.stackTrace;
  329. st.template = qEvents.template;
  330. st.startTime = qEvents.starttime;
  331. st.endTime = qEvents.endtime;
  332. st.parent = qEvents.parent;
  333. st.line = qEvents.line;
  334. arrayAppend(a, st);
  335. }
  336. </cfscript>
  337. </cfloop>
  338. <cfset qTree = queryNew("template,templateId,parentId,duration,line")>
  339. <cfloop index="i" from="1" to="#arrayLen(a)#">
  340. <cfset childidList = "">
  341. <cfset parentidList = "">
  342. <cfloop index="x" from="#arrayLen(a[i].stacktrace.tagcontext)#" to="1" step="-1">
  343. <cfscript>
  344. if( a[i].stacktrace.tagcontext[x].id NEQ "CF_INDEX" ) {
  345. // keep appending the line number from the template stack to form a unique id
  346. childIdList = listAppend(childIdList, a[i].stacktrace.tagcontext[x].line);
  347. if( x eq 1 ) {
  348. parentIdList = listAppend(parentIdList, a[i].stacktrace.tagcontext[x].template);
  349. } else {
  350. parentIdList = listAppend(parentIdList, a[i].stacktrace.tagcontext[x].line);
  351. }
  352. }
  353. </cfscript>
  354. </cfloop>
  355. <cfscript>
  356. // template is the last part of the unique id...12,5,17,c:\wwwroot\foo.cfm
  357. // if we don't remove the "CFC[" prefix, then the parentId and childId relationship
  358. // will be all wrong
  359. startToken = "CFC[ ";
  360. endToken = " | ";
  361. thisTemplate = a[i].template;
  362. startTokenIndex = FindNoCase(startToken, thisTemplate, 1);
  363. if( startTokenIndex NEQ 0 ) {
  364. endTokenIndex = FindNoCase(endToken, thisTemplate, startTokenIndex);
  365. thisTemplate = Trim(Mid(thisTemplate,Len(startToken),endTokenIndex-Len(startToken)));
  366. }
  367. childIdList = listAppend(childIdList, thisTemplate);
  368. queryAddRow(qTree);
  369. querySetCell(qTree, "template", a[i].template);
  370. querySetCell(qTree, "templateId", childIdList);
  371. querySetCell(qTree, "parentId", parentIdList);
  372. querySetCell(qTree, "duration", a[i].endtime - a[i].starttime);
  373. querySetCell(qTree, "line", a[i].line);
  374. </cfscript>
  375. </cfloop>
  376. <cfset stTree = structNew()>
  377. <cfloop query="qTree">
  378. <cfscript>
  379. // empty parent assumed to be top level with the exception of application.cfm
  380. if( len(trim(parentId)) eq 0 ){
  381. parentId = 0;
  382. }
  383. stTree[parentId] = structNew();
  384. stTree[parentId].templateId = qTree.templateId;
  385. stTree[parentId].template = qTree.template;
  386. stTree[parentId].duration = qTree.duration;
  387. stTree[parentId].line = qTree.line;
  388. stTree[parentId].children = arrayNew(1);
  389. </cfscript>
  390. </cfloop>
  391. <cfloop query="qTree">
  392. <cfscript>
  393. stTree[templateId] = structNew();
  394. stTree[templateId].templateId = qTree.templateId;
  395. stTree[templateId].template = qTree.template;
  396. stTree[templateId].duration = qTree.duration;
  397. stTree[templateId].line = qTree.line;
  398. stTree[templateId].children = arrayNew(1);
  399. </cfscript>
  400. </cfloop>
  401. <cfloop query="qTree">
  402. <cfscript>
  403. arrayAppend(stTree[parentId].children, stTree[templateId]);
  404. </cfscript>
  405. </cfloop>
  406. <cfquery dbType="query" name="topNodes" debug="false">
  407. SELECT parentId, templateid
  408. FROM qTree
  409. WHERE parentId = ''
  410. </cfquery>
  411. <cfoutput>
  412. <p class="cfdebug"><hr/><b class="cfdebuglge">Execution Time</b></p>
  413. </cfoutput>
  414. <cfoutput query="topNodes">
  415. #drawTree(stTree,-1,topNodes.templateid,cfdebugger.settings.template_highlight_minimum)#
  416. </cfoutput>
  417. <cfoutput><p class="template">
  418. (#time_other# ms) STARTUP, PARSING, COMPILING, LOADING, &amp; SHUTDOWN<br />
  419. (#cfdebug_execution.executionTime# ms) TOTAL EXECUTION TIME<br />
  420. <font color="red"><span class="template_overage">red = over #cfdebugger.settings.template_highlight_minimum# ms execution time</span></font>
  421. </p></cfoutput>
  422. <cfelse>
  423.     <cftry>
  424. <!--- added by Aaron Longnion, 2007-03-24, so we can see the order files ran --->
  425.         <cfoutput>
  426.              <p class="cfdebug"><hr/><b class="cfdebuglge">Ordered Templates (DESC)</b></p>
  427.      <table border="1" cellpadding="2" cellspacing="0" class="cfdebug">
  428.      <tr>
  429.                         <td class="cfdebug" align="center"><b>Line</b></td>
  430.                         <td class="cfdebug" align="center"><b>Template</b></td>
  431.                         <td class="cfdebug" align="center"><b>Parent</b></td>
  432.                     </tr>
  433. </cfoutput>
  434.         <cfoutput query="cfdebug_orderedTemplates">
  435.             <cfif Len(cfdebug_orderedTemplates.Parent)
  436.              AND cfdebug_orderedTemplates.Template NEQ cfdebug_orderedTemplates.Parent>
  437.                 <cfset orderedTemplate = Replace(cfdebug_orderedTemplates.Template, cfdebug_orderedTemplates.Parent, "")>
  438.                 <cfset orderedTemplate = Replace(orderedTemplate, "from", "")>
  439.             <cfelse>
  440. <cfset orderedTemplate = cfdebug_orderedTemplates.Template>
  441. </cfif>
  442.             <tr>
  443.                         <td class="cfdebug" align="center"><b>#cfdebug_orderedTemplates.Line#</b></td>
  444.                         <td class="cfdebug" align="center"><b>#orderedTemplate#</b></td>
  445.                         <td class="cfdebug" align="center"><b>#cfdebug_orderedTemplates.Parent#</b></td>
  446.                     </tr>
  447.         </cfoutput>
  448.         <cfoutput>
  449. </table>
  450. </cfoutput>
  451. <cfoutput>
  452. <p class="cfdebug"><hr/><b class="cfdebuglge">Execution Time</b></p>
  453. </cfoutput>
  454.          <cfquery dbType="query" name="cfdebug_templates_summary" debug="false">
  455.      SELECT template, Sum(endTime - startTime) AS totalExecutionTime, count(template) AS instances
  456.      FROM qEvents
  457.      WHERE type = 'Template'
  458.      group by template
  459.      order by totalExecutionTime DESC
  460. </cfquery>
  461. <cfoutput>
  462. <table border="1" cellpadding="2" cellspacing="0" class="cfdebug">
  463. <tr>
  464.                     <td class="cfdebug" align="center"><b>Total Time</b></td>
  465.                     <td class="cfdebug" align="center"><b>Avg Time</b></td>
  466.                     <td class="cfdebug" align="center"><b>Count</b></td>
  467.                     <td class="cfdebug"><b>Template</b></td>
  468.                 </tr>
  469. </cfoutput>
  470. <cftry>
  471. <cfoutput query="cfdebug_templates_summary">
  472. <cfset templateOutput = template>
  473. <cfset templateAverageTime = Round(totalExecutionTime / instances)>
  474. <cfif template EQ ExpandPath(cgi.script_name)>
  475. <cfset templateOutput =
  476. "<b>" & template & "</b>">
  477.                              <cfif templateAverageTime GT cfdebugger.settings.template_highlight_minimum>
  478. <cfset templateOutput = "<font color='red'><span class='template_overage'>" & template & "</span></font>">
  479. <cfset templateAverageTime = "<font color='red'><span class='template_overage'>" & templateAverageTime & "</span></font>">
  480.                                  <cfset totalTime = "<font color='red'><span class='template_overage'>" & totalExecutionTime & "</span></font>">
  481. </cfif>
  482. <cfelse>
  483. <cfif templateAverageTime GT cfdebugger.settings.template_highlight_minimum>
  484. <cfset templateOutput = "<font color='red'><span class='template_overage'>" & template & "</span></font>">
  485. <cfset templateAverageTime = "<font color='red'><span class='template_overage'>" & templateAverageTime & "</span></font>">
  486.                                  <cfset totalTime = "<font color='red'><span class='template_overage'>" & totalExecutionTime & "</span></font>">
  487. </cfif>
  488. </cfif>
  489. <tr>
  490.                             <cfif isDefined("totalTime") and len(trim(totalTime))>
  491.                                 <td align="right" class="cfdebug" nowrap>#totalTime# ms</td>
  492.                                 <cfset totalTime = "">
  493.                             <cfelse>
  494.      <td align="right" class="cfdebug" nowrap>#totalExecutionTime# ms</td>
  495.                             </cfif>
  496. <td align="right" class="cfdebug" nowrap>#templateAverageTime# ms</td>
  497. <td align="center" class="cfdebug" nowrap>#instances#</td>
  498. <td align="left" class="cfdebug" nowrap>#templateOutput#</td>
  499. </tr>
  500. </cfoutput>
  501.     <cfcatch type="Any"></cfcatch>
  502. </cftry>
  503. <cfoutput>
  504. <tr>
  505.                     <td align="right" class="cfdebug" nowrap><i>#time_other# ms</i></td><td colspan=2>&nbsp;</td>
  506. <td align="left" class="cfdebug"><i>STARTUP, PARSING, COMPILING, LOADING, &amp; SHUTDOWN</i></td>
  507.                 </tr>
  508. <tr>
  509.                     <td align="right" class="cfdebug" nowrap><i>#cfdebug_execution.executionTime# ms</i></td><td colspan=2>&nbsp;</td>
  510. <td align="left" class="cfdebug"><i>TOTAL EXECUTION TIME</i></td>
  511.                 </tr>
  512. </table>
  513. <font color="red"><span class="template_overage">red = over #cfdebugger.settings.template_highlight_minimum# ms average execution time</span></font>
  514.     </cfoutput>
  515.     <cfcatch type="Any">
  516.     <cfoutput><br>[[cfcatch.message=#cfcatch.message#]]<br></cfoutput>
  517. </cfcatch>
  518.     </cftry>
  519. </cfif> <!--- template_mode = summary--->
  520. <cfelse>
  521. <p class="cfdebug"><hr/><b class="cfdebuglge">Execution Time</b></p>
  522. <a name="cfdebug_templates">
  523. No top level page was found.
  524. </cfif> <!--- if top level templates are available --->
  525. </cfif>
  526. <!--- CFCS --->
  527. <cfquery dbType="query" name="cfcs" debug="false">
  528.     select template, (endTime - startTime) as et, [timestamp]
  529.     from qEvents
  530.     where type = 'Template'
  531.     and template like 'CFC[[ %'
  532.     escape '['
  533.     group by template, [timestamp], startTime, endTime
  534. </cfquery>
  535. <cfset cfcData = structNew()>
  536. <cfloop query="cfcs">
  537.     <cfset tString = replaceNoCase(template, "CFC[ ", "")>
  538.     <cfset tString = reReplace(tString, "] from .*", "")>
  539.     <cfset theCFC = trim(listFirst(tString, "|"))>
  540.     <cfset theMethod = trim(listLast(tString, "|"))>
  541.     <!--- remove args --->
  542.     <cfset theMethod = trim(reReplaceNoCase(theMethod, "\(.*?\).*", "()"))>
  543.     <cfif not structKeyExists(cfcData, theCFC)>
  544.         <cfset cfcData[theCFC] = structNew()>
  545.     </cfif>
  546.     <cfif not structKeyExists(cfcData[theCFC], theMethod)>
  547.         <cfset cfcData[theCFC][theMethod] = structNew()>
  548.         <cfset cfcData[theCFC][theMethod].count = 0>
  549.         <cfset cfcData[theCFC][theMethod].total = 0>
  550.     </cfif>
  551.     <cfset cfcData[theCFC][theMethod].count = cfcData[theCFC][theMethod].count + 1>
  552.     <cfset cfcData[theCFC][theMethod].total = cfcData[theCFC][theMethod].total + et>
  553. </cfloop>
  554. <!--- make averages --->
  555. <cfloop item="cfc" collection="#cfcData#">
  556.     <cfloop item="method" collection="#cfcdata[cfc]#">
  557.         <cfset cfcdata[cfc][method].average = cfcdata[cfc][method].total / cfcdata[cfc][method].count>
  558.     </cfloop>
  559. </cfloop>
  560. <cfoutput>
  561. <p class="cfdebug"><hr/><b class="cfdebuglge">CFC Data</b></p>
  562. <table border="1" cellpadding="2" cellspacing="0" class="cfdebug">
  563.     <tr>
  564.     <td class="cfdebug" align="center"><b>Total Time</b></td>
  565.     <td class="cfdebug" align="center"><b>Avg Time</b></td>
  566.     <td class="cfdebug" align="center"><b>Count</b></td>
  567.     <td class="cfdebug"><b>CFC</b></td>
  568.     <td class="cfdebug"><b>Method</b></td>
  569.     </tr>
  570. </cfoutput>
  571. <cfloop item="cfc" collection="#cfcData#">
  572.     <cfloop item="method" collection="#cfcdata[cfc]#">
  573.         <cfoutput>
  574.         <tr>
  575.             <td>#cfcdata[cfc][method].total# ms</td>
  576.             <td>#numberFormat(cfcdata[cfc][method].average,"00.00")# ms</td>
  577.             <td>#cfcdata[cfc][method].count#</td>
  578.             <td>#cfc#</td>
  579.             <td>#method#</td>
  580.         </tr>
  581.         </cfoutput>
  582.     </cfloop>
  583. </cfloop>
  584. <cfoutput></table></cfoutput>
  585. <!--- Exceptions --->
  586. <cfif bFoundExceptions>
  587. <cftry>
  588. <cfoutput>
  589.     <p class="cfdebug"><hr/><b class="cfdebuglge"><a name="cfdebug_exceptions">Exceptions</a></b></p>
  590.     <cfloop query="cfdebug_ex">
  591.      <div class="cfdebug">#TimeFormat(cfdebug_ex.timestamp, "HH:mm:ss.SSS")# - #cfdebug_ex.name# <cfif FindNoCase("Exception", cfdebug_ex.name) EQ 0>Exception</cfif> - in #cfdebug_ex.template# : line #cfdebug_ex.line#</div>
  592.      <cfif IsDefined("cfdebug_ex.message") AND Len(Trim(cfdebug_ex.message)) GT 0>
  593.      <pre>
  594.      #cfdebug_ex.message#
  595.      </pre>
  596.      </cfif>
  597.     </cfloop>
  598. </cfoutput>
  599.     <cfcatch type="Any">
  600.         <!--- Error reporting an exception event entry. --->
  601.     </cfcatch>
  602. </cftry>
  603. </cfif>
  604. <!--- SQL Queries --->
  605. <cfoutput>
  606. <!--- added by Matt Jones, 2006, so we easily cut and paste SQL, *with* the params where they should be --->
  607. <!--- ** TOOK OUT IN FAVOR of *mine* .. which has the CFQUERYPARAMS INLINE
  608. <cfif bFoundSQLQueries>
  609.     <cftry>
  610.         <p class="cfdebug"><hr/><b class="cfdebuglge"><a name="cfdebug_sql">SQL Queries</a></b></p>
  611.         <cfloop query="cfdebug_queries">
  612.             <code><b>#cfdebug_queries.name#</b> (Datasource=#cfdebug_queries.datasource#, Time=#Max(cfdebug_queries.executionTime, 0)#ms<cfif IsDefined("cfdebug_queries.rowcount") AND IsNumeric(cfdebug_queries.rowcount)>, Records=#Max(cfdebug_queries.rowcount, 0)#<cfelseif IsDefined("cfdebug_queries.result.recordCount")>, Records=#cfdebug_queries.result.recordCount#</cfif><cfif cfdebug_queries.cachedquery>, Cached Query</cfif>) in #cfdebug_queries.template# @ #TimeFormat(cfdebug_queries.timestamp, "HH:mm:ss.SSS")#</code><br />
  613.             <pre>#htmleditformat(cfdebug_queries.body)#</pre>
  614.             <cfif arrayLen(cfdebug_queries.attributes) GT 0>
  615.              <code>Query Parameter Value(s) -<br />
  616.              <cfloop index="x" from=1 to="#arrayLen(cfdebug_queries.attributes)#">
  617.              <cfset thisParam = #cfdebug_queries.attributes[cfdebug_queries.currentRow][x]#>
  618.              Parameter ###x#<cfif StructKeyExists(thisParam, "sqlType")>(#thisParam.sqlType#)</cfif> = <cfif StructKeyExists(thisParam, "value")>#htmleditformat(thisParam.value)#</cfif><br />
  619.              </cfloop>
  620.              </code><br />
  621.             </cfif>
  622.         </cfloop>
  623.     <cfcatch type="Any">
  624.         <!--- Error reporting query event --->
  625.     </cfcatch>
  626. </cftry>
  627. </cfif>
  628. --->
  629. <cfif bFoundSQLQueries>
  630.     <cftry>
  631.         <fieldset style="background-color:##FFFFCC"><legend>modified sql debugging</legend>
  632.         <p class="cfdebug"><hr/><b class="cfdebuglge"><a name="cfdebug_sql">SQL Queries</a></b></p><BR />
  633.         <cfloop query="cfdebug_queries">
  634.             <div style="background-color:<cfif cfdebug_queries.cachedquery>##CCFFCC</cfif>">
  635.             <code><b>-- #cfdebug_queries.name#</b> (Datasource=#cfdebug_queries.datasource#, Time=#Max(cfdebug_queries.executionTime, 0)#ms<cfif IsDefined("cfdebug_queries.rowcount") AND IsNumeric(cfdebug_queries.rowcount)>, Records=#Max(cfdebug_queries.rowcount, 0)#<cfelseif IsDefined("cfdebug_queries.result.recordCount")>, Records=#cfdebug_queries.result.recordCount#</cfif><cfif cfdebug_queries.cachedquery>, Cached Query</cfif>) in #cfdebug_queries.template# @ #TimeFormat(cfdebug_queries.timestamp, "HH:mm:ss.SSS")#</code><br />
  636.             <cfloop index="x" from=1 to="#arrayLen(cfdebug_queries.attributes)#">
  637.                 <cfscript>
  638.                     thisParam = cfdebug_queries.attributes[cfdebug_queries.currentRow][x];
  639.                     if ( ListFindNoCase('CF_SQL_INTEGER,CF_SQL_BIGINT,CF_SQL_DECIMAL,CF_SQL_DOUBLE,CF_SQL_FLOAT,CF_SQL_NUMERIC',thisParam.sqlType) ) {
  640.                         tmpVal = thisParam.value;
  641.                     } else if ( thisParam.sqlType IS "CF_SQL_BIT" ) {
  642.                         if (thisParam.value IS "YES") {
  643.                             tmpVal = 1;
  644.                         } else if (thisParam.value IS "NO") {
  645.                             tmpVal = 0;
  646.                         } else { // i guess its possible that they might stop using YES and NO for the CF_SQL_BIT bit: if they do just dump it out as is
  647.                             tmpVal = thisParam.value;
  648.                         }
  649.                     } else {
  650.                         tmpVal = "'#thisParam.value#'";
  651.                     }
  652.                     tmpVal = tmpVal & ' /******* Parameter ###x# #IIf(StructKeyExists(thisParam, "sqlType"), DE('(#thisParam.sqlType#)'), DE(''))# = #IIf(StructKeyExists(thisParam, "value"), DE('#htmleditformat(thisParam.value)#'), DE(''))# *******/';
  653.                     cfdebug_queries.body = Replace(cfdebug_queries.body,'?',tmpVal,'one');
  654.                 </cfscript>
  655.             </cfloop>
  656.             <pre>#htmleditformat(cfdebug_queries.body)#</pre>
  657.             <cfif arrayLen(cfdebug_queries.attributes) GT 0>
  658.              <code>-- Query Parameter Value(s) -<br />
  659.              <cfloop index="x" from=1 to="#arrayLen(cfdebug_queries.attributes)#">
  660.              <cfset thisParam = #cfdebug_queries.attributes[cfdebug_queries.currentRow][x]#>
  661.              -- Parameter ###x#<cfif StructKeyExists(thisParam, "sqlType")>(#thisParam.sqlType#)</cfif> = <cfif StructKeyExists(thisParam, "value")>#htmleditformat(thisParam.value)#</cfif><br />
  662.              </cfloop>
  663.              </code><br />
  664.             </cfif>
  665.             </div>
  666.         </cfloop>
  667.         </fieldset>
  668.     <cfcatch type="Any">
  669.         <!--- Error reporting query event --->
  670.     </cfcatch>
  671. </cftry>
  672. </cfif>
  673. <!--- Stored Procs --->
  674. <cfif bFoundStoredProc>
  675. <cftry>
  676. <p class="cfdebug"><hr/><b class="cfdebuglge"><a name="cfdebug_storedproc">Stored Procedures</a></b></p>
  677. <p class="cfdebug">
  678. <cfloop query="cfdebug_storedproc">
  679. <!--- Output stored procedure details, remember, include result (output params) and attributes (input params) columns --->
  680. <code><b>#cfdebug_storedproc.name#</b> (Datasource=#cfdebug_storedproc.datasource#, Time=#Max(cfdebug_storedproc.executionTime, 0)#ms) in #cfdebug_storedproc.template# @ #TimeFormat(cfdebug_storedproc.timestamp, "HH:mm:ss.SSS")#</code><br />
  681. <table border=0 cellpadding=0 cellspacing=0>
  682. <tr>
  683. <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
  684. <td>
  685. <table border=1 cellpadding=2 cellspacing=2>
  686. <tr bgcolor="gray"><td colspan="5" align="center"><font color="white">parameters</font></td></tr>
  687. <tr><td><code><i>type</i></code></td><td><code><i>CFSQLType</i></code></td><td><code><i>value</i></code></td><td><code><i>variable</i></code></td><td><code><i>dbVarName</i></code></td></tr>
  688. <cfloop index="x" from=1 to="#arrayLen(cfdebug_storedproc.attributes)#">
  689. <cfset thisParam = #cfdebug_storedproc.attributes[cfdebug_storedproc.currentRow][x]#>
  690. <tr>
  691. <td>&nbsp;<code><cfif StructKeyExists(thisParam, "type")>#thisParam.type#</cfif></code></td>
  692. <td>&nbsp;<code><cfif StructKeyExists(thisParam, "sqlType")>#thisParam.sqlType#</cfif></code></td>
  693. <td>&nbsp;<code><cfif StructKeyExists(thisParam, "value")>#htmleditformat(thisParam.value)#</cfif></code></td>
  694. <td>&nbsp;<code><cfif StructKeyExists(thisParam, "variable")>#thisParam.variable# = #CFDebugSerializable(thisParam.variable)#</cfif></code></td>
  695. <td>&nbsp;<code><cfif StructKeyExists(thisParam, "dbVarName")>#thisParam.dbVarName#</cfif></code></td>
  696. </tr>
  697. </cfloop>
  698. </table>
  699. </td>
  700. </tr>
  701. <tr>
  702. <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
  703. <td>
  704. <table border=1 cellpadding=2 cellspacing=2>
  705. <tr bgcolor="gray"><td colspan="5" align="center"><font color="white">resultsets</font></td></tr>
  706. <tr><td><code><i>name</i></code></td><td><code><i>resultset</i></code></td></tr>
  707. <cfloop index="x" from=1 to="#arrayLen(cfdebug_storedproc.result)#">
  708. <cfset thisParam = #cfdebug_storedproc.result[cfdebug_storedproc.currentRow][x]#>
  709. <tr>
  710. <td>&nbsp;<code><cfif StructKeyExists(thisParam, "name")>#thisParam.name#</cfif></code></td>
  711. <td>&nbsp;<code><cfif StructKeyExists(thisParam, "resultSet")>#thisParam.resultSet#</cfif></code></td>
  712. </tr>
  713. </cfloop>
  714. </table>
  715. </td>
  716. </tr>
  717. </table>
  718. </cfloop>
  719. </p>
  720.     <cfcatch type="Any">
  721.         <!--- Error reporting stored proc event --->
  722.     </cfcatch>
  723. </cftry>
  724. </cfif>
  725. <!--- :: CFTimer :: --->
  726. <cfif bFoundTimer>
  727. <p class="cfdebug"><hr/><b class="cfdebuglge"><a name="cfdebug_timer">CFTimer Times</a></b></p>
  728. <p class="cfdebug">
  729. <cfloop query="cfdebug_timer">
  730. <cftry>
  731.     <img src='#getpageContext().getRequest().getContextPath()#/CFIDE/debug/images/#Replace(cfdebug_timer.priority, " ", "%20")#_16x16.gif' alt="#cfdebug_timer.priority# type">
  732.          [#val(cfdebug_timer.endTime) - val(cfdebug_timer.startTime)#ms] <i>#cfdebug_timer.message#</i><br />
  733.     <cfcatch type="Any"></cfcatch>
  734. </cftry>
  735. </cfloop>
  736. </p>
  737. </cfif>
  738. <!--- Tracing --->
  739. <cfif bFoundTrace>
  740. <p class="cfdebug"><hr/><b class="cfdebuglge"><a name="cfdebug_trace">Trace Points</a></b></p>
  741. <p class="cfdebug">
  742. <cfset firstTrace=true>
  743. <cfset prevDelta=0>
  744. <cfloop query="cfdebug_trace">
  745. <cfset deltaFromRequest = Val(cfdebug_trace.endTime)>
  746. <cfset deltaFromLast = Val(deltaFromRequest-prevDelta)>
  747. <cftry>
  748.     <img src='#getpageContext().getRequest().getContextPath()#/CFIDE/debug/images/#Replace(cfdebug_trace.priority, " ", "%20")#_16x16.gif' alt="#cfdebug_trace.priority# type"> [#TimeFormat(cfdebug_trace.timestamp, "HH:mm:ss.lll")# #cfdebug_trace.template# @ line: #cfdebug_trace.line#] [#deltaFromRequest# ms (<cfif firstTrace>1st trace<cfelse>#deltaFromLast# ms</cfif>)] - <cfif #cfdebug_trace.category# NEQ "">[#cfdebug_trace.category#]</cfif> <cfif #cfdebug_trace.result# NEQ "">[#cfdebug_trace.result#]</cfif> <i>#cfdebug_trace.message#</i><br />
  749.     <cfcatch type="Any"></cfcatch>
  750. </cftry>
  751. <cfset prevDelta = deltaFromRequest>
  752. <cfset firstTrace=false>
  753. </cfloop>
  754. </p>
  755. </cfif>
  756. <!--- SCOPE VARIABLES --->
  757. <cfif bFoundScopeVars>
  758. <p class="cfdebug"><hr/><b class="cfdebuglge"><a name="cfdebug_scopevars">Scope Variables</a></b></p>
  759. <cftry>
  760. <cfif IsDefined("APPLICATION") AND IsStruct(APPLICATION) AND StructCount(APPLICATION) GT 0 AND cfdebugger.check("ApplicationVar")>
  761. <pre><b>Application Variables:</b>
  762. #sortedScope(application)#</pre>
  763. </cfif>
  764. <cfcatch type="Any"></cfcatch>
  765. </cftry>
  766. <cftry>
  767. <cfif IsDefined("CGI") AND IsStruct(CGI) AND StructCount(CGI) GT 0 AND cfdebugger.check("CGIVar")>
  768. <pre><b>CGI Variables:</b>
  769. #sortedScope(cgi)#</pre>
  770. </cfif>
  771. <cfcatch type="Any"></cfcatch>
  772. </cftry>
  773. <cftry>
  774. <cfif IsDefined("CLIENT") AND IsStruct(CLIENT) AND StructCount(CLIENT) GT 0 AND cfdebugger.check("ClientVar")>
  775. <pre><b>Client Variables:</b>
  776. #sortedScope(client)#</pre>
  777. </cfif>
  778. <cfcatch type="Any"></cfcatch>
  779. </cftry>
  780. <cftry>
  781. <cfif IsDefined("COOKIE") AND IsStruct(COOKIE) AND StructCount(COOKIE) GT 0 AND cfdebugger.check("CookieVar")>
  782. <pre><b>Cookie Variables:</b>
  783. #sortedScope(cookie)#</pre>
  784. </cfif>
  785. <cfcatch type="Any"></cfcatch>
  786. </cftry>
  787. <cftry>
  788. <cfif IsDefined("FORM") AND IsStruct(FORM) AND StructCount(FORM) GT 0 AND cfdebugger.check("FormVar")>
  789. <pre><b>Form Fields:</b>
  790. #sortedScope(form)#</pre>
  791. </cfif>
  792. <cfcatch type="Any"></cfcatch>
  793. </cftry>
  794. <cftry>
  795. <cfif IsDefined("REQUEST") AND IsStruct(REQUEST) AND StructCount(REQUEST) GT 0 AND cfdebugger.check("RequestVar")>
  796. <pre><b>Request Parameters:</b>
  797. #sortedScope(request)#</pre>
  798. </cfif>
  799. <cfcatch type="Any"></cfcatch>
  800. </cftry>
  801. <cftry>
  802. <cfif IsDefined("SERVER") AND IsStruct(SERVER) AND StructCount(SERVER) GT 0 AND cfdebugger.check("ServerVar")>
  803. <pre><b>Server Variables:</b>
  804. #sortedScope(server)#</pre>
  805. </cfif>
  806. <cfcatch type="Any"></cfcatch>
  807. </cftry>
  808. <cftry>
  809. <cfif IsDefined("SESSION") AND IsStruct(SESSION) AND StructCount(SESSION) GT 0 AND cfdebugger.check("SessionVar")>
  810. <pre><b>Session Variables:</b>
  811. #sortedScope(session)#</pre>
  812. </cfif>
  813. <cfcatch type="Any"></cfcatch>
  814. </cftry>
  815. <cftry>
  816. <cfif IsDefined("URL") AND IsStruct(URL) AND StructCount(URL) GT 0 AND cfdebugger.check("URLVar")>
  817. <pre><b>URL Parameters:</b>
  818. #sortedScope(url)#</pre>
  819. </cfif>
  820. <cfcatch type="Any"></cfcatch>
  821. </cftry>
  822. <cftry>
  823. <cfif IsDefined("Attributes") AND IsStruct(Attributes) AND StructCount(Attributes) GT 0>
  824. <pre><b>Attributes Variables:</b>
  825. #sortedScope(Attributes)#</pre>
  826. </cfif>
  827. <cfcatch type="Any"></cfcatch>
  828. </cftry>
  829. </cfif>
  830. <cfset duration = getTickCount() - startTime>
  831. <cfif displayDebug>
  832. <font size="-1" class="cfdebug">
  833. <i>Debug Rendering Time: #duration# ms</i>
  834. </font><br />
  835. </td>
  836. </tr>
  837. </table>
  838. </cfif>
  839. </cfoutput>
  840. <cfsetting enablecfoutputonly="No">
  841. </cfif>
  842. <cfscript>
  843. function CFDebugSerializable(variable)
  844. {
  845. var ret = "";
  846. try
  847. {
  848.         if(IsSimpleValue(variable))
  849.         {
  850.             ret = xmlFormat(variable);
  851.         }
  852.         else
  853.         {
  854.             if (IsStruct(variable))
  855.             {
  856.                 ret = ("Struct (" & StructCount(variable) & ")");
  857.             }
  858.             else if(IsArray(variable))
  859.             {
  860.                 ret = ("Array (" & ArrayLen(variable) & ")");
  861.             }
  862.             else if(IsQuery(variable))
  863.             {
  864.                 ret = ("Query (" & variable.RecordCount & ")");
  865.             }
  866.             else
  867.             {
  868.                 ret = ("Complex type");
  869.             }
  870.         }
  871. }
  872. catch("any" ex)
  873. {
  874. ret = "undefined";
  875. }
  876. return ret;
  877. }
  878. // UDF - tree writing
  879. function drawNode(nTree, indent, id, highlightThreshold) {
  880. var templateOuput = "";
  881. if( nTree[id].duration GT highlightThreshold ) {
  882. templateOutput = "<font color='red'><span class='template_overage'>(#nTree[id].duration#ms) " & nTree[id].template & " @ line " & #nTree[id].line# & "</span></font><br>";
  883. } else {
  884. templateOutput = "<span class='template'>(#nTree[id].duration#ms) " & nTree[id].template & " @ line " & #nTree[id].line# & "</span><br>";
  885. }
  886. writeOutput(repeatString("&nbsp;&nbsp;&middot;", indent + 1) & " <img src='#getpageContext().getRequest().getContextPath()#/CFIDE/debug/images/arrow.gif' alt='arrow' border='0'><img src='#getpageContext().getRequest().getContextPath()#/CFIDE/debug/images/endDoc.gif' alt='top level' border='0'> " & templateOutput);
  887. return "";
  888. }
  889. function drawTree(tree, indent, id, highlightThreshold) {
  890. var alength = 1;
  891. var i = 1;
  892. var templateOuput = "";
  893.     if( structKeyExists(tree, id) )
  894.     {
  895.      // top level nodes (application.cfm,cgi.script_name,etc) have a -1 parent line number
  896.      if(tree[id].line EQ -1) {
  897.             if( Tree[id].duration GT highlightThreshold )
  898.             {
  899.          writeoutput( "<font color='red'><span class='template_overage'><b>(#Tree[id].duration#ms) " & Tree[id].template & "</b></span></font><br>" );
  900.             }
  901.             else
  902.             {
  903.                 writeoutput( "<span class='template'><b>(#Tree[id].duration#ms) " & Tree[id].template & "</b></span><br>" );
  904.             }
  905.      } else {
  906.      if( Tree[id].duration GT highlightThreshold ) {
  907.      templateOutput = "<font color='red'><span class='template_overage'>(#Tree[id].duration#ms) " & Tree[id].template & " @ line " & #Tree[id].line# & "</span></font><br>";
  908.      } else {
  909.      templateOutput = "<span class='template'>(#Tree[id].duration#ms) " & Tree[id].template & " @ line " & #Tree[id].line# & "</span><br>";
  910.      }
  911.      writeoutput( repeatString("&nbsp;&nbsp;&middot;", indent + 1) & " <img src='#getpageContext().getRequest().getContextPath()#/CFIDE/debug/images/arrow.gif' alt='arrow' border='0'><img src='#getpageContext().getRequest().getContextPath()#/CFIDE/debug/images/parentDoc.gif' alt='top level' border='0'> " & templateOutput );
  912.      }
  913.      if( isArray( tree[id].children ) and arrayLen( tree[id].children ) ) {
  914.      alength = arrayLen( tree[id].children );
  915.      for( i = 1; i lte alength; i = i + 1 ) {
  916.      if( isArray(tree[id].children[i].children) and arrayLen( tree[id].children[i].children ) gt 0 ) {
  917.      drawTree(tree, indent + 1, tree[id].children[i].templateid, highlightThreshold);
  918.      } else {
  919.      drawNode(tree, indent + 1, tree[id].children[i].templateid, highlightThreshold);
  920.      }
  921.      }
  922.      } else {
  923.      // single template, no includes?
  924.      //drawNode(tree, indent + 1, tree[id].template, highlightThreshold);
  925.      }
  926.     }
  927. return "";
  928. }
  929. </cfscript>
  930. <cffunction name="sortedScope" output="false">
  931. <cfargument name="scope">
  932. <cfset retVal="">
  933. <cfset keys = structKeyArray(scope)>
  934. <cfset arraySort(keys,"text")>
  935. <cfloop index="x" from=1 to="#arrayLen(keys)#">
  936.     <cfset keyName = keys[x]>
  937. <cfset retVal = retVal & keyName & "=">
  938. <cftry>
  939.          <cfset keyValue = CFDebugSerializable(scope[keyname])>
  940.         <cfcatch>
  941.             <cfset keyValue = "undefined">
  942.     </cfcatch>
  943.      </cftry>
  944. <cfset retVal = retVal & keyValue & Chr(13) & Chr(10)>
  945. </cfloop>
  946. <cfreturn retVal>
  947. </cffunction>