Add debug prints for debugging stochastic bisection. Signed-off-by: Jan Kara <jack@xxxxxxx> --- bisect.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/bisect.c b/bisect.c index 6ed740106795..4d2ba5dbd77e 100644 --- a/bisect.c +++ b/bisect.c @@ -620,6 +620,21 @@ static int sw_rev_bmp_cmp(const void *data, const struct hashmap_entry *ap, return 0; } +static void show_cluster(struct sw_rev_bmp_hash_entry *entry) +{ + int i; + + if (!DEBUG_BISECT) + return; + + fprintf(stderr, "cluster prob %"FPNUM_FMT" members %u reaching revs ", + entry->cluster_p_bad, entry->count); + for (i = 0; i < ptest_revs.nr; i++) + if (sw_rev_bmp_test(entry->commit_weight, i)) + fprintf(stderr, "%.8s ", oid_to_hex(ptest_revs.oid + i)); + fprintf(stderr, "\n"); +} + /* * Compute for each commit a probability it is the bad one given tests * performed so far. @@ -697,6 +712,7 @@ static struct commit_list *compute_commit_weights(struct commit_list *list) hashmap_for_each_entry(&reach_map, &reach_iter, found_entry, entry) { found_entry->cluster_p_bad = fp_div(found_entry->cluster_p_bad, cluster_prob_sum); + show_cluster(found_entry); } /* Uniformly distribute the probability among all nodes of a cluster */ @@ -1111,6 +1127,30 @@ static struct commit_list *managed_skipped(struct commit_list *list, return skip_away(list, count); } +static void print_object(struct object *obj) +{ + unsigned flags = obj->flags; + + fprintf(stderr, "%c%c%c%c ", + (flags & TREESAME) ? ' ' : 'T', + (flags & UNINTERESTING) ? 'U' : ' ', + (flags & SEEN) ? 'S' : ' ', + (flags & COUNTED) ? 'C' : ' '); + fprintf(stderr, "%.8s\n", oid_to_hex(&obj->oid)); +} + +static void show_object_array(const char *str, struct object_array *array) +{ + int i; + + if (!DEBUG_BISECT) + return; + + fprintf(stderr, "%s\n", str); + for (i = 0; i < array->nr; i++) + print_object(array->objects[i].item); +} + static void bisect_rev_setup(struct repository *r, struct rev_info *revs, const char *prefix, const char *bad_format, const char *good_format, @@ -1139,12 +1179,16 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs, setup_revisions(rev_argv.nr, rev_argv.v, revs, NULL); /* XXX leak rev_argv, as "revs" may still be pointing to it */ + show_list("setup_revisions commits", 0, 0, revs->commits); + show_object_array("setup_revisions pending", &revs->pending); } static void bisect_common(struct rev_info *revs) { if (prepare_revision_walk(revs)) die("revision walk setup failed"); + show_list("bisect_common commits", 0, 0, revs->commits); + show_object_array("bisect_common pending", &revs->pending); if (revs->tree_objects) mark_edges_uninteresting(revs, NULL, 0); } @@ -1462,6 +1506,12 @@ void read_bisect_terms(const char **read_bad, const char **read_good) fclose(fp); } +static int debug_print_oid(const struct object_id *oid, void *data) +{ + fprintf(stderr, "%s\n", oid_to_hex(oid)); + return 0; +} + /* * We use the convention that return BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND (-10) means * the bisection process finished successfully. @@ -1493,6 +1543,12 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix) if (read_bisect_refs()) die(_("reading bisect refs failed")); read_bisect_confidences(); + if (DEBUG_BISECT) { + debug_bisect("good revs:\n"); + oid_array_for_each(&good_revs, debug_print_oid, NULL); + debug_bisect("p-test revs:\n"); + oid_array_for_each(&ptest_revs, debug_print_oid, NULL); + } if (file_exists(git_path_bisect_first_parent())) bisect_flags |= FIND_BISECTION_FIRST_PARENT_ONLY; -- 2.26.2