move stringification functions from solverdebug to more correct places
[platform/upstream/libsolv.git] / src / solverdebug.c
1 /*
2  * Copyright (c) 2008, Novell Inc.
3  *
4  * This program is licensed under the BSD license, read LICENSE.BSD
5  * for further information
6  */
7
8 /*
9  * solverdebug.c
10  *
11  * debug functions for the SAT solver
12  */
13
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <unistd.h>
17 #include <string.h>
18 #include <assert.h>
19
20 #include "solver.h"
21 #include "solver_private.h"
22 #include "solverdebug.h"
23 #include "bitmap.h"
24 #include "pool.h"
25 #include "poolarch.h"
26 #include "util.h"
27 #include "evr.h"
28 #include "policy.h"
29
30
31 /*
32  * create obsoletesmap from solver decisions
33  *
34  * for solvables in installed repo:
35  *   0 - not obsoleted
36  *   p - one of the packages that obsolete us
37  * for all others:
38  *   n - number of packages this package obsoletes
39  *
40  */
41
42 /* OBSOLETE: use transaction code instead! */
43
44 Id *
45 solver_create_decisions_obsoletesmap(Solver *solv)
46 {
47   Pool *pool = solv->pool;
48   Repo *installed = solv->installed;
49   Id p, *obsoletesmap = NULL;
50   int i;
51   Solvable *s;
52
53   obsoletesmap = (Id *)solv_calloc(pool->nsolvables, sizeof(Id));
54   if (installed)
55     {
56       for (i = 0; i < solv->decisionq.count; i++)
57         {
58           Id pp, n;
59           int multi;
60
61           n = solv->decisionq.elements[i];
62           if (n < 0)
63             continue;
64           if (n == SYSTEMSOLVABLE)
65             continue;
66           s = pool->solvables + n;
67           if (s->repo == installed)             /* obsoletes don't count for already installed packages */
68             continue;
69           multi = solv->multiversion.size && MAPTST(&solv->multiversion, n);
70           FOR_PROVIDES(p, pp, s->name)
71             {
72               Solvable *ps = pool->solvables + p;
73               if (multi && (s->name != ps->name || s->evr != ps->evr || s->arch != ps->arch))
74                 continue;
75               if (!pool->implicitobsoleteusesprovides && s->name != ps->name)
76                 continue;
77               if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
78                 continue;
79               if (ps->repo == installed && !obsoletesmap[p])
80                 {
81                   obsoletesmap[p] = n;
82                   obsoletesmap[n]++;
83                 }
84             }
85         }
86       for (i = 0; i < solv->decisionq.count; i++)
87         {
88           Id obs, *obsp;
89           Id pp, n;
90
91           n = solv->decisionq.elements[i];
92           if (n < 0)
93             continue;
94           if (n == SYSTEMSOLVABLE)
95             continue;
96           s = pool->solvables + n;
97           if (s->repo == installed)             /* obsoletes don't count for already installed packages */
98             continue;
99           if (!s->obsoletes)
100             continue;
101           if (solv->multiversion.size && MAPTST(&solv->multiversion, n))
102             continue;
103           obsp = s->repo->idarraydata + s->obsoletes;
104           while ((obs = *obsp++) != 0)
105             {
106               FOR_PROVIDES(p, pp, obs)
107                 {
108                   Solvable *ps = pool->solvables + p;
109                   if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, ps, obs))
110                     continue;
111                   if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
112                     continue;
113                   if (pool->solvables[p].repo == installed && !obsoletesmap[p])
114                     {
115                       obsoletesmap[p] = n;
116                       obsoletesmap[n]++;
117                     }
118                 }
119             }
120         }
121     }
122   return obsoletesmap;
123 }
124
125 void
126 solver_printruleelement(Solver *solv, int type, Rule *r, Id v)
127 {
128   Pool *pool = solv->pool;
129   Solvable *s;
130   if (v < 0)
131     {
132       s = pool->solvables + -v;
133       POOL_DEBUG(type, "    !%s [%d]", pool_solvable2str(pool, s), -v);
134     }
135   else
136     {
137       s = pool->solvables + v;
138       POOL_DEBUG(type, "    %s [%d]", pool_solvable2str(pool, s), v);
139     }
140   if (pool->installed && s->repo == pool->installed)
141     POOL_DEBUG(type, "I");
142   if (r)
143     {
144       if (r->w1 == v)
145         POOL_DEBUG(type, " (w1)");
146       if (r->w2 == v)
147         POOL_DEBUG(type, " (w2)");
148     }
149   if (solv->decisionmap[s - pool->solvables] > 0)
150     POOL_DEBUG(type, " Install.level%d", solv->decisionmap[s - pool->solvables]);
151   if (solv->decisionmap[s - pool->solvables] < 0)
152     POOL_DEBUG(type, " Conflict.level%d", -solv->decisionmap[s - pool->solvables]);
153   POOL_DEBUG(type, "\n");
154 }
155
156
157 /*
158  * print rule
159  */
160
161 void
162 solver_printrule(Solver *solv, int type, Rule *r)
163 {
164   Pool *pool = solv->pool;
165   int i;
166   Id d, v;
167
168   if (r >= solv->rules && r < solv->rules + solv->nrules)   /* r is a solver rule */
169     POOL_DEBUG(type, "Rule #%d:", (int)(r - solv->rules));
170   else
171     POOL_DEBUG(type, "Rule:");                 /* r is any rule */
172   if (r && r->d < 0)
173     POOL_DEBUG(type, " (disabled)");
174   POOL_DEBUG(type, "\n");
175   d = r->d < 0 ? -r->d - 1 : r->d;
176   for (i = 0; ; i++)
177     {
178       if (i == 0)
179           /* print direct literal */
180         v = r->p;
181       else if (!d)
182         {
183           if (i == 2)
184             break;
185           /* binary rule --> print w2 as second literal */
186           v = r->w2;
187         }
188       else
189           /* every other which is in d */
190         v = solv->pool->whatprovidesdata[d + i - 1];
191       if (v == ID_NULL)
192         break;
193       solver_printruleelement(solv, type, r, v);
194     }
195   POOL_DEBUG(type, "    next rules: %d %d\n", r->n1, r->n2);
196 }
197
198 void
199 solver_printruleclass(Solver *solv, int type, Rule *r)
200 {
201   Pool *pool = solv->pool;
202   Id p = r - solv->rules;
203   assert(p >= 0);
204   if (p < solv->learntrules)
205     if (MAPTST(&solv->weakrulemap, p))
206       POOL_DEBUG(type, "WEAK ");
207   if (solv->learntrules && p >= solv->learntrules)
208     POOL_DEBUG(type, "LEARNT ");
209   else if (p >= solv->bestrules && p < solv->bestrules_end)
210     POOL_DEBUG(type, "BEST ");
211   else if (p >= solv->choicerules && p < solv->choicerules_end)
212     POOL_DEBUG(type, "CHOICE ");
213   else if (p >= solv->infarchrules && p < solv->infarchrules_end)
214     POOL_DEBUG(type, "INFARCH ");
215   else if (p >= solv->duprules && p < solv->duprules_end)
216     POOL_DEBUG(type, "DUP ");
217   else if (p >= solv->jobrules && p < solv->jobrules_end)
218     POOL_DEBUG(type, "JOB ");
219   else if (p >= solv->updaterules && p < solv->updaterules_end)
220     POOL_DEBUG(type, "UPDATE ");
221   else if (p >= solv->featurerules && p < solv->featurerules_end)
222     POOL_DEBUG(type, "FEATURE ");
223   solver_printrule(solv, type, r);
224 }
225
226 void
227 solver_printproblem(Solver *solv, Id v)
228 {
229   Pool *pool = solv->pool;
230   int i;
231   Rule *r;
232   Id *jp;
233
234   if (v > 0)
235     solver_printruleclass(solv, SOLV_DEBUG_SOLUTIONS, solv->rules + v);
236   else
237     {
238       v = -(v + 1);
239       POOL_DEBUG(SOLV_DEBUG_SOLUTIONS, "JOB %d\n", v);
240       jp = solv->ruletojob.elements;
241       for (i = solv->jobrules, r = solv->rules + i; i < solv->jobrules_end; i++, r++, jp++)
242         if (*jp == v)
243           {
244             POOL_DEBUG(SOLV_DEBUG_SOLUTIONS, "- ");
245             solver_printrule(solv, SOLV_DEBUG_SOLUTIONS, r);
246           }
247       POOL_DEBUG(SOLV_DEBUG_SOLUTIONS, "ENDJOB\n");
248     }
249 }
250
251 void
252 solver_printwatches(Solver *solv, int type)
253 {
254   Pool *pool = solv->pool;
255   int counter;
256
257   POOL_DEBUG(type, "Watches: \n");
258   for (counter = -(pool->nsolvables - 1); counter < pool->nsolvables; counter++)
259     POOL_DEBUG(type, "    solvable [%d] -- rule [%d]\n", counter, solv->watches[counter + pool->nsolvables]);
260 }
261
262 void
263 solver_printdecisionq(Solver *solv, int type)
264 {
265   Pool *pool = solv->pool;
266   int i;
267   Id p, why;
268
269   POOL_DEBUG(type, "Decisions:\n");
270   for (i = 0; i < solv->decisionq.count; i++)
271     {
272       p = solv->decisionq.elements[i];
273       if (p > 0)
274         POOL_DEBUG(type, "%d %d install  %s, ", i, solv->decisionmap[p], pool_solvid2str(pool, p));
275       else
276         POOL_DEBUG(type, "%d %d conflict %s, ", i, -solv->decisionmap[-p], pool_solvid2str(pool, -p));
277       why = solv->decisionq_why.elements[i];
278       if (why > 0)
279         {
280           POOL_DEBUG(type, "forced by ");
281           solver_printruleclass(solv, type, solv->rules + why);
282         }
283       else if (why < 0)
284         {
285           POOL_DEBUG(type, "chosen from ");
286           solver_printruleclass(solv, type, solv->rules - why);
287         }
288       else
289         POOL_DEBUG(type, "picked for some unknown reason.\n");
290     }
291 }
292
293 /*
294  * printdecisions
295  */
296
297 void
298 solver_printdecisions(Solver *solv)
299 {
300   Pool *pool = solv->pool;
301   Repo *installed = solv->installed;
302   Transaction *trans = solver_create_transaction(solv);
303   Id p, type;
304   int i, j;
305   Solvable *s;
306   Queue iq;
307   Queue recommendations;
308   Queue suggestions;
309   Queue orphaned;
310
311   POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
312   POOL_DEBUG(SOLV_DEBUG_RESULT, "transaction:\n");
313
314   queue_init(&iq);
315   for (i = 0; i < trans->steps.count; i++)
316     {
317       p = trans->steps.elements[i];
318       s = pool->solvables + p;
319       type = transaction_type(trans, p, SOLVER_TRANSACTION_SHOW_ACTIVE|SOLVER_TRANSACTION_SHOW_ALL|SOLVER_TRANSACTION_SHOW_OBSOLETES|SOLVER_TRANSACTION_SHOW_MULTIINSTALL);
320       switch(type)
321         {
322         case SOLVER_TRANSACTION_MULTIINSTALL:
323           POOL_DEBUG(SOLV_DEBUG_RESULT, "  multi install %s", pool_solvable2str(pool, s));
324           break;
325         case SOLVER_TRANSACTION_MULTIREINSTALL:
326           POOL_DEBUG(SOLV_DEBUG_RESULT, "  multi reinstall %s", pool_solvable2str(pool, s));
327           break;
328         case SOLVER_TRANSACTION_INSTALL:
329           POOL_DEBUG(SOLV_DEBUG_RESULT, "  install   %s", pool_solvable2str(pool, s));
330           break;
331         case SOLVER_TRANSACTION_REINSTALL:
332           POOL_DEBUG(SOLV_DEBUG_RESULT, "  reinstall %s", pool_solvable2str(pool, s));
333           break;
334         case SOLVER_TRANSACTION_DOWNGRADE:
335           POOL_DEBUG(SOLV_DEBUG_RESULT, "  downgrade %s", pool_solvable2str(pool, s));
336           break;
337         case SOLVER_TRANSACTION_CHANGE:
338           POOL_DEBUG(SOLV_DEBUG_RESULT, "  change    %s", pool_solvable2str(pool, s));
339           break;
340         case SOLVER_TRANSACTION_UPGRADE:
341         case SOLVER_TRANSACTION_OBSOLETES:
342           POOL_DEBUG(SOLV_DEBUG_RESULT, "  upgrade   %s", pool_solvable2str(pool, s));
343           break;
344         case SOLVER_TRANSACTION_ERASE:
345           POOL_DEBUG(SOLV_DEBUG_RESULT, "  erase     %s", pool_solvable2str(pool, s));
346           break;
347         default:
348           break;
349         }
350       switch(type)
351         {
352         case SOLVER_TRANSACTION_INSTALL:
353         case SOLVER_TRANSACTION_ERASE:
354         case SOLVER_TRANSACTION_MULTIINSTALL:
355         case SOLVER_TRANSACTION_MULTIREINSTALL:
356           POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
357           break;
358         case SOLVER_TRANSACTION_REINSTALL:
359         case SOLVER_TRANSACTION_DOWNGRADE:
360         case SOLVER_TRANSACTION_CHANGE:
361         case SOLVER_TRANSACTION_UPGRADE:
362         case SOLVER_TRANSACTION_OBSOLETES:
363           transaction_all_obs_pkgs(trans, p, &iq);
364           if (iq.count)
365             {
366               POOL_DEBUG(SOLV_DEBUG_RESULT, "  (obsoletes");
367               for (j = 0; j < iq.count; j++)
368                 POOL_DEBUG(SOLV_DEBUG_RESULT, " %s", pool_solvid2str(pool, iq.elements[j]));
369               POOL_DEBUG(SOLV_DEBUG_RESULT, ")");
370             }
371           POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
372           break;
373         default:
374           break;
375         }
376     }
377   queue_free(&iq);
378
379   POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
380
381   queue_init(&recommendations);
382   queue_init(&suggestions);
383   queue_init(&orphaned);
384   solver_get_recommendations(solv, &recommendations, &suggestions, 0);
385   if (recommendations.count)
386     {
387       POOL_DEBUG(SOLV_DEBUG_RESULT, "recommended packages:\n");
388       for (i = 0; i < recommendations.count; i++)
389         {
390           s = pool->solvables + recommendations.elements[i];
391           if (solv->decisionmap[recommendations.elements[i]] > 0)
392             {
393               if (installed && s->repo == installed)
394                 POOL_DEBUG(SOLV_DEBUG_RESULT, "  %s (installed)\n", pool_solvable2str(pool, s));
395               else
396                 POOL_DEBUG(SOLV_DEBUG_RESULT, "  %s (selected)\n", pool_solvable2str(pool, s));
397             }
398           else
399             POOL_DEBUG(SOLV_DEBUG_RESULT, "  %s\n", pool_solvable2str(pool, s));
400         }
401       POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
402     }
403
404   if (suggestions.count)
405     {
406       POOL_DEBUG(SOLV_DEBUG_RESULT, "suggested packages:\n");
407       for (i = 0; i < suggestions.count; i++)
408         {
409           s = pool->solvables + suggestions.elements[i];
410           if (solv->decisionmap[suggestions.elements[i]] > 0)
411             {
412               if (installed && s->repo == installed)
413                 POOL_DEBUG(SOLV_DEBUG_RESULT, "  %s (installed)\n", pool_solvable2str(pool, s));
414               else
415                 POOL_DEBUG(SOLV_DEBUG_RESULT, "  %s (selected)\n", pool_solvable2str(pool, s));
416             }
417           else
418             POOL_DEBUG(SOLV_DEBUG_RESULT, "  %s\n", pool_solvable2str(pool, s));
419         }
420       POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
421     }
422   if (orphaned.count)
423     {
424       POOL_DEBUG(SOLV_DEBUG_RESULT, "orphaned packages:\n");
425       for (i = 0; i < orphaned.count; i++)
426         {
427           s = pool->solvables + orphaned.elements[i];
428           if (solv->decisionmap[solv->orphaned.elements[i]] > 0)
429             POOL_DEBUG(SOLV_DEBUG_RESULT, "  %s (kept)\n", pool_solvable2str(pool, s));
430           else
431             POOL_DEBUG(SOLV_DEBUG_RESULT, "  %s (erased)\n", pool_solvable2str(pool, s));
432         }
433       POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
434     }
435   queue_free(&recommendations);
436   queue_free(&suggestions);
437   queue_free(&orphaned);
438   transaction_free(trans);
439 }
440
441 static inline
442 const char *id2strnone(Pool *pool, Id id)
443 {
444   return !id || id == 1 ? "(none)" : pool_id2str(pool, id);
445 }
446
447 void
448 transaction_print(Transaction *trans)
449 {
450   Pool *pool = trans->pool;
451   Queue classes, pkgs;
452   int i, j, mode, l, linel;
453   char line[76];
454   const char *n;
455
456   queue_init(&classes);
457   queue_init(&pkgs);
458   mode = SOLVER_TRANSACTION_SHOW_OBSOLETES | SOLVER_TRANSACTION_OBSOLETE_IS_UPGRADE;
459   transaction_classify(trans, mode, &classes);
460   for (i = 0; i < classes.count; i += 4)
461     {
462       Id class = classes.elements[i];
463       Id cnt = classes.elements[i + 1];
464       switch(class)
465         {
466         case SOLVER_TRANSACTION_ERASE:
467           POOL_DEBUG(SOLV_DEBUG_RESULT, "%d erased packages:\n", cnt);
468           break;
469         case SOLVER_TRANSACTION_INSTALL:
470           POOL_DEBUG(SOLV_DEBUG_RESULT, "%d installed packages:\n", cnt);
471           break;
472         case SOLVER_TRANSACTION_REINSTALLED:
473           POOL_DEBUG(SOLV_DEBUG_RESULT, "%d reinstalled packages:\n", cnt);
474           break;
475         case SOLVER_TRANSACTION_DOWNGRADED:
476           POOL_DEBUG(SOLV_DEBUG_RESULT, "%d downgraded packages:\n", cnt);
477           break;
478         case SOLVER_TRANSACTION_CHANGED:
479           POOL_DEBUG(SOLV_DEBUG_RESULT, "%d changed packages:\n", cnt);
480           break;
481         case SOLVER_TRANSACTION_UPGRADED:
482           POOL_DEBUG(SOLV_DEBUG_RESULT, "%d upgraded packages:\n", cnt);
483           break;
484         case SOLVER_TRANSACTION_VENDORCHANGE:
485           POOL_DEBUG(SOLV_DEBUG_RESULT, "%d vendor changes from '%s' to '%s':\n", cnt, id2strnone(pool, classes.elements[i + 2]), id2strnone(pool, classes.elements[i + 3]));
486           break;
487         case SOLVER_TRANSACTION_ARCHCHANGE:
488           POOL_DEBUG(SOLV_DEBUG_RESULT, "%d arch changes from %s to %s:\n", cnt, pool_id2str(pool, classes.elements[i + 2]), pool_id2str(pool, classes.elements[i + 3]));
489           break;
490         default:
491           class = SOLVER_TRANSACTION_IGNORE;
492           break;
493         }
494       if (class == SOLVER_TRANSACTION_IGNORE)
495         continue;
496       transaction_classify_pkgs(trans, mode, class, classes.elements[i + 2], classes.elements[i + 3], &pkgs);
497       *line = 0;
498       linel = 0;
499       for (j = 0; j < pkgs.count; j++)
500         {
501           Id p = pkgs.elements[j];
502           Solvable *s = pool->solvables + p;
503           Solvable *s2;
504
505           switch(class)
506             {
507             case SOLVER_TRANSACTION_DOWNGRADED:
508             case SOLVER_TRANSACTION_UPGRADED:
509               s2 = pool->solvables + transaction_obs_pkg(trans, p);
510               POOL_DEBUG(SOLV_DEBUG_RESULT, "  - %s -> %s\n", pool_solvable2str(pool, s), pool_solvable2str(pool, s2));
511               break;
512             case SOLVER_TRANSACTION_VENDORCHANGE:
513             case SOLVER_TRANSACTION_ARCHCHANGE:
514               n = pool_id2str(pool, s->name);
515               l = strlen(n);
516               if (l + linel > sizeof(line) - 3)
517                 {
518                   if (*line)
519                     POOL_DEBUG(SOLV_DEBUG_RESULT, "    %s\n", line);
520                   *line = 0;
521                   linel = 0;
522                 }
523               if (l + linel > sizeof(line) - 3)
524                 POOL_DEBUG(SOLV_DEBUG_RESULT, "    %s\n", n);
525               else
526                 {
527                   if (*line)
528                     {
529                       strcpy(line + linel, ", ");
530                       linel += 2;
531                     }
532                   strcpy(line + linel, n);
533                   linel += l;
534                 }
535               break;
536             default:
537               POOL_DEBUG(SOLV_DEBUG_RESULT, "  - %s\n", pool_solvable2str(pool, s));
538               break;
539             }
540         }
541       if (*line)
542         POOL_DEBUG(SOLV_DEBUG_RESULT, "    %s\n", line);
543       POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
544     }
545   queue_free(&classes);
546   queue_free(&pkgs);
547 }
548
549 void
550 solver_printproblemruleinfo(Solver *solv, Id probr)
551 {
552   Pool *pool = solv->pool;
553   Id dep, source, target;
554   SolverRuleinfo type = solver_ruleinfo(solv, probr, &source, &target, &dep);
555
556   POOL_DEBUG(SOLV_DEBUG_RESULT, "%s\n", solver_problemruleinfo2str(solv, type, source, target, dep));
557 }
558
559 void
560 solver_printprobleminfo(Solver *solv, Id problem)
561 {
562   solver_printproblemruleinfo(solv, solver_findproblemrule(solv, problem));
563 }
564
565 void
566 solver_printcompleteprobleminfo(Solver *solv, Id problem)
567 {
568   Queue q;
569   Id probr;
570   int i, nobad = 0;
571
572   queue_init(&q);
573   solver_findallproblemrules(solv, problem, &q);
574   for (i = 0; i < q.count; i++)
575     {
576       probr = q.elements[i];
577       if (!(probr >= solv->updaterules && probr < solv->updaterules_end) && !(probr >= solv->jobrules && probr < solv->jobrules_end))
578         {
579           nobad = 1;
580           break;
581         }
582     }
583   for (i = 0; i < q.count; i++)
584     {
585       probr = q.elements[i];
586       if (nobad && ((probr >= solv->updaterules && probr < solv->updaterules_end) || (probr >= solv->jobrules && probr < solv->jobrules_end)))
587         continue;
588       solver_printproblemruleinfo(solv, probr);
589     }
590   queue_free(&q);
591 }
592
593 static int illegals[] = {
594   POLICY_ILLEGAL_DOWNGRADE,
595   POLICY_ILLEGAL_NAMECHANGE,
596   POLICY_ILLEGAL_ARCHCHANGE,
597   POLICY_ILLEGAL_VENDORCHANGE,
598   0
599 };
600
601 void
602 solver_printsolution(Solver *solv, Id problem, Id solution)
603 {
604   Pool *pool = solv->pool;
605   Id p, rp, element;
606
607   element = 0;
608   while ((element = solver_next_solutionelement(solv, problem, solution, element, &p, &rp)) != 0)
609     {
610       if (p > 0 && rp > 0)
611         {
612           /* for replacements we want to know why it was illegal */
613           Solvable *s = pool->solvables + p, *rs = pool->solvables + rp;
614           int illegal = policy_is_illegal(solv, s, rs, 0);
615           if (illegal)
616             {
617               int i;
618               for (i = 0; illegals[i]; i++)
619                 if ((illegal & illegals[i]) != 0)
620                   {
621                     POOL_DEBUG(SOLV_DEBUG_RESULT, "  - allow %s\n", policy_illegal2str(solv, illegals[i], s, rs));
622                     illegal ^= illegals[i];
623                   }
624               if (!illegal)
625                 continue;
626             }
627         }
628       POOL_DEBUG(SOLV_DEBUG_RESULT, "  - %s\n", solver_solutionelement2str(solv, p, rp));
629     }
630 }
631
632 void
633 solver_printallsolutions(Solver *solv)
634 {
635   Pool *pool = solv->pool;
636   int pcnt;
637   Id problem, solution;
638
639   POOL_DEBUG(SOLV_DEBUG_RESULT, "Encountered problems! Here are the solutions:\n\n");
640   pcnt = 0;
641   problem = 0;
642   while ((problem = solver_next_problem(solv, problem)) != 0)
643     {
644       pcnt++;
645       POOL_DEBUG(SOLV_DEBUG_RESULT, "Problem %d:\n", pcnt);
646       POOL_DEBUG(SOLV_DEBUG_RESULT, "====================================\n");
647 #if 1
648       solver_printprobleminfo(solv, problem);
649 #else
650       solver_printcompleteprobleminfo(solv, problem);
651 #endif
652       POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
653       solution = 0;
654       while ((solution = solver_next_solution(solv, problem, solution)) != 0)
655         {
656           solver_printsolution(solv, problem, solution);
657           POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
658         }
659     }
660 }
661
662 void
663 solver_printtrivial(Solver *solv)
664 {
665   Pool *pool = solv->pool;
666   Queue in, out;
667   Id p;
668   const char *n; 
669   Solvable *s; 
670   int i;
671
672   queue_init(&in);
673   for (p = 1, s = pool->solvables + p; p < solv->pool->nsolvables; p++, s++)
674     {   
675       n = pool_id2str(pool, s->name);
676       if (strncmp(n, "patch:", 6) != 0 && strncmp(n, "pattern:", 8) != 0)
677         continue;
678       queue_push(&in, p); 
679     }   
680   if (!in.count)
681     {
682       queue_free(&in);
683       return;
684     }
685   queue_init(&out);
686   solver_trivial_installable(solv, &in, &out);
687   POOL_DEBUG(SOLV_DEBUG_RESULT, "trivial installable status:\n");
688   for (i = 0; i < in.count; i++)
689     POOL_DEBUG(SOLV_DEBUG_RESULT, "  %s: %d\n", pool_solvid2str(pool, in.elements[i]), out.elements[i]);
690   POOL_DEBUG(SOLV_DEBUG_RESULT, "\n");
691   queue_free(&in);
692   queue_free(&out);
693 }
694