Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion org.eclipse.jdt.debug.jdi.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: JDI Tests
Bundle-SymbolicName: org.eclipse.jdt.debug.jdi.tests; singleton:=true
Bundle-Version: 1.2.0.qualifier
Bundle-Version: 1.2.100.qualifier
Bundle-ClassPath: .
Bundle-Vendor: Eclipse
Require-Bundle: org.junit,
Expand Down
2 changes: 2 additions & 0 deletions org.eclipse.jdt.debug.jdi.tests/forceQualifierUpdate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/3137
2 changes: 1 addition & 1 deletion org.eclipse.jdt.debug.jdi.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.debug.jdi.tests</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.100-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<testSuite>${project.artifactId}</testSuite>
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.debug.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.debug.tests; singleton:=true
Bundle-Version: 3.12.650.qualifier
Bundle-Version: 3.12.750.qualifier
Bundle-ClassPath: javadebugtests.jar
Bundle-Activator: org.eclipse.jdt.debug.testplugin.JavaTestPlugin
Bundle-Vendor: %providerName
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.debug.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.debug.tests</artifactId>
<version>3.12.650-SNAPSHOT</version>
<version>3.12.750-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<testSuite>${project.artifactId}</testSuite>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;

import org.eclipse.core.internal.jobs.JobManager;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.internal.ui.views.console.ProcessConsole;
import org.eclipse.jdt.debug.testplugin.JavaTestPlugin;
import org.eclipse.jface.text.reconciler.AbstractReconciler;
import org.eclipse.swt.widgets.Display;
import org.junit.Assert;

