Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934316AbcCNMQ5 (ORCPT ); Mon, 14 Mar 2016 08:16:57 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:32925 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934267AbcCNMQY (ORCPT ); Mon, 14 Mar 2016 08:16:24 -0400 From: Taeung Song To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Namhyung Kim , Ingo Molnar , Peter Zijlstra , Taeung Song Subject: [PATCH v2 3/5] perf config: Prepare all default configs Date: Mon, 14 Mar 2016 21:16:07 +0900 Message-Id: <1457957769-3700-4-git-send-email-treeze.taeung@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457957769-3700-1-git-send-email-treeze.taeung@gmail.com> References: <1457957769-3700-1-git-send-email-treeze.taeung@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7407 Lines: 207 To precisely manage configs, prepare all default perf's configs that contain default section name, variable name, value and correct type, not string type. In the near future, this will be used when checking type of config variable or showing all configs with default values, etc. Cc: Namhyung Kim Cc: Jiri Olsa Signed-off-by: Taeung Song --- tools/perf/util/config.c | 54 ++++++++++++++++++++++++++--- tools/perf/util/config.h | 89 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 137 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index b9660e4..0b9ba51 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -29,6 +29,52 @@ static int config_file_eof; const char *config_exclusive_filename; +struct perf_config_item default_configs[] = { + CONF_STR_VAR(COLORS_TOP, "colors", "top", "red, default"), + CONF_STR_VAR(COLORS_MEDIUM, "colors", "medium", "green, default"), + CONF_STR_VAR(COLORS_NORMAL, "colors", "normal", "lightgray, default"), + CONF_STR_VAR(COLORS_SELECTED, "colors", "selected", "white, lightgray"), + CONF_STR_VAR(COLORS_JUMP_ARROWS, "colors", "jump_arrows", "blue, default"), + CONF_STR_VAR(COLORS_ADDR, "colors", "addr", "magenta, default"), + CONF_STR_VAR(COLORS_ROOT, "colors", "root", "white, blue"), + CONF_BOOL_VAR(TUI_REPORT, "tui", "report", true), + CONF_BOOL_VAR(TUI_ANNOTATE, "tui", "annotate", true), + CONF_BOOL_VAR(TUI_TOP, "tui", "top", true), + CONF_STR_VAR(BUILDID_DIR, "buildid", "dir", "~/.debug"), + CONF_BOOL_VAR(ANNOTATE_HIDE_SRC_CODE, "annotate", "hide_src_code", false), + CONF_BOOL_VAR(ANNOTATE_USE_OFFSET, "annotate", "use_offset", true), + CONF_BOOL_VAR(ANNOTATE_JUMP_ARROWS, "annotate", "jump_arrows", true), + CONF_BOOL_VAR(ANNOTATE_SHOW_NR_JUMPS, "annotate", "show_nr_jumps", false), + CONF_BOOL_VAR(ANNOTATE_SHOW_LINENR, "annotate", "show_linenr", false), + CONF_BOOL_VAR(ANNOTATE_SHOW_TOTAL_PERIOD, "annotate", "show_total_period", false), + CONF_BOOL_VAR(GTK_ANNOTATE, "gtk", "annotate", false), + CONF_BOOL_VAR(GTK_REPORT, "gtk", "report", false), + CONF_BOOL_VAR(GTK_TOP, "gtk", "top", false), + CONF_BOOL_VAR(PAGER_CMD, "pager", "cmd", true), + CONF_BOOL_VAR(PAGER_REPORT, "pager", "report", true), + CONF_BOOL_VAR(PAGER_ANNOTATE, "pager", "annotate", true), + CONF_BOOL_VAR(PAGER_TOP, "pager", "top", true), + CONF_BOOL_VAR(PAGER_DIFF, "pager", "diff", true), + CONF_STR_VAR(HELP_FORMAT, "help", "format", "man"), + CONF_INT_VAR(HELP_AUTOCORRECT, "help", "autocorrect", 0), + CONF_STR_VAR(HIST_PERCENTAGE, "hist", "percentage", "absolute"), + CONF_BOOL_VAR(UI_SHOW_HEADERS, "ui", "show-headers", true), + CONF_STR_VAR(CALL_GRAPH_RECORD_MODE, "call-graph", "record-mode", "fp"), + CONF_LONG_VAR(CALL_GRAPH_DUMP_SIZE, "call-graph", "dump-size", 8192), + CONF_STR_VAR(CALL_GRAPH_PRINT_TYPE, "call-graph", "print-type", "graph"), + CONF_STR_VAR(CALL_GRAPH_ORDER, "call-graph", "order", "callee"), + CONF_STR_VAR(CALL_GRAPH_SORT_KEY, "call-graph", "sort-key", "function"), + CONF_DOUBLE_VAR(CALL_GRAPH_THRESHOLD, "call-graph", "threshold", 0.5), + CONF_LONG_VAR(CALL_GRAPH_PRINT_LIMIT, "call-graph", "print-limit", 0), + CONF_BOOL_VAR(REPORT_GROUP, "report", "group", true), + CONF_BOOL_VAR(REPORT_CHILDREN, "report", "children", true), + CONF_FLOAT_VAR(REPORT_PERCENT_LIMIT, "report", "percent-limit", 0), + CONF_U64_VAR(REPORT_QUEUE_SIZE, "report", "queue-size", 0), + CONF_BOOL_VAR(TOP_CHILDREN, "top", "children", true), + CONF_STR_VAR(MAN_VIEWER, "man", "viewer", "man"), + CONF_STR_VAR(KMEM_DEFAULT, "kmem", "default", "slab"), +}; + static int get_next_char(void) { int c; @@ -587,8 +633,8 @@ static int collect_config(const char *var, const char *value, if (!config) { config = add_config(config_list, section, name); if (!config) { - free(config->section); - free(config->name); + free((char *)config->section); + free((char *)config->name); ret = -1; goto out_free; } @@ -620,8 +666,8 @@ void perf_config_set__delete(struct perf_config_set *perf_configs) list_for_each_entry_safe(pos, item, &perf_configs->config_list, list) { list_del(&pos->list); - free(pos->section); - free(pos->name); + free((char *)pos->section); + free((char *)pos->name); free(pos->value); free(pos); } diff --git a/tools/perf/util/config.h b/tools/perf/util/config.h index 44c226f..3c30576 100644 --- a/tools/perf/util/config.h +++ b/tools/perf/util/config.h @@ -4,10 +4,30 @@ #include #include +enum perf_config_type { + CONFIG_TYPE_BOOL, + CONFIG_TYPE_INT, + CONFIG_TYPE_LONG, + CONFIG_TYPE_U64, + CONFIG_TYPE_FLOAT, + CONFIG_TYPE_DOUBLE, + CONFIG_TYPE_STRING +}; + struct perf_config_item { - char *section; - char *name; + const char *section; + const char *name; char *value; + union { + bool b; + int i; + u32 l; + u64 ll; + float f; + double d; + const char *s; + } default_value; + enum perf_config_type type; struct list_head list; }; @@ -15,6 +35,71 @@ struct perf_config_set { struct list_head config_list; }; +enum perf_config_idx { + CONFIG_COLORS_TOP, + CONFIG_COLORS_MEDIUM, + CONFIG_COLORS_NORMAL, + CONFIG_COLORS_SELECTED, + CONFIG_COLORS_JUMP_ARROWS, + CONFIG_COLORS_ADDR, + CONFIG_COLORS_ROOT, + CONFIG_TUI_REPORT, + CONFIG_TUI_ANNOTATE, + CONFIG_TUI_TOP, + CONFIG_BUILDID_DIR, + CONFIG_ANNOTATE_HIDE_SRC_CODE, + CONFIG_ANNOTATE_USE_OFFSET, + CONFIG_ANNOTATE_JUMP_ARROWS, + CONFIG_ANNOTATE_SHOW_NR_JUMPS, + CONFIG_ANNOTATE_SHOW_LINENR, + CONFIG_ANNOTATE_SHOW_TOTAL_PERIOD, + CONFIG_GTK_ANNOTATE, + CONFIG_GTK_REPORT, + CONFIG_GTK_TOP, + CONFIG_PAGER_CMD, + CONFIG_PAGER_REPORT, + CONFIG_PAGER_ANNOTATE, + CONFIG_PAGER_TOP, + CONFIG_PAGER_DIFF, + CONFIG_HELP_FORMAT, + CONFIG_HELP_AUTOCORRECT, + CONFIG_HIST_PERCENTAGE, + CONFIG_UI_SHOW_HEADERS, + CONFIG_CALL_GRAPH_RECORD_MODE, + CONFIG_CALL_GRAPH_DUMP_SIZE, + CONFIG_CALL_GRAPH_PRINT_TYPE, + CONFIG_CALL_GRAPH_ORDER, + CONFIG_CALL_GRAPH_SORT_KEY, + CONFIG_CALL_GRAPH_THRESHOLD, + CONFIG_CALL_GRAPH_PRINT_LIMIT, + CONFIG_REPORT_GROUP, + CONFIG_REPORT_CHILDREN, + CONFIG_REPORT_PERCENT_LIMIT, + CONFIG_REPORT_QUEUE_SIZE, + CONFIG_TOP_CHILDREN, + CONFIG_MAN_VIEWER, + CONFIG_KMEM_DEFAULT, + CONFIG_END +}; + +#define CONF_VAR(_sec, _name, _field, _val, _type) \ + { .section = _sec, .name = _name, .default_value._field = _val, .type = _type } + +#define CONF_BOOL_VAR(_idx, _sec, _name, _val) \ + [CONFIG_##_idx] = CONF_VAR(_sec, _name, b, _val, CONFIG_TYPE_BOOL) +#define CONF_INT_VAR(_idx, _sec, _name, _val) \ + [CONFIG_##_idx] = CONF_VAR(_sec, _name, i, _val, CONFIG_TYPE_INT) +#define CONF_LONG_VAR(_idx, _sec, _name, _val) \ + [CONFIG_##_idx] = CONF_VAR(_sec, _name, l, _val, CONFIG_TYPE_LONG) +#define CONF_U64_VAR(_idx, _sec, _name, _val) \ + [CONFIG_##_idx] = CONF_VAR(_sec, _name, ll, _val, CONFIG_TYPE_U64) +#define CONF_FLOAT_VAR(_idx, _sec, _name, _val) \ + [CONFIG_##_idx] = CONF_VAR(_sec, _name, f, _val, CONFIG_TYPE_FLOAT) +#define CONF_DOUBLE_VAR(_idx, _sec, _name, _val) \ + [CONFIG_##_idx] = CONF_VAR(_sec, _name, d, _val, CONFIG_TYPE_DOUBLE) +#define CONF_STR_VAR(_idx, _sec, _name, _val) \ + [CONFIG_##_idx] = CONF_VAR(_sec, _name, s, _val, CONFIG_TYPE_STRING) + struct perf_config_set *perf_config_set__new(void); void perf_config_set__delete(struct perf_config_set *perf_configs); -- 2.5.0