The Art of Debugging Shlomy Gantz 02/13/01MDCFUG.
-
Upload
anthony-griffin -
Category
Documents
-
view
237 -
download
0
Transcript of The Art of Debugging Shlomy Gantz 02/13/01MDCFUG.
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Introduction - Famous Last words
“…“…if debugging is defined as the art of taking if debugging is defined as the art of taking bugs out of a program , programming must be bugs out of a program , programming must be putting them in…”putting them in…”
““..It’s not a bug, It’s a feature “ (Microsoft)..It’s not a bug, It’s a feature “ (Microsoft)
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Types of bugs
Syntax ErrorSyntax Error
Run-Time ErrorsRun-Time Errors
Logical ErrorsLogical Errors
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Types of bugs - Syntax Errors
Syntax Error ExampleSyntax Error Example
<CFSET ClientName = “Shlomy Gantz”>
<CFSET URLstr = URLstr & urlendcodedformat(ClientName) >
View ExampleView Example
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Types of bugs - Run-Time Errors
Run-Time Error ExampleRun-Time Error Example
<CFQUERY NAME=“GetOverPaidEmp” Datasource=“Payroll”>
SELECT
SUM(Salary) AS TotalSalary,
COUNT(Emp_ID) as NumOfEmployees
FROM AnnualSalary
WHERE SALARY > 100000
</CFQUERY>
<CFSET AVGSalary = GetOverPaidEmp.TotalSalary / GetOverPaidEmp.NumOfEmployees >
<CFOUTPUT>#AVGSalary#</CFOUTPUT>
View ExampleView Example
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Types of bugs - Logical Errors
Logical Error exampleLogical Error example
<CFSET MyList=“Shlomy,Michael,Emily,Abraham”>
<CFSET ShlomyExists_YN = listfind(MyList,”shlomy”)>
<CFOUTPUT>#YesNoFormat(ShlomyExists_YN)#</CFOUTPUT>
View ExampleView Example
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Other things that can go wrong
Database connection (ODBC,MDAC …)Database connection (ODBC,MDAC …) Cold Fusion server Cold Fusion server Web ServerWeb Server OSOS HardwareHardware
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Debugging Steps
PlanPlan Back-upBack-up IsolateIsolate Find The errorFind The error Fix - Don’t patchFix - Don’t patch Look for similarLook for similar DocumentDocument
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
“Debugger’s Block”
If all else failsIf all else fails
… … and if that doesn’t workand if that doesn’t work
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Cold Fusion Administrator
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Enable Performance Monitoring
View ExampleView Example
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Enable CFML stack trace
CF tracks what tags have run during page CF tracks what tags have run during page process. process.
Can be used either through CFTRY/CFCATCH Can be used either through CFTRY/CFCATCH or the Studio or the Studio
DebuggerDebugger
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Show Variables
Show all variables processed by ColdFusion:Show all variables processed by ColdFusion:
• FORMFORM• URLURL• CGICGI• CookieCookie
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Show Processing Time
Show how long, in milliseconds, it takes for a Show how long, in milliseconds, it takes for a page process to page process to
run to completionrun to completion
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Detail View
Breakdown of all templates run during a page Breakdown of all templates run during a page process.process.
Proccessing time for each templateProccessing time for each template
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Show SQL and Datasource Name
Shows SQL Statement & DSN in error messagesShows SQL Statement & DSN in error messages
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Show Query Information
Query Name Query Name RecordCountRecordCount Processing Time Processing Time Query ExecutedQuery Executed
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Display Template Path in Error Msg
Show the name of the actual template in which Show the name of the actual template in which with the error occurredwith the error occurred
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Restrict Debug Access
By Default All when debugging is turned on all By Default All when debugging is turned on all users can see debug information.users can see debug information.
You can restrict access to the debugging info You can restrict access to the debugging info through this feature by IP addressthrough this feature by IP address
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Debugging with studio
Setting up Development Mapping.Setting up Development Mapping.
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Using the interactive debugger
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Debugging CF applications
Show your variables (not only once)Show your variables (not only once) Create breakpoints and Follow the flowCreate breakpoints and Follow the flow Use Exception handlingUse Exception handling Look at your application logsLook at your application logs CF_ObjectDumpCF_ObjectDump
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
<CFABORT> & <CFOUTPUT>
Using CFABORT to create breakpointsUsing CFABORT to create breakpoints
<cfinclude template="Header.cfm">
<cfquery datasource="#dsn#" name="getContacts"> Select * from Contacts WHERE Active_YN=1 </cfquery>
<cfoutput>#getContacts.recordcount#</cfoutput> <cfabort>
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
<CFABORT> & <CFOUTPUT>
Following the flowFollowing the flow
<CFIF …………> Step 1
<CFIF ………………..> Step 1.1
<CFELSE>Step 1.2</CFIF>
<CFELSE> Step 2 </CFIF>
View ExampleView Example
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Debugging in CFML
<cfquery debug> <cfquery debug>
<cfstoredproc debug=“yes|no”><cfstoredproc debug=“yes|no”>
<cfsetting showdebug output=“yes/no”><cfsetting showdebug output=“yes/no”>
View ExampleView Example
View ExampleView Example
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Debugging CF applications
<CFERROR><CFERROR> <CFTHROW><CFTHROW> <CFRETHROW><CFRETHROW> <CFCATCH><CFTRY><CFCATCH><CFTRY>
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
<CFERROR>
<CFERROR TYPE="Request" or <CFERROR TYPE="Request" or "Validation" or "Monitor" or "Exception" "Validation" or "Monitor" or "Exception" TEMPLATE="template_path" TEMPLATE="template_path" MAILTO="email_address" MAILTO="email_address" EXCEPTION="exception_type">EXCEPTION="exception_type">
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
<CFTRY><CFCATCH>
<CFTRY><CFTRY> ... Add code here... Add code here <CFCATCH TYPE="exceptiontype"> <CFCATCH TYPE="exceptiontype"> ... Add exception processing code here ... Add exception processing code here
</CFCATCH> </CFCATCH> ... Additional CFCATCH blocks go here ... Additional CFCATCH blocks go here
</CFTRY> </CFTRY>
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
<CFTHROW><CFRETHROW>
<CFTHROW TYPE="exception_type" <CFTHROW TYPE="exception_type" MESSAGE="message" MESSAGE="message" DETAIL="detail_description" DETAIL="detail_description" ERRORCODE="error_code" ERRORCODE="error_code" EXTENDEDINFO="additional_informatioEXTENDEDINFO="additional_information"> n">
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Application Logs
Read your application logs regularly Read your application logs regularly
Error","TID=199","07/27/00","13:32:35","127.0.0.1","Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)","An error has occurred. HTTP/1.0 404 Object Not Found" "Error","TID=199","07/27/00","13:32:45","127.0.0.1","Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)","Error resolving parameter SLOT_IDColdFusion was unable to determine the value of the parameter. This problem is very likely due to the fact that either: You have misspelled the parameter name, or You have not specified a QUERY attribute for a CFOUTPUT, CFMAIL, or CFTABLE tag.The error occurred while evaluating the expression: #slot_id# The error occurred while processing an element with a general identifier of (#slot_id#), occupying document position (4:12) to (4:20) in the template file D:\wwwroot\cfun2000\Examples\JS\JSexample1_CFMW\edit_def.cfmThe specific sequence of files included or processed is:D:\WWWROOT\CFUN2000\EXAMPLES\JS\JSEXAMPLE1_CFMW\EDIT_DEF.CFM .Date/Time: 07/27/00 13:32:45Browser: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)Remote Address: 127.0.0.1HTTP Referer: http://127.0.0.1/cfun2000/Examples/JS/JSexample1_CFMW/EDIT.HTMLTemplate: D:\wwwroot\cfun2000\Examples\JS\JSexample1_CFMW\edit_def.cfm" "Warning","TID=152","07/27/00","15:07:21","In a CF_TagName construct custom tag file 'C:\CFUSION\CustomTags\Pages.cfm' will occlude custom tag file 'C:\CFUSION\CustomTags\cf_pages\Pages.cfm'." "Warning","TID=152","07/27/00","15:07:21","In a CF_TagName construct custom tag file 'C:\CFUSION\CustomTags\Pages.cfm' will occlude custom tag file 'C:\CFUSION\CustomTags\cf_pages\images\Pages.cfm'."
View ExampleView Example
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
CF_Objectdump
Read your application logs regularly Read your application logs regularly
<CF_ObjectDump Object="#Object#" Deserialize="yes|no" >
View ExampleView Example
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Debugging Databases
SQL query analyzerSQL query analyzer
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Debugging JavaScript
““Microsoft Script debugger”/“Netscape Microsoft Script debugger”/“Netscape JavaScript Debugger”JavaScript Debugger”
Using alert() and return false;Using alert() and return false;
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Debugging flash
No debug outputNo debug output
simulated flash requestssimulated flash requests
output in flashoutput in flash
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Tools
http://www.secretagents.com/http://www.secretagents.com/ BugTraqBugTraq http://www.logviewer.com/ http://www.logviewer.com/ Automatic Code Generation ToolsAutomatic Code Generation Tools
• CodeSaver / CodeCharge / CommerceBlocksCodeSaver / CodeCharge / CommerceBlocks
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
What’s new in 5.0
Easier Log AnalysisEasier Log Analysis
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
What’s new in 5.0
New options on CF Admin debug settingNew options on CF Admin debug setting
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
Thank You
Michael Dinowitz, Emily Kim, Michael Imhoff Michael Dinowitz, Emily Kim, Michael Imhoff and Abraham Lloyd.and Abraham Lloyd.
… … Michael SmithMichael Smith
““The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01The Art of Debugging - Copyright Shlomy Gantz 2001 – 03/13/01
QA
Shlomy GantzShlomy Gantz
[email protected]@hotmail.com
http://www.shlomygantz.comhttp://www.shlomygantz.com