Expand Down Expand Up @@ -110,6 +113,8 @@ public static void runEventLoop() {
/**
* Utility for waiting until the execution of jobs of any family has finished or timeout is reached. If no jobs are running, the method waits
* given minimum wait time. While this method is waiting for jobs, UI events are processed.
* <p>
* <b>Note:</b> This method does not wait for jobs that belong to the families specified in {@link #getUsualJobFamiliesToIgnore()}.
*
* @param owner
* name of the caller which will be logged as prefix if the wait times out
Expand All @@ -120,7 +125,7 @@ public static void runEventLoop() {
* @return true if the method timed out, false if all the jobs terminated before the timeout
*/
public static boolean waitForJobs(String owner, long minTimeMs, long maxTimeMs) {
return waitForJobs(owner, minTimeMs, maxTimeMs, (Object[]) null);
return waitForJobs(owner, minTimeMs, maxTimeMs, getUsualJobFamiliesToIgnore());
}

/**
Expand All @@ -146,6 +151,15 @@ public static boolean waitForJobs(String owner, Object jobFamily, long minTimeMs
if (maxTimeMs < minTimeMs) {
throw new IllegalArgumentException("Max time is smaller as min time!");
}
// Not so nice workaround for https://github.com/eclipse-jdt/eclipse.jdt.debug/issues/721
// After https://github.com/eclipse-platform/eclipse.platform.ui/pull/3025 every opened editor
// means there will be a reconciler job running, which is not what we do NOT want to wait for.
// AbstractReconciler.class is the family object we can check for.
if (excludedFamilies == null) {
excludedFamilies = new Object[] { AbstractReconciler.class };
} else if (excludedFamilies.length == 1 && excludedFamilies[0] == ProcessConsole.class) {
excludedFamilies = getUsualJobFamiliesToIgnore();
}
wakeUpSleepingJobs(jobFamily);
final long startNanos = System.nanoTime();
while (System.nanoTime() - startNanos < minTimeMs * 1_000_000L) {
Expand All @@ -168,6 +182,7 @@ public static boolean waitForJobs(String owner, Object jobFamily, long minTimeMs
// only uninteresting jobs running
break;
}
jobs.forEach(Job::wakeUp);

if (!Collections.disjoint(runningJobs, jobs)) {
// There is a job which runs already quite some time, don't wait for it to avoid test timeouts
Expand All @@ -185,11 +200,20 @@ public static boolean waitForJobs(String owner, Object jobFamily, long minTimeMs
return false;
}

private static void wakeUpSleepingJobs(Object family) {
List<Job> sleepingJobs = getSleepingJobs(family);
for (Job job : sleepingJobs) {
job.wakeUp();
}
/**
* Returns a list of job families that are usually ignored in tests.
* <p>
* This is used to avoid waiting for jobs that are not relevant to the test.
* </p>
*
* @return an array of job family classes to ignore
*/
public static Object[] getUsualJobFamiliesToIgnore() {
return new Object[] { ProcessConsole.class, AbstractReconciler.class };
}

private static void wakeUpSleepingJobs(Object jobFamily) {
Job.getJobManager().wakeUp(jobFamily);
}

static Set<Job> runningJobs = new LinkedHashSet<>();
Expand All @@ -210,6 +234,7 @@ private static String dumpRunningOrWaitingJobs(List<Job> jobs) {
runningJobs.add(job);
sb.append("\n'").append(job.toString()).append("'/");
sb.append(job.getClass().getName());
sb.append(":").append(JobManager.printState(job));
Thread thread = job.getThread();
if (thread != null) {
ThreadInfo[] threadInfos = ManagementFactory.getThreadMXBean().getThreadInfo(new long[] { thread.threadId() }, true, true);
Expand Down Expand Up @@ -239,17 +264,6 @@ public static List<Job> getRunningOrWaitingJobs(Object jobFamily, Object... excl
return running;
}

private static List<Job> getSleepingJobs(Object family) {
List<Job> sleeping = new ArrayList<>();
Job[] jobs = Job.getJobManager().find(family);
for (Job job : jobs) {
if (job.getState() == Job.SLEEPING) {
sleeping.add(job);
}
}
return sleeping;
}

private static boolean isRunningOrWaitingJob(Job job) {
int state = job.getState();
return (state == Job.RUNNING || state == Job.WAITING);
Expand Down
7 changes: 6 additions & 1 deletion org.eclipse.jdt.debug.ui/plugin.properties
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,9 @@ OpenFromClipboardAction.name = Open from Clipboard
VariablesView.name = Variables

CompareObjects.label=Compare
CompareObjects.tooltip=Compare selected objects
CompareObjects.tooltip=Compare selected objects

ToggleTriggerpointAction.label=Toggle Triggerpoint
ToggleTriggerpointCommand.description=Creates or removes a triggerpoint
ToggleHitpointAction.label=Toggle Breakpoint with Hit Count
ToggleHitpointCommand.description=Creates or removes a breakpoint with hit count
28 changes: 28 additions & 0 deletions org.eclipse.jdt.debug.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,20 @@
menubarPath="debug"
id="org.eclipse.jdt.debug.ui.actions.EnableDisableBreakpointRulerActionDelegate">
</action>
<action
class="org.eclipse.jdt.internal.debug.ui.actions.RulerToggleHitBreakpointActionDelegate"
icon="icons/full/obj16/brkp_obj.png"
id="org.eclipse.jdt.debug.ui.actions.HitBreakpointRulerActionDelegate"
label="%ToggleHitpointAction.label"
menubarPath="debug">
</action>
<action
class="org.eclipse.jdt.internal.debug.ui.actions.RulerToggleTriggerBreakpointActionDelegate"
icon="icons/full/obj16/brkp_obj.png"
id="org.eclipse.jdt.debug.ui.actions.TriggerBreakpointRulerActionDelegate"
label="%ToggleTriggerpointAction.label"
menubarPath="debug">
</action>
<action
class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
helpContextId="manage_breakpoint_action_context"
Expand Down Expand Up @@ -1102,6 +1116,20 @@
label="%AddLambdaEntryBreakpoint.label"
menubarPath="debug">
</action>
<action
class="org.eclipse.jdt.internal.debug.ui.actions.RulerToggleHitBreakpointActionDelegate"
icon="icons/full/obj16/brkp_obj.png"
id="org.eclipse.jdt.debug.ui.actions.HitBreakpointRulerActionDelegate"
label="%ToggleHitpointAction.label"
menubarPath="debug">
</action>
<action
class="org.eclipse.jdt.internal.debug.ui.actions.RulerToggleTriggerBreakpointActionDelegate"
icon="icons/full/obj16/brkp_obj.png"
id="org.eclipse.jdt.debug.ui.actions.TriggerBreakpointRulerActionDelegate"
label="%ToggleTriggerpointAction.label"
menubarPath="debug">
</action>
<action
label="%EnableBreakpoint.label"
helpContextId="enable_disable_breakpoint_action_context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@

import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IVariable;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jdt.debug.core.IJavaObject;
import org.eclipse.jdt.debug.core.IJavaThread;
import org.eclipse.jdt.debug.core.IJavaValue;
import org.eclipse.jdt.debug.core.IJavaVariable;
import org.eclipse.jdt.internal.debug.core.model.JDIStackFrame;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osgi.util.NLS;

Expand Down Expand Up @@ -68,7 +70,7 @@ public String objectValueExtraction(IJavaValue value) throws DebugException {
}
}
if (interfaceCheck.contains("Number")) {
IJavaThread thread = (IJavaThread) value.getDebugTarget().getThreads()[0];
IJavaThread thread = getSuspendedThread(value);
IJavaValue stringVal = ((IJavaObject) value).sendMessage("doubleValue", "()D", null, thread, false);
return stringVal.getValueString();
}
Expand All @@ -85,7 +87,7 @@ public String objectValueExtraction(IJavaValue value) throws DebugException {
*/
@SuppressWarnings("nls")
private String stringValueExtraction(IJavaObject value) throws DebugException {
IJavaThread thread = (IJavaThread) value.getDebugTarget().getThreads()[0];
IJavaThread thread = getSuspendedThread(value);
IJavaValue stringVal = value.sendMessage("toString", "()Ljava/lang/String;", null, thread, false);
return stringVal.getValueString();
}
Expand Down Expand Up @@ -122,7 +124,7 @@ public Map<IJavaVariable, Object> setExtraction(List<IStructuredSelection> selec
@SuppressWarnings("nls")
public List<String> setElementsExtraction(IJavaObject javaObject1) throws DebugException {
List<String> contents = new ArrayList<>();
IJavaThread thread = (IJavaThread) javaObject1.getDebugTarget().getThreads()[0];
IJavaThread thread = getSuspendedThread(javaObject1);
IJavaValue toArray = javaObject1.sendMessage("toArray", "()[Ljava/lang/Object;", null, thread, false);
for (IVariable ob : toArray.getVariables()) {
contents.add(objectValueExtraction((IJavaValue) ob.getValue()));
Expand Down Expand Up @@ -661,7 +663,7 @@ public Map<IJavaVariable, Object> iterableExtraction(List<IStructuredSelection>
@SuppressWarnings("nls")
public List<String> iterableElementsExtraction(IJavaObject javaObject1) throws DebugException {
List<String> contents = new ArrayList<>();
IJavaThread thread = (IJavaThread) javaObject1.getDebugTarget().getThreads()[0];
IJavaThread thread = getSuspendedThread(javaObject1);
IJavaObject iterator = (IJavaObject) javaObject1.sendMessage("iterator", "()Ljava/util/Iterator;", null, thread, false);
while (true) {
IJavaValue hasNext = iterator.sendMessage("hasNext", "()Z", null, thread, false);
Expand Down Expand Up @@ -707,7 +709,7 @@ public Map<IJavaVariable, Object> listExtraction(List<IStructuredSelection> sele
@SuppressWarnings("nls")
public List<String> listElementsExtraction(IJavaObject javaObject1) throws DebugException {
List<String> contents = new ArrayList<>();
IJavaThread thread = (IJavaThread) javaObject1.getDebugTarget().getThreads()[0];
IJavaThread thread = getSuspendedThread(javaObject1);
IJavaValue toArray = javaObject1.sendMessage("toArray", "()[Ljava/lang/Object;", null, thread, false);
for (IVariable ob : toArray.getVariables()) {
contents.add(objectValueExtraction((IJavaValue) ob.getValue()));
Expand Down Expand Up @@ -766,9 +768,9 @@ public Map<IJavaVariable, Object> stringExtraction(List<IStructuredSelection> se
@SuppressWarnings("nls")
public Map<String, Object> mapElementsExtraction(IJavaVariable selectedObject1) throws DebugException {
if (selectedObject1.getValue() instanceof IJavaObject javaObject1) {
IJavaThread thread = getSuspendedThread(javaObject1);
Map<String, Object> result = new HashMap<>();
List<String> keySet = new ArrayList<>();
IJavaThread thread = (IJavaThread) javaObject1.getDebugTarget().getThreads()[0];
IJavaObject keySetObject = (IJavaObject) javaObject1.sendMessage("keySet", "()Ljava/util/Set;", null, thread, false);
IJavaValue keyToArray = keySetObject.sendMessage("toArray", "()[Ljava/lang/Object;", null, thread, false);
for (IVariable ob : keyToArray.getVariables()) {
Expand Down Expand Up @@ -854,4 +856,20 @@ public static String checkInterfaces(String className) {
}
}

/**
* Returns a suspended thread for vm message operation
*
* @param value
* IJavaValue object
* @return returns a suspended IJavaThread object
*/
private IJavaThread getSuspendedThread(IJavaValue value) throws DebugException {
IJavaThread thread = (IJavaThread) value.getDebugTarget().getThreads()[0];
if (!thread.isSuspended()) {
JDIStackFrame frame = (JDIStackFrame) DebugUITools.getDebugContext();
thread = (IJavaThread) frame.getThread();
}
return thread;
}

}
Loading