diff options
author | Ingo Molnar <mingo@kernel.org> | 2017-04-20 04:07:18 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-04-20 04:07:18 -0400 |
commit | 07590a7d4030c159b9a0d7171f81049a9ce23245 (patch) | |
tree | 1aa05455a4eacca2ca9dc3b228f19addf7bfd395 | |
parent | afa7a17f3aafb64647ba4cd38e20f3d678c7949b (diff) | |
parent | 1b5ad16c7aa7177512ce141e345ff36b9f1a6136 (diff) |
Merge tag 'perf-core-for-mingo-4.12-20170419' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core cleanups from Arnaldo Carvalho de Melo:
- Introduce new header files out of the hodge-podge that util/util.h
became, trying to disentangle the includes hell that all C projects
end up growing. This should help in build times, as changes to
seemingly unrelated files (util.h included tons of headers) won't
trigger a rebuild of most object files.
- Use equivalent facilities found in the kernel source code base
originated tools/include/ header files, such as __stringify(),
ARRAY_SIZE, that has extra checks (__must_be_array()), etc.
- For that get some more files from the kernel sources, like
include/linux/bug.h, some just with the bits needed at this time.
- Use the headers where facilities declared in them are used, such
as PRIxu(32,64) macros (inttypes.h), errno defines (errno.h), etc.
- Remove various leftovers from the initial code base we copied from
git.git: FLEX_ARRAY, etc.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
180 files changed, 659 insertions, 376 deletions
diff --git a/tools/include/linux/bug.h b/tools/include/linux/bug.h new file mode 100644 index 000000000000..8e4a4f49135d --- /dev/null +++ b/tools/include/linux/bug.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef _TOOLS_PERF_LINUX_BUG_H | ||
2 | #define _TOOLS_PERF_LINUX_BUG_H | ||
3 | |||
4 | /* Force a compilation error if condition is true, but also produce a | ||
5 | result (of value 0 and type size_t), so the expression can be used | ||
6 | e.g. in a structure initializer (or where-ever else comma expressions | ||
7 | aren't permitted). */ | ||
8 | #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) | ||
9 | |||
10 | #endif /* _TOOLS_PERF_LINUX_BUG_H */ | ||
diff --git a/tools/include/linux/compiler-gcc.h b/tools/include/linux/compiler-gcc.h index 616935f1ff56..825d44f89a29 100644 --- a/tools/include/linux/compiler-gcc.h +++ b/tools/include/linux/compiler-gcc.h | |||
@@ -16,3 +16,6 @@ | |||
16 | #if GCC_VERSION >= 40300 | 16 | #if GCC_VERSION >= 40300 |
17 | # define __compiletime_error(message) __attribute__((error(message))) | 17 | # define __compiletime_error(message) __attribute__((error(message))) |
18 | #endif /* GCC_VERSION >= 40300 */ | 18 | #endif /* GCC_VERSION >= 40300 */ |
19 | |||
20 | /* &a[0] degrades to a pointer: a different type from an array */ | ||
21 | #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) | ||
diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h index c9e65e8faacd..23299d7e7160 100644 --- a/tools/include/linux/compiler.h +++ b/tools/include/linux/compiler.h | |||
@@ -17,6 +17,11 @@ | |||
17 | # define __always_inline inline __attribute__((always_inline)) | 17 | # define __always_inline inline __attribute__((always_inline)) |
18 | #endif | 18 | #endif |
19 | 19 | ||
20 | /* Are two types/vars the same type (ignoring qualifiers)? */ | ||
21 | #ifndef __same_type | ||
22 | # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) | ||
23 | #endif | ||
24 | |||
20 | #ifdef __ANDROID__ | 25 | #ifdef __ANDROID__ |
21 | /* | 26 | /* |
22 | * FIXME: Big hammer to get rid of tons of: | 27 | * FIXME: Big hammer to get rid of tons of: |
diff --git a/tools/include/linux/hashtable.h b/tools/include/linux/hashtable.h index c65cc0aa2659..251eabf2a05e 100644 --- a/tools/include/linux/hashtable.h +++ b/tools/include/linux/hashtable.h | |||
@@ -13,10 +13,6 @@ | |||
13 | #include <linux/hash.h> | 13 | #include <linux/hash.h> |
14 | #include <linux/log2.h> | 14 | #include <linux/log2.h> |
15 | 15 | ||
16 | #ifndef ARRAY_SIZE | ||
17 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
18 | #endif | ||
19 | |||
20 | #define DEFINE_HASHTABLE(name, bits) \ | 16 | #define DEFINE_HASHTABLE(name, bits) \ |
21 | struct hlist_head name[1 << (bits)] = \ | 17 | struct hlist_head name[1 << (bits)] = \ |
22 | { [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT } | 18 | { [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT } |
diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h index adb4d0147755..73ccc48126bb 100644 --- a/tools/include/linux/kernel.h +++ b/tools/include/linux/kernel.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <stdarg.h> | 4 | #include <stdarg.h> |
5 | #include <stddef.h> | 5 | #include <stddef.h> |
6 | #include <assert.h> | 6 | #include <assert.h> |
7 | #include <linux/compiler.h> | ||
7 | 8 | ||
8 | #ifndef UINT_MAX | 9 | #ifndef UINT_MAX |
9 | #define UINT_MAX (~0U) | 10 | #define UINT_MAX (~0U) |
@@ -76,6 +77,8 @@ | |||
76 | int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); | 77 | int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); |
77 | int scnprintf(char * buf, size_t size, const char * fmt, ...); | 78 | int scnprintf(char * buf, size_t size, const char * fmt, ...); |
78 | 79 | ||
80 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) | ||
81 | |||
79 | /* | 82 | /* |
80 | * This looks more complex than it should be. But we need to | 83 | * This looks more complex than it should be. But we need to |
81 | * get the type for the ~ right in round_down (it needs to be | 84 | * get the type for the ~ right in round_down (it needs to be |
diff --git a/tools/include/linux/log2.h b/tools/include/linux/log2.h index d5677d39c1e4..0325cefc2220 100644 --- a/tools/include/linux/log2.h +++ b/tools/include/linux/log2.h | |||
@@ -12,6 +12,9 @@ | |||
12 | #ifndef _TOOLS_LINUX_LOG2_H | 12 | #ifndef _TOOLS_LINUX_LOG2_H |
13 | #define _TOOLS_LINUX_LOG2_H | 13 | #define _TOOLS_LINUX_LOG2_H |
14 | 14 | ||
15 | #include <linux/bitops.h> | ||
16 | #include <linux/types.h> | ||
17 | |||
15 | /* | 18 | /* |
16 | * non-constant log of base 2 calculators | 19 | * non-constant log of base 2 calculators |
17 | * - the arch may override these in asm/bitops.h if they can be implemented | 20 | * - the arch may override these in asm/bitops.h if they can be implemented |
diff --git a/tools/lib/symbol/kallsyms.c b/tools/lib/symbol/kallsyms.c index 5e431077fcd6..d270ac00613d 100644 --- a/tools/lib/symbol/kallsyms.c +++ b/tools/lib/symbol/kallsyms.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <ctype.h> | ||
1 | #include "symbol/kallsyms.h" | 2 | #include "symbol/kallsyms.h" |
2 | #include <stdio.h> | 3 | #include <stdio.h> |
3 | #include <stdlib.h> | 4 | #include <stdlib.h> |
diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index 066086dd59a8..282a60368b14 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c | |||
@@ -36,8 +36,7 @@ | |||
36 | #include "warn.h" | 36 | #include "warn.h" |
37 | 37 | ||
38 | #include <linux/hashtable.h> | 38 | #include <linux/hashtable.h> |
39 | 39 | #include <linux/kernel.h> | |
40 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
41 | 40 | ||
42 | #define STATE_FP_SAVED 0x1 | 41 | #define STATE_FP_SAVED 0x1 |
43 | #define STATE_FP_SETUP 0x2 | 42 | #define STATE_FP_SETUP 0x2 |
diff --git a/tools/objtool/objtool.c b/tools/objtool/objtool.c index 46c326db4f46..ecc5b1b5d15d 100644 --- a/tools/objtool/objtool.c +++ b/tools/objtool/objtool.c | |||
@@ -31,11 +31,10 @@ | |||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | #include <subcmd/exec-cmd.h> | 32 | #include <subcmd/exec-cmd.h> |
33 | #include <subcmd/pager.h> | 33 | #include <subcmd/pager.h> |
34 | #include <linux/kernel.h> | ||
34 | 35 | ||
35 | #include "builtin.h" | 36 | #include "builtin.h" |
36 | 37 | ||
37 | #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) | ||
38 | |||
39 | struct cmd_struct { | 38 | struct cmd_struct { |
40 | const char *name; | 39 | const char *name; |
41 | int (*fn)(int, const char **); | 40 | int (*fn)(int, const char **); |
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST index 89018c7311a4..a29da46d180f 100644 --- a/tools/perf/MANIFEST +++ b/tools/perf/MANIFEST | |||
@@ -64,6 +64,7 @@ tools/include/linux/bitops.h | |||
64 | tools/include/linux/compiler.h | 64 | tools/include/linux/compiler.h |
65 | tools/include/linux/compiler-gcc.h | 65 | tools/include/linux/compiler-gcc.h |
66 | tools/include/linux/coresight-pmu.h | 66 | tools/include/linux/coresight-pmu.h |
67 | tools/include/linux/bug.h | ||
67 | tools/include/linux/filter.h | 68 | tools/include/linux/filter.h |
68 | tools/include/linux/hash.h | 69 | tools/include/linux/hash.h |
69 | tools/include/linux/kernel.h | 70 | tools/include/linux/kernel.h |
diff --git a/tools/perf/arch/arm/util/dwarf-regs.c b/tools/perf/arch/arm/util/dwarf-regs.c index 33ec5b339da8..8bb176a37990 100644 --- a/tools/perf/arch/arm/util/dwarf-regs.c +++ b/tools/perf/arch/arm/util/dwarf-regs.c | |||
@@ -9,6 +9,7 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <stddef.h> | 11 | #include <stddef.h> |
12 | #include <linux/stringify.h> | ||
12 | #include <dwarf-regs.h> | 13 | #include <dwarf-regs.h> |
13 | 14 | ||
14 | struct pt_regs_dwarfnum { | 15 | struct pt_regs_dwarfnum { |
@@ -16,10 +17,9 @@ struct pt_regs_dwarfnum { | |||
16 | unsigned int dwarfnum; | 17 | unsigned int dwarfnum; |
17 | }; | 18 | }; |
18 | 19 | ||
19 | #define STR(s) #s | ||
20 | #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num} | 20 | #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num} |
21 | #define GPR_DWARFNUM_NAME(num) \ | 21 | #define GPR_DWARFNUM_NAME(num) \ |
22 | {.name = STR(%r##num), .dwarfnum = num} | 22 | {.name = __stringify(%r##num), .dwarfnum = num} |
23 | #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0} | 23 | #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0} |
24 | 24 | ||
25 | /* | 25 | /* |
diff --git a/tools/perf/arch/arm64/util/dwarf-regs.c b/tools/perf/arch/arm64/util/dwarf-regs.c index 068b6189157b..f268720ff021 100644 --- a/tools/perf/arch/arm64/util/dwarf-regs.c +++ b/tools/perf/arch/arm64/util/dwarf-regs.c | |||
@@ -8,9 +8,11 @@ | |||
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <errno.h> | ||
11 | #include <stddef.h> | 12 | #include <stddef.h> |
12 | #include <dwarf-regs.h> | 13 | #include <dwarf-regs.h> |
13 | #include <linux/ptrace.h> /* for struct user_pt_regs */ | 14 | #include <linux/ptrace.h> /* for struct user_pt_regs */ |
15 | #include <linux/stringify.h> | ||
14 | #include "util.h" | 16 | #include "util.h" |
15 | 17 | ||
16 | struct pt_regs_dwarfnum { | 18 | struct pt_regs_dwarfnum { |
@@ -20,7 +22,7 @@ struct pt_regs_dwarfnum { | |||
20 | 22 | ||
21 | #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num} | 23 | #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num} |
22 | #define GPR_DWARFNUM_NAME(num) \ | 24 | #define GPR_DWARFNUM_NAME(num) \ |
23 | {.name = STR(%x##num), .dwarfnum = num} | 25 | {.name = __stringify(%x##num), .dwarfnum = num} |
24 | #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0} | 26 | #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0} |
25 | #define DWARFNUM2OFFSET(index) \ | 27 | #define DWARFNUM2OFFSET(index) \ |
26 | (index * sizeof((struct user_pt_regs *)0)->regs[0]) | 28 | (index * sizeof((struct user_pt_regs *)0)->regs[0]) |
diff --git a/tools/perf/arch/arm64/util/unwind-libunwind.c b/tools/perf/arch/arm64/util/unwind-libunwind.c index c116b713f7f7..b415dfdbccca 100644 --- a/tools/perf/arch/arm64/util/unwind-libunwind.c +++ b/tools/perf/arch/arm64/util/unwind-libunwind.c | |||
@@ -1,6 +1,6 @@ | |||
1 | #include <errno.h> | ||
1 | 2 | ||
2 | #ifndef REMOTE_UNWIND_LIBUNWIND | 3 | #ifndef REMOTE_UNWIND_LIBUNWIND |
3 | #include <errno.h> | ||
4 | #include <libunwind.h> | 4 | #include <libunwind.h> |
5 | #include "perf_regs.h" | 5 | #include "perf_regs.h" |
6 | #include "../../util/unwind.h" | 6 | #include "../../util/unwind.h" |
diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c index 886dd2aaff0d..837067f48a4c 100644 --- a/tools/perf/arch/common.c +++ b/tools/perf/arch/common.c | |||
@@ -4,6 +4,8 @@ | |||
4 | #include "../util/util.h" | 4 | #include "../util/util.h" |
5 | #include "../util/debug.h" | 5 | #include "../util/debug.h" |
6 | 6 | ||
7 | #include "sane_ctype.h" | ||
8 | |||
7 | const char *const arm_triplets[] = { | 9 | const char *const arm_triplets[] = { |
8 | "arm-eabi-", | 10 | "arm-eabi-", |
9 | "arm-linux-androideabi-", | 11 | "arm-linux-androideabi-", |
diff --git a/tools/perf/arch/powerpc/util/dwarf-regs.c b/tools/perf/arch/powerpc/util/dwarf-regs.c index 41bdf9530d82..98ac87052a74 100644 --- a/tools/perf/arch/powerpc/util/dwarf-regs.c +++ b/tools/perf/arch/powerpc/util/dwarf-regs.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <dwarf-regs.h> | 15 | #include <dwarf-regs.h> |
16 | #include <linux/ptrace.h> | 16 | #include <linux/ptrace.h> |
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/stringify.h> | ||
18 | #include "util.h" | 19 | #include "util.h" |
19 | 20 | ||
20 | struct pt_regs_dwarfnum { | 21 | struct pt_regs_dwarfnum { |
@@ -24,10 +25,10 @@ struct pt_regs_dwarfnum { | |||
24 | }; | 25 | }; |
25 | 26 | ||
26 | #define REG_DWARFNUM_NAME(r, num) \ | 27 | #define REG_DWARFNUM_NAME(r, num) \ |
27 | {.name = STR(%)STR(r), .dwarfnum = num, \ | 28 | {.name = __stringify(%)__stringify(r), .dwarfnum = num, \ |
28 | .ptregs_offset = offsetof(struct pt_regs, r)} | 29 | .ptregs_offset = offsetof(struct pt_regs, r)} |
29 | #define GPR_DWARFNUM_NAME(num) \ | 30 | #define GPR_DWARFNUM_NAME(num) \ |
30 | {.name = STR(%gpr##num), .dwarfnum = num, \ | 31 | {.name = __stringify(%gpr##num), .dwarfnum = num, \ |
31 | .ptregs_offset = offsetof(struct pt_regs, gpr[num])} | 32 | .ptregs_offset = offsetof(struct pt_regs, gpr[num])} |
32 | #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0, .ptregs_offset = 0} | 33 | #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0, .ptregs_offset = 0} |
33 | 34 | ||
diff --git a/tools/perf/arch/powerpc/util/kvm-stat.c b/tools/perf/arch/powerpc/util/kvm-stat.c index 74eee30398f8..249723f0e6a9 100644 --- a/tools/perf/arch/powerpc/util/kvm-stat.c +++ b/tools/perf/arch/powerpc/util/kvm-stat.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <errno.h> | ||
1 | #include "util/kvm-stat.h" | 2 | #include "util/kvm-stat.h" |
2 | #include "util/parse-events.h" | 3 | #include "util/parse-events.h" |
3 | #include "util/debug.h" | 4 | #include "util/debug.h" |
diff --git a/tools/perf/arch/powerpc/util/perf_regs.c b/tools/perf/arch/powerpc/util/perf_regs.c index 4268f7762e25..f860dc411f69 100644 --- a/tools/perf/arch/powerpc/util/perf_regs.c +++ b/tools/perf/arch/powerpc/util/perf_regs.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <errno.h> | ||
1 | #include <string.h> | 2 | #include <string.h> |
2 | #include <regex.h> | 3 | #include <regex.h> |
3 | 4 | ||
diff --git a/tools/perf/arch/s390/util/kvm-stat.c b/tools/perf/arch/s390/util/kvm-stat.c index ed57df2e6d68..d233e2eb9592 100644 --- a/tools/perf/arch/s390/util/kvm-stat.c +++ b/tools/perf/arch/s390/util/kvm-stat.c | |||
@@ -9,6 +9,7 @@ | |||
9 | * as published by the Free Software Foundation. | 9 | * as published by the Free Software Foundation. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <errno.h> | ||
12 | #include "../../util/kvm-stat.h" | 13 | #include "../../util/kvm-stat.h" |
13 | #include <asm/sie.h> | 14 | #include <asm/sie.h> |
14 | 15 | ||
diff --git a/tools/perf/arch/x86/tests/intel-cqm.c b/tools/perf/arch/x86/tests/intel-cqm.c index 7f064eb37158..03c62eb0106b 100644 --- a/tools/perf/arch/x86/tests/intel-cqm.c +++ b/tools/perf/arch/x86/tests/intel-cqm.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include "arch-tests.h" | 7 | #include "arch-tests.h" |
8 | 8 | ||
9 | #include <sys/mman.h> | 9 | #include <sys/mman.h> |
10 | #include <errno.h> | ||
10 | #include <string.h> | 11 | #include <string.h> |
11 | 12 | ||
12 | static pid_t spawn(void) | 13 | static pid_t spawn(void) |
diff --git a/tools/perf/arch/x86/tests/perf-time-to-tsc.c b/tools/perf/arch/x86/tests/perf-time-to-tsc.c index 5c76cc83186a..e3ae9cff2b67 100644 --- a/tools/perf/arch/x86/tests/perf-time-to-tsc.c +++ b/tools/perf/arch/x86/tests/perf-time-to-tsc.c | |||
@@ -1,3 +1,5 @@ | |||
1 | #include <errno.h> | ||
2 | #include <inttypes.h> | ||
1 | #include <stdio.h> | 3 | #include <stdio.h> |
2 | #include <unistd.h> | 4 | #include <unistd.h> |
3 | #include <linux/types.h> | 5 | #include <linux/types.h> |
diff --git a/tools/perf/arch/x86/util/auxtrace.c b/tools/perf/arch/x86/util/auxtrace.c index cc1d865e31f1..6aa3f2a38321 100644 --- a/tools/perf/arch/x86/util/auxtrace.c +++ b/tools/perf/arch/x86/util/auxtrace.c | |||
@@ -13,6 +13,7 @@ | |||
13 | * | 13 | * |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <errno.h> | ||
16 | #include <stdbool.h> | 17 | #include <stdbool.h> |
17 | 18 | ||
18 | #include "../../util/header.h" | 19 | #include "../../util/header.h" |
diff --git a/tools/perf/arch/x86/util/intel-bts.c b/tools/perf/arch/x86/util/intel-bts.c index 5132775a044f..af2bce7a2cd6 100644 --- a/tools/perf/arch/x86/util/intel-bts.c +++ b/tools/perf/arch/x86/util/intel-bts.c | |||
@@ -13,6 +13,7 @@ | |||
13 | * | 13 | * |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <errno.h> | ||
16 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
17 | #include <linux/types.h> | 18 | #include <linux/types.h> |
18 | #include <linux/bitops.h> | 19 | #include <linux/bitops.h> |
diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c index 90fa2286edcf..f630de0206a1 100644 --- a/tools/perf/arch/x86/util/intel-pt.c +++ b/tools/perf/arch/x86/util/intel-pt.c | |||
@@ -13,6 +13,7 @@ | |||
13 | * | 13 | * |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <errno.h> | ||
16 | #include <stdbool.h> | 17 | #include <stdbool.h> |
17 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
18 | #include <linux/types.h> | 19 | #include <linux/types.h> |
diff --git a/tools/perf/arch/x86/util/kvm-stat.c b/tools/perf/arch/x86/util/kvm-stat.c index b63d4be655a2..bf817beca0a8 100644 --- a/tools/perf/arch/x86/util/kvm-stat.c +++ b/tools/perf/arch/x86/util/kvm-stat.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <errno.h> | ||
1 | #include "../../util/kvm-stat.h" | 2 | #include "../../util/kvm-stat.h" |
2 | #include <asm/svm.h> | 3 | #include <asm/svm.h> |
3 | #include <asm/vmx.h> | 4 | #include <asm/vmx.h> |
diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c index 3bf3548c5e2d..f95edebfb716 100644 --- a/tools/perf/arch/x86/util/perf_regs.c +++ b/tools/perf/arch/x86/util/perf_regs.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <errno.h> | ||
1 | #include <string.h> | 2 | #include <string.h> |
2 | #include <regex.h> | 3 | #include <regex.h> |
3 | 4 | ||
diff --git a/tools/perf/bench/mem-functions.c b/tools/perf/bench/mem-functions.c index d1dea33dcfcf..fbd732b54047 100644 --- a/tools/perf/bench/mem-functions.c +++ b/tools/perf/bench/mem-functions.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <subcmd/parse-options.h> | 12 | #include <subcmd/parse-options.h> |
13 | #include "../util/header.h" | 13 | #include "../util/header.h" |
14 | #include "../util/cloexec.h" | 14 | #include "../util/cloexec.h" |
15 | #include "../util/string2.h" | ||
15 | #include "bench.h" | 16 | #include "bench.h" |
16 | #include "mem-memcpy-arch.h" | 17 | #include "mem-memcpy-arch.h" |
17 | #include "mem-memset-arch.h" | 18 | #include "mem-memset-arch.h" |
diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c index 1fe43bd5a012..27de0c8c5c19 100644 --- a/tools/perf/bench/numa.c +++ b/tools/perf/bench/numa.c | |||
@@ -4,6 +4,7 @@ | |||
4 | * numa: Simulate NUMA-sensitive workload and measure their NUMA performance | 4 | * numa: Simulate NUMA-sensitive workload and measure their NUMA performance |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <inttypes.h> | ||
7 | /* For the CLR_() macros */ | 8 | /* For the CLR_() macros */ |
8 | #include <pthread.h> | 9 | #include <pthread.h> |
9 | 10 | ||
@@ -30,6 +31,7 @@ | |||
30 | #include <sys/wait.h> | 31 | #include <sys/wait.h> |
31 | #include <sys/prctl.h> | 32 | #include <sys/prctl.h> |
32 | #include <sys/types.h> | 33 | #include <sys/types.h> |
34 | #include <linux/kernel.h> | ||
33 | #include <linux/time64.h> | 35 | #include <linux/time64.h> |
34 | 36 | ||
35 | #include <numa.h> | 37 | #include <numa.h> |
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index b2b2722f6bb7..7a5dc7e5c577 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "util/block-range.h" | 33 | #include "util/block-range.h" |
34 | 34 | ||
35 | #include <dlfcn.h> | 35 | #include <dlfcn.h> |
36 | #include <errno.h> | ||
36 | #include <linux/bitmap.h> | 37 | #include <linux/bitmap.h> |
37 | 38 | ||
38 | struct perf_annotate { | 39 | struct perf_annotate { |
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index 94b55eee0d9b..034c3d4a7b27 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <sys/time.h> | 10 | #include <sys/time.h> |
11 | #include <time.h> | 11 | #include <time.h> |
12 | #include <dirent.h> | 12 | #include <dirent.h> |
13 | #include <errno.h> | ||
13 | #include <unistd.h> | 14 | #include <unistd.h> |
14 | #include "builtin.h" | 15 | #include "builtin.h" |
15 | #include "perf.h" | 16 | #include "perf.h" |
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index 26f4e608207f..fdaca16e0c74 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include "util/session.h" | 16 | #include "util/session.h" |
17 | #include "util/symbol.h" | 17 | #include "util/symbol.h" |
18 | #include "util/data.h" | 18 | #include "util/data.h" |
19 | #include <errno.h> | ||
19 | 20 | ||
20 | static int sysfs__fprintf_build_id(FILE *fp) | 21 | static int sysfs__fprintf_build_id(FILE *fp) |
21 | { | 22 | { |
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 70c2c773a2b8..a90c1260f49e 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * Dick Fowles <fowles@inreach.com> | 9 | * Dick Fowles <fowles@inreach.com> |
10 | * Joe Mario <jmario@redhat.com> | 10 | * Joe Mario <jmario@redhat.com> |
11 | */ | 11 | */ |
12 | #include <errno.h> | ||
13 | #include <inttypes.h> | ||
12 | #include <linux/compiler.h> | 14 | #include <linux/compiler.h> |
13 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
14 | #include <linux/stringify.h> | 16 | #include <linux/stringify.h> |
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index cd2605d86984..eec5df80f5a3 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
@@ -19,6 +19,8 @@ | |||
19 | #include "util/data.h" | 19 | #include "util/data.h" |
20 | #include "util/config.h" | 20 | #include "util/config.h" |
21 | 21 | ||
22 | #include <errno.h> | ||
23 | #include <inttypes.h> | ||
22 | #include <stdlib.h> | 24 | #include <stdlib.h> |
23 | #include <math.h> | 25 | #include <math.h> |
24 | 26 | ||
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index f80fb60b00b0..0f34ab7a9ec1 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c | |||
@@ -9,12 +9,14 @@ | |||
9 | #include "builtin.h" | 9 | #include "builtin.h" |
10 | #include "perf.h" | 10 | #include "perf.h" |
11 | 11 | ||
12 | #include <errno.h> | ||
12 | #include <unistd.h> | 13 | #include <unistd.h> |
13 | #include <signal.h> | 14 | #include <signal.h> |
14 | #include <fcntl.h> | 15 | #include <fcntl.h> |
15 | 16 | ||
16 | #include "debug.h" | 17 | #include "debug.h" |
17 | #include <subcmd/parse-options.h> | 18 | #include <subcmd/parse-options.h> |
19 | #include <api/fs/tracing_path.h> | ||
18 | #include "evlist.h" | 20 | #include "evlist.h" |
19 | #include "target.h" | 21 | #include "target.h" |
20 | #include "cpumap.h" | 22 | #include "cpumap.h" |
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 1eec96a0fa67..7bde2f59dac2 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c | |||
@@ -12,16 +12,18 @@ | |||
12 | #include <subcmd/run-command.h> | 12 | #include <subcmd/run-command.h> |
13 | #include <subcmd/help.h> | 13 | #include <subcmd/help.h> |
14 | #include "util/debug.h" | 14 | #include "util/debug.h" |
15 | #include <linux/kernel.h> | ||
16 | #include <errno.h> | ||
15 | 17 | ||
16 | static struct man_viewer_list { | 18 | static struct man_viewer_list { |
17 | struct man_viewer_list *next; | 19 | struct man_viewer_list *next; |
18 | char name[FLEX_ARRAY]; | 20 | char name[0]; |
19 | } *man_viewer_list; | 21 | } *man_viewer_list; |
20 | 22 | ||
21 | static struct man_viewer_info_list { | 23 | static struct man_viewer_info_list { |
22 | struct man_viewer_info_list *next; | 24 | struct man_viewer_info_list *next; |
23 | const char *info; | 25 | const char *info; |
24 | char name[FLEX_ARRAY]; | 26 | char name[0]; |
25 | } *man_viewer_info_list; | 27 | } *man_viewer_info_list; |
26 | 28 | ||
27 | enum help_format { | 29 | enum help_format { |
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 65e1c026a2f0..b102ee702aa1 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <subcmd/parse-options.h> | 22 | #include <subcmd/parse-options.h> |
23 | 23 | ||
24 | #include <linux/list.h> | 24 | #include <linux/list.h> |
25 | #include <errno.h> | ||
25 | 26 | ||
26 | struct perf_inject { | 27 | struct perf_inject { |
27 | struct perf_tool tool; | 28 | struct perf_tool tool; |
diff --git a/tools/perf/builtin-kallsyms.c b/tools/perf/builtin-kallsyms.c index 8ff38c4eb2c0..bcfb363112d3 100644 --- a/tools/perf/builtin-kallsyms.c +++ b/tools/perf/builtin-kallsyms.c | |||
@@ -7,6 +7,7 @@ | |||
7 | * | 7 | * |
8 | * Released under the GPL v2. (and only v2, not any later version) | 8 | * Released under the GPL v2. (and only v2, not any later version) |
9 | */ | 9 | */ |
10 | #include <inttypes.h> | ||
10 | #include "builtin.h" | 11 | #include "builtin.h" |
11 | #include <linux/compiler.h> | 12 | #include <linux/compiler.h> |
12 | #include <subcmd/parse-options.h> | 13 | #include <subcmd/parse-options.h> |
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 515587825af4..9409c9464667 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c | |||
@@ -20,11 +20,16 @@ | |||
20 | 20 | ||
21 | #include "util/debug.h" | 21 | #include "util/debug.h" |
22 | 22 | ||
23 | #include <linux/kernel.h> | ||
23 | #include <linux/rbtree.h> | 24 | #include <linux/rbtree.h> |
24 | #include <linux/string.h> | 25 | #include <linux/string.h> |
26 | #include <errno.h> | ||
27 | #include <inttypes.h> | ||
25 | #include <locale.h> | 28 | #include <locale.h> |
26 | #include <regex.h> | 29 | #include <regex.h> |
27 | 30 | ||
31 | #include "sane_ctype.h" | ||
32 | |||
28 | static int kmem_slab; | 33 | static int kmem_slab; |
29 | static int kmem_page; | 34 | static int kmem_page; |
30 | 35 | ||
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 38b409173693..4002277475cf 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include "util/evsel.h" | 4 | #include "util/evsel.h" |
5 | #include "util/evlist.h" | 5 | #include "util/evlist.h" |
6 | #include "util/term.h" | ||
6 | #include "util/util.h" | 7 | #include "util/util.h" |
7 | #include "util/cache.h" | 8 | #include "util/cache.h" |
8 | #include "util/symbol.h" | 9 | #include "util/symbol.h" |
@@ -24,7 +25,10 @@ | |||
24 | #include <sys/timerfd.h> | 25 | #include <sys/timerfd.h> |
25 | #endif | 26 | #endif |
26 | 27 | ||
28 | #include <linux/kernel.h> | ||
27 | #include <linux/time64.h> | 29 | #include <linux/time64.h> |
30 | #include <errno.h> | ||
31 | #include <inttypes.h> | ||
28 | #include <termios.h> | 32 | #include <termios.h> |
29 | #include <semaphore.h> | 33 | #include <semaphore.h> |
30 | #include <pthread.h> | 34 | #include <pthread.h> |
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index b686fb6759da..ff98652484a7 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c | |||
@@ -1,3 +1,5 @@ | |||
1 | #include <errno.h> | ||
2 | #include <inttypes.h> | ||
1 | #include "builtin.h" | 3 | #include "builtin.h" |
2 | #include "perf.h" | 4 | #include "perf.h" |
3 | 5 | ||
@@ -26,6 +28,7 @@ | |||
26 | 28 | ||
27 | #include <linux/list.h> | 29 | #include <linux/list.h> |
28 | #include <linux/hash.h> | 30 | #include <linux/hash.h> |
31 | #include <linux/kernel.h> | ||
29 | 32 | ||
30 | static struct perf_session *session; | 33 | static struct perf_session *session; |
31 | 34 | ||
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index 643f4faac0d0..1ebc67390898 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <inttypes.h> | ||
1 | #include "builtin.h" | 2 | #include "builtin.h" |
2 | #include "perf.h" | 3 | #include "perf.h" |
3 | 4 | ||
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 3191ab063852..70340ff2008d 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -40,6 +40,8 @@ | |||
40 | #include "util/perf-hooks.h" | 40 | #include "util/perf-hooks.h" |
41 | #include "asm/bug.h" | 41 | #include "asm/bug.h" |
42 | 42 | ||
43 | #include <errno.h> | ||
44 | #include <inttypes.h> | ||
43 | #include <unistd.h> | 45 | #include <unistd.h> |
44 | #include <sched.h> | 46 | #include <sched.h> |
45 | #include <sys/mman.h> | 47 | #include <sys/mman.h> |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index c18158b83eb1..5bbd4b2ef6d2 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/rbtree.h> | 16 | #include <linux/rbtree.h> |
17 | #include "util/symbol.h" | 17 | #include "util/symbol.h" |
18 | #include "util/callchain.h" | 18 | #include "util/callchain.h" |
19 | #include "util/strlist.h" | ||
20 | #include "util/values.h" | 19 | #include "util/values.h" |
21 | 20 | ||
22 | #include "perf.h" | 21 | #include "perf.h" |
@@ -40,6 +39,9 @@ | |||
40 | #include "util/auxtrace.h" | 39 | #include "util/auxtrace.h" |
41 | 40 | ||
42 | #include <dlfcn.h> | 41 | #include <dlfcn.h> |
42 | #include <errno.h> | ||
43 | #include <inttypes.h> | ||
44 | #include <regex.h> | ||
43 | #include <linux/bitmap.h> | 45 | #include <linux/bitmap.h> |
44 | #include <linux/stringify.h> | 46 | #include <linux/stringify.h> |
45 | 47 | ||
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 79833e226789..39996c53995a 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -22,16 +22,21 @@ | |||
22 | 22 | ||
23 | #include "util/debug.h" | 23 | #include "util/debug.h" |
24 | 24 | ||
25 | #include <linux/kernel.h> | ||
25 | #include <linux/log2.h> | 26 | #include <linux/log2.h> |
26 | #include <sys/prctl.h> | 27 | #include <sys/prctl.h> |
27 | #include <sys/resource.h> | 28 | #include <sys/resource.h> |
29 | #include <inttypes.h> | ||
28 | 30 | ||
31 | #include <errno.h> | ||
29 | #include <semaphore.h> | 32 | #include <semaphore.h> |
30 | #include <pthread.h> | 33 | #include <pthread.h> |
31 | #include <math.h> | 34 | #include <math.h> |
32 | #include <api/fs/fs.h> | 35 | #include <api/fs/fs.h> |
33 | #include <linux/time64.h> | 36 | #include <linux/time64.h> |
34 | 37 | ||
38 | #include "sane_ctype.h" | ||
39 | |||
35 | #define PR_SET_NAME 15 /* Set process name */ | 40 | #define PR_SET_NAME 15 /* Set process name */ |
36 | #define MAX_CPUS 4096 | 41 | #define MAX_CPUS 4096 |
37 | #define COMM_LEN 20 | 42 | #define COMM_LEN 20 |
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 2dab70fba2ba..fe1dcd4f2c6d 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -21,14 +21,22 @@ | |||
21 | #include "util/cpumap.h" | 21 | #include "util/cpumap.h" |
22 | #include "util/thread_map.h" | 22 | #include "util/thread_map.h" |
23 | #include "util/stat.h" | 23 | #include "util/stat.h" |
24 | #include "util/string2.h" | ||
24 | #include "util/thread-stack.h" | 25 | #include "util/thread-stack.h" |
25 | #include "util/time-utils.h" | 26 | #include "util/time-utils.h" |
27 | #include "print_binary.h" | ||
26 | #include <linux/bitmap.h> | 28 | #include <linux/bitmap.h> |
29 | #include <linux/kernel.h> | ||
27 | #include <linux/stringify.h> | 30 | #include <linux/stringify.h> |
28 | #include <linux/time64.h> | 31 | #include <linux/time64.h> |
29 | #include "asm/bug.h" | 32 | #include "asm/bug.h" |
30 | #include "util/mem-events.h" | 33 | #include "util/mem-events.h" |
31 | #include "util/dump-insn.h" | 34 | #include "util/dump-insn.h" |
35 | #include <dirent.h> | ||
36 | #include <errno.h> | ||
37 | #include <inttypes.h> | ||
38 | |||
39 | #include "sane_ctype.h" | ||
32 | 40 | ||
33 | static char const *script_name; | 41 | static char const *script_name; |
34 | static char const *generate_script_lang; | 42 | static char const *generate_script_lang; |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 610225b6326e..be2cd537c537 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -64,15 +64,20 @@ | |||
64 | #include "util/session.h" | 64 | #include "util/session.h" |
65 | #include "util/tool.h" | 65 | #include "util/tool.h" |
66 | #include "util/group.h" | 66 | #include "util/group.h" |
67 | #include "util/string2.h" | ||
67 | #include "asm/bug.h" | 68 | #include "asm/bug.h" |
68 | 69 | ||
69 | #include <linux/time64.h> | 70 | #include <linux/time64.h> |
70 | #include <api/fs/fs.h> | 71 | #include <api/fs/fs.h> |
72 | #include <errno.h> | ||
71 | #include <stdlib.h> | 73 | #include <stdlib.h> |
72 | #include <sys/prctl.h> | 74 | #include <sys/prctl.h> |
75 | #include <inttypes.h> | ||
73 | #include <locale.h> | 76 | #include <locale.h> |
74 | #include <math.h> | 77 | #include <math.h> |
75 | 78 | ||
79 | #include "sane_ctype.h" | ||
80 | |||
76 | #define DEFAULT_SEPARATOR " " | 81 | #define DEFAULT_SEPARATOR " " |
77 | #define CNTR_NOT_SUPPORTED "<not supported>" | 82 | #define CNTR_NOT_SUPPORTED "<not supported>" |
78 | #define CNTR_NOT_COUNTED "<not counted>" | 83 | #define CNTR_NOT_COUNTED "<not counted>" |
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index fafdb44b8bcb..38e2c437b7b3 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c | |||
@@ -12,6 +12,8 @@ | |||
12 | * of the License. | 12 | * of the License. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <errno.h> | ||
16 | #include <inttypes.h> | ||
15 | #include <traceevent/event-parse.h> | 17 | #include <traceevent/event-parse.h> |
16 | 18 | ||
17 | #include "builtin.h" | 19 | #include "builtin.h" |
@@ -23,11 +25,11 @@ | |||
23 | #include "util/cache.h" | 25 | #include "util/cache.h" |
24 | #include "util/evlist.h" | 26 | #include "util/evlist.h" |
25 | #include "util/evsel.h" | 27 | #include "util/evsel.h" |
28 | #include <linux/kernel.h> | ||
26 | #include <linux/rbtree.h> | 29 | #include <linux/rbtree.h> |
27 | #include <linux/time64.h> | 30 | #include <linux/time64.h> |
28 | #include "util/symbol.h" | 31 | #include "util/symbol.h" |
29 | #include "util/callchain.h" | 32 | #include "util/callchain.h" |
30 | #include "util/strlist.h" | ||
31 | 33 | ||
32 | #include "perf.h" | 34 | #include "perf.h" |
33 | #include "util/header.h" | 35 | #include "util/header.h" |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index a0c97c70ec81..47984a838b73 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include "util/cpumap.h" | 40 | #include "util/cpumap.h" |
41 | #include "util/xyarray.h" | 41 | #include "util/xyarray.h" |
42 | #include "util/sort.h" | 42 | #include "util/sort.h" |
43 | #include "util/term.h" | ||
43 | #include "util/intlist.h" | 44 | #include "util/intlist.h" |
44 | #include "util/parse-branch-options.h" | 45 | #include "util/parse-branch-options.h" |
45 | #include "arch/common.h" | 46 | #include "arch/common.h" |
@@ -72,6 +73,8 @@ | |||
72 | #include <linux/time64.h> | 73 | #include <linux/time64.h> |
73 | #include <linux/types.h> | 74 | #include <linux/types.h> |
74 | 75 | ||
76 | #include "sane_ctype.h" | ||
77 | |||
75 | static volatile int done; | 78 | static volatile int done; |
76 | 79 | ||
77 | #define HEADER_LINE_NR 5 | 80 | #define HEADER_LINE_NR 5 |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index fce278d5fada..d1c8cdc6788b 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "util/evlist.h" | 24 | #include "util/evlist.h" |
25 | #include <subcmd/exec-cmd.h> | 25 | #include <subcmd/exec-cmd.h> |
26 | #include "util/machine.h" | 26 | #include "util/machine.h" |
27 | #include "util/path.h" | ||
27 | #include "util/session.h" | 28 | #include "util/session.h" |
28 | #include "util/thread.h" | 29 | #include "util/thread.h" |
29 | #include <subcmd/parse-options.h> | 30 | #include <subcmd/parse-options.h> |
@@ -36,19 +37,26 @@ | |||
36 | #include "util/parse-events.h" | 37 | #include "util/parse-events.h" |
37 | #include "util/bpf-loader.h" | 38 | #include "util/bpf-loader.h" |
38 | #include "callchain.h" | 39 | #include "callchain.h" |
40 | #include "print_binary.h" | ||
41 | #include "string2.h" | ||
39 | #include "syscalltbl.h" | 42 | #include "syscalltbl.h" |
40 | #include "rb_resort.h" | 43 | #include "rb_resort.h" |
41 | 44 | ||
45 | #include <errno.h> | ||
46 | #include <inttypes.h> | ||
42 | #include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */ | 47 | #include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */ |
43 | #include <stdlib.h> | 48 | #include <stdlib.h> |
44 | #include <string.h> | 49 | #include <string.h> |
45 | #include <linux/err.h> | 50 | #include <linux/err.h> |
46 | #include <linux/filter.h> | 51 | #include <linux/filter.h> |
47 | #include <linux/audit.h> | 52 | #include <linux/audit.h> |
53 | #include <linux/kernel.h> | ||
48 | #include <linux/random.h> | 54 | #include <linux/random.h> |
49 | #include <linux/stringify.h> | 55 | #include <linux/stringify.h> |
50 | #include <linux/time64.h> | 56 | #include <linux/time64.h> |
51 | 57 | ||
58 | #include "sane_ctype.h" | ||
59 | |||
52 | #ifndef O_CLOEXEC | 60 | #ifndef O_CLOEXEC |
53 | # define O_CLOEXEC 02000000 | 61 | # define O_CLOEXEC 02000000 |
54 | #endif | 62 | #endif |
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 9dc346f2b255..9ccccb0fbd8f 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
@@ -19,9 +19,11 @@ | |||
19 | #include "util/debug.h" | 19 | #include "util/debug.h" |
20 | #include <api/fs/fs.h> | 20 | #include <api/fs/fs.h> |
21 | #include <api/fs/tracing_path.h> | 21 | #include <api/fs/tracing_path.h> |
22 | #include <errno.h> | ||
22 | #include <pthread.h> | 23 | #include <pthread.h> |
23 | #include <stdlib.h> | 24 | #include <stdlib.h> |
24 | #include <time.h> | 25 | #include <time.h> |
26 | #include <linux/kernel.h> | ||
25 | 27 | ||
26 | const char perf_usage_string[] = | 28 | const char perf_usage_string[] = |
27 | "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]"; | 29 | "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]"; |
@@ -327,16 +329,6 @@ static void handle_internal_command(int argc, const char **argv) | |||
327 | { | 329 | { |
328 | const char *cmd = argv[0]; | 330 | const char *cmd = argv[0]; |
329 | unsigned int i; | 331 | unsigned int i; |
330 | static const char ext[] = STRIP_EXTENSION; | ||
331 | |||
332 | if (sizeof(ext) > 1) { | ||
333 | i = strlen(argv[0]) - strlen(ext); | ||
334 | if (i > 0 && !strcmp(argv[0] + i, ext)) { | ||
335 | char *argv0 = strdup(argv[0]); | ||
336 | argv[0] = cmd = argv0; | ||
337 | argv0[i] = '\0'; | ||
338 | } | ||
339 | } | ||
340 | 332 | ||
341 | /* Turn "perf cmd --help" into "perf help cmd" */ | 333 | /* Turn "perf cmd --help" into "perf help cmd" */ |
342 | if (argc > 1 && !strcmp(argv[1], "--help")) { | 334 | if (argc > 1 && !strcmp(argv[1], "--help")) { |
diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c index 88dc51f4c27b..ba87cd529bfc 100644 --- a/tools/perf/tests/attr.c +++ b/tools/perf/tests/attr.c | |||
@@ -18,6 +18,8 @@ | |||
18 | * permissions. All the event text files are stored there. | 18 | * permissions. All the event text files are stored there. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <errno.h> | ||
22 | #include <inttypes.h> | ||
21 | #include <stdlib.h> | 23 | #include <stdlib.h> |
22 | #include <stdio.h> | 24 | #include <stdio.h> |
23 | #include <linux/types.h> | 25 | #include <linux/types.h> |
diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c index 42e892b1e979..50f6d7afee58 100644 --- a/tools/perf/tests/backward-ring-buffer.c +++ b/tools/perf/tests/backward-ring-buffer.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <sys/prctl.h> | 8 | #include <sys/prctl.h> |
9 | #include "tests.h" | 9 | #include "tests.h" |
10 | #include "debug.h" | 10 | #include "debug.h" |
11 | #include <errno.h> | ||
11 | 12 | ||
12 | #define NR_ITERS 111 | 13 | #define NR_ITERS 111 |
13 | 14 | ||
diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c index 1a04fe77487d..b78fbd611a7c 100644 --- a/tools/perf/tests/bpf.c +++ b/tools/perf/tests/bpf.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <errno.h> | ||
1 | #include <stdio.h> | 2 | #include <stdio.h> |
2 | #include <sys/epoll.h> | 3 | #include <sys/epoll.h> |
3 | #include <util/util.h> | 4 | #include <util/util.h> |
@@ -5,6 +6,7 @@ | |||
5 | #include <util/evlist.h> | 6 | #include <util/evlist.h> |
6 | #include <linux/bpf.h> | 7 | #include <linux/bpf.h> |
7 | #include <linux/filter.h> | 8 | #include <linux/filter.h> |
9 | #include <linux/kernel.h> | ||
8 | #include <api/fs/fs.h> | 10 | #include <api/fs/fs.h> |
9 | #include <bpf/bpf.h> | 11 | #include <bpf/bpf.h> |
10 | #include "tests.h" | 12 | #include "tests.h" |
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index e6d7876c94c2..552fd9aca08d 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Builtin regression testing command: ever growing number of sanity tests | 4 | * Builtin regression testing command: ever growing number of sanity tests |
5 | */ | 5 | */ |
6 | #include <errno.h> | ||
6 | #include <unistd.h> | 7 | #include <unistd.h> |
7 | #include <string.h> | 8 | #include <string.h> |
8 | #include "builtin.h" | 9 | #include "builtin.h" |
@@ -13,6 +14,7 @@ | |||
13 | #include "color.h" | 14 | #include "color.h" |
14 | #include <subcmd/parse-options.h> | 15 | #include <subcmd/parse-options.h> |
15 | #include "symbol.h" | 16 | #include "symbol.h" |
17 | #include <linux/kernel.h> | ||
16 | 18 | ||
17 | static bool dont_fork; | 19 | static bool dont_fork; |
18 | 20 | ||
diff --git a/tools/perf/tests/clang.c b/tools/perf/tests/clang.c index f853e242a86c..c5bb2203f5a9 100644 --- a/tools/perf/tests/clang.c +++ b/tools/perf/tests/clang.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include "debug.h" | 2 | #include "debug.h" |
3 | #include "util.h" | 3 | #include "util.h" |
4 | #include "c++/clang-c.h" | 4 | #include "c++/clang-c.h" |
5 | #include <linux/kernel.h> | ||
5 | 6 | ||
6 | static struct { | 7 | static struct { |
7 | int (*func)(void); | 8 | int (*func)(void); |
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index d1f693041324..3a8bf1565493 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c | |||
@@ -1,8 +1,10 @@ | |||
1 | #include <errno.h> | ||
2 | #include <linux/kernel.h> | ||
1 | #include <linux/types.h> | 3 | #include <linux/types.h> |
4 | #include <inttypes.h> | ||
2 | #include <stdlib.h> | 5 | #include <stdlib.h> |
3 | #include <unistd.h> | 6 | #include <unistd.h> |
4 | #include <stdio.h> | 7 | #include <stdio.h> |
5 | #include <ctype.h> | ||
6 | #include <string.h> | 8 | #include <string.h> |
7 | 9 | ||
8 | #include "parse-events.h" | 10 | #include "parse-events.h" |
@@ -16,6 +18,8 @@ | |||
16 | 18 | ||
17 | #include "tests.h" | 19 | #include "tests.h" |
18 | 20 | ||
21 | #include "sane_ctype.h" | ||
22 | |||
19 | #define BUFSZ 1024 | 23 | #define BUFSZ 1024 |
20 | #define READLEN 128 | 24 | #define READLEN 128 |
21 | 25 | ||
diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c index 13725e09ba22..8f08df5861cb 100644 --- a/tools/perf/tests/dso-data.c +++ b/tools/perf/tests/dso-data.c | |||
@@ -1,4 +1,6 @@ | |||
1 | #include <dirent.h> | ||
1 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <linux/kernel.h> | ||
2 | #include <linux/types.h> | 4 | #include <linux/types.h> |
3 | #include <sys/stat.h> | 5 | #include <sys/stat.h> |
4 | #include <fcntl.h> | 6 | #include <fcntl.h> |
diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c index 1046491de4b2..dfe5c89e2049 100644 --- a/tools/perf/tests/dwarf-unwind.c +++ b/tools/perf/tests/dwarf-unwind.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include <linux/compiler.h> | 1 | #include <linux/compiler.h> |
2 | #include <linux/types.h> | 2 | #include <linux/types.h> |
3 | #include <inttypes.h> | ||
3 | #include <unistd.h> | 4 | #include <unistd.h> |
4 | #include "tests.h" | 5 | #include "tests.h" |
5 | #include "debug.h" | 6 | #include "debug.h" |
diff --git a/tools/perf/tests/event-times.c b/tools/perf/tests/event-times.c index 19ef77bd6eb4..4683514751d6 100644 --- a/tools/perf/tests/event-times.c +++ b/tools/perf/tests/event-times.c | |||
@@ -1,4 +1,6 @@ | |||
1 | #include <linux/compiler.h> | 1 | #include <linux/compiler.h> |
2 | #include <errno.h> | ||
3 | #include <inttypes.h> | ||
2 | #include <string.h> | 4 | #include <string.h> |
3 | #include "tests.h" | 5 | #include "tests.h" |
4 | #include "evlist.h" | 6 | #include "evlist.h" |
diff --git a/tools/perf/tests/evsel-roundtrip-name.c b/tools/perf/tests/evsel-roundtrip-name.c index 60926a1f6fd7..d2bea6f780f8 100644 --- a/tools/perf/tests/evsel-roundtrip-name.c +++ b/tools/perf/tests/evsel-roundtrip-name.c | |||
@@ -3,6 +3,8 @@ | |||
3 | #include "parse-events.h" | 3 | #include "parse-events.h" |
4 | #include "tests.h" | 4 | #include "tests.h" |
5 | #include "debug.h" | 5 | #include "debug.h" |
6 | #include <errno.h> | ||
7 | #include <linux/kernel.h> | ||
6 | 8 | ||
7 | static int perf_evsel__roundtrip_cache_name_test(void) | 9 | static int perf_evsel__roundtrip_cache_name_test(void) |
8 | { | 10 | { |
diff --git a/tools/perf/tests/hists_common.c b/tools/perf/tests/hists_common.c index 6b21746d6eec..00b8dc50f3db 100644 --- a/tools/perf/tests/hists_common.c +++ b/tools/perf/tests/hists_common.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <inttypes.h> | ||
1 | #include "perf.h" | 2 | #include "perf.h" |
2 | #include "util/debug.h" | 3 | #include "util/debug.h" |
3 | #include "util/symbol.h" | 4 | #include "util/symbol.h" |
@@ -7,6 +8,7 @@ | |||
7 | #include "util/machine.h" | 8 | #include "util/machine.h" |
8 | #include "util/thread.h" | 9 | #include "util/thread.h" |
9 | #include "tests/hists_common.h" | 10 | #include "tests/hists_common.h" |
11 | #include <linux/kernel.h> | ||
10 | 12 | ||
11 | static struct { | 13 | static struct { |
12 | u32 pid; | 14 | u32 pid; |
diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c index 9fd54b79a788..70918b986568 100644 --- a/tools/perf/tests/hists_cumulate.c +++ b/tools/perf/tests/hists_cumulate.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "util/parse-events.h" | 9 | #include "util/parse-events.h" |
10 | #include "tests/tests.h" | 10 | #include "tests/tests.h" |
11 | #include "tests/hists_common.h" | 11 | #include "tests/hists_common.h" |
12 | #include <linux/kernel.h> | ||
12 | 13 | ||
13 | struct sample { | 14 | struct sample { |
14 | u32 pid; | 15 | u32 pid; |
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c index 62efb14f3a5a..f171b2da4899 100644 --- a/tools/perf/tests/hists_filter.c +++ b/tools/perf/tests/hists_filter.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "util/parse-events.h" | 9 | #include "util/parse-events.h" |
10 | #include "tests/tests.h" | 10 | #include "tests/tests.h" |
11 | #include "tests/hists_common.h" | 11 | #include "tests/hists_common.h" |
12 | #include <linux/kernel.h> | ||
12 | 13 | ||
13 | struct sample { | 14 | struct sample { |
14 | u32 pid; | 15 | u32 pid; |
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c index eddc7407ff8a..a26cbb79e988 100644 --- a/tools/perf/tests/hists_link.c +++ b/tools/perf/tests/hists_link.c | |||
@@ -9,6 +9,8 @@ | |||
9 | #include "thread.h" | 9 | #include "thread.h" |
10 | #include "parse-events.h" | 10 | #include "parse-events.h" |
11 | #include "hists_common.h" | 11 | #include "hists_common.h" |
12 | #include <errno.h> | ||
13 | #include <linux/kernel.h> | ||
12 | 14 | ||
13 | struct sample { | 15 | struct sample { |
14 | u32 pid; | 16 | u32 pid; |
diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c index 63c5efaba1b5..cdf0dde5fe97 100644 --- a/tools/perf/tests/hists_output.c +++ b/tools/perf/tests/hists_output.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "util/parse-events.h" | 9 | #include "util/parse-events.h" |
10 | #include "tests/tests.h" | 10 | #include "tests/tests.h" |
11 | #include "tests/hists_common.h" | 11 | #include "tests/hists_common.h" |
12 | #include <linux/kernel.h> | ||
12 | 13 | ||
13 | struct sample { | 14 | struct sample { |
14 | u32 cpu; | 15 | u32 cpu; |
diff --git a/tools/perf/tests/is_printable_array.c b/tools/perf/tests/is_printable_array.c index 42e13393e502..a5192f6a20d7 100644 --- a/tools/perf/tests/is_printable_array.c +++ b/tools/perf/tests/is_printable_array.c | |||
@@ -1,7 +1,8 @@ | |||
1 | #include <linux/compiler.h> | 1 | #include <linux/compiler.h> |
2 | #include <linux/kernel.h> | ||
2 | #include "tests.h" | 3 | #include "tests.h" |
3 | #include "debug.h" | 4 | #include "debug.h" |
4 | #include "util.h" | 5 | #include "print_binary.h" |
5 | 6 | ||
6 | int test__is_printable_array(int subtest __maybe_unused) | 7 | int test__is_printable_array(int subtest __maybe_unused) |
7 | { | 8 | { |
diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index 634bce9caebd..15c770856aac 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c | |||
@@ -1,3 +1,5 @@ | |||
1 | #include <errno.h> | ||
2 | #include <inttypes.h> | ||
1 | /* For the CLR_() macros */ | 3 | /* For the CLR_() macros */ |
2 | #include <pthread.h> | 4 | #include <pthread.h> |
3 | 5 | ||
@@ -7,6 +9,7 @@ | |||
7 | #include "cpumap.h" | 9 | #include "cpumap.h" |
8 | #include "tests.h" | 10 | #include "tests.h" |
9 | #include <linux/err.h> | 11 | #include <linux/err.h> |
12 | #include <linux/kernel.h> | ||
10 | 13 | ||
11 | /* | 14 | /* |
12 | * This test will generate random numbers of calls to some getpid syscalls, | 15 | * This test will generate random numbers of calls to some getpid syscalls, |
diff --git a/tools/perf/tests/mmap-thread-lookup.c b/tools/perf/tests/mmap-thread-lookup.c index 0c5ce44f723f..6ea4d8a5d26b 100644 --- a/tools/perf/tests/mmap-thread-lookup.c +++ b/tools/perf/tests/mmap-thread-lookup.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <inttypes.h> | ||
1 | #include <unistd.h> | 2 | #include <unistd.h> |
2 | #include <sys/syscall.h> | 3 | #include <sys/syscall.h> |
3 | #include <sys/types.h> | 4 | #include <sys/types.h> |
@@ -11,6 +12,7 @@ | |||
11 | #include "thread_map.h" | 12 | #include "thread_map.h" |
12 | #include "symbol.h" | 13 | #include "symbol.h" |
13 | #include "thread.h" | 14 | #include "thread.h" |
15 | #include "util.h" | ||
14 | 16 | ||
15 | #define THREADS 4 | 17 | #define THREADS 4 |
16 | 18 | ||
diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c index c8d9592eb142..1a74dd9fd067 100644 --- a/tools/perf/tests/openat-syscall-all-cpus.c +++ b/tools/perf/tests/openat-syscall-all-cpus.c | |||
@@ -1,8 +1,14 @@ | |||
1 | #include <errno.h> | ||
2 | #include <inttypes.h> | ||
1 | /* For the CPU_* macros */ | 3 | /* For the CPU_* macros */ |
2 | #include <pthread.h> | 4 | #include <pthread.h> |
3 | 5 | ||
6 | #include <sys/types.h> | ||
7 | #include <sys/stat.h> | ||
8 | #include <fcntl.h> | ||
4 | #include <api/fs/fs.h> | 9 | #include <api/fs/fs.h> |
5 | #include <linux/err.h> | 10 | #include <linux/err.h> |
11 | #include <api/fs/tracing_path.h> | ||
6 | #include "evsel.h" | 12 | #include "evsel.h" |
7 | #include "tests.h" | 13 | #include "tests.h" |
8 | #include "thread_map.h" | 14 | #include "thread_map.h" |
diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c index f52239fed361..9788fac91095 100644 --- a/tools/perf/tests/openat-syscall-tp-fields.c +++ b/tools/perf/tests/openat-syscall-tp-fields.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include "thread_map.h" | 5 | #include "thread_map.h" |
6 | #include "tests.h" | 6 | #include "tests.h" |
7 | #include "debug.h" | 7 | #include "debug.h" |
8 | #include <errno.h> | ||
8 | 9 | ||
9 | #ifndef O_DIRECTORY | 10 | #ifndef O_DIRECTORY |
10 | #define O_DIRECTORY 00200000 | 11 | #define O_DIRECTORY 00200000 |
diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c index d7414128d7fe..e44506e21ee7 100644 --- a/tools/perf/tests/openat-syscall.c +++ b/tools/perf/tests/openat-syscall.c | |||
@@ -1,5 +1,10 @@ | |||
1 | #include <errno.h> | ||
2 | #include <inttypes.h> | ||
1 | #include <api/fs/tracing_path.h> | 3 | #include <api/fs/tracing_path.h> |
2 | #include <linux/err.h> | 4 | #include <linux/err.h> |
5 | #include <sys/types.h> | ||
6 | #include <sys/stat.h> | ||
7 | #include <fcntl.h> | ||
3 | #include "thread_map.h" | 8 | #include "thread_map.h" |
4 | #include "evsel.h" | 9 | #include "evsel.h" |
5 | #include "debug.h" | 10 | #include "debug.h" |
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index 1dc838014422..981d2bf9914f 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | #include "parse-events.h" | 1 | #include "parse-events.h" |
3 | #include "evsel.h" | 2 | #include "evsel.h" |
4 | #include "evlist.h" | 3 | #include "evlist.h" |
@@ -6,8 +5,12 @@ | |||
6 | #include "tests.h" | 5 | #include "tests.h" |
7 | #include "debug.h" | 6 | #include "debug.h" |
8 | #include "util.h" | 7 | #include "util.h" |
8 | #include <dirent.h> | ||
9 | #include <errno.h> | ||
10 | #include <linux/kernel.h> | ||
9 | #include <linux/hw_breakpoint.h> | 11 | #include <linux/hw_breakpoint.h> |
10 | #include <api/fs/fs.h> | 12 | #include <api/fs/fs.h> |
13 | #include <api/fs/tracing_path.h> | ||
11 | 14 | ||
12 | #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \ | 15 | #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \ |
13 | PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) | 16 | PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) |
diff --git a/tools/perf/tests/parse-no-sample-id-all.c b/tools/perf/tests/parse-no-sample-id-all.c index 65dcf48a92fb..c6207db09f12 100644 --- a/tools/perf/tests/parse-no-sample-id-all.c +++ b/tools/perf/tests/parse-no-sample-id-all.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <linux/kernel.h> | ||
1 | #include <linux/types.h> | 2 | #include <linux/types.h> |
2 | #include <stddef.h> | 3 | #include <stddef.h> |
3 | 4 | ||
diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c index 87893f3ba5f1..d37cd9588cc0 100644 --- a/tools/perf/tests/perf-record.c +++ b/tools/perf/tests/perf-record.c | |||
@@ -1,3 +1,5 @@ | |||
1 | #include <errno.h> | ||
2 | #include <inttypes.h> | ||
1 | /* For the CLR_() macros */ | 3 | /* For the CLR_() macros */ |
2 | #include <pthread.h> | 4 | #include <pthread.h> |
3 | 5 | ||
diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c index 1e2ba2602930..a6d7aef30030 100644 --- a/tools/perf/tests/pmu.c +++ b/tools/perf/tests/pmu.c | |||
@@ -2,6 +2,8 @@ | |||
2 | #include "pmu.h" | 2 | #include "pmu.h" |
3 | #include "util.h" | 3 | #include "util.h" |
4 | #include "tests.h" | 4 | #include "tests.h" |
5 | #include <errno.h> | ||
6 | #include <linux/kernel.h> | ||
5 | 7 | ||
6 | /* Simulated format definitions. */ | 8 | /* Simulated format definitions. */ |
7 | static struct test_format { | 9 | static struct test_format { |
diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c index 5f23710b9fee..bac5c3885b3b 100644 --- a/tools/perf/tests/sample-parsing.c +++ b/tools/perf/tests/sample-parsing.c | |||
@@ -1,4 +1,6 @@ | |||
1 | #include <stdbool.h> | 1 | #include <stdbool.h> |
2 | #include <inttypes.h> | ||
3 | #include <linux/kernel.h> | ||
2 | #include <linux/types.h> | 4 | #include <linux/types.h> |
3 | 5 | ||
4 | #include "util.h" | 6 | #include "util.h" |
diff --git a/tools/perf/tests/sdt.c b/tools/perf/tests/sdt.c index 26e5b7a0b839..f73b3c5e125d 100644 --- a/tools/perf/tests/sdt.c +++ b/tools/perf/tests/sdt.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <errno.h> | ||
1 | #include <stdio.h> | 2 | #include <stdio.h> |
2 | #include <sys/epoll.h> | 3 | #include <sys/epoll.h> |
3 | #include <util/util.h> | 4 | #include <util/util.h> |
diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c index 4c9fd046d57b..828494db4a19 100644 --- a/tools/perf/tests/sw-clock.c +++ b/tools/perf/tests/sw-clock.c | |||
@@ -1,3 +1,5 @@ | |||
1 | #include <errno.h> | ||
2 | #include <inttypes.h> | ||
1 | #include <unistd.h> | 3 | #include <unistd.h> |
2 | #include <stdlib.h> | 4 | #include <stdlib.h> |
3 | #include <signal.h> | 5 | #include <signal.h> |
diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c index 7ddbe267d0ac..65474fd80da7 100644 --- a/tools/perf/tests/switch-tracking.c +++ b/tools/perf/tests/switch-tracking.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include <sys/time.h> | 1 | #include <sys/time.h> |
2 | #include <sys/prctl.h> | 2 | #include <sys/prctl.h> |
3 | #include <errno.h> | ||
3 | #include <time.h> | 4 | #include <time.h> |
4 | #include <stdlib.h> | 5 | #include <stdlib.h> |
5 | 6 | ||
diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c index 01a5ba2788c6..32873ec91a4e 100644 --- a/tools/perf/tests/task-exit.c +++ b/tools/perf/tests/task-exit.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include "cpumap.h" | 4 | #include "cpumap.h" |
5 | #include "tests.h" | 5 | #include "tests.h" |
6 | 6 | ||
7 | #include <errno.h> | ||
7 | #include <signal.h> | 8 | #include <signal.h> |
8 | 9 | ||
9 | static int exited; | 10 | static int exited; |
diff --git a/tools/perf/tests/unit_number__scnprintf.c b/tools/perf/tests/unit_number__scnprintf.c index 623c2aa53c4a..f84cb70ee5e5 100644 --- a/tools/perf/tests/unit_number__scnprintf.c +++ b/tools/perf/tests/unit_number__scnprintf.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <inttypes.h> | ||
1 | #include <linux/compiler.h> | 2 | #include <linux/compiler.h> |
2 | #include <linux/types.h> | 3 | #include <linux/types.h> |
3 | #include "tests.h" | 4 | #include "tests.h" |
diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c index 862b043e5924..8456175fc234 100644 --- a/tools/perf/tests/vmlinux-kallsyms.c +++ b/tools/perf/tests/vmlinux-kallsyms.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include <linux/compiler.h> | 1 | #include <linux/compiler.h> |
2 | #include <linux/rbtree.h> | 2 | #include <linux/rbtree.h> |
3 | #include <inttypes.h> | ||
3 | #include <string.h> | 4 | #include <string.h> |
4 | #include "map.h" | 5 | #include "map.h" |
5 | #include "symbol.h" | 6 | #include "symbol.h" |
diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c index 9e47ccbe07f1..a4d3762cd825 100644 --- a/tools/perf/ui/browser.c +++ b/tools/perf/ui/browser.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #include "../util.h" | 1 | #include "../util.h" |
2 | #include "../string2.h" | ||
2 | #include "../config.h" | 3 | #include "../config.h" |
3 | #include "../../perf.h" | 4 | #include "../../perf.h" |
4 | #include "libslang.h" | 5 | #include "libslang.h" |
@@ -13,6 +14,7 @@ | |||
13 | #include "helpline.h" | 14 | #include "helpline.h" |
14 | #include "keysyms.h" | 15 | #include "keysyms.h" |
15 | #include "../color.h" | 16 | #include "../color.h" |
17 | #include "sane_ctype.h" | ||
16 | 18 | ||
17 | static int ui_browser__percent_color(struct ui_browser *browser, | 19 | static int ui_browser__percent_color(struct ui_browser *browser, |
18 | double percent, bool current) | 20 | double percent, bool current) |
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index ba36aac340bc..d990ad08a3c6 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -9,7 +9,10 @@ | |||
9 | #include "../../util/symbol.h" | 9 | #include "../../util/symbol.h" |
10 | #include "../../util/evsel.h" | 10 | #include "../../util/evsel.h" |
11 | #include "../../util/config.h" | 11 | #include "../../util/config.h" |
12 | #include <inttypes.h> | ||
12 | #include <pthread.h> | 13 | #include <pthread.h> |
14 | #include <linux/kernel.h> | ||
15 | #include <sys/ttydefaults.h> | ||
13 | 16 | ||
14 | struct disasm_line_samples { | 17 | struct disasm_line_samples { |
15 | double percent; | 18 | double percent; |
diff --git a/tools/perf/ui/browsers/header.c b/tools/perf/ui/browsers/header.c index edbeaaf31ace..e2c9390ff4c5 100644 --- a/tools/perf/ui/browsers/header.c +++ b/tools/perf/ui/browsers/header.c | |||
@@ -8,6 +8,8 @@ | |||
8 | #include "util/header.h" | 8 | #include "util/header.h" |
9 | #include "util/session.h" | 9 | #include "util/session.h" |
10 | 10 | ||
11 | #include <sys/ttydefaults.h> | ||
12 | |||
11 | static void ui_browser__argv_write(struct ui_browser *browser, | 13 | static void ui_browser__argv_write(struct ui_browser *browser, |
12 | void *entry, int row) | 14 | void *entry, int row) |
13 | { | 15 | { |
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index da24072bb76e..f0b5b2b0e521 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -1,7 +1,11 @@ | |||
1 | #include <dirent.h> | ||
2 | #include <errno.h> | ||
3 | #include <inttypes.h> | ||
1 | #include <stdio.h> | 4 | #include <stdio.h> |
2 | #include <stdlib.h> | 5 | #include <stdlib.h> |
3 | #include <string.h> | 6 | #include <string.h> |
4 | #include <linux/rbtree.h> | 7 | #include <linux/rbtree.h> |
8 | #include <sys/ttydefaults.h> | ||
5 | 9 | ||
6 | #include "../../util/evsel.h" | 10 | #include "../../util/evsel.h" |
7 | #include "../../util/evlist.h" | 11 | #include "../../util/evlist.h" |
@@ -18,6 +22,10 @@ | |||
18 | #include "../ui.h" | 22 | #include "../ui.h" |
19 | #include "map.h" | 23 | #include "map.h" |
20 | #include "annotate.h" | 24 | #include "annotate.h" |
25 | #include "srcline.h" | ||
26 | #include "string2.h" | ||
27 | |||
28 | #include "sane_ctype.h" | ||
21 | 29 | ||
22 | extern void hist_browser__init_hpp(void); | 30 | extern void hist_browser__init_hpp(void); |
23 | 31 | ||
diff --git a/tools/perf/ui/browsers/map.c b/tools/perf/ui/browsers/map.c index 9ce142de536d..ffa5addf631d 100644 --- a/tools/perf/ui/browsers/map.c +++ b/tools/perf/ui/browsers/map.c | |||
@@ -11,6 +11,8 @@ | |||
11 | #include "../keysyms.h" | 11 | #include "../keysyms.h" |
12 | #include "map.h" | 12 | #include "map.h" |
13 | 13 | ||
14 | #include "sane_ctype.h" | ||
15 | |||
14 | struct map_browser { | 16 | struct map_browser { |
15 | struct ui_browser b; | 17 | struct ui_browser b; |
16 | struct map *map; | 18 | struct map *map; |
diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c index 8c9308ac30b7..71359b898b67 100644 --- a/tools/perf/ui/gtk/annotate.c +++ b/tools/perf/ui/gtk/annotate.c | |||
@@ -3,7 +3,7 @@ | |||
3 | #include "util/annotate.h" | 3 | #include "util/annotate.h" |
4 | #include "util/evsel.h" | 4 | #include "util/evsel.h" |
5 | #include "ui/helpline.h" | 5 | #include "ui/helpline.h" |
6 | 6 | #include <inttypes.h> | |
7 | 7 | ||
8 | enum { | 8 | enum { |
9 | ANN_COL__PERCENT, | 9 | ANN_COL__PERCENT, |
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index a4f02de7c1b5..c42de4dcc055 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include "../sort.h" | 4 | #include "../sort.h" |
5 | #include "../hist.h" | 5 | #include "../hist.h" |
6 | #include "../helpline.h" | 6 | #include "../helpline.h" |
7 | #include "../string2.h" | ||
7 | #include "gtk.h" | 8 | #include "gtk.h" |
8 | 9 | ||
9 | #define MAX_COLUMNS 32 | 10 | #define MAX_COLUMNS 32 |
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 5d632dca672a..59addd52d9cd 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <inttypes.h> | ||
1 | #include <math.h> | 2 | #include <math.h> |
2 | #include <linux/compiler.h> | 3 | #include <linux/compiler.h> |
3 | 4 | ||
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c index 50d13e58210f..5ea0b40c4fc2 100644 --- a/tools/perf/ui/setup.c +++ b/tools/perf/ui/setup.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include "../util/cache.h" | 4 | #include "../util/cache.h" |
5 | #include "../util/debug.h" | 5 | #include "../util/debug.h" |
6 | #include "../util/hist.h" | 6 | #include "../util/hist.h" |
7 | #include "../util/util.h" | ||
7 | 8 | ||
8 | pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; | 9 | pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; |
9 | void *perf_gtk_handle; | 10 | void *perf_gtk_handle; |
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index d52d5f64ea89..5565105c9688 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
@@ -4,7 +4,9 @@ | |||
4 | #include "../../util/hist.h" | 4 | #include "../../util/hist.h" |
5 | #include "../../util/sort.h" | 5 | #include "../../util/sort.h" |
6 | #include "../../util/evsel.h" | 6 | #include "../../util/evsel.h" |
7 | 7 | #include "../../util/srcline.h" | |
8 | #include "../../util/string2.h" | ||
9 | #include "../../util/sane_ctype.h" | ||
8 | 10 | ||
9 | static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin) | 11 | static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin) |
10 | { | 12 | { |
diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c index 4ea2ba861fc2..d9350a1da48b 100644 --- a/tools/perf/ui/tui/setup.c +++ b/tools/perf/ui/tui/setup.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include <errno.h> | 1 | #include <errno.h> |
2 | #include <signal.h> | 2 | #include <signal.h> |
3 | #include <stdbool.h> | 3 | #include <stdbool.h> |
4 | #include <linux/kernel.h> | ||
4 | #ifdef HAVE_BACKTRACE_SUPPORT | 5 | #ifdef HAVE_BACKTRACE_SUPPORT |
5 | #include <execinfo.h> | 6 | #include <execinfo.h> |
6 | #endif | 7 | #endif |
diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 5c0ea11a8f0a..f0b9e5d0e2fc 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build | |||
@@ -16,6 +16,7 @@ libperf-y += llvm-utils.o | |||
16 | libperf-y += parse-events.o | 16 | libperf-y += parse-events.o |
17 | libperf-y += perf_regs.o | 17 | libperf-y += perf_regs.o |
18 | libperf-y += path.o | 18 | libperf-y += path.o |
19 | libperf-y += print_binary.o | ||
19 | libperf-y += rbtree.o | 20 | libperf-y += rbtree.o |
20 | libperf-y += libstring.o | 21 | libperf-y += libstring.o |
21 | libperf-y += bitmap.o | 22 | libperf-y += bitmap.o |
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 30498a2d4a6f..683f8340460c 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -7,6 +7,8 @@ | |||
7 | * Released under the GPL v2. (and only v2, not any later version) | 7 | * Released under the GPL v2. (and only v2, not any later version) |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <errno.h> | ||
11 | #include <inttypes.h> | ||
10 | #include "util.h" | 12 | #include "util.h" |
11 | #include "ui/ui.h" | 13 | #include "ui/ui.h" |
12 | #include "sort.h" | 14 | #include "sort.h" |
@@ -18,12 +20,16 @@ | |||
18 | #include "annotate.h" | 20 | #include "annotate.h" |
19 | #include "evsel.h" | 21 | #include "evsel.h" |
20 | #include "block-range.h" | 22 | #include "block-range.h" |
23 | #include "string2.h" | ||
21 | #include "arch/common.h" | 24 | #include "arch/common.h" |
22 | #include <regex.h> | 25 | #include <regex.h> |
23 | #include <pthread.h> | 26 | #include <pthread.h> |
24 | #include <linux/bitops.h> | 27 | #include <linux/bitops.h> |
28 | #include <linux/kernel.h> | ||
25 | #include <sys/utsname.h> | 29 | #include <sys/utsname.h> |
26 | 30 | ||
31 | #include "sane_ctype.h" | ||
32 | |||
27 | const char *disassembler_style; | 33 | const char *disassembler_style; |
28 | const char *objdump_path; | 34 | const char *objdump_path; |
29 | static regex_t file_lineno; | 35 | static regex_t file_lineno; |
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 78bd632f144d..0daf63b9ee3e 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c | |||
@@ -13,10 +13,10 @@ | |||
13 | * | 13 | * |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <inttypes.h> | ||
16 | #include <sys/types.h> | 17 | #include <sys/types.h> |
17 | #include <sys/mman.h> | 18 | #include <sys/mman.h> |
18 | #include <stdbool.h> | 19 | #include <stdbool.h> |
19 | #include <ctype.h> | ||
20 | #include <string.h> | 20 | #include <string.h> |
21 | #include <limits.h> | 21 | #include <limits.h> |
22 | #include <errno.h> | 22 | #include <errno.h> |
@@ -46,7 +46,6 @@ | |||
46 | #include "cpumap.h" | 46 | #include "cpumap.h" |
47 | #include "thread_map.h" | 47 | #include "thread_map.h" |
48 | #include "asm/bug.h" | 48 | #include "asm/bug.h" |
49 | #include "symbol/kallsyms.h" | ||
50 | #include "auxtrace.h" | 49 | #include "auxtrace.h" |
51 | 50 | ||
52 | #include <linux/hash.h> | 51 | #include <linux/hash.h> |
@@ -59,6 +58,9 @@ | |||
59 | #include "intel-pt.h" | 58 | #include "intel-pt.h" |
60 | #include "intel-bts.h" | 59 | #include "intel-bts.h" |
61 | 60 | ||
61 | #include "sane_ctype.h" | ||
62 | #include "symbol/kallsyms.h" | ||
63 | |||
62 | int auxtrace_mmap__mmap(struct auxtrace_mmap *mm, | 64 | int auxtrace_mmap__mmap(struct auxtrace_mmap *mm, |
63 | struct auxtrace_mmap_params *mp, | 65 | struct auxtrace_mmap_params *mp, |
64 | void *userpg, int fd) | 66 | void *userpg, int fd) |
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 26fb1ee5746a..9f0de72d58e2 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h | |||
@@ -17,6 +17,7 @@ | |||
17 | #define __PERF_AUXTRACE_H | 17 | #define __PERF_AUXTRACE_H |
18 | 18 | ||
19 | #include <sys/types.h> | 19 | #include <sys/types.h> |
20 | #include <errno.h> | ||
20 | #include <stdbool.h> | 21 | #include <stdbool.h> |
21 | #include <stddef.h> | 22 | #include <stddef.h> |
22 | #include <linux/list.h> | 23 | #include <linux/list.h> |
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index bc6bc7062eb4..4bd2d1d882af 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c | |||
@@ -9,7 +9,9 @@ | |||
9 | #include <bpf/libbpf.h> | 9 | #include <bpf/libbpf.h> |
10 | #include <bpf/bpf.h> | 10 | #include <bpf/bpf.h> |
11 | #include <linux/err.h> | 11 | #include <linux/err.h> |
12 | #include <linux/kernel.h> | ||
12 | #include <linux/string.h> | 13 | #include <linux/string.h> |
14 | #include <errno.h> | ||
13 | #include "perf.h" | 15 | #include "perf.h" |
14 | #include "debug.h" | 16 | #include "debug.h" |
15 | #include "bpf-loader.h" | 17 | #include "bpf-loader.h" |
@@ -17,6 +19,7 @@ | |||
17 | #include "probe-event.h" | 19 | #include "probe-event.h" |
18 | #include "probe-finder.h" // for MAX_PROBES | 20 | #include "probe-finder.h" // for MAX_PROBES |
19 | #include "parse-events.h" | 21 | #include "parse-events.h" |
22 | #include "strfilter.h" | ||
20 | #include "llvm-utils.h" | 23 | #include "llvm-utils.h" |
21 | #include "c++/clang-c.h" | 24 | #include "c++/clang-c.h" |
22 | 25 | ||
diff --git a/tools/perf/util/bpf-loader.h b/tools/perf/util/bpf-loader.h index f2b737b225f2..48863867878b 100644 --- a/tools/perf/util/bpf-loader.h +++ b/tools/perf/util/bpf-loader.h | |||
@@ -85,6 +85,8 @@ int bpf__strerror_setup_stdout(struct perf_evlist *evlist, int err, | |||
85 | char *buf, size_t size); | 85 | char *buf, size_t size); |
86 | 86 | ||
87 | #else | 87 | #else |
88 | #include <errno.h> | ||
89 | |||
88 | static inline struct bpf_object * | 90 | static inline struct bpf_object * |
89 | bpf__prepare_load(const char *filename __maybe_unused, | 91 | bpf__prepare_load(const char *filename __maybe_unused, |
90 | bool source __maybe_unused) | 92 | bool source __maybe_unused) |
diff --git a/tools/perf/util/bpf-prologue.c b/tools/perf/util/bpf-prologue.c index 6cdbee119ceb..1356220a9f1b 100644 --- a/tools/perf/util/bpf-prologue.c +++ b/tools/perf/util/bpf-prologue.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "bpf-loader.h" | 12 | #include "bpf-loader.h" |
13 | #include "bpf-prologue.h" | 13 | #include "bpf-prologue.h" |
14 | #include "probe-finder.h" | 14 | #include "probe-finder.h" |
15 | #include <errno.h> | ||
15 | #include <dwarf-regs.h> | 16 | #include <dwarf-regs.h> |
16 | #include <linux/filter.h> | 17 | #include <linux/filter.h> |
17 | 18 | ||
diff --git a/tools/perf/util/bpf-prologue.h b/tools/perf/util/bpf-prologue.h index d94cbea12899..ba564838375f 100644 --- a/tools/perf/util/bpf-prologue.h +++ b/tools/perf/util/bpf-prologue.h | |||
@@ -18,6 +18,8 @@ int bpf__gen_prologue(struct probe_trace_arg *args, int nargs, | |||
18 | struct bpf_insn *new_prog, size_t *new_cnt, | 18 | struct bpf_insn *new_prog, size_t *new_cnt, |
19 | size_t cnt_space); | 19 | size_t cnt_space); |
20 | #else | 20 | #else |
21 | #include <errno.h> | ||
22 | |||
21 | static inline int | 23 | static inline int |
22 | bpf__gen_prologue(struct probe_trace_arg *args __maybe_unused, | 24 | bpf__gen_prologue(struct probe_trace_arg *args __maybe_unused, |
23 | int nargs __maybe_unused, | 25 | int nargs __maybe_unused, |
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 33af67530d30..923ea290bb6e 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c | |||
@@ -7,6 +7,8 @@ | |||
7 | * Copyright (C) 2009, 2010 Arnaldo Carvalho de Melo <acme@redhat.com> | 7 | * Copyright (C) 2009, 2010 Arnaldo Carvalho de Melo <acme@redhat.com> |
8 | */ | 8 | */ |
9 | #include "util.h" | 9 | #include "util.h" |
10 | #include <dirent.h> | ||
11 | #include <errno.h> | ||
10 | #include <stdio.h> | 12 | #include <stdio.h> |
11 | #include "build-id.h" | 13 | #include "build-id.h" |
12 | #include "event.h" | 14 | #include "event.h" |
@@ -17,8 +19,11 @@ | |||
17 | #include "tool.h" | 19 | #include "tool.h" |
18 | #include "header.h" | 20 | #include "header.h" |
19 | #include "vdso.h" | 21 | #include "vdso.h" |
22 | #include "path.h" | ||
20 | #include "probe-file.h" | 23 | #include "probe-file.h" |
24 | #include "strlist.h" | ||
21 | 25 | ||
26 | #include "sane_ctype.h" | ||
22 | 27 | ||
23 | static bool no_buildid_cache; | 28 | static bool no_buildid_cache; |
24 | 29 | ||
@@ -447,14 +452,14 @@ void disable_buildid_cache(void) | |||
447 | } | 452 | } |
448 | 453 | ||
449 | static bool lsdir_bid_head_filter(const char *name __maybe_unused, | 454 | static bool lsdir_bid_head_filter(const char *name __maybe_unused, |
450 | struct dirent *d __maybe_unused) | 455 | struct dirent *d) |
451 | { | 456 | { |
452 | return (strlen(d->d_name) == 2) && | 457 | return (strlen(d->d_name) == 2) && |
453 | isxdigit(d->d_name[0]) && isxdigit(d->d_name[1]); | 458 | isxdigit(d->d_name[0]) && isxdigit(d->d_name[1]); |
454 | } | 459 | } |
455 | 460 | ||
456 | static bool lsdir_bid_tail_filter(const char *name __maybe_unused, | 461 | static bool lsdir_bid_tail_filter(const char *name __maybe_unused, |
457 | struct dirent *d __maybe_unused) | 462 | struct dirent *d) |
458 | { | 463 | { |
459 | int i = 0; | 464 | int i = 0; |
460 | while (isxdigit(d->d_name[i]) && i < SBUILD_ID_SIZE - 3) | 465 | while (isxdigit(d->d_name[i]) && i < SBUILD_ID_SIZE - 3) |
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index d27990610f9f..a96081121179 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h | |||
@@ -5,7 +5,6 @@ | |||
5 | #define SBUILD_ID_SIZE (BUILD_ID_SIZE * 2 + 1) | 5 | #define SBUILD_ID_SIZE (BUILD_ID_SIZE * 2 + 1) |
6 | 6 | ||
7 | #include "tool.h" | 7 | #include "tool.h" |
8 | #include "strlist.h" | ||
9 | #include <linux/types.h> | 8 | #include <linux/types.h> |
10 | 9 | ||
11 | extern struct perf_tool build_id__mark_dso_hit_ops; | 10 | extern struct perf_tool build_id__mark_dso_hit_ops; |
@@ -34,6 +33,9 @@ char *build_id_cache__origname(const char *sbuild_id); | |||
34 | char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size); | 33 | char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size); |
35 | char *build_id_cache__cachedir(const char *sbuild_id, const char *name, | 34 | char *build_id_cache__cachedir(const char *sbuild_id, const char *name, |
36 | bool is_kallsyms, bool is_vdso); | 35 | bool is_kallsyms, bool is_vdso); |
36 | |||
37 | struct strlist; | ||
38 | |||
37 | struct strlist *build_id_cache__list_all(bool validonly); | 39 | struct strlist *build_id_cache__list_all(bool validonly); |
38 | char *build_id_cache__complement(const char *incomplete_sbuild_id); | 40 | char *build_id_cache__complement(const char *incomplete_sbuild_id); |
39 | int build_id_cache__list_build_ids(const char *pathname, | 41 | int build_id_cache__list_build_ids(const char *pathname, |
diff --git a/tools/perf/util/c++/clang-c.h b/tools/perf/util/c++/clang-c.h index 0eadd792ab1f..ccafcf72b37a 100644 --- a/tools/perf/util/c++/clang-c.h +++ b/tools/perf/util/c++/clang-c.h | |||
@@ -20,6 +20,7 @@ extern int perf_clang__compile_bpf(const char *filename, | |||
20 | size_t *p_obj_buf_sz); | 20 | size_t *p_obj_buf_sz); |
21 | #else | 21 | #else |
22 | 22 | ||
23 | #include <errno.h> | ||
23 | 24 | ||
24 | static inline void perf_clang__init(void) { } | 25 | static inline void perf_clang__init(void) { } |
25 | static inline void perf_clang__cleanup(void) { } | 26 | static inline void perf_clang__cleanup(void) { } |
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 2e5eff5abef0..0096d45a06b3 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c | |||
@@ -9,6 +9,7 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <inttypes.h> | ||
12 | #include <stdlib.h> | 13 | #include <stdlib.h> |
13 | #include <stdio.h> | 14 | #include <stdio.h> |
14 | #include <stdbool.h> | 15 | #include <stdbool.h> |
diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c index 86399eda3684..03347748f3fa 100644 --- a/tools/perf/util/cgroup.c +++ b/tools/perf/util/cgroup.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include "evsel.h" | 4 | #include "evsel.h" |
5 | #include "cgroup.h" | 5 | #include "cgroup.h" |
6 | #include "evlist.h" | 6 | #include "evlist.h" |
7 | #include <linux/stringify.h> | ||
7 | 8 | ||
8 | int nr_cgroups; | 9 | int nr_cgroups; |
9 | 10 | ||
@@ -27,8 +28,8 @@ cgroupfs_find_mountpoint(char *buf, size_t maxlen) | |||
27 | path_v1[0] = '\0'; | 28 | path_v1[0] = '\0'; |
28 | path_v2[0] = '\0'; | 29 | path_v2[0] = '\0'; |
29 | 30 | ||
30 | while (fscanf(fp, "%*s %"STR(PATH_MAX)"s %"STR(PATH_MAX)"s %" | 31 | while (fscanf(fp, "%*s %"__stringify(PATH_MAX)"s %"__stringify(PATH_MAX)"s %" |
31 | STR(PATH_MAX)"s %*d %*d\n", | 32 | __stringify(PATH_MAX)"s %*d %*d\n", |
32 | mountpoint, type, tokens) == 3) { | 33 | mountpoint, type, tokens) == 3) { |
33 | 34 | ||
34 | if (!path_v1[0] && !strcmp(type, "cgroup")) { | 35 | if (!path_v1[0] && !strcmp(type, "cgroup")) { |
diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c index f0dcd0ee0afa..4b4f00df58a8 100644 --- a/tools/perf/util/cloexec.c +++ b/tools/perf/util/cloexec.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <errno.h> | ||
1 | #include <sched.h> | 2 | #include <sched.h> |
2 | #include "util.h" | 3 | #include "util.h" |
3 | #include "../perf.h" | 4 | #include "../perf.h" |
diff --git a/tools/perf/util/comm.c b/tools/perf/util/comm.c index 32837b6f7879..530a62a7b51e 100644 --- a/tools/perf/util/comm.c +++ b/tools/perf/util/comm.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include "comm.h" | 1 | #include "comm.h" |
2 | #include "util.h" | 2 | #include "util.h" |
3 | #include <errno.h> | ||
3 | #include <stdlib.h> | 4 | #include <stdlib.h> |
4 | #include <stdio.h> | 5 | #include <stdio.h> |
5 | #include <linux/refcount.h> | 6 | #include <linux/refcount.h> |
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 7b01d59076d3..f5604039cbe4 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * Copyright (C) Johannes Schindelin, 2005 | 8 | * Copyright (C) Johannes Schindelin, 2005 |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | #include <errno.h> | ||
11 | #include "util.h" | 12 | #include "util.h" |
12 | #include "cache.h" | 13 | #include "cache.h" |
13 | #include <subcmd/exec-cmd.h> | 14 | #include <subcmd/exec-cmd.h> |
@@ -15,6 +16,8 @@ | |||
15 | #include "util/llvm-utils.h" /* perf_llvm_config */ | 16 | #include "util/llvm-utils.h" /* perf_llvm_config */ |
16 | #include "config.h" | 17 | #include "config.h" |
17 | 18 | ||
19 | #include "sane_ctype.h" | ||
20 | |||
18 | #define MAXNAME (256) | 21 | #define MAXNAME (256) |
19 | 22 | ||
20 | #define DEBUG_CACHE_DIR ".debug" | 23 | #define DEBUG_CACHE_DIR ".debug" |
diff --git a/tools/perf/util/counts.c b/tools/perf/util/counts.c index e3fde313deb2..c4af82ab7808 100644 --- a/tools/perf/util/counts.c +++ b/tools/perf/util/counts.c | |||
@@ -1,6 +1,8 @@ | |||
1 | #include <errno.h> | ||
1 | #include <stdlib.h> | 2 | #include <stdlib.h> |
2 | #include "evsel.h" | 3 | #include "evsel.h" |
3 | #include "counts.h" | 4 | #include "counts.h" |
5 | #include "util.h" | ||
4 | 6 | ||
5 | struct perf_counts *perf_counts__new(int ncpus, int nthreads) | 7 | struct perf_counts *perf_counts__new(int ncpus, int nthreads) |
6 | { | 8 | { |
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index 061018b42393..37b3bb79ee08 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c | |||
@@ -3,11 +3,14 @@ | |||
3 | #include "../perf.h" | 3 | #include "../perf.h" |
4 | #include "cpumap.h" | 4 | #include "cpumap.h" |
5 | #include <assert.h> | 5 | #include <assert.h> |
6 | #include <dirent.h> | ||
6 | #include <stdio.h> | 7 | #include <stdio.h> |
7 | #include <stdlib.h> | 8 | #include <stdlib.h> |
8 | #include <linux/bitmap.h> | 9 | #include <linux/bitmap.h> |
9 | #include "asm/bug.h" | 10 | #include "asm/bug.h" |
10 | 11 | ||
12 | #include "sane_ctype.h" | ||
13 | |||
11 | static int max_cpu_num; | 14 | static int max_cpu_num; |
12 | static int max_present_cpu_num; | 15 | static int max_present_cpu_num; |
13 | static int max_node_num; | 16 | static int max_node_num; |
diff --git a/tools/perf/util/ctype.c b/tools/perf/util/ctype.c index d4a5a21c2a7e..4b261c2ec0f1 100644 --- a/tools/perf/util/ctype.c +++ b/tools/perf/util/ctype.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * No surprises, and works with signed and unsigned chars. | 4 | * No surprises, and works with signed and unsigned chars. |
5 | */ | 5 | */ |
6 | #include "util.h" | 6 | #include "sane_ctype.h" |
7 | 7 | ||
8 | enum { | 8 | enum { |
9 | S = GIT_SPACE, | 9 | S = GIT_SPACE, |
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index 89ece2445713..89d50318833d 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c | |||
@@ -7,7 +7,10 @@ | |||
7 | * Released under the GPL v2. (and only v2, not any later version) | 7 | * Released under the GPL v2. (and only v2, not any later version) |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <errno.h> | ||
11 | #include <inttypes.h> | ||
10 | #include <linux/compiler.h> | 12 | #include <linux/compiler.h> |
13 | #include <linux/kernel.h> | ||
11 | #include <babeltrace/ctf-writer/writer.h> | 14 | #include <babeltrace/ctf-writer/writer.h> |
12 | #include <babeltrace/ctf-writer/clock.h> | 15 | #include <babeltrace/ctf-writer/clock.h> |
13 | #include <babeltrace/ctf-writer/stream.h> | 16 | #include <babeltrace/ctf-writer/stream.h> |
@@ -27,6 +30,7 @@ | |||
27 | #include "evsel.h" | 30 | #include "evsel.h" |
28 | #include "machine.h" | 31 | #include "machine.h" |
29 | #include "config.h" | 32 | #include "config.h" |
33 | #include "sane_ctype.h" | ||
30 | 34 | ||
31 | #define pr_N(n, fmt, ...) \ | 35 | #define pr_N(n, fmt, ...) \ |
32 | eprintf(n, debug_data_convert, fmt, ##__VA_ARGS__) | 36 | eprintf(n, debug_data_convert, fmt, ##__VA_ARGS__) |
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index 60bfc9ca1e22..e84bbc8ec058 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <linux/kernel.h> | 2 | #include <linux/kernel.h> |
3 | #include <sys/types.h> | 3 | #include <sys/types.h> |
4 | #include <sys/stat.h> | 4 | #include <sys/stat.h> |
5 | #include <errno.h> | ||
5 | #include <unistd.h> | 6 | #include <unistd.h> |
6 | #include <string.h> | 7 | #include <string.h> |
7 | 8 | ||
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 03eb81f30d0d..6e1d7e159649 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | #include "../perf.h" | 3 | #include "../perf.h" |
4 | 4 | ||
5 | #include <inttypes.h> | ||
5 | #include <string.h> | 6 | #include <string.h> |
6 | #include <stdarg.h> | 7 | #include <stdarg.h> |
7 | #include <stdio.h> | 8 | #include <stdio.h> |
@@ -12,9 +13,12 @@ | |||
12 | #include "color.h" | 13 | #include "color.h" |
13 | #include "event.h" | 14 | #include "event.h" |
14 | #include "debug.h" | 15 | #include "debug.h" |
16 | #include "print_binary.h" | ||
15 | #include "util.h" | 17 | #include "util.h" |
16 | #include "target.h" | 18 | #include "target.h" |
17 | 19 | ||
20 | #include "sane_ctype.h" | ||
21 | |||
18 | int verbose; | 22 | int verbose; |
19 | bool dump_trace = false, quiet = false; | 23 | bool dump_trace = false, quiet = false; |
20 | int debug_ordered_events; | 24 | int debug_ordered_events; |
diff --git a/tools/perf/util/demangle-java.c b/tools/perf/util/demangle-java.c index 3e6062ab2cdd..cb66d334f532 100644 --- a/tools/perf/util/demangle-java.c +++ b/tools/perf/util/demangle-java.c | |||
@@ -7,6 +7,8 @@ | |||
7 | 7 | ||
8 | #include "demangle-java.h" | 8 | #include "demangle-java.h" |
9 | 9 | ||
10 | #include "sane_ctype.h" | ||
11 | |||
10 | enum { | 12 | enum { |
11 | MODE_PREFIX = 0, | 13 | MODE_PREFIX = 0, |
12 | MODE_CLASS = 1, | 14 | MODE_CLASS = 1, |
diff --git a/tools/perf/util/drv_configs.c b/tools/perf/util/drv_configs.c index 1647f285c629..eec754243f4d 100644 --- a/tools/perf/util/drv_configs.c +++ b/tools/perf/util/drv_configs.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include "evlist.h" | 17 | #include "evlist.h" |
18 | #include "evsel.h" | 18 | #include "evsel.h" |
19 | #include "pmu.h" | 19 | #include "pmu.h" |
20 | #include <errno.h> | ||
20 | 21 | ||
21 | static int | 22 | static int |
22 | perf_evsel__apply_drv_configs(struct perf_evsel *evsel, | 23 | perf_evsel__apply_drv_configs(struct perf_evsel *evsel, |
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 42db00d78573..cbfe17f5168a 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c | |||
@@ -1,12 +1,16 @@ | |||
1 | #include <asm/bug.h> | 1 | #include <asm/bug.h> |
2 | #include <linux/kernel.h> | ||
2 | #include <sys/time.h> | 3 | #include <sys/time.h> |
3 | #include <sys/resource.h> | 4 | #include <sys/resource.h> |
5 | #include <errno.h> | ||
6 | #include "path.h" | ||
4 | #include "symbol.h" | 7 | #include "symbol.h" |
5 | #include "dso.h" | 8 | #include "dso.h" |
6 | #include "machine.h" | 9 | #include "machine.h" |
7 | #include "auxtrace.h" | 10 | #include "auxtrace.h" |
8 | #include "util.h" | 11 | #include "util.h" |
9 | #include "debug.h" | 12 | #include "debug.h" |
13 | #include "string2.h" | ||
10 | #include "vdso.h" | 14 | #include "vdso.h" |
11 | 15 | ||
12 | static const char * const debuglink_paths[] = { | 16 | static const char * const debuglink_paths[] = { |
diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index 41e068e94349..f5acda13dcfa 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c | |||
@@ -17,10 +17,13 @@ | |||
17 | * | 17 | * |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <errno.h> | ||
21 | #include <inttypes.h> | ||
20 | #include <stdbool.h> | 22 | #include <stdbool.h> |
21 | #include "util.h" | 23 | #include "util.h" |
22 | #include "debug.h" | 24 | #include "debug.h" |
23 | #include "dwarf-aux.h" | 25 | #include "dwarf-aux.h" |
26 | #include "string2.h" | ||
24 | 27 | ||
25 | /** | 28 | /** |
26 | * cu_find_realpath - Find the realpath of the target file | 29 | * cu_find_realpath - Find the realpath of the target file |
diff --git a/tools/perf/util/dwarf-regs.c b/tools/perf/util/dwarf-regs.c index 62bc4a86a970..c708395b3cb6 100644 --- a/tools/perf/util/dwarf-regs.c +++ b/tools/perf/util/dwarf-regs.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <debug.h> | 8 | #include <debug.h> |
9 | #include <dwarf-regs.h> | 9 | #include <dwarf-regs.h> |
10 | #include <elf.h> | 10 | #include <elf.h> |
11 | #include <linux/kernel.h> | ||
11 | 12 | ||
12 | #ifndef EM_AARCH64 | 13 | #ifndef EM_AARCH64 |
13 | #define EM_AARCH64 183 /* ARM 64 bit */ | 14 | #define EM_AARCH64 183 /* ARM 64 bit */ |
diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index 075fc77286bf..9e21538c42ae 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include "cpumap.h" | 1 | #include "cpumap.h" |
2 | #include "env.h" | 2 | #include "env.h" |
3 | #include "util.h" | 3 | #include "util.h" |
4 | #include <errno.h> | ||
4 | 5 | ||
5 | struct perf_env perf_env; | 6 | struct perf_env perf_env; |
6 | 7 | ||
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 4d7e65fa9d86..cf457ef534da 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -1,3 +1,7 @@ | |||
1 | #include <dirent.h> | ||
2 | #include <errno.h> | ||
3 | #include <inttypes.h> | ||
4 | #include <linux/kernel.h> | ||
1 | #include <linux/types.h> | 5 | #include <linux/types.h> |
2 | #include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */ | 6 | #include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */ |
3 | #include <api/fs/fs.h> | 7 | #include <api/fs/fs.h> |
@@ -6,10 +10,11 @@ | |||
6 | #include "hist.h" | 10 | #include "hist.h" |
7 | #include "machine.h" | 11 | #include "machine.h" |
8 | #include "sort.h" | 12 | #include "sort.h" |
9 | #include "string.h" | 13 | #include "string2.h" |
10 | #include "strlist.h" | 14 | #include "strlist.h" |
11 | #include "thread.h" | 15 | #include "thread.h" |
12 | #include "thread_map.h" | 16 | #include "thread_map.h" |
17 | #include "sane_ctype.h" | ||
13 | #include "symbol/kallsyms.h" | 18 | #include "symbol/kallsyms.h" |
14 | #include "asm/bug.h" | 19 | #include "asm/bug.h" |
15 | #include "stat.h" | 20 | #include "stat.h" |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 50420cd35446..f74ea2e55fde 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -8,6 +8,8 @@ | |||
8 | */ | 8 | */ |
9 | #include "util.h" | 9 | #include "util.h" |
10 | #include <api/fs/fs.h> | 10 | #include <api/fs/fs.h> |
11 | #include <errno.h> | ||
12 | #include <inttypes.h> | ||
11 | #include <poll.h> | 13 | #include <poll.h> |
12 | #include "cpumap.h" | 14 | #include "cpumap.h" |
13 | #include "thread_map.h" | 15 | #include "thread_map.h" |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 39942995f537..3fed4fb2e866 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef __PERF_EVLIST_H | 1 | #ifndef __PERF_EVLIST_H |
2 | #define __PERF_EVLIST_H 1 | 2 | #define __PERF_EVLIST_H 1 |
3 | 3 | ||
4 | #include <linux/kernel.h> | ||
4 | #include <linux/refcount.h> | 5 | #include <linux/refcount.h> |
5 | #include <linux/list.h> | 6 | #include <linux/list.h> |
6 | #include <api/fd/array.h> | 7 | #include <api/fd/array.h> |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 3779b9f3f134..44a7aef3911b 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -8,6 +8,8 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <byteswap.h> | 10 | #include <byteswap.h> |
11 | #include <errno.h> | ||
12 | #include <inttypes.h> | ||
11 | #include <linux/bitops.h> | 13 | #include <linux/bitops.h> |
12 | #include <api/fs/tracing_path.h> | 14 | #include <api/fs/tracing_path.h> |
13 | #include <traceevent/event-parse.h> | 15 | #include <traceevent/event-parse.h> |
@@ -30,6 +32,8 @@ | |||
30 | #include "stat.h" | 32 | #include "stat.h" |
31 | #include "util/parse-branch-options.h" | 33 | #include "util/parse-branch-options.h" |
32 | 34 | ||
35 | #include "sane_ctype.h" | ||
36 | |||
33 | static struct { | 37 | static struct { |
34 | bool sample_id_all; | 38 | bool sample_id_all; |
35 | bool exclude_guest; | 39 | bool exclude_guest; |
diff --git a/tools/perf/util/evsel_fprintf.c b/tools/perf/util/evsel_fprintf.c index 4ef5184819a0..e415aee6a245 100644 --- a/tools/perf/util/evsel_fprintf.c +++ b/tools/perf/util/evsel_fprintf.c | |||
@@ -1,9 +1,11 @@ | |||
1 | #include <inttypes.h> | ||
1 | #include <stdio.h> | 2 | #include <stdio.h> |
2 | #include <stdbool.h> | 3 | #include <stdbool.h> |
3 | #include <traceevent/event-parse.h> | 4 | #include <traceevent/event-parse.h> |
4 | #include "evsel.h" | 5 | #include "evsel.h" |
5 | #include "callchain.h" | 6 | #include "callchain.h" |
6 | #include "map.h" | 7 | #include "map.h" |
8 | #include "strlist.h" | ||
7 | #include "symbol.h" | 9 | #include "symbol.h" |
8 | 10 | ||
9 | static int comma_fprintf(FILE *fp, bool *first, const char *fmt, ...) | 11 | static int comma_fprintf(FILE *fp, bool *first, const char *fmt, ...) |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 2ccc7f06db79..28a3acb7b313 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -1,4 +1,7 @@ | |||
1 | #include <errno.h> | ||
2 | #include <inttypes.h> | ||
1 | #include "util.h" | 3 | #include "util.h" |
4 | #include "string2.h" | ||
2 | #include <sys/types.h> | 5 | #include <sys/types.h> |
3 | #include <byteswap.h> | 6 | #include <byteswap.h> |
4 | #include <unistd.h> | 7 | #include <unistd.h> |
@@ -26,6 +29,8 @@ | |||
26 | #include <api/fs/fs.h> | 29 | #include <api/fs/fs.h> |
27 | #include "asm/bug.h" | 30 | #include "asm/bug.h" |
28 | 31 | ||
32 | #include "sane_ctype.h" | ||
33 | |||
29 | /* | 34 | /* |
30 | * magic2 = "PERFILE2" | 35 | * magic2 = "PERFILE2" |
31 | * must be a numerical value to let the endianness | 36 | * must be a numerical value to let the endianness |
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 61bf304206fd..65d42758aadd 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -8,7 +8,9 @@ | |||
8 | #include "evlist.h" | 8 | #include "evlist.h" |
9 | #include "evsel.h" | 9 | #include "evsel.h" |
10 | #include "annotate.h" | 10 | #include "annotate.h" |
11 | #include "srcline.h" | ||
11 | #include "ui/progress.h" | 12 | #include "ui/progress.h" |
13 | #include <errno.h> | ||
12 | #include <math.h> | 14 | #include <math.h> |
13 | 15 | ||
14 | static bool hists__filter_entry_by_dso(struct hists *hists, | 16 | static bool hists__filter_entry_by_dso(struct hists *hists, |
diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index 6c2eb5da4afc..b2834ac7b1f5 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c | |||
@@ -14,7 +14,9 @@ | |||
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <endian.h> | 16 | #include <endian.h> |
17 | #include <errno.h> | ||
17 | #include <byteswap.h> | 18 | #include <byteswap.h> |
19 | #include <inttypes.h> | ||
18 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
19 | #include <linux/types.h> | 21 | #include <linux/types.h> |
20 | #include <linux/bitops.h> | 22 | #include <linux/bitops.h> |
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index da20cd5612e9..bdd4a28c6cee 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c | |||
@@ -13,6 +13,7 @@ | |||
13 | * | 13 | * |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <inttypes.h> | ||
16 | #include <stdio.h> | 17 | #include <stdio.h> |
17 | #include <stdbool.h> | 18 | #include <stdbool.h> |
18 | #include <errno.h> | 19 | #include <errno.h> |
diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index c9a941ef0f6d..9084930e1757 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include <sys/sysmacros.h> | 1 | #include <sys/sysmacros.h> |
2 | #include <sys/types.h> | 2 | #include <sys/types.h> |
3 | #include <errno.h> | ||
3 | #include <stdio.h> | 4 | #include <stdio.h> |
4 | #include <stdlib.h> | 5 | #include <stdlib.h> |
5 | #include <string.h> | 6 | #include <string.h> |
@@ -9,13 +10,13 @@ | |||
9 | #include <byteswap.h> | 10 | #include <byteswap.h> |
10 | #include <sys/stat.h> | 11 | #include <sys/stat.h> |
11 | #include <sys/mman.h> | 12 | #include <sys/mman.h> |
13 | #include <linux/stringify.h> | ||
12 | 14 | ||
13 | #include "util.h" | 15 | #include "util.h" |
14 | #include "event.h" | 16 | #include "event.h" |
15 | #include "debug.h" | 17 | #include "debug.h" |
16 | #include "evlist.h" | 18 | #include "evlist.h" |
17 | #include "symbol.h" | 19 | #include "symbol.h" |
18 | #include "strlist.h" | ||
19 | #include <elf.h> | 20 | #include <elf.h> |
20 | 21 | ||
21 | #include "tsc.h" | 22 | #include "tsc.h" |
@@ -25,6 +26,8 @@ | |||
25 | #include "genelf.h" | 26 | #include "genelf.h" |
26 | #include "../builtin.h" | 27 | #include "../builtin.h" |
27 | 28 | ||
29 | #include "sane_ctype.h" | ||
30 | |||
28 | struct jit_buf_desc { | 31 | struct jit_buf_desc { |
29 | struct perf_data_file *output; | 32 | struct perf_data_file *output; |
30 | struct perf_session *session; | 33 | struct perf_session *session; |
@@ -181,7 +184,7 @@ jit_open(struct jit_buf_desc *jd, const char *name) | |||
181 | jd->use_arch_timestamp); | 184 | jd->use_arch_timestamp); |
182 | 185 | ||
183 | if (header.version > JITHEADER_VERSION) { | 186 | if (header.version > JITHEADER_VERSION) { |
184 | pr_err("wrong jitdump version %u, expected " STR(JITHEADER_VERSION), | 187 | pr_err("wrong jitdump version %u, expected " __stringify(JITHEADER_VERSION), |
185 | header.version); | 188 | header.version); |
186 | goto error; | 189 | goto error; |
187 | } | 190 | } |
diff --git a/tools/perf/util/lzma.c b/tools/perf/util/lzma.c index 9ddea5cecd94..5b73b268c169 100644 --- a/tools/perf/util/lzma.c +++ b/tools/perf/util/lzma.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <errno.h> | ||
1 | #include <lzma.h> | 2 | #include <lzma.h> |
2 | #include <stdio.h> | 3 | #include <stdio.h> |
3 | #include <linux/compiler.h> | 4 | #include <linux/compiler.h> |
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index dfc600446586..988e84ce6f88 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
@@ -1,3 +1,7 @@ | |||
1 | #include <dirent.h> | ||
2 | #include <errno.h> | ||
3 | #include <inttypes.h> | ||
4 | #include <regex.h> | ||
1 | #include "callchain.h" | 5 | #include "callchain.h" |
2 | #include "debug.h" | 6 | #include "debug.h" |
3 | #include "event.h" | 7 | #include "event.h" |
@@ -10,11 +14,13 @@ | |||
10 | #include "thread.h" | 14 | #include "thread.h" |
11 | #include "vdso.h" | 15 | #include "vdso.h" |
12 | #include <stdbool.h> | 16 | #include <stdbool.h> |
13 | #include <symbol/kallsyms.h> | ||
14 | #include "unwind.h" | 17 | #include "unwind.h" |
15 | #include "linux/hash.h" | 18 | #include "linux/hash.h" |
16 | #include "asm/bug.h" | 19 | #include "asm/bug.h" |
17 | 20 | ||
21 | #include "sane_ctype.h" | ||
22 | #include <symbol/kallsyms.h> | ||
23 | |||
18 | static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock); | 24 | static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock); |
19 | 25 | ||
20 | static void dsos__init(struct dsos *dsos) | 26 | static void dsos__init(struct dsos *dsos) |
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index c1870ac365a3..ebfa5d92358a 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
@@ -9,13 +9,13 @@ | |||
9 | #include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */ | 9 | #include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */ |
10 | #include "map.h" | 10 | #include "map.h" |
11 | #include "thread.h" | 11 | #include "thread.h" |
12 | #include "strlist.h" | ||
13 | #include "vdso.h" | 12 | #include "vdso.h" |
14 | #include "build-id.h" | 13 | #include "build-id.h" |
15 | #include "util.h" | 14 | #include "util.h" |
16 | #include "debug.h" | 15 | #include "debug.h" |
17 | #include "machine.h" | 16 | #include "machine.h" |
18 | #include <linux/string.h> | 17 | #include <linux/string.h> |
18 | #include "srcline.h" | ||
19 | #include "unwind.h" | 19 | #include "unwind.h" |
20 | 20 | ||
21 | static void __maps__insert(struct maps *maps, struct map *map); | 21 | static void __maps__insert(struct maps *maps, struct map *map); |
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c index 1d4ab53c60ca..c56d52f90b54 100644 --- a/tools/perf/util/mem-events.c +++ b/tools/perf/util/mem-events.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <sys/stat.h> | 6 | #include <sys/stat.h> |
7 | #include <unistd.h> | 7 | #include <unistd.h> |
8 | #include <api/fs/fs.h> | 8 | #include <api/fs/fs.h> |
9 | #include <linux/kernel.h> | ||
9 | #include "mem-events.h" | 10 | #include "mem-events.h" |
10 | #include "debug.h" | 11 | #include "debug.h" |
11 | #include "symbol.h" | 12 | #include "symbol.h" |
diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c index e70e935b1841..4de398cfb577 100644 --- a/tools/perf/util/ordered-events.c +++ b/tools/perf/util/ordered-events.c | |||
@@ -1,3 +1,5 @@ | |||
1 | #include <errno.h> | ||
2 | #include <inttypes.h> | ||
1 | #include <linux/list.h> | 3 | #include <linux/list.h> |
2 | #include <linux/compiler.h> | 4 | #include <linux/compiler.h> |
3 | #include <linux/string.h> | 5 | #include <linux/string.h> |
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 6b498aea9fde..7d84338b19ee 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -1,13 +1,16 @@ | |||
1 | #include <linux/hw_breakpoint.h> | 1 | #include <linux/hw_breakpoint.h> |
2 | #include <linux/err.h> | 2 | #include <linux/err.h> |
3 | #include "util.h" | 3 | #include <dirent.h> |
4 | #include <errno.h> | ||
5 | #include "term.h" | ||
4 | #include "../perf.h" | 6 | #include "../perf.h" |
5 | #include "evlist.h" | 7 | #include "evlist.h" |
6 | #include "evsel.h" | 8 | #include "evsel.h" |
7 | #include <subcmd/parse-options.h> | 9 | #include <subcmd/parse-options.h> |
8 | #include "parse-events.h" | 10 | #include "parse-events.h" |
9 | #include <subcmd/exec-cmd.h> | 11 | #include <subcmd/exec-cmd.h> |
10 | #include "string.h" | 12 | #include "string2.h" |
13 | #include "strlist.h" | ||
11 | #include "symbol.h" | 14 | #include "symbol.h" |
12 | #include "cache.h" | 15 | #include "cache.h" |
13 | #include "header.h" | 16 | #include "header.h" |
diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c index 7c7630be5a89..50ec3bc87a60 100644 --- a/tools/perf/util/path.c +++ b/tools/perf/util/path.c | |||
@@ -11,8 +11,13 @@ | |||
11 | * which is what it's designed for. | 11 | * which is what it's designed for. |
12 | */ | 12 | */ |
13 | #include "cache.h" | 13 | #include "cache.h" |
14 | #include "util.h" | 14 | #include "path.h" |
15 | #include <linux/kernel.h> | ||
15 | #include <limits.h> | 16 | #include <limits.h> |
17 | #include <stdio.h> | ||
18 | #include <sys/types.h> | ||
19 | #include <sys/stat.h> | ||
20 | #include <unistd.h> | ||
16 | 21 | ||
17 | static char bad_path[] = "/bad-path/"; | 22 | static char bad_path[] = "/bad-path/"; |
18 | /* | 23 | /* |
@@ -50,3 +55,24 @@ char *mkpath(const char *fmt, ...) | |||
50 | return bad_path; | 55 | return bad_path; |
51 | return cleanup_path(pathname); | 56 | return cleanup_path(pathname); |
52 | } | 57 | } |
58 | |||
59 | int path__join(char *bf, size_t size, const char *path1, const char *path2) | ||
60 | { | ||
61 | return scnprintf(bf, size, "%s%s%s", path1, path1[0] ? "/" : "", path2); | ||
62 | } | ||
63 | |||
64 | int path__join3(char *bf, size_t size, const char *path1, const char *path2, const char *path3) | ||
65 | { | ||
66 | return scnprintf(bf, size, "%s%s%s%s%s", path1, path1[0] ? "/" : "", | ||
67 | path2, path2[0] ? "/" : "", path3); | ||
68 | } | ||
69 | |||
70 | bool is_regular_file(const char *file) | ||
71 | { | ||
72 | struct stat st; | ||
73 | |||
74 | if (stat(file, &st)) | ||
75 | return false; | ||
76 | |||
77 | return S_ISREG(st.st_mode); | ||
78 | } | ||
diff --git a/tools/perf/util/path.h b/tools/perf/util/path.h new file mode 100644 index 000000000000..9a276a58e3c2 --- /dev/null +++ b/tools/perf/util/path.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef _PERF_PATH_H | ||
2 | #define _PERF_PATH_H | ||
3 | |||
4 | int path__join(char *bf, size_t size, const char *path1, const char *path2); | ||
5 | int path__join3(char *bf, size_t size, const char *path1, const char *path2, const char *path3); | ||
6 | |||
7 | bool is_regular_file(const char *file); | ||
8 | |||
9 | #endif /* _PERF_PATH_H */ | ||
diff --git a/tools/perf/util/perf-hooks.c b/tools/perf/util/perf-hooks.c index cb368306b12b..d55092964da2 100644 --- a/tools/perf/util/perf-hooks.c +++ b/tools/perf/util/perf-hooks.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
10 | #include <setjmp.h> | 10 | #include <setjmp.h> |
11 | #include <linux/err.h> | 11 | #include <linux/err.h> |
12 | #include <linux/kernel.h> | ||
12 | #include "util/util.h" | 13 | #include "util/util.h" |
13 | #include "util/debug.h" | 14 | #include "util/debug.h" |
14 | #include "util/perf-hooks.h" | 15 | #include "util/perf-hooks.h" |
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 11c752561c55..bca1844594d0 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include <linux/list.h> | 1 | #include <linux/list.h> |
2 | #include <linux/compiler.h> | 2 | #include <linux/compiler.h> |
3 | #include <sys/types.h> | 3 | #include <sys/types.h> |
4 | #include <errno.h> | ||
4 | #include <unistd.h> | 5 | #include <unistd.h> |
5 | #include <stdio.h> | 6 | #include <stdio.h> |
6 | #include <stdbool.h> | 7 | #include <stdbool.h> |
@@ -15,6 +16,7 @@ | |||
15 | #include "header.h" | 16 | #include "header.h" |
16 | #include "pmu-events/pmu-events.h" | 17 | #include "pmu-events/pmu-events.h" |
17 | #include "cache.h" | 18 | #include "cache.h" |
19 | #include "string2.h" | ||
18 | 20 | ||
19 | struct perf_pmu_format { | 21 | struct perf_pmu_format { |
20 | char *name; | 22 | char *name; |
diff --git a/tools/perf/util/print_binary.c b/tools/perf/util/print_binary.c new file mode 100644 index 000000000000..e908177b9976 --- /dev/null +++ b/tools/perf/util/print_binary.c | |||
@@ -0,0 +1,55 @@ | |||
1 | #include "print_binary.h" | ||
2 | #include <linux/log2.h> | ||
3 | #include "sane_ctype.h" | ||
4 | |||
5 | void print_binary(unsigned char *data, size_t len, | ||
6 | size_t bytes_per_line, print_binary_t printer, | ||
7 | void *extra) | ||
8 | { | ||
9 | size_t i, j, mask; | ||
10 | |||
11 | if (!printer) | ||
12 | return; | ||
13 | |||
14 | bytes_per_line = roundup_pow_of_two(bytes_per_line); | ||
15 | mask = bytes_per_line - 1; | ||
16 | |||
17 | printer(BINARY_PRINT_DATA_BEGIN, 0, extra); | ||
18 | for (i = 0; i < len; i++) { | ||
19 | if ((i & mask) == 0) { | ||
20 | printer(BINARY_PRINT_LINE_BEGIN, -1, extra); | ||
21 | printer(BINARY_PRINT_ADDR, i, extra); | ||
22 | } | ||
23 | |||
24 | printer(BINARY_PRINT_NUM_DATA, data[i], extra); | ||
25 | |||
26 | if (((i & mask) == mask) || i == len - 1) { | ||
27 | for (j = 0; j < mask-(i & mask); j++) | ||
28 | printer(BINARY_PRINT_NUM_PAD, -1, extra); | ||
29 | |||
30 | printer(BINARY_PRINT_SEP, i, extra); | ||
31 | for (j = i & ~mask; j <= i; j++) | ||
32 | printer(BINARY_PRINT_CHAR_DATA, data[j], extra); | ||
33 | for (j = 0; j < mask-(i & mask); j++) | ||
34 | printer(BINARY_PRINT_CHAR_PAD, i, extra); | ||
35 | printer(BINARY_PRINT_LINE_END, -1, extra); | ||
36 | } | ||
37 | } | ||
38 | printer(BINARY_PRINT_DATA_END, -1, extra); | ||
39 | } | ||
40 | |||
41 | int is_printable_array(char *p, unsigned int len) | ||
42 | { | ||
43 | unsigned int i; | ||
44 | |||
45 | if (!p || !len || p[len - 1] != 0) | ||
46 | return 0; | ||
47 | |||
48 | len--; | ||
49 | |||
50 | for (i = 0; i < len; i++) { | ||
51 | if (!isprint(p[i]) && !isspace(p[i])) | ||
52 | return 0; | ||
53 | } | ||
54 | return 1; | ||
55 | } | ||
diff --git a/tools/perf/util/print_binary.h b/tools/perf/util/print_binary.h new file mode 100644 index 000000000000..da0427263d2d --- /dev/null +++ b/tools/perf/util/print_binary.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef PERF_PRINT_BINARY_H | ||
2 | #define PERF_PRINT_BINARY_H | ||
3 | |||
4 | #include <stddef.h> | ||
5 | |||
6 | enum binary_printer_ops { | ||
7 | BINARY_PRINT_DATA_BEGIN, | ||
8 | BINARY_PRINT_LINE_BEGIN, | ||
9 | BINARY_PRINT_ADDR, | ||
10 | BINARY_PRINT_NUM_DATA, | ||
11 | BINARY_PRINT_NUM_PAD, | ||
12 | BINARY_PRINT_SEP, | ||
13 | BINARY_PRINT_CHAR_DATA, | ||
14 | BINARY_PRINT_CHAR_PAD, | ||
15 | BINARY_PRINT_LINE_END, | ||
16 | BINARY_PRINT_DATA_END, | ||
17 | }; | ||
18 | |||
19 | typedef void (*print_binary_t)(enum binary_printer_ops op, | ||
20 | unsigned int val, void *extra); | ||
21 | |||
22 | void print_binary(unsigned char *data, size_t len, | ||
23 | size_t bytes_per_line, print_binary_t printer, | ||
24 | void *extra); | ||
25 | |||
26 | int is_printable_array(char *p, unsigned int len); | ||
27 | |||
28 | #endif /* PERF_PRINT_BINARY_H */ | ||
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index e4b889444447..84e7e698411e 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -19,6 +19,7 @@ | |||
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <inttypes.h> | ||
22 | #include <sys/utsname.h> | 23 | #include <sys/utsname.h> |
23 | #include <sys/types.h> | 24 | #include <sys/types.h> |
24 | #include <sys/stat.h> | 25 | #include <sys/stat.h> |
@@ -35,6 +36,7 @@ | |||
35 | #include "util.h" | 36 | #include "util.h" |
36 | #include "event.h" | 37 | #include "event.h" |
37 | #include "strlist.h" | 38 | #include "strlist.h" |
39 | #include "strfilter.h" | ||
38 | #include "debug.h" | 40 | #include "debug.h" |
39 | #include "cache.h" | 41 | #include "cache.h" |
40 | #include "color.h" | 42 | #include "color.h" |
@@ -46,6 +48,9 @@ | |||
46 | #include "probe-finder.h" | 48 | #include "probe-finder.h" |
47 | #include "probe-file.h" | 49 | #include "probe-file.h" |
48 | #include "session.h" | 50 | #include "session.h" |
51 | #include "string2.h" | ||
52 | |||
53 | #include "sane_ctype.h" | ||
49 | 54 | ||
50 | #define PERFPROBE_GROUP "probe" | 55 | #define PERFPROBE_GROUP "probe" |
51 | 56 | ||
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h index 5d4e94061402..373842656fb6 100644 --- a/tools/perf/util/probe-event.h +++ b/tools/perf/util/probe-event.h | |||
@@ -3,8 +3,6 @@ | |||
3 | 3 | ||
4 | #include <stdbool.h> | 4 | #include <stdbool.h> |
5 | #include "intlist.h" | 5 | #include "intlist.h" |
6 | #include "strlist.h" | ||
7 | #include "strfilter.h" | ||
8 | 6 | ||
9 | /* Probe related configurations */ | 7 | /* Probe related configurations */ |
10 | struct probe_conf { | 8 | struct probe_conf { |
@@ -107,6 +105,8 @@ struct line_range { | |||
107 | struct intlist *line_list; /* Visible lines */ | 105 | struct intlist *line_list; /* Visible lines */ |
108 | }; | 106 | }; |
109 | 107 | ||
108 | struct strlist; | ||
109 | |||
110 | /* List of variables */ | 110 | /* List of variables */ |
111 | struct variable_list { | 111 | struct variable_list { |
112 | struct probe_trace_point point; /* Actual probepoint */ | 112 | struct probe_trace_point point; /* Actual probepoint */ |
@@ -153,6 +153,9 @@ int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs); | |||
153 | int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs); | 153 | int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs); |
154 | int show_probe_trace_events(struct perf_probe_event *pevs, int npevs); | 154 | int show_probe_trace_events(struct perf_probe_event *pevs, int npevs); |
155 | void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs); | 155 | void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs); |
156 | |||
157 | struct strfilter; | ||
158 | |||
156 | int del_perf_probe_events(struct strfilter *filter); | 159 | int del_perf_probe_events(struct strfilter *filter); |
157 | 160 | ||
158 | int show_perf_probe_event(const char *group, const char *event, | 161 | int show_perf_probe_event(const char *group, const char *event, |
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 88714dec8912..685653f2bc32 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c | |||
@@ -14,10 +14,12 @@ | |||
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | * | 15 | * |
16 | */ | 16 | */ |
17 | #include <errno.h> | ||
17 | #include <sys/uio.h> | 18 | #include <sys/uio.h> |
18 | #include "util.h" | 19 | #include "util.h" |
19 | #include "event.h" | 20 | #include "event.h" |
20 | #include "strlist.h" | 21 | #include "strlist.h" |
22 | #include "strfilter.h" | ||
21 | #include "debug.h" | 23 | #include "debug.h" |
22 | #include "cache.h" | 24 | #include "cache.h" |
23 | #include "color.h" | 25 | #include "color.h" |
@@ -28,6 +30,7 @@ | |||
28 | #include "probe-file.h" | 30 | #include "probe-file.h" |
29 | #include "session.h" | 31 | #include "session.h" |
30 | #include "perf_regs.h" | 32 | #include "perf_regs.h" |
33 | #include "string2.h" | ||
31 | 34 | ||
32 | /* 4096 - 2 ('\n' + '\0') */ | 35 | /* 4096 - 2 ('\n' + '\0') */ |
33 | #define MAX_CMDLEN 4094 | 36 | #define MAX_CMDLEN 4094 |
diff --git a/tools/perf/util/probe-file.h b/tools/perf/util/probe-file.h index dbf95a00864a..5ecc9d3925db 100644 --- a/tools/perf/util/probe-file.h +++ b/tools/perf/util/probe-file.h | |||
@@ -1,10 +1,11 @@ | |||
1 | #ifndef __PROBE_FILE_H | 1 | #ifndef __PROBE_FILE_H |
2 | #define __PROBE_FILE_H | 2 | #define __PROBE_FILE_H |
3 | 3 | ||
4 | #include "strlist.h" | ||
5 | #include "strfilter.h" | ||
6 | #include "probe-event.h" | 4 | #include "probe-event.h" |
7 | 5 | ||
6 | struct strlist; | ||
7 | struct strfilter; | ||
8 | |||
8 | /* Cache of probe definitions */ | 9 | /* Cache of probe definitions */ |
9 | struct probe_cache_entry { | 10 | struct probe_cache_entry { |
10 | struct list_head node; | 11 | struct list_head node; |
@@ -41,6 +42,7 @@ int probe_file__open_both(int *kfd, int *ufd, int flag); | |||
41 | struct strlist *probe_file__get_namelist(int fd); | 42 | struct strlist *probe_file__get_namelist(int fd); |
42 | struct strlist *probe_file__get_rawlist(int fd); | 43 | struct strlist *probe_file__get_rawlist(int fd); |
43 | int probe_file__add_event(int fd, struct probe_trace_event *tev); | 44 | int probe_file__add_event(int fd, struct probe_trace_event *tev); |
45 | |||
44 | int probe_file__del_events(int fd, struct strfilter *filter); | 46 | int probe_file__del_events(int fd, struct strfilter *filter); |
45 | int probe_file__get_events(int fd, struct strfilter *filter, | 47 | int probe_file__get_events(int fd, struct strfilter *filter, |
46 | struct strlist *plist); | 48 | struct strlist *plist); |
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 57cd268d4275..a5731de0e5eb 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -19,6 +19,7 @@ | |||
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <inttypes.h> | ||
22 | #include <sys/utsname.h> | 23 | #include <sys/utsname.h> |
23 | #include <sys/types.h> | 24 | #include <sys/types.h> |
24 | #include <sys/stat.h> | 25 | #include <sys/stat.h> |
@@ -37,9 +38,11 @@ | |||
37 | #include "debug.h" | 38 | #include "debug.h" |
38 | #include "intlist.h" | 39 | #include "intlist.h" |
39 | #include "util.h" | 40 | #include "util.h" |
41 | #include "strlist.h" | ||
40 | #include "symbol.h" | 42 | #include "symbol.h" |
41 | #include "probe-finder.h" | 43 | #include "probe-finder.h" |
42 | #include "probe-file.h" | 44 | #include "probe-file.h" |
45 | #include "string2.h" | ||
43 | 46 | ||
44 | /* Kprobe tracer basic type is up to u64 */ | 47 | /* Kprobe tracer basic type is up to u64 */ |
45 | #define MAX_BASIC_TYPE_BITS 64 | 48 | #define MAX_BASIC_TYPE_BITS 64 |
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h index 2956c5198652..27f061551012 100644 --- a/tools/perf/util/probe-finder.h +++ b/tools/perf/util/probe-finder.h | |||
@@ -2,9 +2,9 @@ | |||
2 | #define _PROBE_FINDER_H | 2 | #define _PROBE_FINDER_H |
3 | 3 | ||
4 | #include <stdbool.h> | 4 | #include <stdbool.h> |
5 | #include "util.h" | ||
6 | #include "intlist.h" | 5 | #include "intlist.h" |
7 | #include "probe-event.h" | 6 | #include "probe-event.h" |
7 | #include "sane_ctype.h" | ||
8 | 8 | ||
9 | #define MAX_PROBE_BUFFER 1024 | 9 | #define MAX_PROBE_BUFFER 1024 |
10 | #define MAX_PROBES 128 | 10 | #define MAX_PROBES 128 |
diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources index 0546a4304347..7d3927447fba 100644 --- a/tools/perf/util/python-ext-sources +++ b/tools/perf/util/python-ext-sources | |||
@@ -21,6 +21,7 @@ util/cgroup.c | |||
21 | util/parse-branch-options.c | 21 | util/parse-branch-options.c |
22 | util/rblist.c | 22 | util/rblist.c |
23 | util/counts.c | 23 | util/counts.c |
24 | util/print_binary.c | ||
24 | util/strlist.c | 25 | util/strlist.c |
25 | util/trace-event.c | 26 | util/trace-event.c |
26 | ../lib/rbtree.c | 27 | ../lib/rbtree.c |
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index a5fbc012e3df..0533711af44d 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include "evsel.h" | 7 | #include "evsel.h" |
8 | #include "event.h" | 8 | #include "event.h" |
9 | #include "cpumap.h" | 9 | #include "cpumap.h" |
10 | #include "print_binary.h" | ||
10 | #include "thread_map.h" | 11 | #include "thread_map.h" |
11 | 12 | ||
12 | /* | 13 | /* |
diff --git a/tools/perf/util/quote.c b/tools/perf/util/quote.c index 293534c1a474..1ba8920151d8 100644 --- a/tools/perf/util/quote.c +++ b/tools/perf/util/quote.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <errno.h> | ||
1 | #include <stdlib.h> | 2 | #include <stdlib.h> |
2 | #include "strbuf.h" | 3 | #include "strbuf.h" |
3 | #include "quote.h" | 4 | #include "quote.h" |
diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index 98bf584853ea..d91bdf5a1aa4 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include "evsel.h" | 2 | #include "evsel.h" |
3 | #include "cpumap.h" | 3 | #include "cpumap.h" |
4 | #include "parse-events.h" | 4 | #include "parse-events.h" |
5 | #include <errno.h> | ||
5 | #include <api/fs/fs.h> | 6 | #include <api/fs/fs.h> |
6 | #include "util.h" | 7 | #include "util.h" |
7 | #include "cloexec.h" | 8 | #include "cloexec.h" |
diff --git a/tools/perf/util/sane_ctype.h b/tools/perf/util/sane_ctype.h new file mode 100644 index 000000000000..4308c22c22ad --- /dev/null +++ b/tools/perf/util/sane_ctype.h | |||
@@ -0,0 +1,51 @@ | |||
1 | #ifndef _PERF_SANE_CTYPE_H | ||
2 | #define _PERF_SANE_CTYPE_H | ||
3 | |||
4 | extern const char *graph_line; | ||
5 | extern const char *graph_dotted_line; | ||
6 | extern const char *spaces; | ||
7 | extern const char *dots; | ||
8 | |||
9 | /* Sane ctype - no locale, and works with signed chars */ | ||
10 | #undef isascii | ||
11 | #undef isspace | ||
12 | #undef isdigit | ||
13 | #undef isxdigit | ||
14 | #undef isalpha | ||
15 | #undef isprint | ||
16 | #undef isalnum | ||
17 | #undef islower | ||
18 | #undef isupper | ||
19 | #undef tolower | ||
20 | #undef toupper | ||
21 | |||
22 | extern unsigned char sane_ctype[256]; | ||
23 | #define GIT_SPACE 0x01 | ||
24 | #define GIT_DIGIT 0x02 | ||
25 | #define GIT_ALPHA 0x04 | ||
26 | #define GIT_GLOB_SPECIAL 0x08 | ||
27 | #define GIT_REGEX_SPECIAL 0x10 | ||
28 | #define GIT_PRINT_EXTRA 0x20 | ||
29 | #define GIT_PRINT 0x3E | ||
30 | #define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0) | ||
31 | #define isascii(x) (((x) & ~0x7f) == 0) | ||
32 | #define isspace(x) sane_istest(x,GIT_SPACE) | ||
33 | #define isdigit(x) sane_istest(x,GIT_DIGIT) | ||
34 | #define isxdigit(x) \ | ||
35 | (sane_istest(toupper(x), GIT_ALPHA | GIT_DIGIT) && toupper(x) < 'G') | ||
36 | #define isalpha(x) sane_istest(x,GIT_ALPHA) | ||
37 | #define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT) | ||
38 | #define isprint(x) sane_istest(x,GIT_PRINT) | ||
39 | #define islower(x) (sane_istest(x,GIT_ALPHA) && (x & 0x20)) | ||
40 | #define isupper(x) (sane_istest(x,GIT_ALPHA) && !(x & 0x20)) | ||
41 | #define tolower(x) sane_case((unsigned char)(x), 0x20) | ||
42 | #define toupper(x) sane_case((unsigned char)(x), 0) | ||
43 | |||
44 | static inline int sane_case(int x, int high) | ||
45 | { | ||
46 | if (sane_istest(x, GIT_ALPHA)) | ||
47 | x = (x & ~0x20) | high; | ||
48 | return x; | ||
49 | } | ||
50 | |||
51 | #endif /* _PERF_SANE_CTYPE_H */ | ||
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c index dff043a29589..2b12bdb3ce33 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c | |||
@@ -19,6 +19,7 @@ | |||
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <inttypes.h> | ||
22 | #include <stdio.h> | 23 | #include <stdio.h> |
23 | #include <stdlib.h> | 24 | #include <stdlib.h> |
24 | #include <string.h> | 25 | #include <string.h> |
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index 783326cfbaa6..9d92af7d0718 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include <Python.h> | 22 | #include <Python.h> |
23 | 23 | ||
24 | #include <inttypes.h> | ||
24 | #include <stdio.h> | 25 | #include <stdio.h> |
25 | #include <stdlib.h> | 26 | #include <stdlib.h> |
26 | #include <string.h> | 27 | #include <string.h> |
@@ -45,6 +46,7 @@ | |||
45 | #include "../call-path.h" | 46 | #include "../call-path.h" |
46 | #include "thread_map.h" | 47 | #include "thread_map.h" |
47 | #include "cpumap.h" | 48 | #include "cpumap.h" |
49 | #include "print_binary.h" | ||
48 | #include "stat.h" | 50 | #include "stat.h" |
49 | 51 | ||
50 | PyMODINIT_FUNC initperf_trace_context(void); | 52 | PyMODINIT_FUNC initperf_trace_context(void); |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 7b740a73e595..19d993f2a305 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -1,3 +1,5 @@ | |||
1 | #include <errno.h> | ||
2 | #include <inttypes.h> | ||
1 | #include <linux/kernel.h> | 3 | #include <linux/kernel.h> |
2 | #include <traceevent/event-parse.h> | 4 | #include <traceevent/event-parse.h> |
3 | #include <api/fs/fs.h> | 5 | #include <api/fs/fs.h> |
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 4bd758553450..1ffae42f76a1 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "thread.h" | 9 | #include "thread.h" |
10 | #include "data.h" | 10 | #include "data.h" |
11 | #include "ordered-events.h" | 11 | #include "ordered-events.h" |
12 | #include <linux/kernel.h> | ||
12 | #include <linux/rbtree.h> | 13 | #include <linux/rbtree.h> |
13 | #include <linux/perf_event.h> | 14 | #include <linux/perf_event.h> |
14 | 15 | ||
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 73f3ec1cf2a0..fe4fd7b5f8e0 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
@@ -1,3 +1,6 @@ | |||
1 | #include <errno.h> | ||
2 | #include <inttypes.h> | ||
3 | #include <regex.h> | ||
1 | #include <sys/mman.h> | 4 | #include <sys/mman.h> |
2 | #include "sort.h" | 5 | #include "sort.h" |
3 | #include "hist.h" | 6 | #include "hist.h" |
@@ -5,8 +8,10 @@ | |||
5 | #include "symbol.h" | 8 | #include "symbol.h" |
6 | #include "evsel.h" | 9 | #include "evsel.h" |
7 | #include "evlist.h" | 10 | #include "evlist.h" |
11 | #include "strlist.h" | ||
8 | #include <traceevent/event-parse.h> | 12 | #include <traceevent/event-parse.h> |
9 | #include "mem-events.h" | 13 | #include "mem-events.h" |
14 | #include <linux/kernel.h> | ||
10 | 15 | ||
11 | regex_t parent_regex; | 16 | regex_t parent_regex; |
12 | const char default_parent_pattern[] = "^sys_|^do_page_fault"; | 17 | const char default_parent_pattern[] = "^sys_|^do_page_fault"; |
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index e35fb186d048..8bcec05ee578 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #define __PERF_SORT_H | 2 | #define __PERF_SORT_H |
3 | #include "../builtin.h" | 3 | #include "../builtin.h" |
4 | 4 | ||
5 | #include "util.h" | 5 | #include <regex.h> |
6 | 6 | ||
7 | #include "color.h" | 7 | #include "color.h" |
8 | #include <linux/list.h> | 8 | #include <linux/list.h> |
@@ -11,7 +11,6 @@ | |||
11 | #include "symbol.h" | 11 | #include "symbol.h" |
12 | #include "string.h" | 12 | #include "string.h" |
13 | #include "callchain.h" | 13 | #include "callchain.h" |
14 | #include "strlist.h" | ||
15 | #include "values.h" | 14 | #include "values.h" |
16 | 15 | ||
17 | #include "../perf.h" | 16 | #include "../perf.h" |
@@ -21,6 +20,7 @@ | |||
21 | #include <subcmd/parse-options.h> | 20 | #include <subcmd/parse-options.h> |
22 | #include "parse-events.h" | 21 | #include "parse-events.h" |
23 | #include "hist.h" | 22 | #include "hist.h" |
23 | #include "srcline.h" | ||
24 | #include "thread.h" | 24 | #include "thread.h" |
25 | 25 | ||
26 | extern regex_t parent_regex; | 26 | extern regex_t parent_regex; |
diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c index 778ccb5d99d1..df051a52393c 100644 --- a/tools/perf/util/srcline.c +++ b/tools/perf/util/srcline.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <inttypes.h> | ||
1 | #include <stdio.h> | 2 | #include <stdio.h> |
2 | #include <stdlib.h> | 3 | #include <stdlib.h> |
3 | #include <string.h> | 4 | #include <string.h> |
@@ -8,6 +9,7 @@ | |||
8 | #include "util/util.h" | 9 | #include "util/util.h" |
9 | #include "util/debug.h" | 10 | #include "util/debug.h" |
10 | #include "util/callchain.h" | 11 | #include "util/callchain.h" |
12 | #include "srcline.h" | ||
11 | 13 | ||
12 | #include "symbol.h" | 14 | #include "symbol.h" |
13 | 15 | ||
diff --git a/tools/perf/util/srcline.h b/tools/perf/util/srcline.h new file mode 100644 index 000000000000..7b52ba88676e --- /dev/null +++ b/tools/perf/util/srcline.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef PERF_SRCLINE_H | ||
2 | #define PERF_SRCLINE_H | ||
3 | |||
4 | #include <linux/list.h> | ||
5 | #include <linux/types.h> | ||
6 | |||
7 | struct dso; | ||
8 | struct symbol; | ||
9 | |||
10 | extern bool srcline_full_filename; | ||
11 | char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym, | ||
12 | bool show_sym, bool show_addr); | ||
13 | char *__get_srcline(struct dso *dso, u64 addr, struct symbol *sym, | ||
14 | bool show_sym, bool show_addr, bool unwind_inlines); | ||
15 | void free_srcline(char *srcline); | ||
16 | |||
17 | #define SRCLINE_UNKNOWN ((char *) "??:0") | ||
18 | |||
19 | struct inline_list { | ||
20 | char *filename; | ||
21 | char *funcname; | ||
22 | unsigned int line_nr; | ||
23 | struct list_head list; | ||
24 | }; | ||
25 | |||
26 | struct inline_node { | ||
27 | u64 addr; | ||
28 | struct list_head val; | ||
29 | }; | ||
30 | |||
31 | struct inline_node *dso__parse_addr_inlines(struct dso *dso, u64 addr); | ||
32 | void inline_node__delete(struct inline_node *node); | ||
33 | |||
34 | #endif /* PERF_SRCLINE_H */ | ||
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 0d51334a9b46..c58174443dc1 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c | |||
@@ -1,3 +1,5 @@ | |||
1 | #include <errno.h> | ||
2 | #include <inttypes.h> | ||
1 | #include <math.h> | 3 | #include <math.h> |
2 | #include "stat.h" | 4 | #include "stat.h" |
3 | #include "evlist.h" | 5 | #include "evlist.h" |
diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c index 817593908d47..e91b5e86f027 100644 --- a/tools/perf/util/strbuf.c +++ b/tools/perf/util/strbuf.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include "debug.h" | 1 | #include "debug.h" |
2 | #include "util.h" | 2 | #include "util.h" |
3 | #include <linux/kernel.h> | 3 | #include <linux/kernel.h> |
4 | #include <errno.h> | ||
4 | 5 | ||
5 | int prefixcmp(const char *str, const char *prefix) | 6 | int prefixcmp(const char *str, const char *prefix) |
6 | { | 7 | { |
diff --git a/tools/perf/util/strfilter.c b/tools/perf/util/strfilter.c index efb53772e0ec..4dc0af669a30 100644 --- a/tools/perf/util/strfilter.c +++ b/tools/perf/util/strfilter.c | |||
@@ -1,7 +1,10 @@ | |||
1 | #include "util.h" | 1 | #include "util.h" |
2 | #include "string.h" | 2 | #include "string2.h" |
3 | #include "strfilter.h" | 3 | #include "strfilter.h" |
4 | 4 | ||
5 | #include <errno.h> | ||
6 | #include "sane_ctype.h" | ||
7 | |||
5 | /* Operators */ | 8 | /* Operators */ |
6 | static const char *OP_and = "&"; /* Logical AND */ | 9 | static const char *OP_and = "&"; /* Logical AND */ |
7 | static const char *OP_or = "|"; /* Logical OR */ | 10 | static const char *OP_or = "|"; /* Logical OR */ |
diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c index e8feb142c9c9..cca53b693a48 100644 --- a/tools/perf/util/string.c +++ b/tools/perf/util/string.c | |||
@@ -1,5 +1,9 @@ | |||
1 | #include "util.h" | 1 | #include "string2.h" |
2 | #include "linux/string.h" | 2 | #include <linux/kernel.h> |
3 | #include <linux/string.h> | ||
4 | #include <stdlib.h> | ||
5 | |||
6 | #include "sane_ctype.h" | ||
3 | 7 | ||
4 | #define K 1024LL | 8 | #define K 1024LL |
5 | /* | 9 | /* |
@@ -99,8 +103,10 @@ static int count_argc(const char *str) | |||
99 | void argv_free(char **argv) | 103 | void argv_free(char **argv) |
100 | { | 104 | { |
101 | char **p; | 105 | char **p; |
102 | for (p = argv; *p; p++) | 106 | for (p = argv; *p; p++) { |
103 | zfree(p); | 107 | free(*p); |
108 | *p = NULL; | ||
109 | } | ||
104 | 110 | ||
105 | free(argv); | 111 | free(argv); |
106 | } | 112 | } |
@@ -120,7 +126,7 @@ void argv_free(char **argv) | |||
120 | char **argv_split(const char *str, int *argcp) | 126 | char **argv_split(const char *str, int *argcp) |
121 | { | 127 | { |
122 | int argc = count_argc(str); | 128 | int argc = count_argc(str); |
123 | char **argv = zalloc(sizeof(*argv) * (argc+1)); | 129 | char **argv = calloc(argc + 1, sizeof(*argv)); |
124 | char **argvp; | 130 | char **argvp; |
125 | 131 | ||
126 | if (argv == NULL) | 132 | if (argv == NULL) |
@@ -377,7 +383,7 @@ char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints | |||
377 | goto out_err_overflow; | 383 | goto out_err_overflow; |
378 | 384 | ||
379 | if (i > 0) | 385 | if (i > 0) |
380 | printed += snprintf(e + printed, size - printed, " %s ", or_and); | 386 | printed += scnprintf(e + printed, size - printed, " %s ", or_and); |
381 | printed += scnprintf(e + printed, size - printed, | 387 | printed += scnprintf(e + printed, size - printed, |
382 | "%s %s %d", var, eq_neq, ints[i]); | 388 | "%s %s %d", var, eq_neq, ints[i]); |
383 | } | 389 | } |
diff --git a/tools/perf/util/string2.h b/tools/perf/util/string2.h new file mode 100644 index 000000000000..2f619681bd6a --- /dev/null +++ b/tools/perf/util/string2.h | |||
@@ -0,0 +1,42 @@ | |||
1 | #ifndef PERF_STRING_H | ||
2 | #define PERF_STRING_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | #include <stddef.h> | ||
6 | #include <string.h> | ||
7 | |||
8 | s64 perf_atoll(const char *str); | ||
9 | char **argv_split(const char *str, int *argcp); | ||
10 | void argv_free(char **argv); | ||
11 | bool strglobmatch(const char *str, const char *pat); | ||
12 | bool strglobmatch_nocase(const char *str, const char *pat); | ||
13 | bool strlazymatch(const char *str, const char *pat); | ||
14 | static inline bool strisglob(const char *str) | ||
15 | { | ||
16 | return strpbrk(str, "*?[") != NULL; | ||
17 | } | ||
18 | int strtailcmp(const char *s1, const char *s2); | ||
19 | char *strxfrchar(char *s, char from, char to); | ||
20 | |||
21 | char *ltrim(char *s); | ||
22 | char *rtrim(char *s); | ||
23 | |||
24 | static inline char *trim(char *s) | ||
25 | { | ||
26 | return ltrim(rtrim(s)); | ||
27 | } | ||
28 | |||
29 | char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints); | ||
30 | |||
31 | static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints) | ||
32 | { | ||
33 | return asprintf_expr_inout_ints(var, true, nints, ints); | ||
34 | } | ||
35 | |||
36 | static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int *ints) | ||
37 | { | ||
38 | return asprintf_expr_inout_ints(var, false, nints, ints); | ||
39 | } | ||
40 | |||
41 | |||
42 | #endif /* PERF_STRING_H */ | ||
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index d1a40bb642ff..e7ee47f7377a 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c | |||
@@ -10,8 +10,9 @@ | |||
10 | #include "demangle-rust.h" | 10 | #include "demangle-rust.h" |
11 | #include "machine.h" | 11 | #include "machine.h" |
12 | #include "vdso.h" | 12 | #include "vdso.h" |
13 | #include <symbol/kallsyms.h> | ||
14 | #include "debug.h" | 13 | #include "debug.h" |
14 | #include "sane_ctype.h" | ||
15 | #include <symbol/kallsyms.h> | ||
15 | 16 | ||
16 | #ifndef EM_AARCH64 | 17 | #ifndef EM_AARCH64 |
17 | #define EM_AARCH64 183 /* ARM 64 bit */ | 18 | #define EM_AARCH64 183 /* ARM 64 bit */ |
diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c index 870ef0f0659c..40bf5d4c0bfd 100644 --- a/tools/perf/util/symbol-minimal.c +++ b/tools/perf/util/symbol-minimal.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include "symbol.h" | 1 | #include "symbol.h" |
2 | #include "util.h" | 2 | #include "util.h" |
3 | 3 | ||
4 | #include <errno.h> | ||
4 | #include <stdio.h> | 5 | #include <stdio.h> |
5 | #include <fcntl.h> | 6 | #include <fcntl.h> |
6 | #include <string.h> | 7 | #include <string.h> |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 9b4d8ba22fed..2cb7665e9973 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <stdio.h> | 4 | #include <stdio.h> |
5 | #include <string.h> | 5 | #include <string.h> |
6 | #include <linux/kernel.h> | ||
6 | #include <sys/types.h> | 7 | #include <sys/types.h> |
7 | #include <sys/stat.h> | 8 | #include <sys/stat.h> |
8 | #include <sys/param.h> | 9 | #include <sys/param.h> |
@@ -18,6 +19,8 @@ | |||
18 | #include "strlist.h" | 19 | #include "strlist.h" |
19 | #include "intlist.h" | 20 | #include "intlist.h" |
20 | #include "header.h" | 21 | #include "header.h" |
22 | #include "path.h" | ||
23 | #include "sane_ctype.h" | ||
21 | 24 | ||
22 | #include <elf.h> | 25 | #include <elf.h> |
23 | #include <limits.h> | 26 | #include <limits.h> |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 5245d2fb1a0a..7acd70fce68e 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <libgen.h> | 13 | #include <libgen.h> |
14 | #include "build-id.h" | 14 | #include "build-id.h" |
15 | #include "event.h" | 15 | #include "event.h" |
16 | #include "util.h" | 16 | #include "path.h" |
17 | 17 | ||
18 | #ifdef HAVE_LIBELF_SUPPORT | 18 | #ifdef HAVE_LIBELF_SUPPORT |
19 | #include <libelf.h> | 19 | #include <libelf.h> |
diff --git a/tools/perf/util/term.c b/tools/perf/util/term.c index 90b47d8aa19c..8f254a74d97d 100644 --- a/tools/perf/util/term.c +++ b/tools/perf/util/term.c | |||
@@ -1,4 +1,8 @@ | |||
1 | #include "util.h" | 1 | #include "term.h" |
2 | #include <stdlib.h> | ||
3 | #include <termios.h> | ||
4 | #include <unistd.h> | ||
5 | #include <sys/ioctl.h> | ||
2 | 6 | ||
3 | void get_term_dimensions(struct winsize *ws) | 7 | void get_term_dimensions(struct winsize *ws) |
4 | { | 8 | { |
diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c index d3301529f6a7..dd17d6a38d3a 100644 --- a/tools/perf/util/thread-stack.c +++ b/tools/perf/util/thread-stack.c | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | #include <linux/rbtree.h> | 16 | #include <linux/rbtree.h> |
17 | #include <linux/list.h> | 17 | #include <linux/list.h> |
18 | #include <errno.h> | ||
18 | #include "thread.h" | 19 | #include "thread.h" |
19 | #include "event.h" | 20 | #include "event.h" |
20 | #include "machine.h" | 21 | #include "machine.h" |
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index dcdb87a5d0a1..378c418ca0c1 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c | |||
@@ -1,7 +1,9 @@ | |||
1 | #include "../perf.h" | 1 | #include "../perf.h" |
2 | #include <errno.h> | ||
2 | #include <stdlib.h> | 3 | #include <stdlib.h> |
3 | #include <stdio.h> | 4 | #include <stdio.h> |
4 | #include <string.h> | 5 | #include <string.h> |
6 | #include <linux/kernel.h> | ||
5 | #include "session.h" | 7 | #include "session.h" |
6 | #include "thread.h" | 8 | #include "thread.h" |
7 | #include "thread-stack.h" | 9 | #include "thread-stack.h" |
diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c index 9026408ea55b..63ead7b06324 100644 --- a/tools/perf/util/thread_map.c +++ b/tools/perf/util/thread_map.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #include <dirent.h> | 1 | #include <dirent.h> |
2 | #include <errno.h> | ||
2 | #include <limits.h> | 3 | #include <limits.h> |
3 | #include <stdbool.h> | 4 | #include <stdbool.h> |
4 | #include <stdlib.h> | 5 | #include <stdlib.h> |
@@ -6,6 +7,7 @@ | |||
6 | #include <sys/types.h> | 7 | #include <sys/types.h> |
7 | #include <sys/stat.h> | 8 | #include <sys/stat.h> |
8 | #include <unistd.h> | 9 | #include <unistd.h> |
10 | #include "string2.h" | ||
9 | #include "strlist.h" | 11 | #include "strlist.h" |
10 | #include <string.h> | 12 | #include <string.h> |
11 | #include <api/fs/fs.h> | 13 | #include <api/fs/fs.h> |
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index de0078e21408..746bbee645d9 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c | |||
@@ -21,13 +21,14 @@ | |||
21 | #include <stdio.h> | 21 | #include <stdio.h> |
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | #include <string.h> | 23 | #include <string.h> |
24 | #include <ctype.h> | ||
25 | #include <errno.h> | 24 | #include <errno.h> |
26 | 25 | ||
27 | #include "../perf.h" | 26 | #include "../perf.h" |
28 | #include "util.h" | 27 | #include "util.h" |
29 | #include "trace-event.h" | 28 | #include "trace-event.h" |
30 | 29 | ||
30 | #include "sane_ctype.h" | ||
31 | |||
31 | static int get_common_field(struct scripting_context *context, | 32 | static int get_common_field(struct scripting_context *context, |
32 | int *offset, int *size, const char *type) | 33 | int *offset, int *size, const char *type) |
33 | { | 34 | { |
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c index 783a53fb7a4e..f90e11a555b2 100644 --- a/tools/perf/util/unwind-libdw.c +++ b/tools/perf/util/unwind-libdw.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "event.h" | 12 | #include "event.h" |
13 | #include "perf_regs.h" | 13 | #include "perf_regs.h" |
14 | #include "callchain.h" | 14 | #include "callchain.h" |
15 | #include "util.h" | ||
15 | 16 | ||
16 | static char *debuginfo_path; | 17 | static char *debuginfo_path; |
17 | 18 | ||
diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c index bfb9b7987692..f8455bed6e65 100644 --- a/tools/perf/util/unwind-libunwind-local.c +++ b/tools/perf/util/unwind-libunwind-local.c | |||
@@ -16,8 +16,10 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <elf.h> | 18 | #include <elf.h> |
19 | #include <errno.h> | ||
19 | #include <gelf.h> | 20 | #include <gelf.h> |
20 | #include <fcntl.h> | 21 | #include <fcntl.h> |
22 | #include <inttypes.h> | ||
21 | #include <string.h> | 23 | #include <string.h> |
22 | #include <unistd.h> | 24 | #include <unistd.h> |
23 | #include <sys/mman.h> | 25 | #include <sys/mman.h> |
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 6097d87429e2..b9716bc6e8fd 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -7,6 +7,8 @@ | |||
7 | #ifdef HAVE_BACKTRACE_SUPPORT | 7 | #ifdef HAVE_BACKTRACE_SUPPORT |
8 | #include <execinfo.h> | 8 | #include <execinfo.h> |
9 | #endif | 9 | #endif |
10 | #include <dirent.h> | ||
11 | #include <inttypes.h> | ||
10 | #include <stdio.h> | 12 | #include <stdio.h> |
11 | #include <stdlib.h> | 13 | #include <stdlib.h> |
12 | #include <string.h> | 14 | #include <string.h> |
@@ -712,16 +714,6 @@ out: | |||
712 | return tip; | 714 | return tip; |
713 | } | 715 | } |
714 | 716 | ||
715 | bool is_regular_file(const char *file) | ||
716 | { | ||
717 | struct stat st; | ||
718 | |||
719 | if (stat(file, &st)) | ||
720 | return false; | ||
721 | |||
722 | return S_ISREG(st.st_mode); | ||
723 | } | ||
724 | |||
725 | int fetch_current_timestamp(char *buf, size_t sz) | 717 | int fetch_current_timestamp(char *buf, size_t sz) |
726 | { | 718 | { |
727 | struct timeval tv; | 719 | struct timeval tv; |
@@ -739,58 +731,6 @@ int fetch_current_timestamp(char *buf, size_t sz) | |||
739 | return 0; | 731 | return 0; |
740 | } | 732 | } |
741 | 733 | ||
742 | void print_binary(unsigned char *data, size_t len, | ||
743 | size_t bytes_per_line, print_binary_t printer, | ||
744 | void *extra) | ||
745 | { | ||
746 | size_t i, j, mask; | ||
747 | |||
748 | if (!printer) | ||
749 | return; | ||
750 | |||
751 | bytes_per_line = roundup_pow_of_two(bytes_per_line); | ||
752 | mask = bytes_per_line - 1; | ||
753 | |||
754 | printer(BINARY_PRINT_DATA_BEGIN, 0, extra); | ||
755 | for (i = 0; i < len; i++) { | ||
756 | if ((i & mask) == 0) { | ||
757 | printer(BINARY_PRINT_LINE_BEGIN, -1, extra); | ||
758 | printer(BINARY_PRINT_ADDR, i, extra); | ||
759 | } | ||
760 | |||
761 | printer(BINARY_PRINT_NUM_DATA, data[i], extra); | ||
762 | |||
763 | if (((i & mask) == mask) || i == len - 1) { | ||
764 | for (j = 0; j < mask-(i & mask); j++) | ||
765 | printer(BINARY_PRINT_NUM_PAD, -1, extra); | ||
766 | |||
767 | printer(BINARY_PRINT_SEP, i, extra); | ||
768 | for (j = i & ~mask; j <= i; j++) | ||
769 | printer(BINARY_PRINT_CHAR_DATA, data[j], extra); | ||
770 | for (j = 0; j < mask-(i & mask); j++) | ||
771 | printer(BINARY_PRINT_CHAR_PAD, i, extra); | ||
772 | printer(BINARY_PRINT_LINE_END, -1, extra); | ||
773 | } | ||
774 | } | ||
775 | printer(BINARY_PRINT_DATA_END, -1, extra); | ||
776 | } | ||
777 | |||
778 | int is_printable_array(char *p, unsigned int len) | ||
779 | { | ||
780 | unsigned int i; | ||
781 | |||
782 | if (!p || !len || p[len - 1] != 0) | ||
783 | return 0; | ||
784 | |||
785 | len--; | ||
786 | |||
787 | for (i = 0; i < len; i++) { | ||
788 | if (!isprint(p[i]) && !isspace(p[i])) | ||
789 | return 0; | ||
790 | } | ||
791 | return 1; | ||
792 | } | ||
793 | |||
794 | int unit_number__scnprintf(char *buf, size_t size, u64 n) | 734 | int unit_number__scnprintf(char *buf, size_t size, u64 n) |
795 | { | 735 | { |
796 | char unit[4] = "BKMG"; | 736 | char unit[4] = "BKMG"; |
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 7cf5752b38fd..2a1166f8bb37 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -1,42 +1,6 @@ | |||
1 | #ifndef GIT_COMPAT_UTIL_H | 1 | #ifndef GIT_COMPAT_UTIL_H |
2 | #define GIT_COMPAT_UTIL_H | 2 | #define GIT_COMPAT_UTIL_H |
3 | 3 | ||
4 | #ifndef FLEX_ARRAY | ||
5 | /* | ||
6 | * See if our compiler is known to support flexible array members. | ||
7 | */ | ||
8 | #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) | ||
9 | # define FLEX_ARRAY /* empty */ | ||
10 | #elif defined(__GNUC__) | ||
11 | # if (__GNUC__ >= 3) | ||
12 | # define FLEX_ARRAY /* empty */ | ||
13 | # else | ||
14 | # define FLEX_ARRAY 0 /* older GNU extension */ | ||
15 | # endif | ||
16 | #endif | ||
17 | |||
18 | /* | ||
19 | * Otherwise, default to safer but a bit wasteful traditional style | ||
20 | */ | ||
21 | #ifndef FLEX_ARRAY | ||
22 | # define FLEX_ARRAY 1 | ||
23 | #endif | ||
24 | #endif | ||
25 | |||
26 | #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) | ||
27 | |||
28 | #ifdef __GNUC__ | ||
29 | #define TYPEOF(x) (__typeof__(x)) | ||
30 | #else | ||
31 | #define TYPEOF(x) | ||
32 | #endif | ||
33 | |||
34 | #define MSB(x, bits) ((x) & TYPEOF(x)(~0ULL << (sizeof(x) * 8 - (bits)))) | ||
35 | #define HAS_MULTI_BITS(i) ((i) & ((i) - 1)) /* checks if an integer has more than 1 bit set */ | ||
36 | |||
37 | /* Approximation of the length of the decimal representation of this type. */ | ||
38 | #define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1) | ||
39 | |||
40 | #define _ALL_SOURCE 1 | 4 | #define _ALL_SOURCE 1 |
41 | #define _BSD_SOURCE 1 | 5 | #define _BSD_SOURCE 1 |
42 | /* glibc 2.20 deprecates _BSD_SOURCE in favour of _DEFAULT_SOURCE */ | 6 | /* glibc 2.20 deprecates _BSD_SOURCE in favour of _DEFAULT_SOURCE */ |
@@ -53,73 +17,22 @@ | |||
53 | #include <stdlib.h> | 17 | #include <stdlib.h> |
54 | #include <stdarg.h> | 18 | #include <stdarg.h> |
55 | #include <string.h> | 19 | #include <string.h> |
56 | #include <term.h> | ||
57 | #include <errno.h> | ||
58 | #include <limits.h> | 20 | #include <limits.h> |
59 | #include <sys/param.h> | 21 | #include <sys/param.h> |
60 | #include <sys/types.h> | 22 | #include <sys/types.h> |
61 | #include <dirent.h> | ||
62 | #include <sys/time.h> | 23 | #include <sys/time.h> |
63 | #include <time.h> | 24 | #include <time.h> |
64 | #include <signal.h> | 25 | #include <signal.h> |
65 | #include <fnmatch.h> | ||
66 | #include <assert.h> | 26 | #include <assert.h> |
67 | #include <regex.h> | ||
68 | #include <utime.h> | 27 | #include <utime.h> |
69 | #include <sys/wait.h> | 28 | #include <sys/wait.h> |
70 | #include <poll.h> | 29 | #include <poll.h> |
71 | #include <sys/socket.h> | 30 | #include <sys/socket.h> |
72 | #include <sys/ioctl.h> | 31 | #include <sys/ioctl.h> |
73 | #include <inttypes.h> | ||
74 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
75 | #include <linux/types.h> | 33 | #include <linux/types.h> |
76 | #include <sys/ttydefaults.h> | ||
77 | #include <api/fs/tracing_path.h> | ||
78 | #include <termios.h> | ||
79 | #include <linux/bitops.h> | ||
80 | #include <termios.h> | ||
81 | #include "strlist.h" | ||
82 | |||
83 | extern const char *graph_line; | ||
84 | extern const char *graph_dotted_line; | ||
85 | extern const char *spaces; | ||
86 | extern const char *dots; | ||
87 | extern char buildid_dir[]; | ||
88 | |||
89 | /* On most systems <limits.h> would have given us this, but | ||
90 | * not on some systems (e.g. GNU/Hurd). | ||
91 | */ | ||
92 | #ifndef PATH_MAX | ||
93 | #define PATH_MAX 4096 | ||
94 | #endif | ||
95 | |||
96 | #ifndef PRIuMAX | ||
97 | #define PRIuMAX "llu" | ||
98 | #endif | ||
99 | |||
100 | #ifndef PRIu32 | ||
101 | #define PRIu32 "u" | ||
102 | #endif | ||
103 | |||
104 | #ifndef PRIx32 | ||
105 | #define PRIx32 "x" | ||
106 | #endif | ||
107 | |||
108 | #ifndef PATH_SEP | ||
109 | #define PATH_SEP ':' | ||
110 | #endif | ||
111 | |||
112 | #ifndef STRIP_EXTENSION | ||
113 | #define STRIP_EXTENSION "" | ||
114 | #endif | ||
115 | |||
116 | #ifndef has_dos_drive_prefix | ||
117 | #define has_dos_drive_prefix(path) 0 | ||
118 | #endif | ||
119 | 34 | ||
120 | #ifndef is_dir_sep | 35 | extern char buildid_dir[]; |
121 | #define is_dir_sep(c) ((c) == '/') | ||
122 | #endif | ||
123 | 36 | ||
124 | #ifdef __GNUC__ | 37 | #ifdef __GNUC__ |
125 | #define NORETURN __attribute__((__noreturn__)) | 38 | #define NORETURN __attribute__((__noreturn__)) |
@@ -143,22 +56,6 @@ void set_warning_routine(void (*routine)(const char *err, va_list params)); | |||
143 | int prefixcmp(const char *str, const char *prefix); | 56 | int prefixcmp(const char *str, const char *prefix); |
144 | void set_buildid_dir(const char *dir); | 57 | void set_buildid_dir(const char *dir); |
145 | 58 | ||
146 | #ifdef __GLIBC_PREREQ | ||
147 | #if __GLIBC_PREREQ(2, 1) | ||
148 | #define HAVE_STRCHRNUL | ||
149 | #endif | ||
150 | #endif | ||
151 | |||
152 | #ifndef HAVE_STRCHRNUL | ||
153 | #define strchrnul gitstrchrnul | ||
154 | static inline char *gitstrchrnul(const char *s, int c) | ||
155 | { | ||
156 | while (*s && *s != c) | ||
157 | s++; | ||
158 | return (char *)s; | ||
159 | } | ||
160 | #endif | ||
161 | |||
162 | static inline void *zalloc(size_t size) | 59 | static inline void *zalloc(size_t size) |
163 | { | 60 | { |
164 | return calloc(1, size); | 61 | return calloc(1, size); |
@@ -166,47 +63,8 @@ static inline void *zalloc(size_t size) | |||
166 | 63 | ||
167 | #define zfree(ptr) ({ free(*ptr); *ptr = NULL; }) | 64 | #define zfree(ptr) ({ free(*ptr); *ptr = NULL; }) |
168 | 65 | ||
169 | /* Sane ctype - no locale, and works with signed chars */ | 66 | struct dirent; |
170 | #undef isascii | 67 | struct strlist; |
171 | #undef isspace | ||
172 | #undef isdigit | ||
173 | #undef isxdigit | ||
174 | #undef isalpha | ||
175 | #undef isprint | ||
176 | #undef isalnum | ||
177 | #undef islower | ||
178 | #undef isupper | ||
179 | #undef tolower | ||
180 | #undef toupper | ||
181 | |||
182 | extern unsigned char sane_ctype[256]; | ||
183 | #define GIT_SPACE 0x01 | ||
184 | #define GIT_DIGIT 0x02 | ||
185 | #define GIT_ALPHA 0x04 | ||
186 | #define GIT_GLOB_SPECIAL 0x08 | ||
187 | #define GIT_REGEX_SPECIAL 0x10 | ||
188 | #define GIT_PRINT_EXTRA 0x20 | ||
189 | #define GIT_PRINT 0x3E | ||
190 | #define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0) | ||
191 | #define isascii(x) (((x) & ~0x7f) == 0) | ||
192 | #define isspace(x) sane_istest(x,GIT_SPACE) | ||
193 | #define isdigit(x) sane_istest(x,GIT_DIGIT) | ||
194 | #define isxdigit(x) \ | ||
195 | (sane_istest(toupper(x), GIT_ALPHA | GIT_DIGIT) && toupper(x) < 'G') | ||
196 | #define isalpha(x) sane_istest(x,GIT_ALPHA) | ||
197 | #define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT) | ||
198 | #define isprint(x) sane_istest(x,GIT_PRINT) | ||
199 | #define islower(x) (sane_istest(x,GIT_ALPHA) && (x & 0x20)) | ||
200 | #define isupper(x) (sane_istest(x,GIT_ALPHA) && !(x & 0x20)) | ||
201 | #define tolower(x) sane_case((unsigned char)(x), 0x20) | ||
202 | #define toupper(x) sane_case((unsigned char)(x), 0) | ||
203 | |||
204 | static inline int sane_case(int x, int high) | ||
205 | { | ||
206 | if (sane_istest(x, GIT_ALPHA)) | ||
207 | x = (x & ~0x20) | high; | ||
208 | return x; | ||
209 | } | ||
210 | 68 | ||
211 | int mkdir_p(char *path, mode_t mode); | 69 | int mkdir_p(char *path, mode_t mode); |
212 | int rm_rf(const char *path); | 70 | int rm_rf(const char *path); |
@@ -216,18 +74,6 @@ int copyfile(const char *from, const char *to); | |||
216 | int copyfile_mode(const char *from, const char *to, mode_t mode); | 74 | int copyfile_mode(const char *from, const char *to, mode_t mode); |
217 | int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 size); | 75 | int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 size); |
218 | 76 | ||
219 | s64 perf_atoll(const char *str); | ||
220 | char **argv_split(const char *str, int *argcp); | ||
221 | void argv_free(char **argv); | ||
222 | bool strglobmatch(const char *str, const char *pat); | ||
223 | bool strglobmatch_nocase(const char *str, const char *pat); | ||
224 | bool strlazymatch(const char *str, const char *pat); | ||
225 | static inline bool strisglob(const char *str) | ||
226 | { | ||
227 | return strpbrk(str, "*?[") != NULL; | ||
228 | } | ||
229 | int strtailcmp(const char *s1, const char *s2); | ||
230 | char *strxfrchar(char *s, char from, char to); | ||
231 | unsigned long convert_unit(unsigned long value, char *unit); | 77 | unsigned long convert_unit(unsigned long value, char *unit); |
232 | ssize_t readn(int fd, void *buf, size_t n); | 78 | ssize_t readn(int fd, void *buf, size_t n); |
233 | ssize_t writen(int fd, void *buf, size_t n); | 79 | ssize_t writen(int fd, void *buf, size_t n); |
@@ -236,20 +82,9 @@ struct perf_event_attr; | |||
236 | 82 | ||
237 | void event_attr_init(struct perf_event_attr *attr); | 83 | void event_attr_init(struct perf_event_attr *attr); |
238 | 84 | ||
239 | #define _STR(x) #x | ||
240 | #define STR(x) _STR(x) | ||
241 | |||
242 | size_t hex_width(u64 v); | 85 | size_t hex_width(u64 v); |
243 | int hex2u64(const char *ptr, u64 *val); | 86 | int hex2u64(const char *ptr, u64 *val); |
244 | 87 | ||
245 | char *ltrim(char *s); | ||
246 | char *rtrim(char *s); | ||
247 | |||
248 | static inline char *trim(char *s) | ||
249 | { | ||
250 | return ltrim(rtrim(s)); | ||
251 | } | ||
252 | |||
253 | void dump_stack(void); | 88 | void dump_stack(void); |
254 | void sighandler_dump_stack(int sig); | 89 | void sighandler_dump_stack(int sig); |
255 | 90 | ||
@@ -265,33 +100,6 @@ struct parse_tag { | |||
265 | 100 | ||
266 | unsigned long parse_tag_value(const char *str, struct parse_tag *tags); | 101 | unsigned long parse_tag_value(const char *str, struct parse_tag *tags); |
267 | 102 | ||
268 | #define SRCLINE_UNKNOWN ((char *) "??:0") | ||
269 | |||
270 | static inline int path__join(char *bf, size_t size, | ||
271 | const char *path1, const char *path2) | ||
272 | { | ||
273 | return scnprintf(bf, size, "%s%s%s", path1, path1[0] ? "/" : "", path2); | ||
274 | } | ||
275 | |||
276 | static inline int path__join3(char *bf, size_t size, | ||
277 | const char *path1, const char *path2, | ||
278 | const char *path3) | ||
279 | { | ||
280 | return scnprintf(bf, size, "%s%s%s%s%s", | ||
281 | path1, path1[0] ? "/" : "", | ||
282 | path2, path2[0] ? "/" : "", path3); | ||
283 | } | ||
284 | |||
285 | struct dso; | ||
286 | struct symbol; | ||
287 | |||
288 | extern bool srcline_full_filename; | ||
289 | char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym, | ||
290 | bool show_sym, bool show_addr); | ||
291 | char *__get_srcline(struct dso *dso, u64 addr, struct symbol *sym, | ||
292 | bool show_sym, bool show_addr, bool unwind_inlines); | ||
293 | void free_srcline(char *srcline); | ||
294 | |||
295 | int perf_event_paranoid(void); | 103 | int perf_event_paranoid(void); |
296 | 104 | ||
297 | void mem_bswap_64(void *src, int byte_size); | 105 | void mem_bswap_64(void *src, int byte_size); |
@@ -308,18 +116,6 @@ int gzip_decompress_to_file(const char *input, int output_fd); | |||
308 | int lzma_decompress_to_file(const char *input, int output_fd); | 116 | int lzma_decompress_to_file(const char *input, int output_fd); |
309 | #endif | 117 | #endif |
310 | 118 | ||
311 | char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints); | ||
312 | |||
313 | static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints) | ||
314 | { | ||
315 | return asprintf_expr_inout_ints(var, true, nints, ints); | ||
316 | } | ||
317 | |||
318 | static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int *ints) | ||
319 | { | ||
320 | return asprintf_expr_inout_ints(var, false, nints, ints); | ||
321 | } | ||
322 | |||
323 | int get_stack_size(const char *str, unsigned long *_size); | 119 | int get_stack_size(const char *str, unsigned long *_size); |
324 | 120 | ||
325 | int fetch_kernel_version(unsigned int *puint, | 121 | int fetch_kernel_version(unsigned int *puint, |
@@ -331,53 +127,14 @@ int fetch_kernel_version(unsigned int *puint, | |||
331 | #define KVER_PARAM(x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x) | 127 | #define KVER_PARAM(x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x) |
332 | 128 | ||
333 | const char *perf_tip(const char *dirpath); | 129 | const char *perf_tip(const char *dirpath); |
334 | bool is_regular_file(const char *file); | ||
335 | int fetch_current_timestamp(char *buf, size_t sz); | 130 | int fetch_current_timestamp(char *buf, size_t sz); |
336 | 131 | ||
337 | enum binary_printer_ops { | ||
338 | BINARY_PRINT_DATA_BEGIN, | ||
339 | BINARY_PRINT_LINE_BEGIN, | ||
340 | BINARY_PRINT_ADDR, | ||
341 | BINARY_PRINT_NUM_DATA, | ||
342 | BINARY_PRINT_NUM_PAD, | ||
343 | BINARY_PRINT_SEP, | ||
344 | BINARY_PRINT_CHAR_DATA, | ||
345 | BINARY_PRINT_CHAR_PAD, | ||
346 | BINARY_PRINT_LINE_END, | ||
347 | BINARY_PRINT_DATA_END, | ||
348 | }; | ||
349 | |||
350 | typedef void (*print_binary_t)(enum binary_printer_ops, | ||
351 | unsigned int val, | ||
352 | void *extra); | ||
353 | |||
354 | void print_binary(unsigned char *data, size_t len, | ||
355 | size_t bytes_per_line, print_binary_t printer, | ||
356 | void *extra); | ||
357 | |||
358 | #ifndef HAVE_SCHED_GETCPU_SUPPORT | 132 | #ifndef HAVE_SCHED_GETCPU_SUPPORT |
359 | int sched_getcpu(void); | 133 | int sched_getcpu(void); |
360 | #endif | 134 | #endif |
361 | 135 | ||
362 | int is_printable_array(char *p, unsigned int len); | ||
363 | |||
364 | int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz); | 136 | int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz); |
365 | 137 | ||
366 | int unit_number__scnprintf(char *buf, size_t size, u64 n); | 138 | int unit_number__scnprintf(char *buf, size_t size, u64 n); |
367 | 139 | ||
368 | struct inline_list { | ||
369 | char *filename; | ||
370 | char *funcname; | ||
371 | unsigned int line_nr; | ||
372 | struct list_head list; | ||
373 | }; | ||
374 | |||
375 | struct inline_node { | ||
376 | u64 addr; | ||
377 | struct list_head val; | ||
378 | }; | ||
379 | |||
380 | struct inline_node *dso__parse_addr_inlines(struct dso *dso, u64 addr); | ||
381 | void inline_node__delete(struct inline_node *node); | ||
382 | |||
383 | #endif /* GIT_COMPAT_UTIL_H */ | 140 | #endif /* GIT_COMPAT_UTIL_H */ |
diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c index 7bdcad484225..d3c39eec89a8 100644 --- a/tools/perf/util/vdso.c +++ b/tools/perf/util/vdso.c | |||
@@ -1,4 +1,4 @@ | |||
1 | 1 | #include <errno.h> | |
2 | #include <unistd.h> | 2 | #include <unistd.h> |
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <string.h> | 4 | #include <string.h> |