aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Adada2013-11-14 08:03:24 (EST)
committerThomas Watson2014-01-10 10:47:20 (EST)
commitce6b60b7ce80556449c120d33f19bf582fa14762 (patch)
tree9895d57689550ccab41e7741810f8ca0780ef5d1
parentd73a55a0382d46ea740f7ccad9b1593c58336b3b (diff)
downloadrt.equinox.framework-ce6b60b7ce80556449c120d33f19bf582fa14762.zip
rt.equinox.framework-ce6b60b7ce80556449c120d33f19bf582fa14762.tar.gz
rt.equinox.framework-ce6b60b7ce80556449c120d33f19bf582fa14762.tar.bz2
Bug 421604 - Enhance the Resolver debug logs to ease the investigation
of conflicts. Added a new debug option "org.eclipse.osgi/resolver/conflicts" to print out detailed information regarding initial conflicts during the resolution process. Change-Id: Iec103cabc9f6cbfd56d32c1e572a222d56c6e8fe Signed-off-by: Michael Adada <michael.adada@softwareag.com>
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java34
1 files changed, 32 insertions, 2 deletions
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
index d0d54fd..3f845b6 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
@@ -40,6 +40,7 @@ public class ResolverImpl implements Resolver {
private static final String OPTION_REQUIRES = RESOLVER + "/requires"; //$NON-NLS-1$
private static final String OPTION_GENERICS = RESOLVER + "/generics"; //$NON-NLS-1$
private static final String OPTION_USES = RESOLVER + "/uses"; //$NON-NLS-1$
+ private static final String OPTION_CONFLICTS = RESOLVER + "/conflicts"; //$NON-NLS-1$
private static final String OPTION_CYCLES = RESOLVER + "/cycles"; //$NON-NLS-1$
public static boolean DEBUG = false;
public static boolean DEBUG_WIRING = false;
@@ -47,6 +48,7 @@ public class ResolverImpl implements Resolver {
public static boolean DEBUG_REQUIRES = false;
public static boolean DEBUG_GENERICS = false;
public static boolean DEBUG_USES = false;
+ public static boolean DEBUG_CONFLICTS = false;
public static boolean DEBUG_CYCLES = false;
private static int MAX_MULTIPLE_SUPPLIERS_MERGE = 10;
private static int MAX_USES_TIME_BASE = 30000; // 30 seconds
@@ -935,6 +937,13 @@ public class ResolverImpl implements Resolver {
else
timeLimit = usesTimeout;
+ if (DEBUG_USES) {
+ System.out.println(multipleSuppliers.length + " Uses constraint were found for the following declarations: "); //$NON-NLS-1$
+ for (ResolverConstraint[] constraint : multipleSuppliers) {
+ System.out.println(Arrays.toString(constraint));
+ }
+ }
+
int bestConflictCount = getConflictCount(bestConflicts);
ResolverBundle[] bestConflictBundles = getConflictedBundles(bestConflicts);
while (bestConflictCount != 0 && getNextCombination(multipleSuppliers)) {
@@ -953,7 +962,7 @@ public class ResolverImpl implements Resolver {
int conflictCount = getConflictCount(conflicts);
if (conflictCount >= bestConflictCount) {
if (DEBUG_USES)
- System.out.println("Combination is not better that current best: " + conflictCount + ">=" + bestConflictCount); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("Combination is not better than current best: " + conflictCount + ">=" + bestConflictCount); //$NON-NLS-1$ //$NON-NLS-2$
// no need to test the other bundles;
// this combination is no better for the bundles which conflict with the current best combination
continue;
@@ -971,9 +980,12 @@ public class ResolverImpl implements Resolver {
if (DEBUG_USES)
System.out.println("Combination selected as current best: number of conflicts: " + bestConflictCount); //$NON-NLS-1$
} else if (DEBUG_USES) {
- System.out.println("Combination is not better that current best: " + conflictCount + ">=" + bestConflictCount); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("Combination is not better than current best: " + conflictCount + ">=" + bestConflictCount); //$NON-NLS-1$ //$NON-NLS-2$
}
}
+
+ if (DEBUG_USES && !usesCalculationTimeout)
+ System.out.println("Uses constraint check has finished after " + (System.currentTimeMillis() - initialTime) + "ms out of " + timeLimit + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return bestConflicts;
}
@@ -1040,6 +1052,10 @@ public class ResolverImpl implements Resolver {
PackageRoots[][] conflict = selectedSupplier == null ? null : groupingChecker.isConsistent(bundle, selectedSupplier);
if (conflict != null) {
addConflictNames(conflict, packageConstraints, bundleConstraints);
+
+ if (DEBUG_CONFLICTS)
+ printConflict(conflict, requires[i], bundle);
+
if (conflicts == null)
conflicts = new ArrayList<ResolverConstraint>(1);
conflicts.add(requires[i]);
@@ -1051,6 +1067,10 @@ public class ResolverImpl implements Resolver {
PackageRoots[][] conflict = selectedSupplier == null ? null : groupingChecker.isConsistent(bundle, selectedSupplier);
if (conflict != null) {
addConflictNames(conflict, packageConstraints, bundleConstraints);
+
+ if (DEBUG_CONFLICTS)
+ printConflict(conflict, imports[i], bundle);
+
if (conflicts == null)
conflicts = new ArrayList<ResolverConstraint>(1);
conflicts.add(imports[i]);
@@ -1093,6 +1113,15 @@ public class ResolverImpl implements Resolver {
return conflicts;
}
+ private void printConflict(PackageRoots[][] conflict, ResolverConstraint constraint, ResolverBundle bundle) {
+ System.out.println("Found conflict for bundle: " + bundle + ", when trying to resolve constraint: " + constraint); //$NON-NLS-1$//$NON-NLS-2$
+ for (PackageRoots[] rootConflicts : conflict) {
+ ResolverExport export0 = rootConflicts[0].getRoots()[0];
+ ResolverExport export1 = rootConflicts[1].getRoots()[0];
+ System.out.println(" " + export0 + ", provided by bundle: " + export0.getResolverBundle() + " conflicts with " + export1 + ", provided by bundle: " + export1.getResolverBundle()); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+ }
+
// records the conflict names we can use to scope down the list of multiple suppliers
private void addConflictNames(PackageRoots[][] conflict, Set<String> packageConstraints, Set<String> bundleConstraints) {
if (packageConstraints == null || bundleConstraints == null)
@@ -2164,6 +2193,7 @@ public class ResolverImpl implements Resolver {
DEBUG_REQUIRES = options.getBooleanOption(OPTION_REQUIRES, false);
DEBUG_GENERICS = options.getBooleanOption(OPTION_GENERICS, false);
DEBUG_USES = options.getBooleanOption(OPTION_USES, false);
+ DEBUG_CONFLICTS = options.getBooleanOption(OPTION_CONFLICTS, false);
DEBUG_CYCLES = options.getBooleanOption(OPTION_CYCLES, false);
}