In the Navigator view, right-click the project and select Properties.
Debugging lets you examine and troubleshoot your application. When you debug, you can control when the application must stop at specific points in the code. You can also monitor important variables and test your code. Debugging uses a configuration to control how applications are launched. When you debug your application, you run the debug version of the application file.
Using ColdFusion debugger
Before you use the ColdFusion Debugger, ensure that you do the following:
Set up ColdFusion to use the Debugger
Before you use the Debugger, ensure the following:
- A server is associated with the project or the project containing the files that you want to debug.
-
-
In the Properties dialog box, select ColdFusion Server Settings.
-
Under Select Servers, ensure that a server is selected. If no server is selected, select the Servers drop-down list and select an available server, or select Add Server to configure a new server.
- RDS is enabled on the ColdFusion server, and you have specified the correct RDS configuration information in ColdFusion Builder.
- Debugging is enabled in ColdFusion Administrator.
-
In ColdFusion Administrator, select Debugging & Logging > Debugger Settings.
-
Select Allow Line Debugging.
-
Specify the port to use for debugging. The default value is 5005.
-
Specify the maximum number of simultaneous debug sessions. The default value is 5.
-
Click Submit Changes.
-
To increase the time after which requests time out, do the following:
-
Select Server Settings > Settings.
-
Select Timeout Requests After (Seconds) and enter the required timeout value. For example, 300.
-
Click Submit Changes.
-
The debugger server listens for commands from ColdFusion Builder on a separate port than the one specified in step 3. By default, ColdFusion launches the debugger server with a random available port. This could be a problem if ColdFusion (and hence debugger server) is behind a firewall. Because, the firewall blocks the random port that the debugger is listening. To prevent this problem, specify a fixed debugger server port number and allow this port in the firewall. To set a fixed debugger server port number, specify the following JVM argument on the Java And JVM page of the ColdFusion Administrator (or the appropriate place for your J2EE Application Server). Replace portNumber with the port that you want to use:
-DDEBUGGER_SERVER_PORT=portNumber
-
Restart ColdFusion. If you are running the J2EE configuration of ColdFusion, restart the server in debug mode with the debug port as specified.
Set up debugging for J2EE configuration of ColdFusion
-
If you are not running the server configuration of ColdFusion, specify Java debugging parameters in the configuration file or startup script of the application server you are running. The parameters must look like the following:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=<port_number>
Ensure that the port number you specify is the same port number specified on the Debugger Settings page of ColdFusion Administrator.If you are running the server configuration, ColdFusion writes these debugging parameters to the jvm.config file when you use the Debugger Settings page of the ColdFusion Administrator.
-
If you are not running the server configuration and your application server is not running on JRE 1.6, copy the tools.jar file of the JDK version that your application server is running to the \lib folder of ColdFusion. For example, if you are running JRun that runs on JRE 1.4, copy the tools.jar file of JDK 1.4 to the \lib folder of ColdFusion.
-
If you are running the server version of ColdFusion and you specify a JRE version other than JRE 1.6 in the jvm.config file, copy the tools.jar file of the JDK version specified in your jvm.config file to the \lib folder of ColdFusion.
Specify debugger settings in ColdFusion Builder
-
In ColdFusion Builder, select Window > Preferences.
-
In the tree view, select ColdFusion > Debug Settings.
-
Specify the home page URL that points to the page that appears in the Debug Output Buffer of the debugger when you click the Home button.
-
Specify the extensions of the types of files that you can debug and debugger scopes that you want the Debugger to recognize. To improve performance when debugging large files, deselect all scopes for which you do not require information.
-
Select Break On CFML Runtime Exception to stop the debugger on the line that causes a ColdFusion error.
-
Select Log An Exception To The Eclipse Error Log to display the server logs in the TailView view instead of showing a warning dialog.
Debugging your application
After you enabled the debugger in the ColdFusion Administrator and configured the debugger in ColdFusion Builder, you can debug projects in ColdFusion Builder.
Create or edit launch configurations
When you debug a project in your application, ColdFusion Builder creates a project-specific launch configuration for the first time that you debug. The launch configuration automatically defines a project name (based on the project that you are debugging), main application file, and the path to debug the application.
Launch configurations are managed through the Create, Manage, and Run Configurations dialog box.
Debug configuration
You can edit the default launch configuration that ColdFusion Builder creates.
-
Select the project to debug in the Navigator view.
-
You can access the launch configuration in the following ways:
- Select Run > Debug or Run > Debug Configurations
- Select in the workbench toolbar.
- Right-click the project and select Debug As > Debug Configurations.
-
Select the launch configuration to edit in the Debug Configurations dialog box.You can also create a launch configuration or base a new configuration on an existing configuration.
-
Click the Perspectives link to modify the launch configuration preferences, as required.
Run the application
Run the application that you want to debug before setting any breakpoints. Running the application before debugging compiles the application and improves performance during debugging.
-
Select the project to run in the Navigator view.
-
Select or modify the Run configuration using the Run Configurations dialog box. You can access this dialog box in the following ways:
- Select Run > Run configurations.
- Right-click the project and select Run As > Run Configurations.
-
Select the configuration to run or modify, if necessary.
-
Click Run.
The application is run in your computer’s default browser. To specify a different external browser, do as follows:
- (Windows) Right-click the project and select Properties. Go to ColdFusion Server Settings, and select a a web browser installed on your computer.
- (Mac) In the Preferences dialog box, select General > Web Browser, and select a web browser installed on your computer.
Set and remove breakpoints
You use breakpoints to control the running of your application so you can inspect your code and debug your application. You add breakpoints in the code editor and then manage them in the Breakpoints view. You can also set breakpoints as you write code or while you debug.
For more information about managing breakpoints using the Breakpoints view, see Breakpoints view.
ColdFusion breakpoints
ColdFusion breakpoints have the following four states in the ColdFusion debugger:
- Enabled and Valid This state indicates that the breakpoint is at a valid location. The breakpoint appears as a solid blue circle in the left margin of the CFML Editor. Code execution stops when this breakpoint is encountered.
- Unresolved ColdFusion sets the breakpoint for the page that is loaded in its memory. If you modify the page and do not run it, the source is no longer in sync with the page on the server. In this situation, ColdFusion sometimes does not know whether the line where you want to set the breakpoint is valid. A question mark represents this type of breakpoint.
- Invalid If ColdFusion determines that the CFML that you are editing in ColdFusion Builder is the same as the CFML in its memory, and that the breakpoint you have set is at an invalid line, the breakpoint appears as a red X.
- Disabled This state indicates that the breakpoint is disabled.
Set a breakpoint in the code editor
-
Open the ColdFusion Builder project that contains the code in which you want to set breakpoints.
-
Locate the line of code where you want to set a breakpoint, and do one of the following:
- Double-click in the marker bar along the left-edge of the editor.
Select Run > Toggle Breakpoint or Run > Toggle Line Breakpoint.
註解:Toggle Method Breakpoint and Toggle Watchpoint are not supported in ColdFusion Builder.
-
You can set breakpoints in your CFML file to stop executing the page at particular points. When you set a breakpoint on a line, the CFML stops executing just before that line. For example, if you set a breakpoint on the third line in the following CFML page, execution stops before <cfset myName = "Wilson">.
<cfoutput>Your name is #yourName#.</cfoutput>
<cfset myName = "Wilson"
A blue dot appears before the line on which you set the breakpoint.
You can also view a list of breakpoints set in the current project in the Breakpoints view of the ColdFusion Builder Debugging perspective.
Skip all breakpoints in the code editor
After setting breakpoints in your code, you can ignore all breakpoints at the time of debugging.
-
Open the ColdFusion Builder project that contains the code with breakpoints.
-
In the Breakpoints view toolbar, select Skip All Breakpoints.
Remove a breakpoint in the code editor
In the marker bar along the left-edge of the editor, double-click an existing breakpoint.
The breakpoint is removed from the marker bar and the Breakpoints view of the ColdFusion Builder Debugging perspective.
To remove all the breakpoints in the file, select Run > Remove all Breakpoints from the main toolbar menu.
Start a debugging session
-
In the Navigator view, select the project or file to debug.
-
You can start the debugging session in the following ways:
- Select Run > Debug
- Click in the workbench toolbar.
- Right-click the project and select Debug As > ColdFusion Application.
The Debug launch configuration is automatically created and launched.
If you are debugging a page and then try to browse to or refresh that page, it can result in unexpected behavior in the Debugger.
Manage the debugging session
Use the Debug view to control the debugging of the application, to suspend, resume, or terminate the application, or to step into or over code.
For information about the various views in the ColdFusion Debug perspective, see ColdFusion Debugging perspective.
Run code line by line
You can use the Step Into, Step Over, and Step Return buttons to proceed through your CFML application line by line.
For the stepping process to work properly, clear the cache of compiled classes. To do so, recompile all CFML pages compiled with an earlier version of ColdFusion.
In large files, you sometimes find that stepping and breakpoints are slow. To improve performance, do the following:
-
In ColdFusion Builder, select Windows > Preferences.
-
In the tree view, select ColdFusion > Debug Settings
-
Deselect all scopes for which you do not require information.
Step Into
Use Step Into for UDFs, CFCs, custom tags, and included files. Avoid using Step Into on CFML tags such as the cfset tag. Step Into is more performance intensive than Step Over. When stepping into functions, tags, and files, the file must be displayed in one of the open projects. The file that you are stepping in must be in an open project.
Step Over
Use Step Over to proceed through your CFML application, bypassing included files, such as UDFs or CFCs.
Step Return
Use Step Return to return to the original page from which you entered the included file, such as UDFs or CFCs.
Inspect variables
As you run CFML code, you can see the values and scope of variables in the Variables view. Only variables whose scopes are what you selected in the Preferences dialog box appear in the Variables view. For more information about using the Variables view, see Variables view.
Watch expressions
Watch expressions are useful to watch critical variables that sometimes go out of scope when you step into a different function. You can create your own expressions to watch and evaluate. You can modify the expressions during the debugging session.
You can do the following in the Expressions view:
- Create a watch expression by right-clicking and selecting Add Watch Expression. You can then enter the expression in the Add Watch Expression dialog box.
- Ignore a watch expression that you’ve added by right-clicking the expression and selecting Disable.
- Edit a watch expression by right-clicking the expression and selecting Edit Watch Expression. You can then modify the expression.
For more information about using the Expressions view, see Expressions view.
Debugging remote applications
If ColdFusion is running on a remote server, configure a remote server connection and specify a mapping between ColdFusion and ColdFusion Builder. Mapping ensures that ColdFusion Builder and ColdFusion are working on a copy of the same project or file.
-
To configure a remote server, see Add a remote server. Enter the RDS configuration information, as required.
-
In the Server view, right-click the server and select Edit Server. In the Mappings screen of the Server wizard, enter the following mapping details:
- Local Path: Path that ColdFusion Builder uses to find projects or folders on the remote ColdFusion server.
Remote Path: Path to the project or folder on the remote ColdFusion server.
You can specify multiple mappings between the remote ColdFusion server and ColdFusion Builder.
For example, if you are editing files in a ColdFusion project that points to D:\MyCoolApp and the corresponding files exist on a remote server at D:\Shared\websites\MyCoolSite. Then, create a mapping by specifying the local path as D:\MyCool App and the remote path as D:\Shared\websites\MyCoolSite.When you deploy the files to the ColdFusion server, you copy them to W:\websites\MyCoolSite\, which the ColdFusion server recognizes as D:\Shared\websites\MyCoolSite. The mapping in ColdFusion Builder specifies that the ColdFusion Builder directory is D:\MyCoolApp and the server is D:\Shared\websites\MyCoolSite. So, ColdFusion Builder translates the file path (D:\MyCoolApp\index.cfm) to a path that the ColdFusion server recognizes (D:\Shared\websites\MyCoolSite\index.cfm). To see more information about the interaction between the client and the server, add the following to the JVM arguments in the ColdFusion Administrator:
-DDEBUGGER_TRACE=true |
In the Navigator view, select the project or file to debug and click in the workbench toolbar.