| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| <html lang="en"> |
| <head> |
| <meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2017. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." > |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css"> |
| <title> Managing conditional breakpoints </title> |
| </head> |
| <body> |
| <h1> Managing conditional breakpoints </h1> |
| <p> |
| A conditional expression can be applied to a line breakpoint or a watchpoint such that the |
| breakpoint suspends execution of a thread in one of these cases: </p> |
| <ul> |
| <li>when the result of the expression is true</li> |
| <li>when the result of the expression changes</li> |
| </ul> |
| <p>A conditional expression can contain arbitrary Java code and may contain more than one statement, allowing breakpoint conditions to implement features like tracing. For example, a condition can execute a print statement and then return a hard coded value to never suspend ("<code>System.out.println(...); return false;</code>").</p> |
| <p>To set a condition on a breakpoint: </p> |
| <ol> |
| <li> |
| Find the breakpoint to which an enabling condition is to be applied (in |
| the <a href="../reference/views/breakpoints/ref-breakpoints_view.htm"><strong>Breakpoints View</strong></a> or in the editor marker bar). </li> |
| <li> |
| From the breakpoint's pop-up menu, select <strong><a href="../reference/views/breakpoints/ref-properties_contextaction.htm">Breakpoint |
| Properties...</a></strong>. The Breakpoint properties dialog will open. </li> |
| <li> In the properties dialog, check the <strong><a href="../reference/breakpoints/ref-condition_option.htm">Enable Condition</a></strong> checkbox. </li> |
| <li> In the <strong><a href="../reference/breakpoints/ref-condition_option.htm">Condition</a></strong> field enter the expression for |
| the breakpoint condition. </li> |
| <li> Do one of the following: |
| <ul> |
| <li>If you want the breakpoint to stop every time the condition evaluates |
| to <em>true</em>, select the <strong>condition is 'true' </strong>option. |
| The expression provided must be a boolean expression.</li> |
| <li>If you want the breakpoint to stop only when the result of the |
| condition changes, select the <strong>value of condition changes </strong>option.</li> |
| </ul> |
| </li> |
| <li> Select <strong>OK</strong> to close the dialog and commit the changes. While |
| the breakpoint is enabled, thread execution suspends before that line of code |
| is executed if the breakpoint condition evaluates to <em>true</em>. |
| </li> |
| </ol> |
| <p> |
| A conditional breakpoint has a question mark overlay on the breakpoint icon.</p> |
| <h3 class="related">Related concepts</h3> |
| <a href="../concepts/cdebugger.htm">Debugger</a><br> |
| <a href="../concepts/concept-java-perspective.htm">Java perspectives</a><br> |
| <a href="../concepts/concept-java-editor.htm">Java editor</a> |
| <h3 class="related">Related tasks</h3> |
| <a href="../tasks/task-add_line_breakpoints.htm">Adding breakpoints</a><br> |
| <a href="task-apply_hit_count.htm">Applying hit counts</a><br> |
| <a href="task-catching_exceptions.htm">Catching Java exceptions</a><br> |
| <a href="../tasks/task-remove_line_breakpoints.htm">Removing breakpoints</a><br> |
| <a href="task-set_method_breakpoints.htm">Setting method breakpoints</a><br> |
| <a href="../tasks/task-stepping.htm">Stepping through the execution of a program</a> |
| <h3 class="related">Related references</h3> |
| <a href="../reference/views/breakpoints/ref-breakpoints_view.htm">Breakpoints view</a> |
| </body> |
| </html> |
| |