From 1414c61996bba1f0b181a4e2bfbce892d0022d8b Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Wed, 25 May 2011 12:10:36 +0200 Subject: [PATCH] un-inline some functions, remove SAT_DEBUG_SCHUBI --- src/libsolv.ver | 6 ++++++ src/pool.c | 19 +++++++++++++++++-- src/pool.h | 26 ++++++-------------------- src/problems.c | 2 -- src/repo.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/repo.h | 45 +++------------------------------------------ src/rules.c | 14 -------------- src/solver.c | 20 ++------------------ src/solverdebug.c | 11 ----------- 9 files changed, 78 insertions(+), 109 deletions(-) diff --git a/src/libsolv.ver b/src/libsolv.ver index 84daea6..a992a6b 100644 --- a/src/libsolv.ver +++ b/src/libsolv.ver @@ -82,7 +82,10 @@ SOLV_1.0 { pool_set_languages; pool_setarch; pool_setarchpolicy; + pool_setdebugcallback; pool_setdebuglevel; + pool_setdebugmask; + pool_setloadcallback; pool_setvendorclasses; pool_shrink_rels; pool_shrink_strings; @@ -110,6 +113,8 @@ SOLV_1.0 { repo_add_repodata; repo_add_solv; repo_add_solv_flags; + repo_add_solvable; + repo_add_solvable_block; repo_addid; repo_addid_dep; repo_create; @@ -119,6 +124,7 @@ SOLV_1.0 { repo_fix_supplements; repo_free; repo_freeallrepos; + repo_free_solvable; repo_free_solvable_block; repo_internalize; repo_last_repodata; diff --git a/src/pool.c b/src/pool.c index 66d0e9c..ee65813 100644 --- a/src/pool.c +++ b/src/pool.c @@ -786,12 +786,27 @@ pool_setdebuglevel(Pool *pool, int level) mask |= SAT_DEBUG_PROPAGATE; if (level > 3) mask |= SAT_DEBUG_RULE_CREATION; - if (level > 4) - mask |= SAT_DEBUG_SCHUBI; mask |= pool->debugmask & SAT_DEBUG_TO_STDERR; /* keep bit */ pool->debugmask = mask; } +void pool_setdebugcallback(Pool *pool, void (*debugcallback)(struct _Pool *, void *data, int type, const char *str), void *debugcallbackdata) +{ + pool->debugcallback = debugcallback; + pool->debugcallbackdata = debugcallbackdata; +} + +void pool_setdebugmask(Pool *pool, int mask) +{ + pool->debugmask = mask; +} + +void pool_setloadcallback(Pool *pool, int (*cb)(struct _Pool *, struct _Repodata *, void *), void *loadcbdata) +{ + pool->loadcallback = cb; + pool->loadcallbackdata = loadcbdata; +} + /*************************************************************************/ struct searchfiles { diff --git a/src/pool.h b/src/pool.h index 198a069..2b1a93b 100644 --- a/src/pool.h +++ b/src/pool.h @@ -151,9 +151,8 @@ struct _Pool { #define SAT_DEBUG_POLICY (1<<9) #define SAT_DEBUG_RESULT (1<<10) #define SAT_DEBUG_JOB (1<<11) -#define SAT_DEBUG_SCHUBI (1<<12) -#define SAT_DEBUG_SOLVER (1<<13) -#define SAT_DEBUG_TRANSACTION (1<<14) +#define SAT_DEBUG_SOLVER (1<<12) +#define SAT_DEBUG_TRANSACTION (1<<13) #define SAT_DEBUG_TO_STDERR (1<<30) @@ -198,6 +197,10 @@ extern void pool_setdisttype(Pool *pool, int disttype); extern void pool_setvendorclasses(Pool *pool, const char **vendorclasses); extern void pool_debug(Pool *pool, int type, const char *format, ...) __attribute__((format(printf, 3, 4))); +extern void pool_setdebugcallback(Pool *pool, void (*debugcallback)(struct _Pool *, void *data, int type, const char *str), void *debugcallbackdata); +extern void pool_setdebugmask(Pool *pool, int mask); +extern void pool_setloadcallback(Pool *pool, int (*cb)(struct _Pool *, struct _Repodata *, void *), void *loadcbdata); + extern char *pool_alloctmpspace(Pool *pool, int len); extern void pool_freetmpspace(Pool *pool, const char *space); @@ -300,23 +303,6 @@ static inline Id *pool_whatprovides_ptr(Pool *pool, Id d) return pool->whatprovidesdata + off; } -static inline void pool_setdebugcallback(Pool *pool, void (*debugcallback)(struct _Pool *, void *data, int type, const char *str), void *debugcallbackdata) -{ - pool->debugcallback = debugcallback; - pool->debugcallbackdata = debugcallbackdata; -} - -static inline void pool_setdebugmask(Pool *pool, int mask) -{ - pool->debugmask = mask; -} - -static inline void pool_setloadcallback(Pool *pool, int (*cb)(struct _Pool *, struct _Repodata *, void *), void *loadcbdata) -{ - pool->loadcallback = cb; - pool->loadcallbackdata = loadcbdata; -} - /* search the pool. the following filters are available: * p - search just this solvable * key - search only this key diff --git a/src/problems.c b/src/problems.c index 866ca11..ce75614 100644 --- a/src/problems.c +++ b/src/problems.c @@ -229,8 +229,6 @@ refine_suggestion(Solver *solv, Id *problem, Id sug, Queue *refined, int essenti if (!solv->problems.count) { POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "no more problems!\n"); - IF_POOLDEBUG (SAT_DEBUG_SCHUBI) - solver_printdecisions(solv); break; /* great, no more problems */ } disabledcnt = disabled.count; diff --git a/src/repo.c b/src/repo.c index 6e582ff..55e9fd8 100644 --- a/src/repo.c +++ b/src/repo.c @@ -147,6 +147,50 @@ repo_freeallrepos(Pool *pool, int reuseids) pool_free_solvable_block(pool, 2, pool->nsolvables - 2, reuseids); } +Id repo_add_solvable(Repo *repo) +{ + Id p = pool_add_solvable(repo->pool); + if (!repo->start || repo->start == repo->end) + repo->start = repo->end = p; + /* warning: sidedata must be extended before adapting start/end */ + if (repo->rpmdbid) + repo->rpmdbid = (Id *)repo_sidedata_extend(repo, repo->rpmdbid, sizeof(Id), p, 1); + if (p < repo->start) + repo->start = p; + if (p + 1 > repo->end) + repo->end = p + 1; + repo->nsolvables++; + repo->pool->solvables[p].repo = repo; + return p; +} + +Id repo_add_solvable_block(Repo *repo, int count) +{ + Id p; + Solvable *s; + if (!count) + return 0; + p = pool_add_solvable_block(repo->pool, count); + if (!repo->start || repo->start == repo->end) + repo->start = repo->end = p; + /* warning: sidedata must be extended before adapting start/end */ + if (repo->rpmdbid) + repo->rpmdbid = (Id *)repo_sidedata_extend(repo, repo->rpmdbid, sizeof(Id), p, count); + if (p < repo->start) + repo->start = p; + if (p + count > repo->end) + repo->end = p + count; + repo->nsolvables += count; + for (s = repo->pool->solvables + p; count--; s++) + s->repo = repo; + return p; +} + +void repo_free_solvable(Repo *repo, Id p, int reuseids) +{ + repo_free_solvable_block(repo, p, 1, reuseids); +} + void repo_free_solvable_block(Repo *repo, Id start, int count, int reuseids) { Solvable *s; diff --git a/src/repo.h b/src/repo.h index b0f5957..fbec7bf 100644 --- a/src/repo.h +++ b/src/repo.h @@ -48,6 +48,9 @@ extern Repo *repo_create(Pool *pool, const char *name); extern void repo_free(Repo *repo, int reuseids); extern void repo_empty(Repo *repo, int reuseids); extern void repo_freeallrepos(Pool *pool, int reuseids); +extern Id repo_add_solvable(Repo *repo); +extern Id repo_add_solvable_block(Repo *repo, int count); +extern void repo_free_solvable(Repo *repo, Id p, int reuseids); extern void repo_free_solvable_block(Repo *repo, Id start, int count, int reuseids); extern void *repo_sidedata_create(Repo *repo, size_t size); extern void *repo_sidedata_extend(Repo *repo, void *b, size_t size, Id p, int count); @@ -63,48 +66,6 @@ static inline const char *repo_name(const Repo *repo) return repo->name; } -static inline Id repo_add_solvable(Repo *repo) -{ - extern Id pool_add_solvable(Pool *pool); - Id p = pool_add_solvable(repo->pool); - if (!repo->start || repo->start == repo->end) - repo->start = repo->end = p; - /* warning: sidedata must be extended before adapting start/end */ - if (repo->rpmdbid) - repo->rpmdbid = (Id *)repo_sidedata_extend(repo, repo->rpmdbid, sizeof(Id), p, 1); - if (p < repo->start) - repo->start = p; - if (p + 1 > repo->end) - repo->end = p + 1; - repo->nsolvables++; - repo->pool->solvables[p].repo = repo; - return p; -} - -static inline Id repo_add_solvable_block(Repo *repo, int count) -{ - extern Id pool_add_solvable_block(Pool *pool, int count); - Id p; - Solvable *s; - if (!count) - return 0; - p = pool_add_solvable_block(repo->pool, count); - if (!repo->start || repo->start == repo->end) - repo->start = repo->end = p; - /* warning: sidedata must be extended before adapting start/end */ - if (repo->rpmdbid) - repo->rpmdbid = (Id *)repo_sidedata_extend(repo, repo->rpmdbid, sizeof(Id), p, count); - if (p < repo->start) - repo->start = p; - if (p + count > repo->end) - repo->end = p + count; - repo->nsolvables += count; - for (s = repo->pool->solvables + p; count--; s++) - s->repo = repo; - return p; -} - - #define FOR_REPO_SOLVABLES(r, p, s) \ for (p = (r)->start, s = (r)->pool->solvables + p; p < (r)->end; p++, s = (r)->pool->solvables + p) \ if (s->repo == (r)) diff --git a/src/rules.c b/src/rules.c index 344c4e8..db39717 100644 --- a/src/rules.c +++ b/src/rules.c @@ -143,8 +143,6 @@ solver_unifyrules(Solver *solv) if (solv->nrules <= 2) /* nothing to unify */ return; - POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- unifyrules -----\n"); - /* sort rules first */ sat_sort(solv->rules + 1, solv->nrules - 1, sizeof(Rule), unifyrules_sortcmp, solv->pool); @@ -194,7 +192,6 @@ solver_unifyrules(Solver *solv) POOL_DEBUG(SAT_DEBUG_STATS, " binary: %d\n", binr); POOL_DEBUG(SAT_DEBUG_STATS, " normal: %d, %d literals\n", solv->nrules - 1 - binr, lits); } - POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- unifyrules end -----\n"); } #if 0 @@ -479,8 +476,6 @@ solver_addrpmrulesforsolvable(Solver *solv, Solvable *s, Map *m) Id *dp; /* ptr to 'whatprovides' */ Id n; /* Id for current solvable 's' */ - POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforsolvable -----\n"); - queue_init_buffer(&workq, workqbuf, sizeof(workqbuf)/sizeof(*workqbuf)); queue_push(&workq, s - pool->solvables); /* push solvable Id to work queue */ @@ -750,7 +745,6 @@ solver_addrpmrulesforsolvable(Solver *solv, Solvable *s, Map *m) } } queue_free(&workq); - POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforsolvable end -----\n"); } @@ -769,7 +763,6 @@ solver_addrpmrulesforweak(Solver *solv, Map *m) Id sup, *supp; int i, n; - POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforweak -----\n"); /* foreach solvable in pool */ for (i = n = 1; n < pool->nsolvables; i++, n++) { @@ -806,7 +799,6 @@ solver_addrpmrulesforweak(Solver *solv, Map *m) solver_addrpmrulesforsolvable(solv, s, m); n = 0; /* check all solvables again because we added solvables to m */ } - POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforweak end -----\n"); } @@ -828,8 +820,6 @@ solver_addrpmrulesforupdaters(Solver *solv, Solvable *s, Map *m, int allow_all) Queue qs; Id qsbuf[64]; - POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforupdaters -----\n"); - queue_init_buffer(&qs, qsbuf, sizeof(qsbuf)/sizeof(*qsbuf)); /* find update candidates for 's' */ policy_findupdatepackages(solv, s, &qs, allow_all); @@ -841,8 +831,6 @@ solver_addrpmrulesforupdaters(Solver *solv, Solvable *s, Map *m, int allow_all) if (!MAPTST(m, qs.elements[i])) solver_addrpmrulesforsolvable(solv, pool->solvables + qs.elements[i], m); queue_free(&qs); - - POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforupdaters -----\n"); } @@ -926,7 +914,6 @@ solver_addupdaterule(Solver *solv, Solvable *s, int allow_all) Queue qs; Id qsbuf[64]; - POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addupdaterule -----\n"); queue_init_buffer(&qs, qsbuf, sizeof(qsbuf)/sizeof(*qsbuf)); p = s - pool->solvables; /* find update candidates for 's' */ @@ -976,7 +963,6 @@ solver_addupdaterule(Solver *solv, Solvable *s, int allow_all) d = qs.count ? pool_queuetowhatprovides(pool, &qs) : 0; queue_free(&qs); solver_addrule(solv, p, d); /* allow update of s */ - POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addupdaterule end -----\n"); } static inline void diff --git a/src/solver.c b/src/solver.c index 2105879..2d70850 100644 --- a/src/solver.c +++ b/src/solver.c @@ -114,8 +114,6 @@ makeruledecisions(Solver *solv) int decisionstart; int record_proof = 1; - POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- makeruledecisions ; size decisionq: %d -----\n",solv->decisionq.count); - /* The system solvable is always installed first */ assert(solv->decisionq.count == 0); queue_push(&solv->decisionq, SYSTEMSOLVABLE); @@ -359,8 +357,6 @@ makeruledecisions(Solver *solv) if (v < 0) solver_reenablepolicyrules(solv, -(v + 1)); } - - POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- makeruledecisions end; size decisionq: %d -----\n",solv->decisionq.count); } @@ -1379,9 +1375,6 @@ solver_run_sat(Solver *solv, int disablerules, int doweak) POOL_DEBUG(SAT_DEBUG_SOLVER, "initial decisions: %d\n", solv->decisionq.count); - IF_POOLDEBUG (SAT_DEBUG_SCHUBI) - solver_printdecisions(solv); - /* start SAT algorithm */ level = 1; systemlevel = level + 1; @@ -2136,7 +2129,6 @@ removedisabledconflicts(Solver *solv, Queue *removed) Rule *r; Id *decisionmap = solv->decisionmap; - POOL_DEBUG(SAT_DEBUG_SCHUBI, "removedisabledconflicts\n"); queue_empty(removed); for (i = 0; i < solv->decisionq.count; i++) { @@ -2156,7 +2148,7 @@ removedisabledconflicts(Solver *solv, Queue *removed) if (r->d < 0 && decisionmap[-p]) { /* rule is now disabled, remove from decisionmap */ - POOL_DEBUG(SAT_DEBUG_SCHUBI, "removing conflict for package %s[%d]\n", pool_solvid2str(pool, -p), -p); + POOL_DEBUG(SAT_DEBUG_SOLVER, "removing conflict for package %s[%d]\n", pool_solvid2str(pool, -p), -p); queue_push(removed, -p); queue_push(removed, decisionmap[-p]); decisionmap[-p] = 0; @@ -2219,7 +2211,7 @@ removedisabledconflicts(Solver *solv, Queue *removed) } if (new) { - POOL_DEBUG(SAT_DEBUG_SCHUBI, "re-conflicting package %s[%d]\n", pool_solvid2str(pool, -new), -new); + POOL_DEBUG(SAT_DEBUG_SOLVER, "re-conflicting package %s[%d]\n", pool_solvid2str(pool, -new), -new); decisionmap[-new] = -1; new = 0; n = 0; /* redo all rules */ @@ -2602,11 +2594,9 @@ solver_solve(Solver *solv, Queue *job) } oldnrules = solv->nrules; - POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** create rpm rules for installed solvables ***\n"); FOR_REPO_SOLVABLES(installed, p, s) solver_addrpmrulesforsolvable(solv, s, &addedmap); POOL_DEBUG(SAT_DEBUG_STATS, "added %d rpm rules for installed solvables\n", solv->nrules - oldnrules); - POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** create rpm rules for updaters of installed solvables ***\n"); oldnrules = solv->nrules; FOR_REPO_SOLVABLES(installed, p, s) solver_addrpmrulesforupdaters(solv, s, &addedmap, 1); @@ -2618,7 +2608,6 @@ solver_solve(Solver *solv, Queue *job) * (to be installed or removed) */ - POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** create rpm rules for packages involved with a job ***\n"); oldnrules = solv->nrules; for (i = 0; i < job->count; i += 2) { @@ -2654,7 +2643,6 @@ solver_solve(Solver *solv, Queue *job) /* * add rules for suggests, enhances */ - POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** create rpm rules for suggested/enhanced packages ***\n"); oldnrules = solv->nrules; solver_addrpmrulesforweak(solv, &addedmap); POOL_DEBUG(SAT_DEBUG_STATS, "added %d rpm rules because of weak dependencies\n", solv->nrules - oldnrules); @@ -2703,7 +2691,6 @@ solver_solve(Solver *solv, Queue *job) * best effort mode */ - POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** Add feature rules ***\n"); solv->featurerules = solv->nrules; /* mark start of feature rules */ if (installed) { @@ -2729,7 +2716,6 @@ solver_solve(Solver *solv, Queue *job) * except that downgrades/archchanges/vendorchanges are not allowed */ - POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** Add update rules ***\n"); solv->updaterules = solv->nrules; if (installed) @@ -2793,8 +2779,6 @@ solver_solve(Solver *solv, Queue *job) * now add all job rules */ - POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** Add JOB rules ***\n"); - solv->jobrules = solv->nrules; for (i = 0; i < job->count; i += 2) { diff --git a/src/solverdebug.c b/src/solverdebug.c index 94f657e..7cc737e 100644 --- a/src/solverdebug.c +++ b/src/solverdebug.c @@ -301,17 +301,6 @@ solver_printdecisions(Solver *solv) Solvable *s; Queue iq; - IF_POOLDEBUG (SAT_DEBUG_SCHUBI) - { - POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- Decisions -----\n"); - for (i = 0; i < solv->decisionq.count; i++) - { - p = solv->decisionq.elements[i]; - solver_printruleelement(solv, SAT_DEBUG_SCHUBI, 0, p); - } - POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- Decisions end -----\n"); - } - POOL_DEBUG(SAT_DEBUG_RESULT, "\n"); POOL_DEBUG(SAT_DEBUG_RESULT, "transaction:\n"); -- 2.34.1