formEncoding = getEncoding("FORM"); urlEncoding = getEncoding("URL"); setEncoding("FORM", formEncoding); setEncoding("URL", urlEncoding); SELECT template, parent, Sum(endTime - StartTime) AS et FROM qEvents WHERE type = 'Template' GROUP BY template, parent ORDER BY et DESC if( cfdebug_templates.recordCount eq 1 and not len(trim(cfdebug_templates.et)) ) { querySetCell(cfdebug_templates, "et", "0", 1); } cfdebug_templates = queryNew('template, parent, et'); SELECT * FROM qEvents WHERE type = 'ORMSqlQuery' cfdebug_orm_queries = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL, et'); SELECT *, (endTime - startTime) AS executionTime FROM qEvents WHERE type = 'SqlQuery' if( cfdebug_queries.recordCount eq 1 and not len(trim(cfdebug_queries.executionTime)) ) { querySetCell(cfdebug_queries, "executionTime", "0", 1); } cfdebug_queries = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL, et'); SELECT *, (endTime - startTime) AS executionTime FROM qEvents WHERE type = 'ObjectQuery' if( cfdebug_cfoql.recordCount eq 1 and not len(trim(cfdebug_cfoql.executionTime)) ) { querySetCell(cfdebug_cfoql, "executionTime", "0", 1); } cfdebug_cfoql = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL'); SELECT *, (endTime - startTime) AS executionTime FROM qEvents WHERE type = 'StoredProcedure' if( cfdebug_storedproc.recordCount eq 1 and not len(trim(cfdebug_storedproc.executionTime)) ) { querySetCell(cfdebug_storedproc, "executionTime", "0", 1); } cfdebug_storedproc = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL'); SELECT * FROM qEvents WHERE type = 'Trace' cfdebug_trace = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL'); SELECT * FROM qEvents WHERE type = 'CFTimer' cfdebug_timer = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL'); SELECT * FROM qEvents WHERE type = 'LockWarning' cfdebug_lock = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL'); SELECT * FROM qEvents WHERE type = 'Exception' cfdebug_ex = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL'); // no longer doing template query at the top since we have tree and summary mode bFoundTemplates = cfdebugger.check("Template"); if( bFoundTemplates ) { displayDebug=true; } if ( isDefined("cfdebugger.settings.general") and cfdebugger.settings.general ) { bGeneral = true; displayDebug=true; } if (IsDefined("cfdebug_ex") AND cfdebug_ex.recordCount GT 0) { bFoundExceptions = true; displayDebug=true; } else { bFoundExceptions = false; } if (IsDefined("cfdebug_orm_queries") AND cfdebug_orm_queries.RecordCount GT 0) { bFoundORMSQLQueries = true; displayDebug=true; } else { bFoundORMSQLQueries = false; } if (IsDefined("cfdebug_queries") AND cfdebug_queries.RecordCount GT 0) { bFoundSQLQueries = true; displayDebug=true; } else { bFoundSQLQueries = false; } if (IsDefined("cfdebug_cfoql") AND cfdebug_cfoql.RecordCount GT 0) { bFoundObjectQueries = true; displayDebug=true; } else { bFoundObjectQueries = false; } if (IsDefined("cfdebug_storedproc") AND cfdebug_storedproc.RecordCount GT 0) { bFoundStoredProc = true; displayDebug=true; } else { bFoundStoredProc = false; } if (IsDefined("cfdebug_trace") AND cfdebug_trace.recordCount GT 0) { bFoundTrace = true; displayDebug=true; } else { bFoundTrace = false; } if (IsDefined("cfdebug_timer") AND cfdebug_timer.recordCount GT 0) { bFoundTimer = true; displayDebug=true; } else { bFoundTimer = false; } if (IsDefined("cfdebug_lock") AND cfdebug_lock.recordCount GT 0) { bFoundLocking = true; displayDebug=true; } else { bFoundLocking = false; } if (IsDefined("cfdebugger") AND cfdebugger.check("Variables")) { bFoundScopeVars = true; displayDebug=true; } else { bFoundScopeVars = false; }


