Fix ctl regression.

Fix ctl to correctly compute the number of children at each level of the
ctl tree.
This commit is contained in:
Jason Evans 2012-04-23 19:31:45 -07:00
parent 598779aa55
commit 65f343a632
2 changed files with 32 additions and 30 deletions

View File

@ -17,17 +17,17 @@ struct ctl_node_s {
struct ctl_named_node_s { struct ctl_named_node_s {
struct ctl_node_s node; struct ctl_node_s node;
const char *name; const char *name;
/* If (nchildren == 0), this is a terminal node. */ /* If (nchildren == 0), this is a terminal node. */
unsigned nchildren; unsigned nchildren;
const ctl_node_t *children; const ctl_node_t *children;
int (*ctl)(const size_t *, size_t, void *, size_t *, void *, int (*ctl)(const size_t *, size_t, void *, size_t *,
size_t); void *, size_t);
}; };
struct ctl_indexed_node_s { struct ctl_indexed_node_s {
struct ctl_node_s node; struct ctl_node_s node;
const ctl_named_node_t *(*index)(const size_t *, size_t, size_t); const ctl_named_node_t *(*index)(const size_t *, size_t, size_t);
}; };
struct ctl_arena_stats_s { struct ctl_arena_stats_s {

View File

@ -176,8 +176,10 @@ CTL_PROTO(stats_mapped)
#define CTL_MAX_DEPTH 6 #define CTL_MAX_DEPTH 6
#define NAME(n) {true}, n #define NAME(n) {true}, n
#define CHILD(c) \ #define CHILD(t, c) \
sizeof(c##_node) / sizeof(ctl_node_t), (ctl_node_t *)c##_node, NULL sizeof(c##_node) / sizeof(ctl_##t##_node_t), \
(ctl_node_t *)c##_node, \
NULL
#define CTL(c) 0, NULL, c##_ctl #define CTL(c) 0, NULL, c##_ctl
/* /*
@ -197,7 +199,7 @@ static const ctl_named_node_t thread_node[] = {
{NAME("allocatedp"), CTL(thread_allocatedp)}, {NAME("allocatedp"), CTL(thread_allocatedp)},
{NAME("deallocated"), CTL(thread_deallocated)}, {NAME("deallocated"), CTL(thread_deallocated)},
{NAME("deallocatedp"), CTL(thread_deallocatedp)}, {NAME("deallocatedp"), CTL(thread_deallocatedp)},
{NAME("tcache"), CHILD(tcache)} {NAME("tcache"), CHILD(named, tcache)}
}; };
static const ctl_named_node_t config_node[] = { static const ctl_named_node_t config_node[] = {
@ -249,7 +251,7 @@ static const ctl_named_node_t arenas_bin_i_node[] = {
{NAME("run_size"), CTL(arenas_bin_i_run_size)} {NAME("run_size"), CTL(arenas_bin_i_run_size)}
}; };
static const ctl_named_node_t super_arenas_bin_i_node[] = { static const ctl_named_node_t super_arenas_bin_i_node[] = {
{NAME(""), CHILD(arenas_bin_i)} {NAME(""), CHILD(named, arenas_bin_i)}
}; };
static const ctl_indexed_node_t arenas_bin_node[] = { static const ctl_indexed_node_t arenas_bin_node[] = {
@ -260,7 +262,7 @@ static const ctl_named_node_t arenas_lrun_i_node[] = {
{NAME("size"), CTL(arenas_lrun_i_size)} {NAME("size"), CTL(arenas_lrun_i_size)}
}; };
static const ctl_named_node_t super_arenas_lrun_i_node[] = { static const ctl_named_node_t super_arenas_lrun_i_node[] = {
{NAME(""), CHILD(arenas_lrun_i)} {NAME(""), CHILD(named, arenas_lrun_i)}
}; };
static const ctl_indexed_node_t arenas_lrun_node[] = { static const ctl_indexed_node_t arenas_lrun_node[] = {
@ -275,9 +277,9 @@ static const ctl_named_node_t arenas_node[] = {
{NAME("tcache_max"), CTL(arenas_tcache_max)}, {NAME("tcache_max"), CTL(arenas_tcache_max)},
{NAME("nbins"), CTL(arenas_nbins)}, {NAME("nbins"), CTL(arenas_nbins)},
{NAME("nhbins"), CTL(arenas_nhbins)}, {NAME("nhbins"), CTL(arenas_nhbins)},
{NAME("bin"), CHILD(arenas_bin)}, {NAME("bin"), CHILD(indexed, arenas_bin)},
{NAME("nlruns"), CTL(arenas_nlruns)}, {NAME("nlruns"), CTL(arenas_nlruns)},
{NAME("lrun"), CHILD(arenas_lrun)}, {NAME("lrun"), CHILD(indexed, arenas_lrun)},
{NAME("purge"), CTL(arenas_purge)} {NAME("purge"), CTL(arenas_purge)}
}; };
@ -325,7 +327,7 @@ static const ctl_named_node_t stats_arenas_i_bins_j_node[] = {
{NAME("curruns"), CTL(stats_arenas_i_bins_j_curruns)} {NAME("curruns"), CTL(stats_arenas_i_bins_j_curruns)}
}; };
static const ctl_named_node_t super_stats_arenas_i_bins_j_node[] = { static const ctl_named_node_t super_stats_arenas_i_bins_j_node[] = {
{NAME(""), CHILD(stats_arenas_i_bins_j)} {NAME(""), CHILD(named, stats_arenas_i_bins_j)}
}; };
static const ctl_indexed_node_t stats_arenas_i_bins_node[] = { static const ctl_indexed_node_t stats_arenas_i_bins_node[] = {
@ -339,7 +341,7 @@ static const ctl_named_node_t stats_arenas_i_lruns_j_node[] = {
{NAME("curruns"), CTL(stats_arenas_i_lruns_j_curruns)} {NAME("curruns"), CTL(stats_arenas_i_lruns_j_curruns)}
}; };
static const ctl_named_node_t super_stats_arenas_i_lruns_j_node[] = { static const ctl_named_node_t super_stats_arenas_i_lruns_j_node[] = {
{NAME(""), CHILD(stats_arenas_i_lruns_j)} {NAME(""), CHILD(named, stats_arenas_i_lruns_j)}
}; };
static const ctl_indexed_node_t stats_arenas_i_lruns_node[] = { static const ctl_indexed_node_t stats_arenas_i_lruns_node[] = {
@ -354,13 +356,13 @@ static const ctl_named_node_t stats_arenas_i_node[] = {
{NAME("npurge"), CTL(stats_arenas_i_npurge)}, {NAME("npurge"), CTL(stats_arenas_i_npurge)},
{NAME("nmadvise"), CTL(stats_arenas_i_nmadvise)}, {NAME("nmadvise"), CTL(stats_arenas_i_nmadvise)},
{NAME("purged"), CTL(stats_arenas_i_purged)}, {NAME("purged"), CTL(stats_arenas_i_purged)},
{NAME("small"), CHILD(stats_arenas_i_small)}, {NAME("small"), CHILD(named, stats_arenas_i_small)},
{NAME("large"), CHILD(stats_arenas_i_large)}, {NAME("large"), CHILD(named, stats_arenas_i_large)},
{NAME("bins"), CHILD(stats_arenas_i_bins)}, {NAME("bins"), CHILD(named, stats_arenas_i_bins)},
{NAME("lruns"), CHILD(stats_arenas_i_lruns)} {NAME("lruns"), CHILD(named, stats_arenas_i_lruns)}
}; };
static const ctl_named_node_t super_stats_arenas_i_node[] = { static const ctl_named_node_t super_stats_arenas_i_node[] = {
{NAME(""), CHILD(stats_arenas_i)} {NAME(""), CHILD(named, stats_arenas_i)}
}; };
static const ctl_indexed_node_t stats_arenas_node[] = { static const ctl_indexed_node_t stats_arenas_node[] = {
@ -372,23 +374,23 @@ static const ctl_named_node_t stats_node[] = {
{NAME("allocated"), CTL(stats_allocated)}, {NAME("allocated"), CTL(stats_allocated)},
{NAME("active"), CTL(stats_active)}, {NAME("active"), CTL(stats_active)},
{NAME("mapped"), CTL(stats_mapped)}, {NAME("mapped"), CTL(stats_mapped)},
{NAME("chunks"), CHILD(stats_chunks)}, {NAME("chunks"), CHILD(named, stats_chunks)},
{NAME("huge"), CHILD(stats_huge)}, {NAME("huge"), CHILD(named, stats_huge)},
{NAME("arenas"), CHILD(stats_arenas)} {NAME("arenas"), CHILD(indexed, stats_arenas)}
}; };
static const ctl_named_node_t root_node[] = { static const ctl_named_node_t root_node[] = {
{NAME("version"), CTL(version)}, {NAME("version"), CTL(version)},
{NAME("epoch"), CTL(epoch)}, {NAME("epoch"), CTL(epoch)},
{NAME("thread"), CHILD(thread)}, {NAME("thread"), CHILD(named, thread)},
{NAME("config"), CHILD(config)}, {NAME("config"), CHILD(named, config)},
{NAME("opt"), CHILD(opt)}, {NAME("opt"), CHILD(named, opt)},
{NAME("arenas"), CHILD(arenas)}, {NAME("arenas"), CHILD(named, arenas)},
{NAME("prof"), CHILD(prof)}, {NAME("prof"), CHILD(named, prof)},
{NAME("stats"), CHILD(stats)} {NAME("stats"), CHILD(named, stats)}
}; };
static const ctl_named_node_t super_root_node[] = { static const ctl_named_node_t super_root_node[] = {
{NAME(""), CHILD(root)} {NAME(""), CHILD(named, root)}
}; };
#undef NAME #undef NAME