Author: mlschroe Date: Wed May 14 10:34:06 2008 New Revision: 10083 URL: http://svn.opensuse.org/viewcvs/zypp?rev=10083&view=rev Log: - change some comments - add solver_printtrivial debug function, use it in yps and deptestomatic - remove some assertions, return SOLVER_PROBLEM_RPM_RULE instead (we do not want to crash libzypp if we forgot to handle some case) Modified: trunk/sat-solver/src/solver.c trunk/sat-solver/src/solver.h trunk/sat-solver/src/solverdebug.c trunk/sat-solver/src/solverdebug.h trunk/sat-solver/testsuite/deptestomatic.c trunk/sat-solver/testsuite/yps.c Modified: trunk/sat-solver/src/solver.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/solver.c?rev=10083&r1=10082&r2=10083&view=diff ============================================================================== --- trunk/sat-solver/src/solver.c (original) +++ trunk/sat-solver/src/solver.c Wed May 14 10:34:06 2008 @@ -1546,6 +1546,7 @@ */ #define DECISIONMAP_TRUE(p) ((p) > 0 ? (decisionmap[p] > 0) : (decisionmap[-p] < 0)) #define DECISIONMAP_FALSE(p) ((p) > 0 ? (decisionmap[p] < 0) : (decisionmap[-p] > 0)) +#define DECISIONMAP_UNDEF(p) (decisionmap[(p) > 0 ? (p) : -(p)] == 0) /*------------------------------------------------------------------- * @@ -1632,37 +1633,36 @@ continue; /* - * The other literal is false or undecided + * The other literal is FALSE or UNDEF */ if (r->d) { - /* not a binary clause, check if we need to move our watch. - * - * search for a literal that is not other_watch and not false - * (true is also ok, in that case the rule is fulfilled) + /* not a binary clause, try to move our watch. + * search for a literal that is not other_watch and not FALSE + * (TRUE is also ok, in that case the rule is fulfilled) */ if (r->p /* we have a 'p' */ - && r->p != other_watch /* which is not what we just checked */ - && !DECISIONMAP_TRUE(-r->p)) /* and its not already decided 'negative' */ + && r->p != other_watch /* which is watched */ + && !DECISIONMAP_FALSE(r->p)) /* and not FALSE */ { - p = r->p; /* we must get this to 'true' */ + p = r->p; } else /* go find a 'd' to make 'true' */ { /* foreach 'd' */ - /* FIXME: should be a policy */ for (dp = pool->whatprovidesdata + r->d; (p = *dp++) != 0;) - if (p != other_watch /* which is not what we just checked */ - && !DECISIONMAP_TRUE(-p)) /* and its not already decided 'negative' */ + if (p != other_watch /* which is not watched */ + && !DECISIONMAP_FALSE(p)) /* and not FALSE */ break; } - /* - * if p is free to watch, move watch to p - */ if (p) { + /* + * if we found some p that is UNDEF or TRUE, move + * watch to it + */ IF_POOLDEBUG (SAT_DEBUG_PROPAGATE) { if (p > 0) @@ -1687,8 +1687,7 @@ watches[p] = r - solv->rules; continue; } - - /* !p */ + /* search failed, thus all unwatched literals are FALSE */ } /* not binary */ @@ -1696,7 +1695,7 @@ * unit clause found, set literal other_watch to TRUE */ - if (DECISIONMAP_TRUE(-other_watch)) /* check if literal is FALSE */ + if (DECISIONMAP_FALSE(other_watch)) /* check if literal is FALSE */ return r; /* eek, a conflict! */ IF_POOLDEBUG (SAT_DEBUG_PROPAGATE) @@ -3220,17 +3219,20 @@ return SOLVER_PROBLEM_NOTHING_PROVIDES_DEP; } } - assert(!solv->allowselfconflicts); - assert(s->conflicts); - conp = s->repo->idarraydata + s->conflicts; - while ((con = *conp++) != 0) - FOR_PROVIDES(p, pp, con) - if (p == -r->p) - { - *depp = con; - return SOLVER_PROBLEM_SELF_CONFLICT; - } - assert(0); + if (!solv->allowselfconflicts && s->conflicts) + { + conp = s->repo->idarraydata + s->conflicts; + while ((con = *conp++) != 0) + FOR_PROVIDES(p, pp, con) + if (p == -r->p) + { + *depp = con; + return SOLVER_PROBLEM_SELF_CONFLICT; + } + } + /* should never happen */ + *depp = 0; + return SOLVER_PROBLEM_RPM_RULE; } s = pool->solvables - r->p; if (installed && !solv->fixsystem && s->repo == installed) @@ -3359,29 +3361,41 @@ } } /* all cases checked, can't happen */ - assert(0); + *depp = 0; + *sourcep = -r->p; + *targetp = 0; + return SOLVER_PROBLEM_RPM_RULE; } /* simple requires */ - assert(s->requires); - reqp = s->repo->idarraydata + s->requires; - while ((req = *reqp++) != 0) + if (s->requires) { - if (req == SOLVABLE_PREREQMARKER) - continue; - dp = pool_whatprovides(pool, req); - if (d == 0) + reqp = s->repo->idarraydata + s->requires; + while ((req = *reqp++) != 0) { - if (*dp == r->w2 && dp[1] == 0) + if (req == SOLVABLE_PREREQMARKER) + continue; + dp = pool_whatprovides(pool, req); + if (d == 0) + { + if (*dp == r->w2 && dp[1] == 0) + break; + } + else if (dp - pool->whatprovidesdata == d) break; } - else if (dp - pool->whatprovidesdata == d) - break; + if (req) + { + *depp = req; + *sourcep = -r->p; + *targetp = 0; + return SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE; + } } - assert(req); - *depp = req; + /* all cases checked, can't happen */ + *depp = 0; *sourcep = -r->p; *targetp = 0; - return SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE; + return SOLVER_PROBLEM_RPM_RULE; } Modified: trunk/sat-solver/src/solver.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/solver.h?rev=10083&r1=10082&r2=10083&view=diff ============================================================================== --- trunk/sat-solver/src/solver.h (original) +++ trunk/sat-solver/src/solver.h Wed May 14 10:34:06 2008 @@ -236,7 +236,8 @@ SOLVER_PROBLEM_PACKAGE_CONFLICT, SOLVER_PROBLEM_PACKAGE_OBSOLETES, SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE, - SOLVER_PROBLEM_SELF_CONFLICT + SOLVER_PROBLEM_SELF_CONFLICT, + SOLVER_PROBLEM_RPM_RULE } SolverProbleminfo; Modified: trunk/sat-solver/src/solverdebug.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/solverdebug.c?rev=10083&r1=10082&r2=10083&view=diff ============================================================================== --- trunk/sat-solver/src/solverdebug.c (original) +++ trunk/sat-solver/src/solverdebug.c Wed May 14 10:34:06 2008 @@ -263,6 +263,9 @@ POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- Decisions end -----\n"); } + POOL_DEBUG(SAT_DEBUG_RESULT, "\n"); + POOL_DEBUG(SAT_DEBUG_RESULT, "transaction:\n"); + /* print solvables to be erased */ if (installed) @@ -273,7 +276,7 @@ continue; if (obsoletesmap[p]) continue; - POOL_DEBUG(SAT_DEBUG_RESULT, "erase %s\n", solvable2str(pool, s)); + POOL_DEBUG(SAT_DEBUG_RESULT, " erase %s\n", solvable2str(pool, s)); } } @@ -293,7 +296,7 @@ if (!obsoletesmap[p]) { - POOL_DEBUG(SAT_DEBUG_RESULT, "install %s", solvable2str(pool, s)); + POOL_DEBUG(SAT_DEBUG_RESULT, " install %s", solvable2str(pool, s)); } else { @@ -307,9 +310,9 @@ break; } if (xp) - POOL_DEBUG(SAT_DEBUG_RESULT, "downgrade %s", solvable2str(pool, s)); + POOL_DEBUG(SAT_DEBUG_RESULT, " downgrade %s", solvable2str(pool, s)); else - POOL_DEBUG(SAT_DEBUG_RESULT, "upgrade %s", solvable2str(pool, s)); + POOL_DEBUG(SAT_DEBUG_RESULT, " upgrade %s", solvable2str(pool, s)); POOL_DEBUG(SAT_DEBUG_RESULT, " (obsoletes"); for (j = installed->start; j < installed->end; j++) if (obsoletesmap[j] == p) @@ -318,43 +321,46 @@ } POOL_DEBUG(SAT_DEBUG_RESULT, "\n"); } + POOL_DEBUG(SAT_DEBUG_RESULT, "\n"); sat_free(obsoletesmap); if (solv->recommendations.count) { - POOL_DEBUG(SAT_DEBUG_RESULT, "\nrecommended packages:\n"); + POOL_DEBUG(SAT_DEBUG_RESULT, "recommended packages:\n"); for (i = 0; i < solv->recommendations.count; i++) { s = pool->solvables + solv->recommendations.elements[i]; if (solv->decisionmap[solv->recommendations.elements[i]] > 0) { if (installed && s->repo == installed) - POOL_DEBUG(SAT_DEBUG_RESULT, "- %s (installed)\n", solvable2str(pool, s)); + POOL_DEBUG(SAT_DEBUG_RESULT, " %s (installed)\n", solvable2str(pool, s)); else - POOL_DEBUG(SAT_DEBUG_RESULT, "- %s (selected)\n", solvable2str(pool, s)); + POOL_DEBUG(SAT_DEBUG_RESULT, " %s (selected)\n", solvable2str(pool, s)); } else - POOL_DEBUG(SAT_DEBUG_RESULT, "- %s\n", solvable2str(pool, s)); + POOL_DEBUG(SAT_DEBUG_RESULT, " %s\n", solvable2str(pool, s)); } + POOL_DEBUG(SAT_DEBUG_RESULT, "\n"); } if (solv->suggestions.count) { - POOL_DEBUG(SAT_DEBUG_RESULT, "\nsuggested packages:\n"); + POOL_DEBUG(SAT_DEBUG_RESULT, "suggested packages:\n"); for (i = 0; i < solv->suggestions.count; i++) { s = pool->solvables + solv->suggestions.elements[i]; if (solv->decisionmap[solv->suggestions.elements[i]] > 0) { if (installed && s->repo == installed) - POOL_DEBUG(SAT_DEBUG_RESULT, "- %s (installed)\n", solvable2str(pool, s)); + POOL_DEBUG(SAT_DEBUG_RESULT, " %s (installed)\n", solvable2str(pool, s)); else - POOL_DEBUG(SAT_DEBUG_RESULT, "- %s (selected)\n", solvable2str(pool, s)); + POOL_DEBUG(SAT_DEBUG_RESULT, " %s (selected)\n", solvable2str(pool, s)); } else - POOL_DEBUG(SAT_DEBUG_RESULT, "- %s\n", solvable2str(pool, s)); + POOL_DEBUG(SAT_DEBUG_RESULT, " %s\n", solvable2str(pool, s)); } + POOL_DEBUG(SAT_DEBUG_RESULT, "\n"); } } @@ -376,6 +382,9 @@ case SOLVER_PROBLEM_JOB_RULE: POOL_DEBUG(SAT_DEBUG_RESULT, "conflicting requests\n"); return; + case SOLVER_PROBLEM_RPM_RULE: + POOL_DEBUG(SAT_DEBUG_RESULT, "some dependency problem\n"); + return; case SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP: POOL_DEBUG(SAT_DEBUG_RESULT, "nothing provides requested %s\n", dep2str(pool, dep)); return; @@ -520,3 +529,38 @@ } } +void +solver_printtrivial(Solver *solv) +{ + Pool *pool = solv->pool; + Queue in, out; + Map installedmap; + Id p; + const char *n; + Solvable *s; + int i; + + queue_init(&in); + for (p = 1, s = pool->solvables + p; p < solv->pool->nsolvables; p++, s++) + { + n = id2str(pool, s->name); + if (strncmp(n, "patch:", 6) != 0 && strncmp(n, "pattern:", 8) != 0) + continue; + queue_push(&in, p); + } + if (!in.count) + { + queue_free(&in); + return; + } + solver_create_state_maps(solv, &installedmap, 0); + queue_init(&out); + pool_trivial_installable(pool, solv->installed, &installedmap, &in, &out); + POOL_DEBUG(SAT_DEBUG_RESULT, "trivial installable status:\n"); + for (i = 0; i < in.count; i++) + POOL_DEBUG(SAT_DEBUG_RESULT, " %s: %d\n", solvable2str(pool, pool->solvables + in.elements[i]), out.elements[i]); + POOL_DEBUG(SAT_DEBUG_RESULT, "\n"); + map_free(&installedmap); + queue_free(&in); + queue_free(&out); +} Modified: trunk/sat-solver/src/solverdebug.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/solverdebug.h?rev=10083&r1=10082&r2=10083&view=diff ============================================================================== --- trunk/sat-solver/src/solverdebug.h (original) +++ trunk/sat-solver/src/solverdebug.h Wed May 14 10:34:06 2008 @@ -26,6 +26,7 @@ extern void solver_printdecisions(Solver *solv); extern void solver_printprobleminfo(Solver *solv, Queue *job, Id problem); extern void solver_printsolutions(Solver *solv, Queue *job); +extern void solver_printtrivial(Solver *solv); #endif /* SATSOLVER_SOLVERDEBUG_H */ Modified: trunk/sat-solver/testsuite/deptestomatic.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/testsuite/deptestomatic.c?rev=10083&r1=10082&r2=10083&view=diff ============================================================================== --- trunk/sat-solver/testsuite/deptestomatic.c (original) +++ trunk/sat-solver/testsuite/deptestomatic.c Wed May 14 10:34:06 2008 @@ -1405,7 +1405,10 @@ else { if (verbose >= 2) - solver_printdecisions(solv); + { + solver_printdecisions(solv); + solver_printtrivial(solv); + } rc_printdecisions(solv, &pd->trials); } // clean up Modified: trunk/sat-solver/testsuite/yps.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/testsuite/yps.c?rev=10083&r1=10082&r2=10083&view=diff ============================================================================== --- trunk/sat-solver/testsuite/yps.c (original) +++ trunk/sat-solver/testsuite/yps.c Wed May 14 10:34:06 2008 @@ -117,36 +117,6 @@ } } -void -trivialdemo(Solver *solv) -{ - Pool *pool = solv->pool; - Queue in, out; - Map installedmap; - Id p; - const char *n; - Solvable *s; - int i; - - queue_init(&in); - queue_init(&out); - printf("trivial installable status:\n"); - solver_create_state_maps(solv, &installedmap, 0); - for (p = 1, s = pool->solvables + p; p < solv->pool->nsolvables; p++, s++) - { - n = id2str(pool, s->name); - if (strncmp(n, "patch:", 6) != 0 && strncmp(n, "pattern:", 8) != 0) - continue; - queue_push(&in, p); - } - pool_trivial_installable(pool, solv->installed, &installedmap, &in, &out); - for (i = 0; i < in.count; i++) - printf("%s: %d\n", solvable2str(pool, pool->solvables + in.elements[i]), out.elements[i]); - map_free(&installedmap); - queue_free(&in); - queue_free(&out); -} - static Id nscallback(Pool *pool, void *data, Id name, Id evr) { @@ -386,7 +356,6 @@ solver_solve(solv, &job); if (solv->problems.count) solver_printsolutions(solv, &job); - printf("transaction:\n"); solver_printdecisions(solv); if (1) { @@ -405,7 +374,7 @@ langdemo(pool); - trivialdemo(solv); + solver_printtrivial(solv); // clean up -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org