Previously in our discussion, we discussed about the concept
of Conditional
breakpoints. In this article, we will discuss about the Hit
Condition breakpoints.
Consider a case where you have a for loop with iteration of
thousands of records. You know that your records at around 500th location is
corrupted and you need to debug that value. Will you sit and keep pressing F5
until the record number 500 is reached ? This is where you can use the concept
of Hit Condition breakpoints. This is achieved by setting Hit Count condition
on the breakpoint i.e. hit the breakpoint when it has iterated 499 times.
Let's create a sample
application to understand this. Add a for
loop with iteration of 1000 records and add a condition to hit the breakpoint
when the 500th record is being iterated.
To add the condition, right click on the breakpoint and
select the 'Hit Count' condition. This will open up a window where we can define
a condition to hit the breakpoint only when it meets the criteria set for its
execution.
Here we have 4 different conditions and these are self
explanatory in their details. So we select the condition 'break when the hit count is
equal to' and set its value to be 500.
Hover to the breakpoint and see the details:
Run the application and see the value of variable 'i', when
the breakpoint is hit.
So here when the value of i becomes 499 (starting from
0), it is iterating the 500th record and the breakpoint gets hit. So set the
break point and enjoy the debugging...!!!
No comments:
Post a Comment