aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Adada2014-01-10 12:26:42 (EST)
committerThomas Watson2014-01-10 12:28:12 (EST)
commitaf21256f4cd466b6c2196108b59931e01a6c3643 (patch)
treee4640829a211bc8dadc678fc89c4a94288e2baa4
parent357719487ce38176a9b19c03e2843bfd760b4bb3 (diff)
downloadrt.equinox.framework-af21256f4cd466b6c2196108b59931e01a6c3643.zip
rt.equinox.framework-af21256f4cd466b6c2196108b59931e01a6c3643.tar.gz
rt.equinox.framework-af21256f4cd466b6c2196108b59931e01a6c3643.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> Conflicts: bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java Change-Id: Ib905852ec38a219ae1e7e535da1e53fdb08a16e4
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java34
1 files changed, 32 insertions, 2 deletions
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java
index e891188..9118adb 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java
@@ -36,6 +36,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
@@ -923,6 +924,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)) {
@@ -941,7 +949,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;
@@ -959,9 +967,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;
}
@@ -1028,6 +1039,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]);
@@ -1039,6 +1054,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]);
@@ -1081,6 +1100,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)
@@ -2149,6 +2177,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$
*/
private void setDebugOptions() {
@@ -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);
*/
}