Skip to content

Commit 3771b55

Browse files
SougandhSiloveeclipse
authored andcommitted
Add option to Resume VM option on Triggerpoint hit
This commit introduces an option to resume virtual machine execution when a trigger breakpoint is hit. This allows trigger breakpoints to act as barriers, enabling lower-priority breakpoints to remain active without needing to be disabled. Fixes #614
1 parent 7ae683e commit 3771b55

File tree

15 files changed

+258
-26
lines changed

15 files changed

+258
-26
lines changed

org.eclipse.jdt.debug.tests/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Require-Bundle: org.eclipse.ui.ide;resolution:=optional,
3939
org.eclipse.jdt.core;bundle-version="[3.34.0,4.0.0)",
4040
org.eclipse.jdt.ui;bundle-version="[3.33.0,4.0.0)",
4141
org.eclipse.jdt.launching;bundle-version="[3.20.0,4.0.0)",
42-
org.eclipse.jdt.debug;bundle-version="[3.21.0,4.0.0)",
42+
org.eclipse.jdt.debug;bundle-version="[3.23.0,4.0.0)",
4343
org.eclipse.jdt.debug.ui;bundle-version="[3.13.0,4.0.0)",
4444
org.eclipse.debug.core;bundle-version="[3.22.0,4.0.0)",
4545
org.eclipse.debug.ui;bundle-version="[3.13.0,4.0.0)",

org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/breakpoints/TriggerPointBreakpointsTests.java

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2016 IBM Corporation and others.
2+
* Copyright (c) 2016, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,6 +14,7 @@
1414
package org.eclipse.jdt.debug.tests.breakpoints;
1515

1616
import org.eclipse.debug.core.model.IVariable;
17+
import org.eclipse.jdt.debug.core.IJavaBreakpoint;
1718
import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
1819
import org.eclipse.jdt.debug.core.IJavaPrimitiveValue;
1920
import org.eclipse.jdt.debug.core.IJavaStackFrame;
@@ -69,4 +70,69 @@ public void testTriggerPointBreakpoint() throws Exception {
6970
removeAllBreakpoints();
7071
}
7172
}
73+
74+
public void testTriggerPointBreakpointWithResume() throws Exception {
75+
String typeName = "TriggerPoint_01";
76+
IJavaLineBreakpoint bp1 = createLineBreakpoint(20, typeName);
77+
IJavaLineBreakpoint bp2 = createLineBreakpoint(21, typeName);
78+
bp1.setTriggerPoint(true);
79+
bp1.setSuspendPolicy(IJavaBreakpoint.RESUME_ON_HIT); // Resume mode
80+
IJavaThread thread = null;
81+
try {
82+
thread = launchToLineBreakpoint(typeName, bp2);
83+
84+
IJavaStackFrame frame = (IJavaStackFrame) thread.getTopStackFrame();
85+
int lineNumber = frame.getLineNumber();
86+
assertEquals("Breakpoint should resume and hit next breakpoint", 21, lineNumber);
87+
bp1.delete();
88+
bp2.delete();
89+
} finally {
90+
terminateAndRemove(thread);
91+
removeAllBreakpoints();
92+
}
93+
}
94+
95+
public void testTriggerPointBreakpointWithResumeAndCondition() throws Exception {
96+
String typeName = "TriggerPoint_01";
97+
IJavaLineBreakpoint bp1 = createLineBreakpoint(20, typeName);
98+
IJavaLineBreakpoint bp2 = createLineBreakpoint(21, typeName);
99+
bp1.setTriggerPoint(true);
100+
bp1.setConditionEnabled(true);
101+
bp1.setCondition("false"); // this wont let breakpoint to resume
102+
bp1.setSuspendPolicy(IJavaBreakpoint.RESUME_ON_HIT); // Resume mode
103+
IJavaThread thread = null;
104+
try {
105+
thread = launchToBreakpoint(typeName);
106+
IJavaStackFrame frame = (IJavaStackFrame) thread.getTopStackFrame();
107+
int lineNumber = frame.getLineNumber();
108+
assertEquals("Breakpoint should not resume as condition is false", 20, lineNumber);
109+
bp1.delete();
110+
bp2.delete();
111+
} finally {
112+
terminateAndRemove(thread);
113+
removeAllBreakpoints();
114+
}
115+
}
116+
117+
public void testTriggerPointBreakpointWithResumeAndConditionAsTrue() throws Exception {
118+
String typeName = "TriggerPoint_01";
119+
IJavaLineBreakpoint bp1 = createLineBreakpoint(20, typeName);
120+
IJavaLineBreakpoint bp2 = createLineBreakpoint(21, typeName);
121+
bp1.setTriggerPoint(true);
122+
bp1.setConditionEnabled(true);
123+
bp1.setCondition("true"); // this will let breakpoint to resume
124+
bp1.setSuspendPolicy(IJavaBreakpoint.RESUME_ON_HIT); // Resume mode
125+
IJavaThread thread = null;
126+
try {
127+
thread = launchToBreakpoint(typeName);
128+
IJavaStackFrame frame = (IJavaStackFrame) thread.getTopStackFrame();
129+
int lineNumber = frame.getLineNumber();
130+
assertEquals("Breakpoint should not resume as condition is false", 21, lineNumber);
131+
bp1.delete();
132+
bp2.delete();
133+
} finally {
134+
terminateAndRemove(thread);
135+
removeAllBreakpoints();
136+
}
137+
}
72138
}