Debugging Information
#server.coldfusion.productname# #server.coldfusion.productlevel# #server.coldfusion.productversion#
Template #xmlFormat(CGI.Script_Name)#
Time Stamp #DateFormat(Now())# #TimeFormat(Now())#
Locale #GetLocale()#
User Agent #EncodeForErrorSmart(CGI.HTTP_USER_AGENT)#
Remote IP #EncodeForErrorSmart(CGI.REMOTE_ADDR)#
Host Name #EncodeForErrorSmart(CGI.REMOTE_HOST)#

SELECT (endTime - startTime) AS executionTime FROM qEvents WHERE type = 'ExecutionTime' queryAddRow(cfdebug_execution); querySetCell(cfdebug_execution, "executionTime", "-1"); SELECT sum(endTime - startTime) AS executionTime FROM qEvents WHERE type = 'Template' AND parent = ''


Execution Time

// only want templates, IMQ of SELECT * ...where type = 'template' will result // in cannot convert the value "" to a boolean for cachedquery column // SELECT stacktrace will result in Query Of Queries runtime error. // Failed to get meta_data for columnqEvents.stacktrace . // Was told I need to define meta data for debugging event table similar to if( qEvents.type eq "template" ) { st = structNew(); st.StackTrace = qEvents.stackTrace; st.template = qEvents.template; st.startTime = qEvents.starttime; st.endTime = qEvents.endtime; st.parent = qEvents.parent; st.line = qEvents.line; arrayAppend(a, st); } if( a[i].stacktrace.tagcontext[x].id NEQ "CF_INDEX" ) { // keep appending the line number from the template stack to form a unique id childIdList = listAppend(childIdList, a[i].stacktrace.tagcontext[x].line); if( x eq 1 ) { //parentIdList = listAppend(parentIdList, a[i].stacktrace.tagcontext[x].template); raw_trace = a[i].stacktrace.tagcontext[x].raw_trace; findFunctionPrefix = "$func"; // set prefix to account for length and position since CF doesn't have RegEx lookbehind assertion findFunction = ReFindNoCase("(?=\" & findFunctionPrefix & ").*(?=\.runFunction\()",raw_trace,1,true); if( findFunction.len[1] NEQ 0 AND findFunction.pos[1] NEQ 0 ) { // get function name from raw_trace to allow for proper application.cfc tree rendering parentfunction = Trim(Mid(raw_trace, findFunction.pos[1] + Len(findFunctionPrefix), findFunction.len[1] - Len(findFunctionPrefix))); // append the function name (pulled from raw_trace) to the cfc template for tree root comparison. parentIdList = listAppend(parentIdList, a[i].stacktrace.tagcontext[x].template & " | " & lcase(parentfunction)); } else { parentIdList = listAppend(parentIdList, a[i].stacktrace.tagcontext[x].template); } } else { parentIdList = listAppend(parentIdList, a[i].stacktrace.tagcontext[x].line); } } // template is the last part of the unique id...12,5,17,c:\wwwroot\foo.cfm // if we don't remove the "CFC[" prefix, then the parentId and childId relationship // will be all wrong startToken = "CFC[ "; //endToken = " | "; endToken = "("; thisTemplate = a[i].template; startTokenIndex = FindNoCase(startToken, thisTemplate, 1); if( startTokenIndex NEQ 0 ) { endTokenIndex = FindNoCase(endToken, thisTemplate, startTokenIndex); thisTemplate = Trim(Mid(thisTemplate,Len(startToken),endTokenIndex-Len(startToken))); } childIdList = listAppend(childIdList, thisTemplate); queryAddRow(qTree); querySetCell(qTree, "template", a[i].template); querySetCell(qTree, "templateId", childIdList); querySetCell(qTree, "parentId", parentIdList); querySetCell(qTree, "duration", a[i].endtime - a[i].starttime); querySetCell(qTree, "line", a[i].line); // empty parent assumed to be top level with the exception of application.cfm if( len(trim(parentId)) eq 0 ){ parentId = 0; } stTree[parentId] = structNew(); stTree[parentId].templateId = qTree.templateId; stTree[parentId].template = qTree.template; stTree[parentId].duration = qTree.duration; stTree[parentId].line = qTree.line; stTree[parentId].children = arrayNew(1); stTree[templateId] = structNew(); stTree[templateId].templateId = qTree.templateId; stTree[templateId].template = qTree.template; stTree[templateId].duration = qTree.duration; stTree[templateId].line = qTree.line; stTree[templateId].children = arrayNew(1); arrayAppend(stTree[parentId].children, stTree[templateId]); SELECT parentId, templateid FROM qTree WHERE parentId = '' #drawTree(stTree,-1,topNodes.templateid,cfdebugger.settings.template_highlight_minimum)#

