addr_location__init(&al); /* * each evsel will have 10 samples - 5 common and 5 distinct. * However the second evsel also has a collapsed entry for * "bash [libc] malloc" so total 9 entries will be in the tree.
*/
evlist__for_each_entry(evlist, evsel) { struct hists *hists = evsel__hists(evsel);
addr_location__exit(&al); return 0;
out:
addr_location__exit(&al);
pr_debug("Not enough memory for adding a hist entry\n"); return -1;
}
staticvoid put_fake_samples(void)
{
size_t i, j;
for (i = 0; i < ARRAY_SIZE(fake_common_samples); i++)
map__put(fake_common_samples[i].map); for (i = 0; i < ARRAY_SIZE(fake_samples); i++) { for (j = 0; j < ARRAY_SIZE(fake_samples[0]); j++)
map__put(fake_samples[i][j].map);
}
}
staticint find_sample(struct sample *samples, size_t nr_samples, struct thread *t, struct map *m, struct symbol *s)
{ while (nr_samples--) { if (RC_CHK_EQUAL(samples->thread, t) &&
RC_CHK_EQUAL(samples->map, m) &&
samples->sym == s) return 1;
samples++;
} return 0;
}
/* * Only entries from fake_common_samples should have a pair.
*/ if (hists__has(hists, need_collapse))
root = &hists->entries_collapsed; else
root = hists->entries_in;
node = rb_first_cached(root); while (node) { struct hist_entry *he;
he = rb_entry(node, struct hist_entry, rb_node_in);
if (hist_entry__has_pairs(he)) { if (find_sample(fake_common_samples,
ARRAY_SIZE(fake_common_samples),
he->thread, he->ms.map, he->ms.sym)) {
count++;
} else {
pr_debug("Can't find the matched entry\n"); return -1;
}
}
node = rb_next(node);
}
if (count != ARRAY_SIZE(fake_common_samples)) {
pr_debug("Invalid count for matched entries: %zd of %zd\n",
count, ARRAY_SIZE(fake_common_samples)); return -1;
}
/* * Leader hists (idx = 0) will have dummy entries from other, * and some entries will have no pair. However every entry * in other hists should have (dummy) pair.
*/ if (hists__has(hists, need_collapse))
root = &hists->entries_collapsed; else
root = hists->entries_in;
node = rb_first_cached(root); while (node) { struct hist_entry *he;
he = rb_entry(node, struct hist_entry, rb_node_in);
if (hist_entry__has_pairs(he)) { if (!find_sample(fake_common_samples,
ARRAY_SIZE(fake_common_samples),
he->thread, he->ms.map, he->ms.sym) &&
!find_sample(fake_samples[idx],
ARRAY_SIZE(fake_samples[idx]),
he->thread, he->ms.map, he->ms.sym)) {
count_dummy++;
}
count_pair++;
} elseif (idx) {
pr_debug("A entry from the other hists should have pair\n"); return -1;
}
count++;
node = rb_next(node);
}
/* * Note that we have a entry collapsed in the other (idx = 1) hists.
*/ if (idx == 0) { if (count_dummy != ARRAY_SIZE(fake_samples[1]) - 1) {
pr_debug("Invalid count of dummy entries: %zd of %zd\n",
count_dummy, ARRAY_SIZE(fake_samples[1]) - 1); return -1;
} if (count != count_pair + ARRAY_SIZE(fake_samples[0])) {
pr_debug("Invalid count of total leader entries: %zd of %zd\n",
count, count_pair + ARRAY_SIZE(fake_samples[0])); return -1;
}
} else { if (count != count_pair) {
pr_debug("Invalid count of total other entries: %zd of %zd\n",
count, count_pair); return -1;
} if (count_dummy > 0) {
pr_debug("Other hists should not have dummy entries: %zd\n",
count_dummy); return -1;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.