org.eclipse.jdt.debug.ui/META-INF/MANIFEST.MF

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.jdt.debug.ui; singleton:=true
5-
Bundle-Version: 3.14.100.qualifier
5+
Bundle-Version: 3.15.0.qualifier
66
Bundle-Activator: org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin
77
Bundle-Vendor: %providerName
88
Bundle-Localization: plugin
@@ -40,7 +40,7 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)",
4040
org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)",
4141
org.eclipse.jdt.core;bundle-version="[3.40.0,4.0.0)",
4242
org.eclipse.debug.ui;bundle-version="[3.13.400,4.0.0)",
43-
org.eclipse.jdt.debug;bundle-version="[3.21.0,4.0.0)",
43+
org.eclipse.jdt.debug;bundle-version="[3.23.0,4.0.0)",
4444
org.eclipse.jdt.launching;bundle-version="[3.23.0,4.0.0)",
4545
org.eclipse.jdt.ui;bundle-version="[3.33.0,4.0.0)",
4646
org.eclipse.core.runtime;bundle-version="[3.30.0,4.0.0)",

org.eclipse.jdt.debug.ui/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</parent>
1919
<groupId>org.eclipse.jdt</groupId>
2020
<artifactId>org.eclipse.jdt.debug.ui</artifactId>
21-
<version>3.14.100-SNAPSHOT</version>
21+
<version>3.15.0-SNAPSHOT</version>
2222
<packaging>eclipse-plugin</packaging>
2323
<properties>
2424
<defaultSigning-excludeInnerJars>true</defaultSigning-excludeInnerJars>

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/breakpoints/JavaBreakpointConditionEditor.java

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@
2626
import org.eclipse.core.runtime.CoreException;
2727
import org.eclipse.core.runtime.IStatus;
2828
import org.eclipse.core.runtime.Status;
29+
import org.eclipse.debug.internal.ui.DebugUIPlugin;
2930
import org.eclipse.debug.internal.ui.SWTFactory;
3031
import org.eclipse.jdt.core.IClassFile;
3132
import org.eclipse.jdt.core.ICompilationUnit;
3233
import org.eclipse.jdt.core.IField;
3334
import org.eclipse.jdt.core.ISourceRange;
3435
import org.eclipse.jdt.core.IType;
36+
import org.eclipse.jdt.debug.core.IJavaBreakpoint;
3537
import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
3638
import org.eclipse.jdt.debug.core.IJavaWatchpoint;
3739
import org.eclipse.jdt.internal.debug.ui.BreakpointUtils;
@@ -142,8 +144,7 @@ public final class JavaBreakpointConditionEditor extends AbstractJavaBreakpointE
142144
private IAction fViewRedoAction;
143145
private OperationHistoryActionHandler fViewerUndoAction;
144146
private OperationHistoryActionHandler fViewerRedoAction;
145-
146-
147+
private boolean isResumeOnHit;
147148
/**
148149
* Property id for breakpoint condition expression.
149150
*/
@@ -361,6 +362,9 @@ public Control createControl(Composite parent) {
361362
public void widgetSelected(SelectionEvent e) {
362363
boolean checked = fConditional.getSelection();
363364
setEnabled(checked, true);
365+
if (isResumeOnHit) {
366+
updateConditionTextOnResume();
367+
}
364368
setDirty(PROP_CONDITION_ENABLED);
365369
}
366370
});
@@ -455,6 +459,9 @@ public void widgetDisposed(DisposeEvent e) {
455459
dispose();
456460
}
457461
});
462+
if (isResumeOnHit) {
463+
updateConditionTextOnResume();
464+
}
458465
return parent;
459466
}
460467