(#time_other# ms) STARTUP, PARSING, COMPILING, LOADING, & SHUTDOWN
(#cfdebug_execution.executionTime# ms) TOTAL EXECUTION TIME
red = over #cfdebugger.settings.template_highlight_minimum# ms execution time

SELECT template, Sum(endTime - startTime) AS totalExecutionTime, count(template) AS instances FROM qEvents WHERE type = 'Template' group by template order by totalExecutionTime DESC " & template & ""> "> "> "> "> "> ">
Total Time Avg Time Count Template
#totalTime# ms #encodeForErrorSmart(totalExecutionTime)# ms #templateAverageTime# ms #encodeForErrorSmart(instances)# #templateOutput#
#encodeForErrorSmart(time_other)# ms  STARTUP, PARSING, COMPILING, LOADING, & SHUTDOWN
#encodeForErrorSmart(cfdebug_execution.executionTime)# ms  TOTAL EXECUTION TIME
red = over #cfdebugger.settings.template_highlight_minimum# ms average execution time


Execution Time

No top level page was found.


Exceptions

#TimeFormat(cfdebug_ex.timestamp, "HH:mm:ss.SSS")# - #cfdebug_ex.name# Exception - in #encodeForErrorSmart(cfdebug_ex.template)# : line #encodeForErrorSmart(cfdebug_ex.line)#
	    #encodeForErrorSmart(cfdebug_ex.message)#
	    


ORM SQL Queries

#htmleditformat(cfdebug_orm_queries.body)#


SQL Queries

#cfdebug_queries.name# (Datasource=#cfdebug_queries.datasource#, Time=#Max(cfdebug_queries.executionTime, 0)#ms, Records=#Max(cfdebug_queries.rowcount, 0)#, Records=#cfdebug_queries.result.recordCount#, Cached Query) in #cfdebug_queries.template# @ #TimeFormat(cfdebug_queries.timestamp, "HH:mm:ss.SSS")#
#htmleditformat(cfdebug_queries.body)#
Query Parameter Value(s) -
Parameter ###x#(#thisParam.sqlType#) = #htmleditformat(thisParam.value)#


Stored Procedures

#cfdebug_storedproc.name# (Datasource=#cfdebug_storedproc.datasource#, Time=#Max(cfdebug_storedproc.executionTime, 0)#ms) in #cfdebug_storedproc.template# @ #TimeFormat(cfdebug_storedproc.timestamp, "HH:mm:ss.SSS")#
    
parameters
typeCFSQLTypevaluevariabledbVarName
 #encodeForErrorSmart(thisParam.type)#  #encodeForErrorSmart(thisParam.sqlType)#  #htmleditformat(thisParam.value)#  #encodeForErrorSmart(thisParam.variable)# = #CFDebugSerializable(thisParam.variable)#  #encodeForErrorSmart(thisParam.dbVarName)#
    
resultsets
nameresultset
 #thisParam.name#  #thisParam.resultSet#


CFTimer Times

#cfdebug_timer.priority# type [#val(cfdebug_timer.endTime) - val(cfdebug_timer.startTime)#ms] #encodeForErrorSmart(cfdebug_timer.message)#


Trace Points

#cfdebug_trace.priority# type [#TimeFormat(cfdebug_trace.timestamp, "HH:mm:ss.lll")# #cfdebug_trace.template# @ line: #cfdebug_trace.line#] [#deltaFromRequest# ms (1st trace#deltaFromLast# ms)] - [#cfdebug_trace.category#] [#cfdebug_trace.result#] #cfdebug_trace.message#


Scope Variables

Application Variables:
#sortedScope(application)#
CGI Variables:
#sortedScope(cgi)#
Client Variables:
#sortedScope(client)#
Cookie Variables:
#sortedScope(cookie)#
Form Fields:
#sortedScope(form)#
Request Parameters:
#sortedScope(request)#
Server Variables:
#sortedScope(server)#
Session Variables:
#sortedScope(session)#
URL Parameters:
#sortedScope(url)#
Debug Rendering Time: #duration# ms
//UDF - Handle output of complex data types. function CFDebugSerializable(variable) { var ret = ""; try { if(IsSimpleValue(variable)) { ret = xmlFormat(variable); } else { if (IsStruct(variable)) { ret = ("Struct (" & StructCount(variable) & ")"); } else if(IsArray(variable)) { ret = ("Array (" & ArrayLen(variable) & ")"); } else if(IsQuery(variable)) { ret = ("Query (" & variable.RecordCount & ")"); } else { ret = ("Complex type"); } } } catch("any" ex) { ret = "undefined"; } return ret; } // UDF - tree writing function drawNode(nTree, indent, id, highlightThreshold) { var templateOuput = ""; if( nTree[id].duration GT highlightThreshold ) { templateOutput = "(#nTree[id].duration#ms) " & nTree[id].template & " @ line " & #nTree[id].line# & "
"; } else { templateOutput = "(#nTree[id].duration#ms) " & nTree[id].template & " @ line " & #nTree[id].line# & "
"; } writeOutput(repeatString("  ·", indent + 1) & " arrowtop level " & templateOutput); return ""; } function drawTree(tree, indent, id, highlightThreshold) { var alength = 1; var i = 1; var templateOuput = ""; if( structKeyExists(tree, id) ) { // top level nodes (application.cfm,cgi.script_name,etc) have a -1 parent line number if(tree[id].line EQ -1) { if( Tree[id].duration GT highlightThreshold ) { writeoutput( "top level " & "(#Tree[id].duration#ms) " & Tree[id].template & "
" ); } else { writeoutput( "top level " & "(#Tree[id].duration#ms) " & Tree[id].template & "
" ); } } else { if( Tree[id].duration GT highlightThreshold ) { templateOutput = "(#Tree[id].duration#ms) " & Tree[id].template & " @ line " & #Tree[id].line# & "
"; } else { templateOutput = "(#Tree[id].duration#ms) " & Tree[id].template & " @ line " & #Tree[id].line# & "
"; } writeoutput( repeatString("  ·", indent + 1) & " arrowtop level " & templateOutput ); } if( isArray( tree[id].children ) and arrayLen( tree[id].children ) ) { alength = arrayLen( tree[id].children ); for( i = 1; i lte alength; i = i + 1 ) { if( isArray(tree[id].children[i].children) and arrayLen( tree[id].children[i].children ) gt 0 ) { drawTree(tree, indent + 1, tree[id].children[i].templateid, highlightThreshold); } else { drawNode(tree, indent + 1, tree[id].children[i].templateid, highlightThreshold); } } } else { // single template, no includes? //drawNode(tree, indent + 1, tree[id].template, highlightThreshold); } } return ""; }