Debugging is similar to running your applications. However, when you debug you control when the application stops at specific points in the code and whether you want it to monitor important variables, and you can test fixes to your code. Both running and debugging use a configuration to control how applications are launched. When you debug your application, you run the debug version of the application file.
For an overview of the debugging tools available in the Flex Debugging perspective, see The Flex Debugging perspective.
In some cases, you will be prompted to look at the Eclipse log file. For more information, see Eclipse environment errors in the log file.
To begin a debugging session, you run the application launch configuration in the Flex Debugging perspective.
If your project has not been built yet, Flex Builder builds and runs it in debug mode.
Start a debugging session in the plug-in configuration
The Debug command works differently in the plug-in configuration of Flex Builder. Instead of running the selected project, it debugs the most recently launched configuration. You can also select from a list of recently launched configurations.
You use breakpoints to suspend the execution of your application so you can inspect your code and use the Flex Builder debugging tools to explore options to fix errors. You add breakpoints in the code editor and then manage them in the Breakpoints view when you debug your applications.
You add breakpoints to executable lines of code. The debugger stops only at breakpoints set on lines that contain the following:
You can set breakpoints as you write code or while you debug.
Set a breakpoint in the code editor
The marker bar is along the left edge of the code editor.
A breakpoint marker is added to the marker bar and to the list of breakpoints in the Breakpoints view of the Flex Debugging perspective.
When the debugger encounters a breakpoint, the application is suspended, the Flex Debugging perspective is displayed, and the line of code is marked with a breakpoint that is highlighted in the code editor. You then use the debugging commands to interact with the code. (See Managing the debugging session in the Debug view).
Remove a breakpoint in the code editor
In the marker bar, double-click an existing breakpoint.
The breakpoint is removed from the marker bar and the Breakpoints view of the Flex Debugging perspective.
You manage breakpoints in the Breakpoints view. You can remove one or all breakpoints in the list or disable them and re-enable them at a later time (see Managing breakpoints in the Breakpoints view).
In the Breakpoints view you manage breakpoints during a debugging session. You can remove, disable and enable, or skip them.
The following commands are available from the Breakpoints view toolbar (as shown left to right):
|
Button/Command |
Description |
|---|---|
|
Remove Selected Breakpoints |
Removes the selected breakpoints. |
|
Remove All Breakpoints |
Removes all breakpoints. |
|
Show Breakpoints Supported by Selected Target |
Displays breakpoints that are applicable to the select debug target. |
|
Go to File for Breakpoint |
Opens the file (if it is not already open) that contains the breakpoint in the code editor and highlights the line of code on which the breakpoint was set. You can also simply double-click the breakpoint to display it in the code editor. |
|
Skip All Breakpoints |
Skips all breakpoints. |
|
Expand All |
Expands all breakpoints. |
|
Collapse All |
Collapses all breakpoints. |
|
Link With Debug View |
Links to Debug view. |
Remove breakpoints in the Breakpoints view
You can remove one, a few, or all of the breakpoints in the Breakpoints view from the Breakpoints toolbar
Select one or more breakpoints from the list of breakpoints, and then click Remove Selected Breakpoints.
You can also remove all the breakpoints in the Breakpoints view in a single action.
Remove all breakpoints from the Breakpoints view
In the Breakpoints view, click Remove All Breakpoints.
The Debug view is the control center of the Flex Debugging perspective. You use it to control the execution of the application, to suspend, resume, or terminate the application, or to step into or over code.
The Debug view provides the following debugging commands, which are available from the Debug view toolbar (as shown left to right):
|
Button/Command |
Description |
|---|---|
|
Remove All Terminated Launches |
Clears all terminated debugging sessions. |
|
Resume |
Resumes the suspended application. |
|
Suspend |
Suspends the application so that you can inspect, step into the code, and so on. |
|
Terminate |
Terminates the debugging session. |
|
Disconnect |
Disconnects the debugger when debugging remotely. |
|
Step Into |
Steps into the called function and stops at the first line of the function. |
|
Step Over |
Executes the current line of the function and then stops at the next line of the function. |
|
Step Return |
Continues execution until the current function has returned to its caller. |
|
Drop to Frame |
This command is not supported in Flex Builder. |
|
Use Step Filters |
This command is not supported in Flex Builder. |
The Console view displays the output from trace statements placed in your ActionScript code and also feedback from the debugger itself (status, warnings, errors, and so on).
The Console view provides the following commands, which are available from the Console view toolbar (as shown left to right):
|
Button/Command |
Description |
|---|---|
|
Terminate |
Terminates the debugging session. |
|
Remove Launch |
Clears all launched debugging sessions. |
|
Remove All Terminated Launches |
Clears all terminated debugging sessions. |
|
Clear Console |
Clears all content from the Console view. |
|
Scroll Lock |
Prevents the Console view from scrolling. |
|
Show Console When Standard Out Changes |
|
|
Show Console When Standard Error Changes |
|
|
Pin Console |
Prevents the console from refreshing its contents when another process is selected. |
|
Display Selected Console |
|
|
Open Console |
Opens new console and displays pop-up menu to select other console views. |
The Variables view displays the variables that the currently selected stack frame defines (in the Debug view). Simple variables (name and value) are displayed on a single line. Complex variables can be expanded to display their members. You use the Variables view to watch variables by adding them to the Expressions view and to modify the value of variables during the debugging session.
All superclass members are grouped in a separate tree node; by default you see only the members of the current class. This helps reduce excess numbers of variables that are visible at one time in Variables view.
The Variables view provides the following actions, which are available from the Variables view toolbar (as shown left to right):
|
Command |
Description |
|---|---|
|
Show Type Names |
Displays the type names of variables. |
|
Show Logical Structure |
This command is not supported in Flex Builder. |
|
Collapse All |
Collapses the Variables view. |
Change the value of a variable
The variable contains the new value.
Modified variables are displayed in red.
To locate a variable or variable member in the Variables view, with the Variables view selected, begin entering the name of the variable you're looking for. You can also use the wildcard character (*) to search for words that occur anywhere within a variable name (for example, "*color").
You use the Expressions view to watch variables you selected in the Variables view and to add and evaluate watch expressions while debugging your applications.
While debugging, you can inspect and modify the value of the variables that you selected to watch. You can also add watch expressions, which are code expressions that are evaluated whenever debugging is suspended. Watch expressions are useful for watching variables that may go out of scope when you step into a different function and are therefore not visible in the view.
The Expressions view provides the following commands, which are available from the Variables view toolbar (as shown left to right):
|
Command |
Description |
|---|---|
|
Show Type Names |
Shows the object types for items in the Expressions view. |
|
Show Logical Structure |
This command is not supported in Flex Builder. |
|
Collapse All |
Collapses all expressions in view. |
|
Remove Selected Expressions |
Removes the selected variable or watch expression. |
|
Remove All Expressions |
Removes all variables and watch expressions from the Expressions view. |
You can also hover the mouse pointer over an expression or variable in the source editor to see the value of that expression or variable as a tooltip. You can add the expression to the Expressions view by right-clicking and selecting Watch from the menu.