@@ -592,6 +599,19 @@ private void disposeViewerUndoRedoActions() {
592599
* @param focus <code>true</code> if focus should be set, <code>false</code> otherwise
593600
*/
594601
private void setEnabled(boolean enabled, boolean focus) {
602+
try {
603+
if (fBreakpoint != null) {
604+
if (fBreakpoint.getSuspendPolicy() == IJavaBreakpoint.RESUME_ON_HIT) {
605+
updateConditionTextOnResume();
606+
} else {
607+
fWhenTrue.setText(PropertyPageMessages.JavaBreakpointConditionEditor_1);
608+
fWhenChange.setText(PropertyPageMessages.JavaBreakpointConditionEditor_2);
609+
}
610+
}
611+
} catch (CoreException e) {
612+
DebugUIPlugin.log(e);
613+
}
614+
595615
fViewer.setEditable(enabled);
596616
fViewer.getTextWidget().setEnabled(enabled);
597617
fWhenChange.setEnabled(enabled);
@@ -843,4 +863,35 @@ private void checkIfUsedInBreakpointsView() {
843863
}
844864
}
845865

866+
/**
867+
* Update label values in Condition editor for trigger points that resume on hit
868+
*
869+
* @since 3.15
870+
*/
871+
public void updateConditionTextOnResume() {
872+
fWhenTrue.setText(PropertyPageMessages.BreakpointResumeConditionalTrue);
873+
fWhenChange.setText(PropertyPageMessages.BreakpointResumeConditionalValue);
874+
}
875+
876+
/**
877+
* Update label values in Condition editor for suspending breakpoints
878+
*
879+
* @since 3.15
880+
*/
881+
public void updateConditionTextOnSuspend() {
882+
fWhenTrue.setText(PropertyPageMessages.JavaBreakpointConditionEditor_1);
883+
fWhenChange.setText(PropertyPageMessages.JavaBreakpointConditionEditor_2);
884+
}
885+
886+
/**
887+
* Set &quot;Resume on hit&quot; flag
888+
*
889+
* @see IJavaBreakpoint#RESUME_ON_HIT
890+
*
891+
* @since 3.15
892+
*/
893+
public void setResumeOnHit(boolean resume) {
894+
isResumeOnHit = resume;
895+
}
896+
846897
}

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/DebugUIMessages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ public class DebugUIMessages extends NLS {
179179
public static String JDIModelPresentation_target_suspended;
180180
public static String JDIModelPresentation_thread_filtered;
181181
public static String JDIModelPresentation_uncaught_62;
182+
public static String JDIModelPresentation_resume_on_hit;
182183

183184
// thread label keys are built programmatically
184185

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/DebugUIMessages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ JDIModelPresentation_native_method=[native method]
118118
JDIModelPresentation_not_available=not available
119119
JDIModelPresentation_Suspend_VM=[Suspend VM]
120120
JDIModelPresentation_collapsed_frames={0} collapsed frames
121+
JDIModelPresentation_resume_on_hit=[Resume on hit]
121122

122123
###############################################################################
123124
# Thread label keys are built programmatically

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIModelPresentation.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,6 +2023,10 @@ protected void appendSuspendPolicy(IJavaBreakpoint breakpoint, StringBuilder buf
20232023
buffer.append(' ');
20242024
buffer.append(DebugUIMessages.JDIModelPresentation_Suspend_VM);
20252025
}
2026+
if (breakpoint.getSuspendPolicy() == IJavaBreakpoint.RESUME_ON_HIT) {
2027+
buffer.append(' ');
2028+
buffer.append(DebugUIMessages.JDIModelPresentation_resume_on_hit);
2029+
}
20262030
}
20272031

20282032
protected void appendThreadFilter(IJavaBreakpoint breakpoint, StringBuilder buffer) throws CoreException {

0 commit comments

Comments
 (0)