Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf data ctf: Pass convert options through opts structure

Following commits will add new option to 'perf data convert'. All options
should be grouped into a structure and passed to low level converter
(currently there's only one converter).

Introduce data-convert.h and define 'struct perf_data_convert_opts' in
it. Pass 'force' through opts.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-3-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Wang Nan and committed by
Arnaldo Carvalho de Melo
3275f68e 069ee5c4

+20 -6
+6 -3
tools/perf/builtin-data.c
··· 3 3 #include "perf.h" 4 4 #include "debug.h" 5 5 #include <subcmd/parse-options.h> 6 + #include "data-convert.h" 6 7 #include "data-convert-bt.h" 7 8 8 9 typedef int (*data_cmd_fn_t)(int argc, const char **argv, const char *prefix); ··· 54 53 const char *prefix __maybe_unused) 55 54 { 56 55 const char *to_ctf = NULL; 57 - bool force = false; 56 + struct perf_data_convert_opts opts = { 57 + .force = false, 58 + }; 58 59 const struct option options[] = { 59 60 OPT_INCR('v', "verbose", &verbose, "be more verbose"), 60 61 OPT_STRING('i', "input", &input_name, "file", "input file name"), 61 62 #ifdef HAVE_LIBBABELTRACE_SUPPORT 62 63 OPT_STRING(0, "to-ctf", &to_ctf, NULL, "Convert to CTF format"), 63 64 #endif 64 - OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), 65 + OPT_BOOLEAN('f', "force", &opts.force, "don't complain, do it"), 65 66 OPT_END() 66 67 }; 67 68 ··· 81 78 82 79 if (to_ctf) { 83 80 #ifdef HAVE_LIBBABELTRACE_SUPPORT 84 - return bt_convert__perf2ctf(input_name, to_ctf, force); 81 + return bt_convert__perf2ctf(input_name, to_ctf, &opts); 85 82 #else 86 83 pr_err("The libbabeltrace support is not compiled in.\n"); 87 84 return -1;
+3 -2
tools/perf/util/data-convert-bt.c
··· 1304 1304 return 0; 1305 1305 } 1306 1306 1307 - int bt_convert__perf2ctf(const char *input, const char *path, bool force) 1307 + int bt_convert__perf2ctf(const char *input, const char *path, 1308 + struct perf_data_convert_opts *opts) 1308 1309 { 1309 1310 struct perf_session *session; 1310 1311 struct perf_data_file file = { 1311 1312 .path = input, 1312 1313 .mode = PERF_DATA_MODE_READ, 1313 - .force = force, 1314 + .force = opts->force, 1314 1315 }; 1315 1316 struct convert c = { 1316 1317 .tool = {
+3 -1
tools/perf/util/data-convert-bt.h
··· 1 1 #ifndef __DATA_CONVERT_BT_H 2 2 #define __DATA_CONVERT_BT_H 3 + #include "data-convert.h" 3 4 #ifdef HAVE_LIBBABELTRACE_SUPPORT 4 5 5 - int bt_convert__perf2ctf(const char *input_name, const char *to_ctf, bool force); 6 + int bt_convert__perf2ctf(const char *input_name, const char *to_ctf, 7 + struct perf_data_convert_opts *opts); 6 8 7 9 #endif /* HAVE_LIBBABELTRACE_SUPPORT */ 8 10 #endif /* __DATA_CONVERT_BT_H */
+8
tools/perf/util/data-convert.h
··· 1 + #ifndef __DATA_CONVERT_H 2 + #define __DATA_CONVERT_H 3 + 4 + struct perf_data_convert_opts { 5 + bool force; 6 + }; 7 + 8 + #endif /* __DATA_CONVERT_H */