diff options
author | Ian Munsie <imunsie@au.ibm.com> | 2010-04-13 04:37:33 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-04-14 05:26:44 -0400 |
commit | c05556421742eb47f80301767653a4bcb19de9de (patch) | |
tree | 1e9c441a457acee41d2585e05692cc90c1d88be2 | |
parent | 53e5b5c215ce8372250e227f2c9acf9892de8434 (diff) |
perf: Fix endianness argument compatibility with OPT_BOOLEAN() and introduce OPT_INCR()
Parsing an option from the command line with OPT_BOOLEAN on a
bool data type would not work on a big-endian machine due to the
manner in which the boolean was being cast into an int and
incremented. For example, running 'perf probe --list' on a
PowerPC machine would fail to properly set the list_events bool
and would therefore print out the usage information and
terminate.
This patch makes OPT_BOOLEAN work as expected with a bool
datatype. For cases where the original OPT_BOOLEAN was
intentionally being used to increment an int each time it was
passed in on the command line, this patch introduces OPT_INCR
with the old behaviour of OPT_BOOLEAN (the verbose variable is
currently the only such example of this).
I have reviewed every use of OPT_BOOLEAN to verify that a true
C99 bool was passed. Where integers were used, I verified that
they were only being used for boolean logic and changed them to
bools to ensure that they would not be mistakenly used as ints.
The major exception was the verbose variable which now uses
OPT_INCR instead of OPT_BOOLEAN.
Signed-off-by: Ian Munsie <imunsie@au.ibm.com>
Acked-by: David S. Miller <davem@davemloft.net>
Cc: <stable@kernel.org> # NOTE: wont apply to .3[34].x cleanly, please backport
Cc: Git development list <git@vger.kernel.org>
Cc: Ian Munsie <imunsie@au1.ibm.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Eric B Munson <ebmunson@us.ibm.com>
Cc: Valdis.Kletnieks@vt.edu
Cc: WANG Cong <amwang@redhat.com>
Cc: Thiago Farina <tfransosi@gmail.com>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Cc: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Anton Blanchard <anton@samba.org>
Cc: John Kacur <jkacur@redhat.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <1271147857-11604-1-git-send-email-imunsie@au.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | tools/perf/bench/mem-memcpy.c | 2 | ||||
-rw-r--r-- | tools/perf/bench/sched-messaging.c | 4 | ||||
-rw-r--r-- | tools/perf/builtin-annotate.c | 8 | ||||
-rw-r--r-- | tools/perf/builtin-buildid-cache.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-buildid-list.c | 4 | ||||
-rw-r--r-- | tools/perf/builtin-diff.c | 4 | ||||
-rw-r--r-- | tools/perf/builtin-help.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-lock.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-probe.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 24 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 6 | ||||
-rw-r--r-- | tools/perf/builtin-sched.c | 6 | ||||
-rw-r--r-- | tools/perf/builtin-stat.c | 10 | ||||
-rw-r--r-- | tools/perf/builtin-timechart.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 14 | ||||
-rw-r--r-- | tools/perf/builtin-trace.c | 2 | ||||
-rw-r--r-- | tools/perf/util/debug.c | 2 | ||||
-rw-r--r-- | tools/perf/util/debug.h | 3 | ||||
-rw-r--r-- | tools/perf/util/parse-options.c | 6 | ||||
-rw-r--r-- | tools/perf/util/parse-options.h | 4 | ||||
-rw-r--r-- | tools/perf/util/trace-event-parse.c | 2 | ||||
-rw-r--r-- | tools/perf/util/trace-event.h | 3 |
22 files changed, 62 insertions, 52 deletions
diff --git a/tools/perf/bench/mem-memcpy.c b/tools/perf/bench/mem-memcpy.c index 52e646e3e873..38dae7465142 100644 --- a/tools/perf/bench/mem-memcpy.c +++ b/tools/perf/bench/mem-memcpy.c | |||
@@ -23,7 +23,7 @@ | |||
23 | 23 | ||
24 | static const char *length_str = "1MB"; | 24 | static const char *length_str = "1MB"; |
25 | static const char *routine = "default"; | 25 | static const char *routine = "default"; |
26 | static int use_clock = 0; | 26 | static bool use_clock = false; |
27 | static int clock_fd; | 27 | static int clock_fd; |
28 | 28 | ||
29 | static const struct option options[] = { | 29 | static const struct option options[] = { |
diff --git a/tools/perf/bench/sched-messaging.c b/tools/perf/bench/sched-messaging.c index 81cee78181fa..da1b2e9f01ff 100644 --- a/tools/perf/bench/sched-messaging.c +++ b/tools/perf/bench/sched-messaging.c | |||
@@ -31,9 +31,9 @@ | |||
31 | 31 | ||
32 | #define DATASIZE 100 | 32 | #define DATASIZE 100 |
33 | 33 | ||
34 | static int use_pipes = 0; | 34 | static bool use_pipes = false; |
35 | static unsigned int loops = 100; | 35 | static unsigned int loops = 100; |
36 | static unsigned int thread_mode = 0; | 36 | static bool thread_mode = false; |
37 | static unsigned int num_groups = 10; | 37 | static unsigned int num_groups = 10; |
38 | 38 | ||
39 | struct sender_context { | 39 | struct sender_context { |
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index ee0d91726991..06eaebe10d04 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -28,11 +28,11 @@ | |||
28 | 28 | ||
29 | static char const *input_name = "perf.data"; | 29 | static char const *input_name = "perf.data"; |
30 | 30 | ||
31 | static int force; | 31 | static bool force; |
32 | 32 | ||
33 | static int full_paths; | 33 | static bool full_paths; |
34 | 34 | ||
35 | static int print_line; | 35 | static bool print_line; |
36 | 36 | ||
37 | struct sym_hist { | 37 | struct sym_hist { |
38 | u64 sum; | 38 | u64 sum; |
@@ -595,7 +595,7 @@ static const struct option options[] = { | |||
595 | OPT_STRING('s', "symbol", &sym_hist_filter, "symbol", | 595 | OPT_STRING('s', "symbol", &sym_hist_filter, "symbol", |
596 | "symbol to annotate"), | 596 | "symbol to annotate"), |
597 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), | 597 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), |
598 | OPT_BOOLEAN('v', "verbose", &verbose, | 598 | OPT_INCR('v', "verbose", &verbose, |
599 | "be more verbose (show symbol address, etc)"), | 599 | "be more verbose (show symbol address, etc)"), |
600 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, | 600 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, |
601 | "dump raw trace in ASCII"), | 601 | "dump raw trace in ASCII"), |
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index 30a05f552c96..f8e3d1852029 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c | |||
@@ -27,7 +27,7 @@ static const struct option buildid_cache_options[] = { | |||
27 | "file list", "file(s) to add"), | 27 | "file list", "file(s) to add"), |
28 | OPT_STRING('r', "remove", &remove_name_list_str, "file list", | 28 | OPT_STRING('r', "remove", &remove_name_list_str, "file list", |
29 | "file(s) to remove"), | 29 | "file(s) to remove"), |
30 | OPT_BOOLEAN('v', "verbose", &verbose, "be more verbose"), | 30 | OPT_INCR('v', "verbose", &verbose, "be more verbose"), |
31 | OPT_END() | 31 | OPT_END() |
32 | }; | 32 | }; |
33 | 33 | ||
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index d0675c02f81e..af2ad8b92f76 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include "util/symbol.h" | 16 | #include "util/symbol.h" |
17 | 17 | ||
18 | static char const *input_name = "perf.data"; | 18 | static char const *input_name = "perf.data"; |
19 | static int force; | 19 | static bool force; |
20 | static bool with_hits; | 20 | static bool with_hits; |
21 | 21 | ||
22 | static const char * const buildid_list_usage[] = { | 22 | static const char * const buildid_list_usage[] = { |
@@ -29,7 +29,7 @@ static const struct option options[] = { | |||
29 | OPT_STRING('i', "input", &input_name, "file", | 29 | OPT_STRING('i', "input", &input_name, "file", |
30 | "input file name"), | 30 | "input file name"), |
31 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), | 31 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), |
32 | OPT_BOOLEAN('v', "verbose", &verbose, | 32 | OPT_INCR('v', "verbose", &verbose, |
33 | "be more verbose"), | 33 | "be more verbose"), |
34 | OPT_END() | 34 | OPT_END() |
35 | }; | 35 | }; |
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 1ea15d8aeed1..3a1d94d75dce 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
@@ -19,7 +19,7 @@ | |||
19 | static char const *input_old = "perf.data.old", | 19 | static char const *input_old = "perf.data.old", |
20 | *input_new = "perf.data"; | 20 | *input_new = "perf.data"; |
21 | static char diff__default_sort_order[] = "dso,symbol"; | 21 | static char diff__default_sort_order[] = "dso,symbol"; |
22 | static int force; | 22 | static bool force; |
23 | static bool show_displacement; | 23 | static bool show_displacement; |
24 | 24 | ||
25 | static int perf_session__add_hist_entry(struct perf_session *self, | 25 | static int perf_session__add_hist_entry(struct perf_session *self, |
@@ -188,7 +188,7 @@ static const char * const diff_usage[] = { | |||
188 | }; | 188 | }; |
189 | 189 | ||
190 | static const struct option options[] = { | 190 | static const struct option options[] = { |
191 | OPT_BOOLEAN('v', "verbose", &verbose, | 191 | OPT_INCR('v', "verbose", &verbose, |
192 | "be more verbose (show symbol address, etc)"), | 192 | "be more verbose (show symbol address, etc)"), |
193 | OPT_BOOLEAN('m', "displacement", &show_displacement, | 193 | OPT_BOOLEAN('m', "displacement", &show_displacement, |
194 | "Show position displacement relative to baseline"), | 194 | "Show position displacement relative to baseline"), |
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 215b584007b1..81e3ecc40fc7 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c | |||
@@ -29,7 +29,7 @@ enum help_format { | |||
29 | HELP_FORMAT_WEB, | 29 | HELP_FORMAT_WEB, |
30 | }; | 30 | }; |
31 | 31 | ||
32 | static int show_all = 0; | 32 | static bool show_all = false; |
33 | static enum help_format help_format = HELP_FORMAT_MAN; | 33 | static enum help_format help_format = HELP_FORMAT_MAN; |
34 | static struct option builtin_help_options[] = { | 34 | static struct option builtin_help_options[] = { |
35 | OPT_BOOLEAN('a', "all", &show_all, "print all available commands"), | 35 | OPT_BOOLEAN('a', "all", &show_all, "print all available commands"), |
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index e12c844df1e2..6c38e4febf9f 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c | |||
@@ -744,7 +744,7 @@ static const char * const lock_usage[] = { | |||
744 | 744 | ||
745 | static const struct option lock_options[] = { | 745 | static const struct option lock_options[] = { |
746 | OPT_STRING('i', "input", &input_name, "file", "input file name"), | 746 | OPT_STRING('i', "input", &input_name, "file", "input file name"), |
747 | OPT_BOOLEAN('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"), | 747 | OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"), |
748 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), | 748 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), |
749 | OPT_END() | 749 | OPT_END() |
750 | }; | 750 | }; |
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index b3ba25a910fa..bfc47fff9c59 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c | |||
@@ -133,7 +133,7 @@ static const char * const probe_usage[] = { | |||
133 | }; | 133 | }; |
134 | 134 | ||
135 | static const struct option options[] = { | 135 | static const struct option options[] = { |
136 | OPT_BOOLEAN('v', "verbose", &verbose, | 136 | OPT_INCR('v', "verbose", &verbose, |
137 | "be more verbose (show parsed arguments, etc)"), | 137 | "be more verbose (show parsed arguments, etc)"), |
138 | OPT_BOOLEAN('l', "list", ¶ms.list_events, | 138 | OPT_BOOLEAN('l', "list", ¶ms.list_events, |
139 | "list up current probe events"), | 139 | "list up current probe events"), |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index dc61f1b68b40..9a9513687235 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -38,22 +38,22 @@ static int output; | |||
38 | static const char *output_name = "perf.data"; | 38 | static const char *output_name = "perf.data"; |
39 | static int group = 0; | 39 | static int group = 0; |
40 | static unsigned int realtime_prio = 0; | 40 | static unsigned int realtime_prio = 0; |
41 | static int raw_samples = 0; | 41 | static bool raw_samples = false; |
42 | static int system_wide = 0; | 42 | static bool system_wide = false; |
43 | static int profile_cpu = -1; | 43 | static int profile_cpu = -1; |
44 | static pid_t target_pid = -1; | 44 | static pid_t target_pid = -1; |
45 | static pid_t target_tid = -1; | 45 | static pid_t target_tid = -1; |
46 | static pid_t *all_tids = NULL; | 46 | static pid_t *all_tids = NULL; |
47 | static int thread_num = 0; | 47 | static int thread_num = 0; |
48 | static pid_t child_pid = -1; | 48 | static pid_t child_pid = -1; |
49 | static int inherit = 1; | 49 | static bool inherit = true; |
50 | static int force = 0; | 50 | static bool force = false; |
51 | static int append_file = 0; | 51 | static bool append_file = false; |
52 | static int call_graph = 0; | 52 | static bool call_graph = false; |
53 | static int inherit_stat = 0; | 53 | static bool inherit_stat = false; |
54 | static int no_samples = 0; | 54 | static bool no_samples = false; |
55 | static int sample_address = 0; | 55 | static bool sample_address = false; |
56 | static int multiplex = 0; | 56 | static bool multiplex = false; |
57 | static int multiplex_fd = -1; | 57 | static int multiplex_fd = -1; |
58 | 58 | ||
59 | static long samples = 0; | 59 | static long samples = 0; |
@@ -465,7 +465,7 @@ static int __cmd_record(int argc, const char **argv) | |||
465 | rename(output_name, oldname); | 465 | rename(output_name, oldname); |
466 | } | 466 | } |
467 | } else { | 467 | } else { |
468 | append_file = 0; | 468 | append_file = false; |
469 | } | 469 | } |
470 | 470 | ||
471 | flags = O_CREAT|O_RDWR; | 471 | flags = O_CREAT|O_RDWR; |
@@ -701,7 +701,7 @@ static const struct option options[] = { | |||
701 | "number of mmap data pages"), | 701 | "number of mmap data pages"), |
702 | OPT_BOOLEAN('g', "call-graph", &call_graph, | 702 | OPT_BOOLEAN('g', "call-graph", &call_graph, |
703 | "do call-graph (stack chain/backtrace) recording"), | 703 | "do call-graph (stack chain/backtrace) recording"), |
704 | OPT_BOOLEAN('v', "verbose", &verbose, | 704 | OPT_INCR('v', "verbose", &verbose, |
705 | "be more verbose (show counter open errors, etc)"), | 705 | "be more verbose (show counter open errors, etc)"), |
706 | OPT_BOOLEAN('s', "stat", &inherit_stat, | 706 | OPT_BOOLEAN('s', "stat", &inherit_stat, |
707 | "per thread counts"), | 707 | "per thread counts"), |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index e93c69a8e720..daee082ab42b 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -32,11 +32,11 @@ | |||
32 | 32 | ||
33 | static char const *input_name = "perf.data"; | 33 | static char const *input_name = "perf.data"; |
34 | 34 | ||
35 | static int force; | 35 | static bool force; |
36 | static bool hide_unresolved; | 36 | static bool hide_unresolved; |
37 | static bool dont_use_callchains; | 37 | static bool dont_use_callchains; |
38 | 38 | ||
39 | static int show_threads; | 39 | static bool show_threads; |
40 | static struct perf_read_values show_threads_values; | 40 | static struct perf_read_values show_threads_values; |
41 | 41 | ||
42 | static char default_pretty_printing_style[] = "normal"; | 42 | static char default_pretty_printing_style[] = "normal"; |
@@ -418,7 +418,7 @@ static const char * const report_usage[] = { | |||
418 | static const struct option options[] = { | 418 | static const struct option options[] = { |
419 | OPT_STRING('i', "input", &input_name, "file", | 419 | OPT_STRING('i', "input", &input_name, "file", |
420 | "input file name"), | 420 | "input file name"), |
421 | OPT_BOOLEAN('v', "verbose", &verbose, | 421 | OPT_INCR('v', "verbose", &verbose, |
422 | "be more verbose (show symbol address, etc)"), | 422 | "be more verbose (show symbol address, etc)"), |
423 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, | 423 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, |
424 | "dump raw trace in ASCII"), | 424 | "dump raw trace in ASCII"), |
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 5e59c0c40c40..09ddc8e6d8e1 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -1790,7 +1790,7 @@ static const char * const sched_usage[] = { | |||
1790 | static const struct option sched_options[] = { | 1790 | static const struct option sched_options[] = { |
1791 | OPT_STRING('i', "input", &input_name, "file", | 1791 | OPT_STRING('i', "input", &input_name, "file", |
1792 | "input file name"), | 1792 | "input file name"), |
1793 | OPT_BOOLEAN('v', "verbose", &verbose, | 1793 | OPT_INCR('v', "verbose", &verbose, |
1794 | "be more verbose (show symbol address, etc)"), | 1794 | "be more verbose (show symbol address, etc)"), |
1795 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, | 1795 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, |
1796 | "dump raw trace in ASCII"), | 1796 | "dump raw trace in ASCII"), |
@@ -1805,7 +1805,7 @@ static const char * const latency_usage[] = { | |||
1805 | static const struct option latency_options[] = { | 1805 | static const struct option latency_options[] = { |
1806 | OPT_STRING('s', "sort", &sort_order, "key[,key2...]", | 1806 | OPT_STRING('s', "sort", &sort_order, "key[,key2...]", |
1807 | "sort by key(s): runtime, switch, avg, max"), | 1807 | "sort by key(s): runtime, switch, avg, max"), |
1808 | OPT_BOOLEAN('v', "verbose", &verbose, | 1808 | OPT_INCR('v', "verbose", &verbose, |
1809 | "be more verbose (show symbol address, etc)"), | 1809 | "be more verbose (show symbol address, etc)"), |
1810 | OPT_INTEGER('C', "CPU", &profile_cpu, | 1810 | OPT_INTEGER('C', "CPU", &profile_cpu, |
1811 | "CPU to profile on"), | 1811 | "CPU to profile on"), |
@@ -1822,7 +1822,7 @@ static const char * const replay_usage[] = { | |||
1822 | static const struct option replay_options[] = { | 1822 | static const struct option replay_options[] = { |
1823 | OPT_INTEGER('r', "repeat", &replay_repeat, | 1823 | OPT_INTEGER('r', "repeat", &replay_repeat, |
1824 | "repeat the workload replay N times (-1: infinite)"), | 1824 | "repeat the workload replay N times (-1: infinite)"), |
1825 | OPT_BOOLEAN('v', "verbose", &verbose, | 1825 | OPT_INCR('v', "verbose", &verbose, |
1826 | "be more verbose (show symbol address, etc)"), | 1826 | "be more verbose (show symbol address, etc)"), |
1827 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, | 1827 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, |
1828 | "dump raw trace in ASCII"), | 1828 | "dump raw trace in ASCII"), |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 1036ca739e6f..e619ac89dff5 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -67,19 +67,19 @@ static struct perf_event_attr default_attrs[] = { | |||
67 | 67 | ||
68 | }; | 68 | }; |
69 | 69 | ||
70 | static int system_wide = 0; | 70 | static bool system_wide = false; |
71 | static unsigned int nr_cpus = 0; | 71 | static unsigned int nr_cpus = 0; |
72 | static int run_idx = 0; | 72 | static int run_idx = 0; |
73 | 73 | ||
74 | static int run_count = 1; | 74 | static int run_count = 1; |
75 | static int inherit = 1; | 75 | static bool inherit = true; |
76 | static int scale = 1; | 76 | static bool scale = true; |
77 | static pid_t target_pid = -1; | 77 | static pid_t target_pid = -1; |
78 | static pid_t target_tid = -1; | 78 | static pid_t target_tid = -1; |
79 | static pid_t *all_tids = NULL; | 79 | static pid_t *all_tids = NULL; |
80 | static int thread_num = 0; | 80 | static int thread_num = 0; |
81 | static pid_t child_pid = -1; | 81 | static pid_t child_pid = -1; |
82 | static int null_run = 0; | 82 | static bool null_run = false; |
83 | 83 | ||
84 | static int *fd[MAX_NR_CPUS][MAX_COUNTERS]; | 84 | static int *fd[MAX_NR_CPUS][MAX_COUNTERS]; |
85 | 85 | ||
@@ -528,7 +528,7 @@ static const struct option options[] = { | |||
528 | "system-wide collection from all CPUs"), | 528 | "system-wide collection from all CPUs"), |
529 | OPT_BOOLEAN('c', "scale", &scale, | 529 | OPT_BOOLEAN('c', "scale", &scale, |
530 | "scale/normalize counters"), | 530 | "scale/normalize counters"), |
531 | OPT_BOOLEAN('v', "verbose", &verbose, | 531 | OPT_INCR('v', "verbose", &verbose, |
532 | "be more verbose (show counter open errors, etc)"), | 532 | "be more verbose (show counter open errors, etc)"), |
533 | OPT_INTEGER('r', "repeat", &run_count, | 533 | OPT_INTEGER('r', "repeat", &run_count, |
534 | "repeat command and print average + stddev (max: 100)"), | 534 | "repeat command and print average + stddev (max: 100)"), |
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 369c1b490a9e..96f4a092df37 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c | |||
@@ -42,7 +42,7 @@ static u64 turbo_frequency; | |||
42 | 42 | ||
43 | static u64 first_time, last_time; | 43 | static u64 first_time, last_time; |
44 | 44 | ||
45 | static int power_only; | 45 | static bool power_only; |
46 | 46 | ||
47 | 47 | ||
48 | struct per_pid; | 48 | struct per_pid; |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 4abdd9b646b3..40f24dd46ef4 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -57,7 +57,7 @@ | |||
57 | 57 | ||
58 | static int *fd[MAX_NR_CPUS][MAX_COUNTERS]; | 58 | static int *fd[MAX_NR_CPUS][MAX_COUNTERS]; |
59 | 59 | ||
60 | static int system_wide = 0; | 60 | static bool system_wide = false; |
61 | 61 | ||
62 | static int default_interval = 0; | 62 | static int default_interval = 0; |
63 | 63 | ||
@@ -68,18 +68,18 @@ static int target_pid = -1; | |||
68 | static int target_tid = -1; | 68 | static int target_tid = -1; |
69 | static pid_t *all_tids = NULL; | 69 | static pid_t *all_tids = NULL; |
70 | static int thread_num = 0; | 70 | static int thread_num = 0; |
71 | static int inherit = 0; | 71 | static bool inherit = false; |
72 | static int profile_cpu = -1; | 72 | static int profile_cpu = -1; |
73 | static int nr_cpus = 0; | 73 | static int nr_cpus = 0; |
74 | static unsigned int realtime_prio = 0; | 74 | static unsigned int realtime_prio = 0; |
75 | static int group = 0; | 75 | static bool group = false; |
76 | static unsigned int page_size; | 76 | static unsigned int page_size; |
77 | static unsigned int mmap_pages = 16; | 77 | static unsigned int mmap_pages = 16; |
78 | static int freq = 1000; /* 1 KHz */ | 78 | static int freq = 1000; /* 1 KHz */ |
79 | 79 | ||
80 | static int delay_secs = 2; | 80 | static int delay_secs = 2; |
81 | static int zero = 0; | 81 | static bool zero = false; |
82 | static int dump_symtab = 0; | 82 | static bool dump_symtab = false; |
83 | 83 | ||
84 | static bool hide_kernel_symbols = false; | 84 | static bool hide_kernel_symbols = false; |
85 | static bool hide_user_symbols = false; | 85 | static bool hide_user_symbols = false; |
@@ -854,7 +854,7 @@ static void handle_keypress(int c) | |||
854 | display_weighted = ~display_weighted; | 854 | display_weighted = ~display_weighted; |
855 | break; | 855 | break; |
856 | case 'z': | 856 | case 'z': |
857 | zero = ~zero; | 857 | zero = !zero; |
858 | break; | 858 | break; |
859 | default: | 859 | default: |
860 | break; | 860 | break; |
@@ -1335,7 +1335,7 @@ static const struct option options[] = { | |||
1335 | "display this many functions"), | 1335 | "display this many functions"), |
1336 | OPT_BOOLEAN('U', "hide_user_symbols", &hide_user_symbols, | 1336 | OPT_BOOLEAN('U', "hide_user_symbols", &hide_user_symbols, |
1337 | "hide user symbols"), | 1337 | "hide user symbols"), |
1338 | OPT_BOOLEAN('v', "verbose", &verbose, | 1338 | OPT_INCR('v', "verbose", &verbose, |
1339 | "be more verbose (show counter open errors, etc)"), | 1339 | "be more verbose (show counter open errors, etc)"), |
1340 | OPT_END() | 1340 | OPT_END() |
1341 | }; | 1341 | }; |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 407041d20de0..8fc50d831540 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -505,7 +505,7 @@ static const char * const trace_usage[] = { | |||
505 | static const struct option options[] = { | 505 | static const struct option options[] = { |
506 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, | 506 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, |
507 | "dump raw trace in ASCII"), | 507 | "dump raw trace in ASCII"), |
508 | OPT_BOOLEAN('v', "verbose", &verbose, | 508 | OPT_INCR('v', "verbose", &verbose, |
509 | "be more verbose (show symbol address, etc)"), | 509 | "be more verbose (show symbol address, etc)"), |
510 | OPT_BOOLEAN('L', "Latency", &latency_format, | 510 | OPT_BOOLEAN('L', "Latency", &latency_format, |
511 | "show latency attributes (irqs/preemption disabled, etc)"), | 511 | "show latency attributes (irqs/preemption disabled, etc)"), |
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 033d66db863a..dd824cf3b628 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include "util.h" | 13 | #include "util.h" |
14 | 14 | ||
15 | int verbose = 0; | 15 | int verbose = 0; |
16 | int dump_trace = 0; | 16 | bool dump_trace = false; |
17 | 17 | ||
18 | int eprintf(int level, const char *fmt, ...) | 18 | int eprintf(int level, const char *fmt, ...) |
19 | { | 19 | { |
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index 5cb0a1b1401a..047ac3324ebe 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h | |||
@@ -2,10 +2,11 @@ | |||
2 | #ifndef __PERF_DEBUG_H | 2 | #ifndef __PERF_DEBUG_H |
3 | #define __PERF_DEBUG_H | 3 | #define __PERF_DEBUG_H |
4 | 4 | ||
5 | #include <stdbool.h> | ||
5 | #include "event.h" | 6 | #include "event.h" |
6 | 7 | ||
7 | extern int verbose; | 8 | extern int verbose; |
8 | extern int dump_trace; | 9 | extern bool dump_trace; |
9 | 10 | ||
10 | int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); | 11 | int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); |
11 | void trace_event(event_t *event); | 12 | void trace_event(event_t *event); |
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c index 79dfa0c34b3c..ed887642460c 100644 --- a/tools/perf/util/parse-options.c +++ b/tools/perf/util/parse-options.c | |||
@@ -49,6 +49,7 @@ static int get_value(struct parse_opt_ctx_t *p, | |||
49 | break; | 49 | break; |
50 | /* FALLTHROUGH */ | 50 | /* FALLTHROUGH */ |
51 | case OPTION_BOOLEAN: | 51 | case OPTION_BOOLEAN: |
52 | case OPTION_INCR: | ||
52 | case OPTION_BIT: | 53 | case OPTION_BIT: |
53 | case OPTION_SET_INT: | 54 | case OPTION_SET_INT: |
54 | case OPTION_SET_PTR: | 55 | case OPTION_SET_PTR: |
@@ -73,6 +74,10 @@ static int get_value(struct parse_opt_ctx_t *p, | |||
73 | return 0; | 74 | return 0; |
74 | 75 | ||
75 | case OPTION_BOOLEAN: | 76 | case OPTION_BOOLEAN: |
77 | *(bool *)opt->value = unset ? false : true; | ||
78 | return 0; | ||
79 | |||
80 | case OPTION_INCR: | ||
76 | *(int *)opt->value = unset ? 0 : *(int *)opt->value + 1; | 81 | *(int *)opt->value = unset ? 0 : *(int *)opt->value + 1; |
77 | return 0; | 82 | return 0; |
78 | 83 | ||
@@ -478,6 +483,7 @@ int usage_with_options_internal(const char * const *usagestr, | |||
478 | case OPTION_GROUP: | 483 | case OPTION_GROUP: |
479 | case OPTION_BIT: | 484 | case OPTION_BIT: |
480 | case OPTION_BOOLEAN: | 485 | case OPTION_BOOLEAN: |
486 | case OPTION_INCR: | ||
481 | case OPTION_SET_INT: | 487 | case OPTION_SET_INT: |
482 | case OPTION_SET_PTR: | 488 | case OPTION_SET_PTR: |
483 | case OPTION_LONG: | 489 | case OPTION_LONG: |
diff --git a/tools/perf/util/parse-options.h b/tools/perf/util/parse-options.h index 948805af43c2..b2da725f102a 100644 --- a/tools/perf/util/parse-options.h +++ b/tools/perf/util/parse-options.h | |||
@@ -8,7 +8,8 @@ enum parse_opt_type { | |||
8 | OPTION_GROUP, | 8 | OPTION_GROUP, |
9 | /* options with no arguments */ | 9 | /* options with no arguments */ |
10 | OPTION_BIT, | 10 | OPTION_BIT, |
11 | OPTION_BOOLEAN, /* _INCR would have been a better name */ | 11 | OPTION_BOOLEAN, |
12 | OPTION_INCR, | ||
12 | OPTION_SET_INT, | 13 | OPTION_SET_INT, |
13 | OPTION_SET_PTR, | 14 | OPTION_SET_PTR, |
14 | /* options with arguments (usually) */ | 15 | /* options with arguments (usually) */ |
@@ -95,6 +96,7 @@ struct option { | |||
95 | #define OPT_GROUP(h) { .type = OPTION_GROUP, .help = (h) } | 96 | #define OPT_GROUP(h) { .type = OPTION_GROUP, .help = (h) } |
96 | #define OPT_BIT(s, l, v, h, b) { .type = OPTION_BIT, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (b) } | 97 | #define OPT_BIT(s, l, v, h, b) { .type = OPTION_BIT, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (b) } |
97 | #define OPT_BOOLEAN(s, l, v, h) { .type = OPTION_BOOLEAN, .short_name = (s), .long_name = (l), .value = (v), .help = (h) } | 98 | #define OPT_BOOLEAN(s, l, v, h) { .type = OPTION_BOOLEAN, .short_name = (s), .long_name = (l), .value = (v), .help = (h) } |
99 | #define OPT_INCR(s, l, v, h) { .type = OPTION_INCR, .short_name = (s), .long_name = (l), .value = (v), .help = (h) } | ||
98 | #define OPT_SET_INT(s, l, v, h, i) { .type = OPTION_SET_INT, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (i) } | 100 | #define OPT_SET_INT(s, l, v, h, i) { .type = OPTION_SET_INT, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (i) } |
99 | #define OPT_SET_PTR(s, l, v, h, p) { .type = OPTION_SET_PTR, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (p) } | 101 | #define OPT_SET_PTR(s, l, v, h, p) { .type = OPTION_SET_PTR, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (p) } |
100 | #define OPT_INTEGER(s, l, v, h) { .type = OPTION_INTEGER, .short_name = (s), .long_name = (l), .value = (v), .help = (h) } | 102 | #define OPT_INTEGER(s, l, v, h) { .type = OPTION_INTEGER, .short_name = (s), .long_name = (l), .value = (v), .help = (h) } |
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index 3b81250ffedb..17d6d66ed766 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c | |||
@@ -42,7 +42,7 @@ int header_page_overwrite_size; | |||
42 | int header_page_data_offset; | 42 | int header_page_data_offset; |
43 | int header_page_data_size; | 43 | int header_page_data_size; |
44 | 44 | ||
45 | int latency_format; | 45 | bool latency_format; |
46 | 46 | ||
47 | static char *input_buf; | 47 | static char *input_buf; |
48 | static unsigned long long input_buf_ptr; | 48 | static unsigned long long input_buf_ptr; |
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h index c3269b937db4..81f2fd20a0ea 100644 --- a/tools/perf/util/trace-event.h +++ b/tools/perf/util/trace-event.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef __PERF_TRACE_EVENTS_H | 1 | #ifndef __PERF_TRACE_EVENTS_H |
2 | #define __PERF_TRACE_EVENTS_H | 2 | #define __PERF_TRACE_EVENTS_H |
3 | 3 | ||
4 | #include <stdbool.h> | ||
4 | #include "parse-events.h" | 5 | #include "parse-events.h" |
5 | 6 | ||
6 | #define __unused __attribute__((unused)) | 7 | #define __unused __attribute__((unused)) |
@@ -241,7 +242,7 @@ extern int header_page_size_size; | |||
241 | extern int header_page_data_offset; | 242 | extern int header_page_data_offset; |
242 | extern int header_page_data_size; | 243 | extern int header_page_data_size; |
243 | 244 | ||
244 | extern int latency_format; | 245 | extern bool latency_format; |
245 | 246 | ||
246 | int parse_header_page(char *buf, unsigned long size); | 247 | int parse_header_page(char *buf, unsigned long size); |
247 | int trace_parse_common_type(void *data); | 248 | int trace_parse_common_type(void *data); |