diff options
author | Jason Evans <jasone@canonware.com> | 2016-12-23 19:15:44 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2016-12-23 19:15:44 (GMT) |
commit | eab3b180e59d6b23fee5fd2165f96402e7341cba (patch) | |
tree | 3b5c34209fa6aae6cdb55743b93f0c00a7cb519a | |
parent | bacb6afc6c5a83c5bf2e5e04a6db99600046e971 (diff) | |
download | jemalloc-eab3b180e59d6b23fee5fd2165f96402e7341cba.zip jemalloc-eab3b180e59d6b23fee5fd2165f96402e7341cba.tar.gz jemalloc-eab3b180e59d6b23fee5fd2165f96402e7341cba.tar.bz2 |
Fix JSON-mode output for !config_stats and/or !config_prof cases.
These bugs were introduced by 0ba5b9b6189e16a983d8922d8c5cb6ab421906e8
(Add "J" (JSON) support to malloc_stats_print().), which was backported
as b599b32280e1142856b0b96293a71e1684b1ccfb (with the same bugs except
the inapplicable "metatata" misspelling) and first released in 4.3.0.
-rw-r--r-- | src/stats.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/stats.c b/src/stats.c index 3072b2a..e150a27 100644 --- a/src/stats.c +++ b/src/stats.c @@ -407,7 +407,7 @@ stats_arena_print(void (*write_cb)(void *, const char *), void *cbopaque, CTL_M2_GET("stats.arenas.0.metadata", i, &metadata, size_t); if (json) { malloc_cprintf(write_cb, cbopaque, - "\t\t\t\t\"metatata\": %zu%s\n", metadata, (bins || large) ? + "\t\t\t\t\"metadata\": %zu%s\n", metadata, (bins || large) ? "," : ""); } else { malloc_cprintf(write_cb, cbopaque, @@ -422,7 +422,7 @@ stats_arena_print(void (*write_cb)(void *, const char *), void *cbopaque, static void stats_general_print(void (*write_cb)(void *, const char *), void *cbopaque, - bool json, bool merged, bool unmerged) + bool json, bool more) { const char *cpv; bool bv; @@ -717,11 +717,11 @@ stats_general_print(void (*write_cb)(void *, const char *), void *cbopaque, "\t\t\t]\n"); malloc_cprintf(write_cb, cbopaque, - "\t\t},\n"); + "\t\t}%s\n", (config_prof || more) ? "," : ""); } /* prof. */ - if (json) { + if (config_prof && json) { malloc_cprintf(write_cb, cbopaque, "\t\t\"prof\": {\n"); @@ -747,8 +747,7 @@ stats_general_print(void (*write_cb)(void *, const char *), void *cbopaque, "\t\t\t\"lg_sample\": %zd\n", ssv); malloc_cprintf(write_cb, cbopaque, - "\t\t}%s\n", (config_stats || merged || unmerged) ? "," : - ""); + "\t\t}%s\n", more ? "," : ""); } } @@ -872,8 +871,8 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque, size_t u64sz; bool json = false; bool general = true; - bool merged = true; - bool unmerged = true; + bool merged = config_stats; + bool unmerged = config_stats; bool bins = true; bool large = true; @@ -936,8 +935,10 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque, "___ Begin jemalloc statistics ___\n"); } - if (general) - stats_general_print(write_cb, cbopaque, json, merged, unmerged); + if (general) { + bool more = (merged || unmerged); + stats_general_print(write_cb, cbopaque, json, more); + } if (config_stats) { stats_print_helper(write_cb, cbopaque, json, merged, unmerged, bins, large); |