Using Production Debugger to set a conditional break point in a ColdFusion loop

FusionReactor Blog gets selected at #25 of the top 40 Java Blogs
FusionReactor Developer Edition – Ultimate features and insight

This example will show how to set a conditional break point in a ColdFusion loop using the FusionReactor Production Debugger.

Code Example – pdloop.cfm

<cfset aArray = ["January","February","March","April","May","June","July","August","September","October","November","December"]>
<cfloop from="1" to="#arrayLen(aArray)#" index="i">
  <cfoutput>#i#: #aArray[i]#<br></cfoutput>

Setting a conditional breakpoint

In this example, we are going to set a breakpoint when a condition has been met within the aArray variable.   The condition which we would like to set the breakpoint is when:

aArray[i] EQ "March"


Setting this in the Edit Breakpoint form, will look like this.

Breakpoint Trigger Source File/Line Number We are selecting to set a breakpoint within a specific source file and a specific line number
Source Code Filename pdloop.cfm Name / location of the file where the code is stored
Source Line Number 3 This is important.    If we are checking the value of a variable, then this variable must have been set before this line number has been reached in order for the breakpoint to fire.
Condition aArray[i] EQ "March" This is the example condition which will cause the breakpoint to fire and execution of the page to halt
Fire Count Always This indicates that the breakpoint will ALWAYS fire.   If we set the Fire Count to a numeric value, e.g. 3  – then the breakpoint would fire 3 times.


Trigger Handler Pause Thread Will tell FusionReactor to pause the currently executing thread when the condition has been met
Pause Time 60 The thread will be paused for 60 seconds.   During this time, the breakpoint can be intercepted by clicking on the Production Debugger icon – or from within the Paused Threads menu item
Pause Execution On every thread that fires the breakpoint Will cause the engine to halt for every single thread in which the breakpoint condition fires.

When the breakpoint has been setup, you will see the following when you click on the Breakpoints menu item – If the page has not yet been executed – then we will see the State as being Pending


Seeing when a breakpoint fires

When the page pdloop.cfm is executed, the condition will fire and the page will halt execution.

In the Breakpoints menu, the breakpoint will be shown as follows – NOTE – the State now shows the ClassLoader information, as the page has actually been loaded and executed.


When the breakpoint fires, then the Debugger icon will appear in the top banner –

You can either click on the Debugger icon or click the Paused Threads link in the Debug Menu, you will then see the Paused Thread – together with the Timeout Countdown

To start the Production Debugger session, you need to click on the Debug Icon –

Working with the a debugger in the Thread View Page

The Thread View page shows the details of a specific thread once the thread has been paused in the interactive debugger.

Source Code Viewer

The source code viewer will show the source code for the location where the interactive debugger is currently paused – line 3 in our example.

The variables viewer shows the variables currently available on the thread at the specific location that the interactive debugger has paused.

As we have set the breakpoint to fire when aArray[i] EQ "March" – we would expect

I = 3.0

We can also see the Variable values in the aArray variable


Note that the array index starts at 0, not 1

Modifying a variable value

We can now modify the value of a variable.   In this example, let us change the value of May to May in the Spring

You should always use the CF Set button to set a CF variable  – Strings need to be in quotes – numerical values, simply a number


You should now see the following when you expand

Once you have changed the variable value, hit the Resume icon to continue execution of the program.

The page results will then look like.

1: January
2: February
3: March
4: April
5: May in the Spring
6: June
7: July
8: August
9: September
10: October
11: November
12: December