diff options
Diffstat (limited to 'tools/perf')
194 files changed, 1037 insertions, 634 deletions
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/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index dfea6b635525..29361d9b635a 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "../../util/cs-etm.h" | 33 | #include "../../util/cs-etm.h" |
34 | 34 | ||
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | #include <sys/stat.h> | ||
36 | 37 | ||
37 | #define ENABLE_SINK_MAX 128 | 38 | #define ENABLE_SINK_MAX 128 |
38 | #define CS_BUS_DEVICE_PATH "/bus/coresight/devices/" | 39 | #define CS_BUS_DEVICE_PATH "/bus/coresight/devices/" |
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/arm/util/unwind-libdw.c b/tools/perf/arch/arm/util/unwind-libdw.c index b4176c60117a..bacfa00fca39 100644 --- a/tools/perf/arch/arm/util/unwind-libdw.c +++ b/tools/perf/arch/arm/util/unwind-libdw.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include <elfutils/libdwfl.h> | 1 | #include <elfutils/libdwfl.h> |
2 | #include "../../util/unwind-libdw.h" | 2 | #include "../../util/unwind-libdw.h" |
3 | #include "../../util/perf_regs.h" | 3 | #include "../../util/perf_regs.h" |
4 | #include "../../util/event.h" | ||
4 | 5 | ||
5 | bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg) | 6 | bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg) |
6 | { | 7 | { |
diff --git a/tools/perf/arch/arm64/util/dwarf-regs.c b/tools/perf/arch/arm64/util/dwarf-regs.c index 068b6189157b..cd764a9fd098 100644 --- a/tools/perf/arch/arm64/util/dwarf-regs.c +++ b/tools/perf/arch/arm64/util/dwarf-regs.c | |||
@@ -8,9 +8,12 @@ | |||
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> |
13 | #include <string.h> | ||
12 | #include <dwarf-regs.h> | 14 | #include <dwarf-regs.h> |
13 | #include <linux/ptrace.h> /* for struct user_pt_regs */ | 15 | #include <linux/ptrace.h> /* for struct user_pt_regs */ |
16 | #include <linux/stringify.h> | ||
14 | #include "util.h" | 17 | #include "util.h" |
15 | 18 | ||
16 | struct pt_regs_dwarfnum { | 19 | struct pt_regs_dwarfnum { |
@@ -20,7 +23,7 @@ struct pt_regs_dwarfnum { | |||
20 | 23 | ||
21 | #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num} | 24 | #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num} |
22 | #define GPR_DWARFNUM_NAME(num) \ | 25 | #define GPR_DWARFNUM_NAME(num) \ |
23 | {.name = STR(%x##num), .dwarfnum = num} | 26 | {.name = __stringify(%x##num), .dwarfnum = num} |
24 | #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0} | 27 | #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0} |
25 | #define DWARFNUM2OFFSET(index) \ | 28 | #define DWARFNUM2OFFSET(index) \ |
26 | (index * sizeof((struct user_pt_regs *)0)->regs[0]) | 29 | (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..f9713a71d77e 100644 --- a/tools/perf/arch/x86/tests/intel-cqm.c +++ b/tools/perf/arch/x86/tests/intel-cqm.c | |||
@@ -6,7 +6,10 @@ | |||
6 | #include "evsel.h" | 6 | #include "evsel.h" |
7 | #include "arch-tests.h" | 7 | #include "arch-tests.h" |
8 | 8 | ||
9 | #include <signal.h> | ||
9 | #include <sys/mman.h> | 10 | #include <sys/mman.h> |
11 | #include <sys/wait.h> | ||
12 | #include <errno.h> | ||
10 | #include <string.h> | 13 | #include <string.h> |
11 | 14 | ||
12 | static pid_t spawn(void) | 15 | 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/arch/x86/util/unwind-libdw.c b/tools/perf/arch/x86/util/unwind-libdw.c index c4b72176ca83..38dc9bb2a7c9 100644 --- a/tools/perf/arch/x86/util/unwind-libdw.c +++ b/tools/perf/arch/x86/util/unwind-libdw.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include <elfutils/libdwfl.h> | 1 | #include <elfutils/libdwfl.h> |
2 | #include "../../util/unwind-libdw.h" | 2 | #include "../../util/unwind-libdw.h" |
3 | #include "../../util/perf_regs.h" | 3 | #include "../../util/perf_regs.h" |
4 | #include "../../util/event.h" | ||
4 | 5 | ||
5 | bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg) | 6 | bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg) |
6 | { | 7 | { |
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..64b44e81c771 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" |
@@ -21,6 +22,7 @@ | |||
21 | #include "util/build-id.h" | 22 | #include "util/build-id.h" |
22 | #include "util/session.h" | 23 | #include "util/session.h" |
23 | #include "util/symbol.h" | 24 | #include "util/symbol.h" |
25 | #include "util/time-utils.h" | ||
24 | 26 | ||
25 | static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid) | 27 | static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid) |
26 | { | 28 | { |
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..e33b4acece90 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c | |||
@@ -9,10 +9,13 @@ | |||
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> |
15 | #include <asm/bug.h> | 17 | #include <asm/bug.h> |
18 | #include <sys/param.h> | ||
16 | #include "util.h" | 19 | #include "util.h" |
17 | #include "debug.h" | 20 | #include "debug.h" |
18 | #include "builtin.h" | 21 | #include "builtin.h" |
@@ -29,6 +32,7 @@ | |||
29 | #include <asm/bug.h> | 32 | #include <asm/bug.h> |
30 | #include "ui/browsers/hists.h" | 33 | #include "ui/browsers/hists.h" |
31 | #include "evlist.h" | 34 | #include "evlist.h" |
35 | #include "thread.h" | ||
32 | 36 | ||
33 | struct c2c_hists { | 37 | struct c2c_hists { |
34 | struct hists hists; | 38 | struct hists hists; |
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..9e0b35cd0eea 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c | |||
@@ -9,12 +9,15 @@ | |||
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> |
16 | #include <poll.h> | ||
15 | 17 | ||
16 | #include "debug.h" | 18 | #include "debug.h" |
17 | #include <subcmd/parse-options.h> | 19 | #include <subcmd/parse-options.h> |
20 | #include <api/fs/tracing_path.h> | ||
18 | #include "evlist.h" | 21 | #include "evlist.h" |
19 | #include "target.h" | 22 | #include "target.h" |
20 | #include "cpumap.h" | 23 | #include "cpumap.h" |
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 1eec96a0fa67..492f8e14ab09 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c | |||
@@ -12,16 +12,22 @@ | |||
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> | ||
17 | #include <stdio.h> | ||
18 | #include <sys/types.h> | ||
19 | #include <sys/stat.h> | ||
20 | #include <unistd.h> | ||
15 | 21 | ||
16 | static struct man_viewer_list { | 22 | static struct man_viewer_list { |
17 | struct man_viewer_list *next; | 23 | struct man_viewer_list *next; |
18 | char name[FLEX_ARRAY]; | 24 | char name[0]; |
19 | } *man_viewer_list; | 25 | } *man_viewer_list; |
20 | 26 | ||
21 | static struct man_viewer_info_list { | 27 | static struct man_viewer_info_list { |
22 | struct man_viewer_info_list *next; | 28 | struct man_viewer_info_list *next; |
23 | const char *info; | 29 | const char *info; |
24 | char name[FLEX_ARRAY]; | 30 | char name[0]; |
25 | } *man_viewer_info_list; | 31 | } *man_viewer_info_list; |
26 | 32 | ||
27 | enum help_format { | 33 | enum help_format { |
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 65e1c026a2f0..ea8db38eedd1 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c | |||
@@ -18,10 +18,13 @@ | |||
18 | #include "util/data.h" | 18 | #include "util/data.h" |
19 | #include "util/auxtrace.h" | 19 | #include "util/auxtrace.h" |
20 | #include "util/jit.h" | 20 | #include "util/jit.h" |
21 | #include "util/thread.h" | ||
21 | 22 | ||
22 | #include <subcmd/parse-options.h> | 23 | #include <subcmd/parse-options.h> |
23 | 24 | ||
24 | #include <linux/list.h> | 25 | #include <linux/list.h> |
26 | #include <errno.h> | ||
27 | #include <signal.h> | ||
25 | 28 | ||
26 | struct perf_inject { | 29 | struct perf_inject { |
27 | struct perf_tool tool; | 30 | 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..f309c3773522 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" |
@@ -23,13 +24,33 @@ | |||
23 | #ifdef HAVE_TIMERFD_SUPPORT | 24 | #ifdef HAVE_TIMERFD_SUPPORT |
24 | #include <sys/timerfd.h> | 25 | #include <sys/timerfd.h> |
25 | #endif | 26 | #endif |
27 | #include <sys/time.h> | ||
26 | 28 | ||
29 | #include <linux/kernel.h> | ||
27 | #include <linux/time64.h> | 30 | #include <linux/time64.h> |
31 | #include <errno.h> | ||
32 | #include <inttypes.h> | ||
33 | #include <poll.h> | ||
28 | #include <termios.h> | 34 | #include <termios.h> |
29 | #include <semaphore.h> | 35 | #include <semaphore.h> |
36 | #include <signal.h> | ||
30 | #include <pthread.h> | 37 | #include <pthread.h> |
31 | #include <math.h> | 38 | #include <math.h> |
32 | 39 | ||
40 | static const char *get_filename_for_perf_kvm(void) | ||
41 | { | ||
42 | const char *filename; | ||
43 | |||
44 | if (perf_host && !perf_guest) | ||
45 | filename = strdup("perf.data.host"); | ||
46 | else if (!perf_host && perf_guest) | ||
47 | filename = strdup("perf.data.guest"); | ||
48 | else | ||
49 | filename = strdup("perf.data.kvm"); | ||
50 | |||
51 | return filename; | ||
52 | } | ||
53 | |||
33 | #ifdef HAVE_KVM_STAT_SUPPORT | 54 | #ifdef HAVE_KVM_STAT_SUPPORT |
34 | #include "util/kvm-stat.h" | 55 | #include "util/kvm-stat.h" |
35 | 56 | ||
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..e001c0290793 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c | |||
@@ -1,3 +1,7 @@ | |||
1 | #include <inttypes.h> | ||
2 | #include <sys/types.h> | ||
3 | #include <sys/stat.h> | ||
4 | #include <unistd.h> | ||
1 | #include "builtin.h" | 5 | #include "builtin.h" |
2 | #include "perf.h" | 6 | #include "perf.h" |
3 | 7 | ||
@@ -8,6 +12,7 @@ | |||
8 | #include "util/data.h" | 12 | #include "util/data.h" |
9 | #include "util/mem-events.h" | 13 | #include "util/mem-events.h" |
10 | #include "util/debug.h" | 14 | #include "util/debug.h" |
15 | #include "util/symbol.h" | ||
11 | 16 | ||
12 | #define MEM_OPERATION_LOAD 0x1 | 17 | #define MEM_OPERATION_LOAD 0x1 |
13 | #define MEM_OPERATION_STORE 0x2 | 18 | #define MEM_OPERATION_STORE 0x2 |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 3191ab063852..ee7d0a82ccd0 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -38,11 +38,18 @@ | |||
38 | #include "util/bpf-loader.h" | 38 | #include "util/bpf-loader.h" |
39 | #include "util/trigger.h" | 39 | #include "util/trigger.h" |
40 | #include "util/perf-hooks.h" | 40 | #include "util/perf-hooks.h" |
41 | #include "util/time-utils.h" | ||
42 | #include "util/units.h" | ||
41 | #include "asm/bug.h" | 43 | #include "asm/bug.h" |
42 | 44 | ||
45 | #include <errno.h> | ||
46 | #include <inttypes.h> | ||
47 | #include <poll.h> | ||
43 | #include <unistd.h> | 48 | #include <unistd.h> |
44 | #include <sched.h> | 49 | #include <sched.h> |
50 | #include <signal.h> | ||
45 | #include <sys/mman.h> | 51 | #include <sys/mman.h> |
52 | #include <sys/wait.h> | ||
46 | #include <asm/bug.h> | 53 | #include <asm/bug.h> |
47 | #include <linux/time64.h> | 54 | #include <linux/time64.h> |
48 | 55 | ||
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index c18158b83eb1..22478ff2b706 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" |
@@ -38,10 +37,18 @@ | |||
38 | #include "arch/common.h" | 37 | #include "arch/common.h" |
39 | #include "util/time-utils.h" | 38 | #include "util/time-utils.h" |
40 | #include "util/auxtrace.h" | 39 | #include "util/auxtrace.h" |
40 | #include "util/units.h" | ||
41 | 41 | ||
42 | #include <dlfcn.h> | 42 | #include <dlfcn.h> |
43 | #include <errno.h> | ||
44 | #include <inttypes.h> | ||
45 | #include <regex.h> | ||
46 | #include <signal.h> | ||
43 | #include <linux/bitmap.h> | 47 | #include <linux/bitmap.h> |
44 | #include <linux/stringify.h> | 48 | #include <linux/stringify.h> |
49 | #include <sys/types.h> | ||
50 | #include <sys/stat.h> | ||
51 | #include <unistd.h> | ||
45 | 52 | ||
46 | struct report { | 53 | struct report { |
47 | struct perf_tool tool; | 54 | struct perf_tool tool; |
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..d05aec491cff 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -21,14 +21,27 @@ | |||
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 | #include <signal.h> | ||
39 | #include <sys/param.h> | ||
40 | #include <sys/types.h> | ||
41 | #include <sys/stat.h> | ||
42 | #include <unistd.h> | ||
43 | |||
44 | #include "sane_ctype.h" | ||
32 | 45 | ||
33 | static char const *script_name; | 46 | static char const *script_name; |
34 | static char const *generate_script_lang; | 47 | static char const *generate_script_lang; |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 610225b6326e..a935b5023732 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -64,14 +64,24 @@ | |||
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> | ||
73 | #include <signal.h> | ||
71 | #include <stdlib.h> | 74 | #include <stdlib.h> |
72 | #include <sys/prctl.h> | 75 | #include <sys/prctl.h> |
76 | #include <inttypes.h> | ||
73 | #include <locale.h> | 77 | #include <locale.h> |
74 | #include <math.h> | 78 | #include <math.h> |
79 | #include <sys/types.h> | ||
80 | #include <sys/stat.h> | ||
81 | #include <sys/wait.h> | ||
82 | #include <unistd.h> | ||
83 | |||
84 | #include "sane_ctype.h" | ||
75 | 85 | ||
76 | #define DEFAULT_SEPARATOR " " | 86 | #define DEFAULT_SEPARATOR " " |
77 | #define CNTR_NOT_SUPPORTED "<not supported>" | 87 | #define CNTR_NOT_SUPPORTED "<not supported>" |
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index fafdb44b8bcb..4e2e61695986 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,12 @@ | |||
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" |
32 | #include "util/thread.h" | ||
29 | #include "util/callchain.h" | 33 | #include "util/callchain.h" |
30 | #include "util/strlist.h" | ||
31 | 34 | ||
32 | #include "perf.h" | 35 | #include "perf.h" |
33 | #include "util/header.h" | 36 | #include "util/header.h" |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index a0c97c70ec81..7ab42b8311a1 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" |
@@ -58,6 +59,7 @@ | |||
58 | #include <errno.h> | 59 | #include <errno.h> |
59 | #include <time.h> | 60 | #include <time.h> |
60 | #include <sched.h> | 61 | #include <sched.h> |
62 | #include <signal.h> | ||
61 | 63 | ||
62 | #include <sys/syscall.h> | 64 | #include <sys/syscall.h> |
63 | #include <sys/ioctl.h> | 65 | #include <sys/ioctl.h> |
@@ -72,6 +74,8 @@ | |||
72 | #include <linux/time64.h> | 74 | #include <linux/time64.h> |
73 | #include <linux/types.h> | 75 | #include <linux/types.h> |
74 | 76 | ||
77 | #include "sane_ctype.h" | ||
78 | |||
75 | static volatile int done; | 79 | static volatile int done; |
76 | 80 | ||
77 | #define HEADER_LINE_NR 5 | 81 | #define HEADER_LINE_NR 5 |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index fce278d5fada..eaa66fb57347 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,28 @@ | |||
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 */ |
48 | #include <poll.h> | ||
49 | #include <signal.h> | ||
43 | #include <stdlib.h> | 50 | #include <stdlib.h> |
44 | #include <string.h> | 51 | #include <string.h> |
45 | #include <linux/err.h> | 52 | #include <linux/err.h> |
46 | #include <linux/filter.h> | 53 | #include <linux/filter.h> |
47 | #include <linux/audit.h> | 54 | #include <linux/audit.h> |
55 | #include <linux/kernel.h> | ||
48 | #include <linux/random.h> | 56 | #include <linux/random.h> |
49 | #include <linux/stringify.h> | 57 | #include <linux/stringify.h> |
50 | #include <linux/time64.h> | 58 | #include <linux/time64.h> |
51 | 59 | ||
60 | #include "sane_ctype.h" | ||
61 | |||
52 | #ifndef O_CLOEXEC | 62 | #ifndef O_CLOEXEC |
53 | # define O_CLOEXEC 02000000 | 63 | # define O_CLOEXEC 02000000 |
54 | #endif | 64 | #endif |
diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c index b9a095b1db99..d25149456a2f 100644 --- a/tools/perf/builtin-version.c +++ b/tools/perf/builtin-version.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include "util/util.h" | ||
2 | #include "builtin.h" | 1 | #include "builtin.h" |
3 | #include "perf.h" | 2 | #include "perf.h" |
3 | #include <linux/compiler.h> | ||
4 | #include <stdio.h> | ||
4 | 5 | ||
5 | int cmd_version(int argc __maybe_unused, const char **argv __maybe_unused) | 6 | int cmd_version(int argc __maybe_unused, const char **argv __maybe_unused) |
6 | { | 7 | { |
diff --git a/tools/perf/builtin.h b/tools/perf/builtin.h index 26669bf9129c..d4d19fe3d050 100644 --- a/tools/perf/builtin.h +++ b/tools/perf/builtin.h | |||
@@ -2,16 +2,12 @@ | |||
2 | #define BUILTIN_H | 2 | #define BUILTIN_H |
3 | 3 | ||
4 | #include "util/util.h" | 4 | #include "util/util.h" |
5 | #include "util/strbuf.h" | ||
6 | 5 | ||
7 | extern const char perf_usage_string[]; | 6 | extern const char perf_usage_string[]; |
8 | extern const char perf_more_info_string[]; | 7 | extern const char perf_more_info_string[]; |
9 | 8 | ||
10 | void list_common_cmds_help(void); | 9 | void list_common_cmds_help(void); |
11 | const char *help_unknown_cmd(const char *cmd); | 10 | const char *help_unknown_cmd(const char *cmd); |
12 | void prune_packed_objects(int); | ||
13 | int read_line_with_nul(char *buf, int size, FILE *file); | ||
14 | int check_pager_config(const char *cmd); | ||
15 | 11 | ||
16 | int cmd_annotate(int argc, const char **argv); | 12 | int cmd_annotate(int argc, const char **argv); |
17 | int cmd_bench(int argc, const char **argv); | 13 | int cmd_bench(int argc, const char **argv); |
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 9dc346f2b255..4cc6960f6226 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
@@ -19,9 +19,15 @@ | |||
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> |
24 | #include <signal.h> | ||
23 | #include <stdlib.h> | 25 | #include <stdlib.h> |
24 | #include <time.h> | 26 | #include <time.h> |
27 | #include <sys/types.h> | ||
28 | #include <sys/stat.h> | ||
29 | #include <unistd.h> | ||
30 | #include <linux/kernel.h> | ||
25 | 31 | ||
26 | const char perf_usage_string[] = | 32 | const char perf_usage_string[] = |
27 | "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]"; | 33 | "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]"; |
@@ -88,7 +94,7 @@ static int pager_command_config(const char *var, const char *value, void *data) | |||
88 | } | 94 | } |
89 | 95 | ||
90 | /* returns 0 for "no pager", 1 for "use pager", and -1 for "not specified" */ | 96 | /* returns 0 for "no pager", 1 for "use pager", and -1 for "not specified" */ |
91 | int check_pager_config(const char *cmd) | 97 | static int check_pager_config(const char *cmd) |
92 | { | 98 | { |
93 | int err; | 99 | int err; |
94 | struct pager_config c; | 100 | struct pager_config c; |
@@ -327,16 +333,6 @@ static void handle_internal_command(int argc, const char **argv) | |||
327 | { | 333 | { |
328 | const char *cmd = argv[0]; | 334 | const char *cmd = argv[0]; |
329 | unsigned int i; | 335 | 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 | 336 | ||
341 | /* Turn "perf cmd --help" into "perf help cmd" */ | 337 | /* Turn "perf cmd --help" into "perf help cmd" */ |
342 | if (argc > 1 && !strcmp(argv[1], "--help")) { | 338 | if (argc > 1 && !strcmp(argv[1], "--help")) { |
diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c index 88dc51f4c27b..0dd77494bb58 100644 --- a/tools/perf/tests/attr.c +++ b/tools/perf/tests/attr.c | |||
@@ -18,10 +18,16 @@ | |||
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> |
24 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <sys/param.h> | ||
28 | #include <sys/types.h> | ||
29 | #include <sys/stat.h> | ||
30 | #include <unistd.h> | ||
25 | #include "../perf.h" | 31 | #include "../perf.h" |
26 | #include "util.h" | 32 | #include "util.h" |
27 | #include <subcmd/exec-cmd.h> | 33 | #include <subcmd/exec-cmd.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..5876da126b58 100644 --- a/tools/perf/tests/bpf.c +++ b/tools/perf/tests/bpf.c | |||
@@ -1,10 +1,14 @@ | |||
1 | #include <errno.h> | ||
1 | #include <stdio.h> | 2 | #include <stdio.h> |
2 | #include <sys/epoll.h> | 3 | #include <sys/epoll.h> |
4 | #include <sys/types.h> | ||
5 | #include <sys/stat.h> | ||
3 | #include <util/util.h> | 6 | #include <util/util.h> |
4 | #include <util/bpf-loader.h> | 7 | #include <util/bpf-loader.h> |
5 | #include <util/evlist.h> | 8 | #include <util/evlist.h> |
6 | #include <linux/bpf.h> | 9 | #include <linux/bpf.h> |
7 | #include <linux/filter.h> | 10 | #include <linux/filter.h> |
11 | #include <linux/kernel.h> | ||
8 | #include <api/fs/fs.h> | 12 | #include <api/fs/fs.h> |
9 | #include <bpf/bpf.h> | 13 | #include <bpf/bpf.h> |
10 | #include "tests.h" | 14 | #include "tests.h" |
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index e6d7876c94c2..9e08d297f1a9 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c | |||
@@ -3,8 +3,10 @@ | |||
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> |
9 | #include <sys/wait.h> | ||
8 | #include "builtin.h" | 10 | #include "builtin.h" |
9 | #include "hist.h" | 11 | #include "hist.h" |
10 | #include "intlist.h" | 12 | #include "intlist.h" |
@@ -13,6 +15,7 @@ | |||
13 | #include "color.h" | 15 | #include "color.h" |
14 | #include <subcmd/parse-options.h> | 16 | #include <subcmd/parse-options.h> |
15 | #include "symbol.h" | 17 | #include "symbol.h" |
18 | #include <linux/kernel.h> | ||
16 | 19 | ||
17 | static bool dont_fork; | 20 | static bool dont_fork; |
18 | 21 | ||
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..1f14e7612cbb 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c | |||
@@ -1,9 +1,12 @@ | |||
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> |
9 | #include <sys/param.h> | ||
7 | 10 | ||
8 | #include "parse-events.h" | 11 | #include "parse-events.h" |
9 | #include "evlist.h" | 12 | #include "evlist.h" |
@@ -16,6 +19,8 @@ | |||
16 | 19 | ||
17 | #include "tests.h" | 20 | #include "tests.h" |
18 | 21 | ||
22 | #include "sane_ctype.h" | ||
23 | |||
19 | #define BUFSZ 1024 | 24 | #define BUFSZ 1024 |
20 | #define READLEN 128 | 25 | #define READLEN 128 |
21 | 26 | ||
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..634f20c631d8 100644 --- a/tools/perf/tests/event-times.c +++ b/tools/perf/tests/event-times.c | |||
@@ -1,5 +1,8 @@ | |||
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> |
5 | #include <sys/wait.h> | ||
3 | #include "tests.h" | 6 | #include "tests.h" |
4 | #include "evlist.h" | 7 | #include "evlist.h" |
5 | #include "evsel.h" | 8 | #include "evsel.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..7fad885491c5 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,15 @@ | |||
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 <sys/types.h> | ||
11 | #include <sys/stat.h> | ||
12 | #include <unistd.h> | ||
13 | #include <linux/kernel.h> | ||
9 | #include <linux/hw_breakpoint.h> | 14 | #include <linux/hw_breakpoint.h> |
10 | #include <api/fs/fs.h> | 15 | #include <api/fs/fs.h> |
16 | #include <api/fs/tracing_path.h> | ||
11 | 17 | ||
12 | #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \ | 18 | #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \ |
13 | PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) | 19 | 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..44589de084b8 100644 --- a/tools/perf/tests/unit_number__scnprintf.c +++ b/tools/perf/tests/unit_number__scnprintf.c | |||
@@ -1,7 +1,8 @@ | |||
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" |
4 | #include "util.h" | 5 | #include "units.h" |
5 | #include "debug.h" | 6 | #include "debug.h" |
6 | 7 | ||
7 | int test__unit_number__scnprint(int subtest __maybe_unused) | 8 | int test__unit_number__scnprint(int subtest __maybe_unused) |
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/trace/beauty/signum.c b/tools/perf/trace/beauty/signum.c index d3b0b1fab077..fde8f2fc6558 100644 --- a/tools/perf/trace/beauty/signum.c +++ b/tools/perf/trace/beauty/signum.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <signal.h> | ||
1 | 2 | ||
2 | static size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscall_arg *arg) | 3 | static size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscall_arg *arg) |
3 | { | 4 | { |
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..69f4570bd4f9 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" |
@@ -10,6 +14,7 @@ | |||
10 | #include "../../util/sort.h" | 14 | #include "../../util/sort.h" |
11 | #include "../../util/util.h" | 15 | #include "../../util/util.h" |
12 | #include "../../util/top.h" | 16 | #include "../../util/top.h" |
17 | #include "../../util/thread.h" | ||
13 | #include "../../arch/common.h" | 18 | #include "../../arch/common.h" |
14 | 19 | ||
15 | #include "../browsers/hists.h" | 20 | #include "../browsers/hists.h" |
@@ -18,6 +23,11 @@ | |||
18 | #include "../ui.h" | 23 | #include "../ui.h" |
19 | #include "map.h" | 24 | #include "map.h" |
20 | #include "annotate.h" | 25 | #include "annotate.h" |
26 | #include "srcline.h" | ||
27 | #include "string2.h" | ||
28 | #include "units.h" | ||
29 | |||
30 | #include "sane_ctype.h" | ||
21 | 31 | ||
22 | extern void hist_browser__init_hpp(void); | 32 | extern void hist_browser__init_hpp(void); |
23 | 33 | ||
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..e99ba86158d2 100644 --- a/tools/perf/ui/gtk/annotate.c +++ b/tools/perf/ui/gtk/annotate.c | |||
@@ -3,7 +3,8 @@ | |||
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 | #include <signal.h> | ||
7 | 8 | ||
8 | enum { | 9 | enum { |
9 | ANN_COL__PERCENT, | 10 | ANN_COL__PERCENT, |
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index a4f02de7c1b5..e24f83957705 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c | |||
@@ -4,7 +4,9 @@ | |||
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" |
9 | #include <signal.h> | ||
8 | 10 | ||
9 | #define MAX_COLUMNS 32 | 11 | #define MAX_COLUMNS 32 |
10 | 12 | ||
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..42e432bd2eb4 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
@@ -4,7 +4,10 @@ | |||
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/thread.h" | ||
10 | #include "../../util/sane_ctype.h" | ||
8 | 11 | ||
9 | static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin) | 12 | static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin) |
10 | { | 13 | { |
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..069583bdc670 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 |
@@ -88,6 +89,7 @@ libperf-y += help-unknown-cmd.o | |||
88 | libperf-y += mem-events.o | 89 | libperf-y += mem-events.o |
89 | libperf-y += vsprintf.o | 90 | libperf-y += vsprintf.o |
90 | libperf-y += drv_configs.o | 91 | libperf-y += drv_configs.o |
92 | libperf-y += units.o | ||
91 | libperf-y += time-utils.o | 93 | libperf-y += time-utils.o |
92 | libperf-y += expr-bison.o | 94 | libperf-y += expr-bison.o |
93 | 95 | ||
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..168cc49654e7 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c | |||
@@ -7,18 +7,26 @@ | |||
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> |
13 | #include <sys/stat.h> | ||
14 | #include <sys/types.h> | ||
11 | #include "build-id.h" | 15 | #include "build-id.h" |
12 | #include "event.h" | 16 | #include "event.h" |
13 | #include "symbol.h" | 17 | #include "symbol.h" |
18 | #include "thread.h" | ||
14 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
15 | #include "debug.h" | 20 | #include "debug.h" |
16 | #include "session.h" | 21 | #include "session.h" |
17 | #include "tool.h" | 22 | #include "tool.h" |
18 | #include "header.h" | 23 | #include "header.h" |
19 | #include "vdso.h" | 24 | #include "vdso.h" |
25 | #include "path.h" | ||
20 | #include "probe-file.h" | 26 | #include "probe-file.h" |
27 | #include "strlist.h" | ||
21 | 28 | ||
29 | #include "sane_ctype.h" | ||
22 | 30 | ||
23 | static bool no_buildid_cache; | 31 | static bool no_buildid_cache; |
24 | 32 | ||
@@ -447,14 +455,14 @@ void disable_buildid_cache(void) | |||
447 | } | 455 | } |
448 | 456 | ||
449 | static bool lsdir_bid_head_filter(const char *name __maybe_unused, | 457 | static bool lsdir_bid_head_filter(const char *name __maybe_unused, |
450 | struct dirent *d __maybe_unused) | 458 | struct dirent *d) |
451 | { | 459 | { |
452 | return (strlen(d->d_name) == 2) && | 460 | return (strlen(d->d_name) == 2) && |
453 | isxdigit(d->d_name[0]) && isxdigit(d->d_name[1]); | 461 | isxdigit(d->d_name[0]) && isxdigit(d->d_name[1]); |
454 | } | 462 | } |
455 | 463 | ||
456 | static bool lsdir_bid_tail_filter(const char *name __maybe_unused, | 464 | static bool lsdir_bid_tail_filter(const char *name __maybe_unused, |
457 | struct dirent *d __maybe_unused) | 465 | struct dirent *d) |
458 | { | 466 | { |
459 | int i = 0; | 467 | int i = 0; |
460 | while (isxdigit(d->d_name[i]) && i < SBUILD_ID_SIZE - 3) | 468 | 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..81fc29ac798f 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> |
@@ -23,6 +24,21 @@ | |||
23 | #include "machine.h" | 24 | #include "machine.h" |
24 | #include "callchain.h" | 25 | #include "callchain.h" |
25 | 26 | ||
27 | #define CALLCHAIN_PARAM_DEFAULT \ | ||
28 | .mode = CHAIN_GRAPH_ABS, \ | ||
29 | .min_percent = 0.5, \ | ||
30 | .order = ORDER_CALLEE, \ | ||
31 | .key = CCKEY_FUNCTION, \ | ||
32 | .value = CCVAL_PERCENT, \ | ||
33 | |||
34 | struct callchain_param callchain_param = { | ||
35 | CALLCHAIN_PARAM_DEFAULT | ||
36 | }; | ||
37 | |||
38 | struct callchain_param callchain_param_default = { | ||
39 | CALLCHAIN_PARAM_DEFAULT | ||
40 | }; | ||
41 | |||
26 | __thread struct callchain_cursor callchain_cursor; | 42 | __thread struct callchain_cursor callchain_cursor; |
27 | 43 | ||
28 | int parse_callchain_record_opt(const char *arg, struct callchain_param *param) | 44 | int parse_callchain_record_opt(const char *arg, struct callchain_param *param) |
@@ -112,6 +128,32 @@ static int parse_callchain_value(const char *value) | |||
112 | return -1; | 128 | return -1; |
113 | } | 129 | } |
114 | 130 | ||
131 | static int get_stack_size(const char *str, unsigned long *_size) | ||
132 | { | ||
133 | char *endptr; | ||
134 | unsigned long size; | ||
135 | unsigned long max_size = round_down(USHRT_MAX, sizeof(u64)); | ||
136 | |||
137 | size = strtoul(str, &endptr, 0); | ||
138 | |||
139 | do { | ||
140 | if (*endptr) | ||
141 | break; | ||
142 | |||
143 | size = round_up(size, sizeof(u64)); | ||
144 | if (!size || size > max_size) | ||
145 | break; | ||
146 | |||
147 | *_size = size; | ||
148 | return 0; | ||
149 | |||
150 | } while (0); | ||
151 | |||
152 | pr_err("callchain: Incorrect stack dump size (max %ld): %s\n", | ||
153 | max_size, str); | ||
154 | return -1; | ||
155 | } | ||
156 | |||
115 | static int | 157 | static int |
116 | __parse_callchain_report_opt(const char *arg, bool allow_record_opt) | 158 | __parse_callchain_report_opt(const char *arg, bool allow_record_opt) |
117 | { | 159 | { |
@@ -195,6 +237,68 @@ int parse_callchain_top_opt(const char *arg) | |||
195 | return __parse_callchain_report_opt(arg, true); | 237 | return __parse_callchain_report_opt(arg, true); |
196 | } | 238 | } |
197 | 239 | ||
240 | int parse_callchain_record(const char *arg, struct callchain_param *param) | ||
241 | { | ||
242 | char *tok, *name, *saveptr = NULL; | ||
243 | char *buf; | ||
244 | int ret = -1; | ||
245 | |||
246 | /* We need buffer that we know we can write to. */ | ||
247 | buf = malloc(strlen(arg) + 1); | ||
248 | if (!buf) | ||
249 | return -ENOMEM; | ||
250 | |||
251 | strcpy(buf, arg); | ||
252 | |||
253 | tok = strtok_r((char *)buf, ",", &saveptr); | ||
254 | name = tok ? : (char *)buf; | ||
255 | |||
256 | do { | ||
257 | /* Framepointer style */ | ||
258 | if (!strncmp(name, "fp", sizeof("fp"))) { | ||
259 | if (!strtok_r(NULL, ",", &saveptr)) { | ||
260 | param->record_mode = CALLCHAIN_FP; | ||
261 | ret = 0; | ||
262 | } else | ||
263 | pr_err("callchain: No more arguments " | ||
264 | "needed for --call-graph fp\n"); | ||
265 | break; | ||
266 | |||
267 | /* Dwarf style */ | ||
268 | } else if (!strncmp(name, "dwarf", sizeof("dwarf"))) { | ||
269 | const unsigned long default_stack_dump_size = 8192; | ||
270 | |||
271 | ret = 0; | ||
272 | param->record_mode = CALLCHAIN_DWARF; | ||
273 | param->dump_size = default_stack_dump_size; | ||
274 | |||
275 | tok = strtok_r(NULL, ",", &saveptr); | ||
276 | if (tok) { | ||
277 | unsigned long size = 0; | ||
278 | |||
279 | ret = get_stack_size(tok, &size); | ||
280 | param->dump_size = size; | ||
281 | } | ||
282 | } else if (!strncmp(name, "lbr", sizeof("lbr"))) { | ||
283 | if (!strtok_r(NULL, ",", &saveptr)) { | ||
284 | param->record_mode = CALLCHAIN_LBR; | ||
285 | ret = 0; | ||
286 | } else | ||
287 | pr_err("callchain: No more arguments " | ||
288 | "needed for --call-graph lbr\n"); | ||
289 | break; | ||
290 | } else { | ||
291 | pr_err("callchain: Unknown --call-graph option " | ||
292 | "value: %s\n", arg); | ||
293 | break; | ||
294 | } | ||
295 | |||
296 | } while (0); | ||
297 | |||
298 | free(buf); | ||
299 | return ret; | ||
300 | } | ||
301 | |||
198 | int perf_callchain_config(const char *var, const char *value) | 302 | int perf_callchain_config(const char *var, const char *value) |
199 | { | 303 | { |
200 | char *endptr; | 304 | char *endptr; |
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/color.h b/tools/perf/util/color.h index a93997f16dec..52122bcc3170 100644 --- a/tools/perf/util/color.h +++ b/tools/perf/util/color.h | |||
@@ -1,6 +1,8 @@ | |||
1 | #ifndef __PERF_COLOR_H | 1 | #ifndef __PERF_COLOR_H |
2 | #define __PERF_COLOR_H | 2 | #define __PERF_COLOR_H |
3 | 3 | ||
4 | #include <stdio.h> | ||
5 | |||
4 | /* "\033[1;38;5;2xx;48;5;2xxm\0" is 23 bytes */ | 6 | /* "\033[1;38;5;2xx;48;5;2xxm\0" is 23 bytes */ |
5 | #define COLOR_MAXLEN 24 | 7 | #define COLOR_MAXLEN 24 |
6 | 8 | ||
diff --git a/tools/perf/util/comm.c b/tools/perf/util/comm.c index 32837b6f7879..7bc981b6bf29 100644 --- a/tools/perf/util/comm.c +++ b/tools/perf/util/comm.c | |||
@@ -1,7 +1,9 @@ | |||
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> |
6 | #include <string.h> | ||
5 | #include <linux/refcount.h> | 7 | #include <linux/refcount.h> |
6 | 8 | ||
7 | struct comm_str { | 9 | struct comm_str { |
diff --git a/tools/perf/util/compress.h b/tools/perf/util/compress.h new file mode 100644 index 000000000000..67fd1bb7c2b7 --- /dev/null +++ b/tools/perf/util/compress.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef PERF_COMPRESS_H | ||
2 | #define PERF_COMPRESS_H | ||
3 | |||
4 | #ifdef HAVE_ZLIB_SUPPORT | ||
5 | int gzip_decompress_to_file(const char *input, int output_fd); | ||
6 | #endif | ||
7 | |||
8 | #ifdef HAVE_LZMA_SUPPORT | ||
9 | int lzma_decompress_to_file(const char *input, int output_fd); | ||
10 | #endif | ||
11 | |||
12 | #endif /* PERF_COMPRESS_H */ | ||
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 7b01d59076d3..8d724f0fa5a8 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c | |||
@@ -8,12 +8,19 @@ | |||
8 | * Copyright (C) Johannes Schindelin, 2005 | 8 | * Copyright (C) Johannes Schindelin, 2005 |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | #include <errno.h> | ||
12 | #include <sys/param.h> | ||
11 | #include "util.h" | 13 | #include "util.h" |
12 | #include "cache.h" | 14 | #include "cache.h" |
13 | #include <subcmd/exec-cmd.h> | 15 | #include <subcmd/exec-cmd.h> |
14 | #include "util/hist.h" /* perf_hist_config */ | 16 | #include "util/hist.h" /* perf_hist_config */ |
15 | #include "util/llvm-utils.h" /* perf_llvm_config */ | 17 | #include "util/llvm-utils.h" /* perf_llvm_config */ |
16 | #include "config.h" | 18 | #include "config.h" |
19 | #include <sys/types.h> | ||
20 | #include <sys/stat.h> | ||
21 | #include <unistd.h> | ||
22 | |||
23 | #include "sane_ctype.h" | ||
17 | 24 | ||
18 | #define MAXNAME (256) | 25 | #define MAXNAME (256) |
19 | 26 | ||
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..a5b3777ffee6 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c | |||
@@ -2,19 +2,26 @@ | |||
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> |
9 | #include <sys/wait.h> | ||
8 | #include <api/debug.h> | 10 | #include <api/debug.h> |
9 | #include <linux/time64.h> | 11 | #include <linux/time64.h> |
10 | 12 | #ifdef HAVE_BACKTRACE_SUPPORT | |
13 | #include <execinfo.h> | ||
14 | #endif | ||
11 | #include "cache.h" | 15 | #include "cache.h" |
12 | #include "color.h" | 16 | #include "color.h" |
13 | #include "event.h" | 17 | #include "event.h" |
14 | #include "debug.h" | 18 | #include "debug.h" |
19 | #include "print_binary.h" | ||
15 | #include "util.h" | 20 | #include "util.h" |
16 | #include "target.h" | 21 | #include "target.h" |
17 | 22 | ||
23 | #include "sane_ctype.h" | ||
24 | |||
18 | int verbose; | 25 | int verbose; |
19 | bool dump_trace = false, quiet = false; | 26 | bool dump_trace = false, quiet = false; |
20 | int debug_ordered_events; | 27 | int debug_ordered_events; |
@@ -244,3 +251,31 @@ void perf_debug_setup(void) | |||
244 | { | 251 | { |
245 | libapi_set_print(pr_warning_wrapper, pr_warning_wrapper, pr_debug_wrapper); | 252 | libapi_set_print(pr_warning_wrapper, pr_warning_wrapper, pr_debug_wrapper); |
246 | } | 253 | } |
254 | |||
255 | /* Obtain a backtrace and print it to stdout. */ | ||
256 | #ifdef HAVE_BACKTRACE_SUPPORT | ||
257 | void dump_stack(void) | ||
258 | { | ||
259 | void *array[16]; | ||
260 | size_t size = backtrace(array, ARRAY_SIZE(array)); | ||
261 | char **strings = backtrace_symbols(array, size); | ||
262 | size_t i; | ||
263 | |||
264 | printf("Obtained %zd stack frames.\n", size); | ||
265 | |||
266 | for (i = 0; i < size; i++) | ||
267 | printf("%s\n", strings[i]); | ||
268 | |||
269 | free(strings); | ||
270 | } | ||
271 | #else | ||
272 | void dump_stack(void) {} | ||
273 | #endif | ||
274 | |||
275 | void sighandler_dump_stack(int sig) | ||
276 | { | ||
277 | psignal(sig, "perf"); | ||
278 | dump_stack(); | ||
279 | signal(sig, SIG_DFL); | ||
280 | raise(sig); | ||
281 | } | ||
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index 98832f5531d3..8a23ea1a71c7 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h | |||
@@ -56,4 +56,7 @@ int perf_debug_option(const char *str); | |||
56 | void perf_debug_setup(void); | 56 | void perf_debug_setup(void); |
57 | int perf_quiet_option(void); | 57 | int perf_quiet_option(void); |
58 | 58 | ||
59 | void dump_stack(void); | ||
60 | void sighandler_dump_stack(int sig); | ||
61 | |||
59 | #endif /* __PERF_DEBUG_H */ | 62 | #endif /* __PERF_DEBUG_H */ |
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..a96a99d2369f 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c | |||
@@ -1,12 +1,20 @@ | |||
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 <sys/types.h> | ||
6 | #include <sys/stat.h> | ||
7 | #include <unistd.h> | ||
8 | #include <errno.h> | ||
9 | #include "compress.h" | ||
10 | #include "path.h" | ||
4 | #include "symbol.h" | 11 | #include "symbol.h" |
5 | #include "dso.h" | 12 | #include "dso.h" |
6 | #include "machine.h" | 13 | #include "machine.h" |
7 | #include "auxtrace.h" | 14 | #include "auxtrace.h" |
8 | #include "util.h" | 15 | #include "util.h" |
9 | #include "debug.h" | 16 | #include "debug.h" |
17 | #include "string2.h" | ||
10 | #include "vdso.h" | 18 | #include "vdso.h" |
11 | 19 | ||
12 | static const char * const debuglink_paths[] = { | 20 | 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..142835c0ca0a 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -1,4 +1,11 @@ | |||
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> |
6 | #include <sys/types.h> | ||
7 | #include <sys/stat.h> | ||
8 | #include <unistd.h> | ||
2 | #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 */ |
3 | #include <api/fs/fs.h> | 10 | #include <api/fs/fs.h> |
4 | #include "event.h" | 11 | #include "event.h" |
@@ -6,10 +13,11 @@ | |||
6 | #include "hist.h" | 13 | #include "hist.h" |
7 | #include "machine.h" | 14 | #include "machine.h" |
8 | #include "sort.h" | 15 | #include "sort.h" |
9 | #include "string.h" | 16 | #include "string2.h" |
10 | #include "strlist.h" | 17 | #include "strlist.h" |
11 | #include "thread.h" | 18 | #include "thread.h" |
12 | #include "thread_map.h" | 19 | #include "thread_map.h" |
20 | #include "sane_ctype.h" | ||
13 | #include "symbol/kallsyms.h" | 21 | #include "symbol/kallsyms.h" |
14 | #include "asm/bug.h" | 22 | #include "asm/bug.h" |
15 | #include "stat.h" | 23 | #include "stat.h" |
@@ -133,8 +141,15 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len, | |||
133 | ppids = strstr(bf, "PPid:"); | 141 | ppids = strstr(bf, "PPid:"); |
134 | 142 | ||
135 | if (name) { | 143 | if (name) { |
144 | char *nl; | ||
145 | |||
136 | name += 5; /* strlen("Name:") */ | 146 | name += 5; /* strlen("Name:") */ |
137 | name = rtrim(ltrim(name)); | 147 | name = ltrim(name); |
148 | |||
149 | nl = strchr(name, '\n'); | ||
150 | if (nl) | ||
151 | *nl = '\0'; | ||
152 | |||
138 | size = strlen(name); | 153 | size = strlen(name); |
139 | if (size >= len) | 154 | if (size >= len) |
140 | size = len - 1; | 155 | size = len - 1; |
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index eb7a7b200737..db2de6413518 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h | |||
@@ -3,9 +3,9 @@ | |||
3 | 3 | ||
4 | #include <limits.h> | 4 | #include <limits.h> |
5 | #include <stdio.h> | 5 | #include <stdio.h> |
6 | #include <linux/kernel.h> | ||
6 | 7 | ||
7 | #include "../perf.h" | 8 | #include "../perf.h" |
8 | #include "map.h" | ||
9 | #include "build-id.h" | 9 | #include "build-id.h" |
10 | #include "perf_regs.h" | 10 | #include "perf_regs.h" |
11 | 11 | ||
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 50420cd35446..46c0faf6c502 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" |
@@ -15,12 +17,15 @@ | |||
15 | #include "evlist.h" | 17 | #include "evlist.h" |
16 | #include "evsel.h" | 18 | #include "evsel.h" |
17 | #include "debug.h" | 19 | #include "debug.h" |
20 | #include "units.h" | ||
18 | #include "asm/bug.h" | 21 | #include "asm/bug.h" |
22 | #include <signal.h> | ||
19 | #include <unistd.h> | 23 | #include <unistd.h> |
20 | 24 | ||
21 | #include "parse-events.h" | 25 | #include "parse-events.h" |
22 | #include <subcmd/parse-options.h> | 26 | #include <subcmd/parse-options.h> |
23 | 27 | ||
28 | #include <sys/ioctl.h> | ||
24 | #include <sys/mman.h> | 29 | #include <sys/mman.h> |
25 | 30 | ||
26 | #include <linux/bitops.h> | 31 | #include <linux/bitops.h> |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 39942995f537..94cea4398a13 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> |
@@ -10,6 +11,7 @@ | |||
10 | #include "evsel.h" | 11 | #include "evsel.h" |
11 | #include "util.h" | 12 | #include "util.h" |
12 | #include "auxtrace.h" | 13 | #include "auxtrace.h" |
14 | #include <signal.h> | ||
13 | #include <unistd.h> | 15 | #include <unistd.h> |
14 | 16 | ||
15 | struct pollfd; | 17 | struct pollfd; |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 3779b9f3f134..0e879097adfb 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -8,12 +8,15 @@ | |||
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> |
14 | #include <linux/hw_breakpoint.h> | 16 | #include <linux/hw_breakpoint.h> |
15 | #include <linux/perf_event.h> | 17 | #include <linux/perf_event.h> |
16 | #include <linux/err.h> | 18 | #include <linux/err.h> |
19 | #include <sys/ioctl.h> | ||
17 | #include <sys/resource.h> | 20 | #include <sys/resource.h> |
18 | #include "asm/bug.h" | 21 | #include "asm/bug.h" |
19 | #include "callchain.h" | 22 | #include "callchain.h" |
@@ -30,6 +33,8 @@ | |||
30 | #include "stat.h" | 33 | #include "stat.h" |
31 | #include "util/parse-branch-options.h" | 34 | #include "util/parse-branch-options.h" |
32 | 35 | ||
36 | #include "sane_ctype.h" | ||
37 | |||
33 | static struct { | 38 | static struct { |
34 | bool sample_id_all; | 39 | bool sample_id_all; |
35 | bool exclude_guest; | 40 | 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..948b2c5efb65 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -1,4 +1,8 @@ | |||
1 | #include <errno.h> | ||
2 | #include <inttypes.h> | ||
1 | #include "util.h" | 3 | #include "util.h" |
4 | #include "string2.h" | ||
5 | #include <sys/param.h> | ||
2 | #include <sys/types.h> | 6 | #include <sys/types.h> |
3 | #include <byteswap.h> | 7 | #include <byteswap.h> |
4 | #include <unistd.h> | 8 | #include <unistd.h> |
@@ -7,7 +11,10 @@ | |||
7 | #include <linux/list.h> | 11 | #include <linux/list.h> |
8 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
9 | #include <linux/bitops.h> | 13 | #include <linux/bitops.h> |
14 | #include <sys/stat.h> | ||
15 | #include <sys/types.h> | ||
10 | #include <sys/utsname.h> | 16 | #include <sys/utsname.h> |
17 | #include <unistd.h> | ||
11 | 18 | ||
12 | #include "evlist.h" | 19 | #include "evlist.h" |
13 | #include "evsel.h" | 20 | #include "evsel.h" |
@@ -26,6 +33,8 @@ | |||
26 | #include <api/fs/fs.h> | 33 | #include <api/fs/fs.h> |
27 | #include "asm/bug.h" | 34 | #include "asm/bug.h" |
28 | 35 | ||
36 | #include "sane_ctype.h" | ||
37 | |||
29 | /* | 38 | /* |
30 | * magic2 = "PERFILE2" | 39 | * magic2 = "PERFILE2" |
31 | * must be a numerical value to let the endianness | 40 | * must be a numerical value to let the endianness |
diff --git a/tools/perf/util/help-unknown-cmd.c b/tools/perf/util/help-unknown-cmd.c index 34201440ac03..1c88ad6425b8 100644 --- a/tools/perf/util/help-unknown-cmd.c +++ b/tools/perf/util/help-unknown-cmd.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include "cache.h" | 1 | #include "cache.h" |
2 | #include "config.h" | 2 | #include "config.h" |
3 | #include <poll.h> | ||
3 | #include <stdio.h> | 4 | #include <stdio.h> |
4 | #include <subcmd/help.h> | 5 | #include <subcmd/help.h> |
5 | #include "../builtin.h" | 6 | #include "../builtin.h" |
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 61bf304206fd..cf0186a088c1 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -8,8 +8,12 @@ | |||
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" | ||
12 | #include "thread.h" | ||
11 | #include "ui/progress.h" | 13 | #include "ui/progress.h" |
14 | #include <errno.h> | ||
12 | #include <math.h> | 15 | #include <math.h> |
16 | #include <sys/param.h> | ||
13 | 17 | ||
14 | static bool hists__filter_entry_by_dso(struct hists *hists, | 18 | static bool hists__filter_entry_by_dso(struct hists *hists, |
15 | struct hist_entry *he); | 19 | struct hist_entry *he); |
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/llvm-utils.c b/tools/perf/util/llvm-utils.c index 824356488ce6..c6a15f204c03 100644 --- a/tools/perf/util/llvm-utils.c +++ b/tools/perf/util/llvm-utils.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "llvm-utils.h" | 12 | #include "llvm-utils.h" |
13 | #include "config.h" | 13 | #include "config.h" |
14 | #include "util.h" | 14 | #include "util.h" |
15 | #include <sys/wait.h> | ||
15 | 16 | ||
16 | #define CLANG_BPF_CMD_DEFAULT_TEMPLATE \ | 17 | #define CLANG_BPF_CMD_DEFAULT_TEMPLATE \ |
17 | "$CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS "\ | 18 | "$CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS "\ |
diff --git a/tools/perf/util/lzma.c b/tools/perf/util/lzma.c index 9ddea5cecd94..4ca7c5c6cdcd 100644 --- a/tools/perf/util/lzma.c +++ b/tools/perf/util/lzma.c | |||
@@ -1,6 +1,8 @@ | |||
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> |
5 | #include "compress.h" | ||
4 | #include "util.h" | 6 | #include "util.h" |
5 | #include "debug.h" | 7 | #include "debug.h" |
6 | 8 | ||
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index dfc600446586..7a47f52ccfcc 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,16 @@ | |||
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> | 17 | #include <sys/types.h> |
18 | #include <sys/stat.h> | ||
19 | #include <unistd.h> | ||
14 | #include "unwind.h" | 20 | #include "unwind.h" |
15 | #include "linux/hash.h" | 21 | #include "linux/hash.h" |
16 | #include "asm/bug.h" | 22 | #include "asm/bug.h" |
17 | 23 | ||
24 | #include "sane_ctype.h" | ||
25 | #include <symbol/kallsyms.h> | ||
26 | |||
18 | static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock); | 27 | static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock); |
19 | 28 | ||
20 | static void dsos__init(struct dsos *dsos) | 29 | 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..06f5a3a4295c 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" |
@@ -205,8 +206,8 @@ int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info) | |||
205 | static const char * const snoop_access[] = { | 206 | static const char * const snoop_access[] = { |
206 | "N/A", | 207 | "N/A", |
207 | "None", | 208 | "None", |
208 | "Miss", | ||
209 | "Hit", | 209 | "Hit", |
210 | "Miss", | ||
210 | "HitM", | 211 | "HitM", |
211 | }; | 212 | }; |
212 | 213 | ||
diff --git a/tools/perf/util/namespaces.c b/tools/perf/util/namespaces.c index 2de8da64d90c..67dcbcc73c7d 100644 --- a/tools/perf/util/namespaces.c +++ b/tools/perf/util/namespaces.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include "event.h" | 11 | #include "event.h" |
12 | #include <stdlib.h> | 12 | #include <stdlib.h> |
13 | #include <stdio.h> | 13 | #include <stdio.h> |
14 | #include <string.h> | ||
14 | 15 | ||
15 | struct namespaces *namespaces__new(struct namespaces_event *event) | 16 | struct namespaces *namespaces__new(struct namespaces_event *event) |
16 | { | 17 | { |
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..01e779b91c8e 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -1,13 +1,18 @@ | |||
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 <sys/ioctl.h> | ||
6 | #include <sys/param.h> | ||
7 | #include "term.h" | ||
4 | #include "../perf.h" | 8 | #include "../perf.h" |
5 | #include "evlist.h" | 9 | #include "evlist.h" |
6 | #include "evsel.h" | 10 | #include "evsel.h" |
7 | #include <subcmd/parse-options.h> | 11 | #include <subcmd/parse-options.h> |
8 | #include "parse-events.h" | 12 | #include "parse-events.h" |
9 | #include <subcmd/exec-cmd.h> | 13 | #include <subcmd/exec-cmd.h> |
10 | #include "string.h" | 14 | #include "string2.h" |
15 | #include "strlist.h" | ||
11 | #include "symbol.h" | 16 | #include "symbol.h" |
12 | #include "cache.h" | 17 | #include "cache.h" |
13 | #include "header.h" | 18 | #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..ac16a9db1fb5 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c | |||
@@ -1,6 +1,8 @@ | |||
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> | ||
5 | #include <sys/stat.h> | ||
4 | #include <unistd.h> | 6 | #include <unistd.h> |
5 | #include <stdio.h> | 7 | #include <stdio.h> |
6 | #include <stdbool.h> | 8 | #include <stdbool.h> |
@@ -15,6 +17,7 @@ | |||
15 | #include "header.h" | 17 | #include "header.h" |
16 | #include "pmu-events/pmu-events.h" | 18 | #include "pmu-events/pmu-events.h" |
17 | #include "cache.h" | 19 | #include "cache.h" |
20 | #include "string2.h" | ||
18 | 21 | ||
19 | struct perf_pmu_format { | 22 | struct perf_pmu_format { |
20 | char *name; | 23 | 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..d679389e627c 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c | |||
@@ -14,10 +14,15 @@ | |||
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | * | 15 | * |
16 | */ | 16 | */ |
17 | #include <errno.h> | ||
18 | #include <sys/stat.h> | ||
19 | #include <sys/types.h> | ||
17 | #include <sys/uio.h> | 20 | #include <sys/uio.h> |
21 | #include <unistd.h> | ||
18 | #include "util.h" | 22 | #include "util.h" |
19 | #include "event.h" | 23 | #include "event.h" |
20 | #include "strlist.h" | 24 | #include "strlist.h" |
25 | #include "strfilter.h" | ||
21 | #include "debug.h" | 26 | #include "debug.h" |
22 | #include "cache.h" | 27 | #include "cache.h" |
23 | #include "color.h" | 28 | #include "color.h" |
@@ -28,6 +33,7 @@ | |||
28 | #include "probe-file.h" | 33 | #include "probe-file.h" |
29 | #include "session.h" | 34 | #include "session.h" |
30 | #include "perf_regs.h" | 35 | #include "perf_regs.h" |
36 | #include "string2.h" | ||
31 | 37 | ||
32 | /* 4096 - 2 ('\n' + '\0') */ | 38 | /* 4096 - 2 ('\n' + '\0') */ |
33 | #define MAX_CMDLEN 4094 | 39 | #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..9f3b0d9754a8 100644 --- a/tools/perf/util/python-ext-sources +++ b/tools/perf/util/python-ext-sources | |||
@@ -21,8 +21,10 @@ 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 |
27 | util/string.c | 28 | util/string.c |
28 | util/symbol_fprintf.c | 29 | util/symbol_fprintf.c |
30 | util/units.c | ||
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index a5fbc012e3df..c129e99114ae 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c | |||
@@ -4,12 +4,26 @@ | |||
4 | #include <poll.h> | 4 | #include <poll.h> |
5 | #include <linux/err.h> | 5 | #include <linux/err.h> |
6 | #include "evlist.h" | 6 | #include "evlist.h" |
7 | #include "callchain.h" | ||
7 | #include "evsel.h" | 8 | #include "evsel.h" |
8 | #include "event.h" | 9 | #include "event.h" |
9 | #include "cpumap.h" | 10 | #include "cpumap.h" |
11 | #include "print_binary.h" | ||
10 | #include "thread_map.h" | 12 | #include "thread_map.h" |
11 | 13 | ||
12 | /* | 14 | /* |
15 | * Provide these two so that we don't have to link against callchain.c and | ||
16 | * start dragging hist.c, etc. | ||
17 | */ | ||
18 | struct callchain_param callchain_param; | ||
19 | |||
20 | int parse_callchain_record(const char *arg __maybe_unused, | ||
21 | struct callchain_param *param __maybe_unused) | ||
22 | { | ||
23 | return 0; | ||
24 | } | ||
25 | |||
26 | /* | ||
13 | * Support debug printing even though util/debug.c is not linked. That means | 27 | * Support debug printing even though util/debug.c is not linked. That means |
14 | * implementing 'verbose' and 'eprintf'. | 28 | * implementing 'verbose' and 'eprintf'. |
15 | */ | 29 | */ |
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..3041c6b98191 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> |
@@ -17,6 +19,7 @@ | |||
17 | #include "perf_regs.h" | 19 | #include "perf_regs.h" |
18 | #include "asm/bug.h" | 20 | #include "asm/bug.h" |
19 | #include "auxtrace.h" | 21 | #include "auxtrace.h" |
22 | #include "thread.h" | ||
20 | #include "thread-stack.h" | 23 | #include "thread-stack.h" |
21 | #include "stat.h" | 24 | #include "stat.h" |
22 | 25 | ||
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 4bd758553450..47b5e7dbcb18 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
@@ -5,14 +5,14 @@ | |||
5 | #include "event.h" | 5 | #include "event.h" |
6 | #include "header.h" | 6 | #include "header.h" |
7 | #include "machine.h" | 7 | #include "machine.h" |
8 | #include "symbol.h" | ||
9 | #include "thread.h" | ||
10 | #include "data.h" | 8 | #include "data.h" |
11 | #include "ordered-events.h" | 9 | #include "ordered-events.h" |
10 | #include <linux/kernel.h> | ||
12 | #include <linux/rbtree.h> | 11 | #include <linux/rbtree.h> |
13 | #include <linux/perf_event.h> | 12 | #include <linux/perf_event.h> |
14 | 13 | ||
15 | struct ip_callchain; | 14 | struct ip_callchain; |
15 | struct symbol; | ||
16 | struct thread; | 16 | struct thread; |
17 | 17 | ||
18 | struct auxtrace; | 18 | struct auxtrace; |
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 73f3ec1cf2a0..5762ae4e9e91 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
@@ -1,12 +1,18 @@ | |||
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" |
4 | #include "comm.h" | 7 | #include "comm.h" |
5 | #include "symbol.h" | 8 | #include "symbol.h" |
9 | #include "thread.h" | ||
6 | #include "evsel.h" | 10 | #include "evsel.h" |
7 | #include "evlist.h" | 11 | #include "evlist.h" |
12 | #include "strlist.h" | ||
8 | #include <traceevent/event-parse.h> | 13 | #include <traceevent/event-parse.h> |
9 | #include "mem-events.h" | 14 | #include "mem-events.h" |
15 | #include <linux/kernel.h> | ||
10 | 16 | ||
11 | regex_t parent_regex; | 17 | regex_t parent_regex; |
12 | const char default_parent_pattern[] = "^sys_|^do_page_fault"; | 18 | 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..b7c75597e18f 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,7 +20,9 @@ | |||
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" |
24 | #include "thread.h" | 23 | #include "srcline.h" |
24 | |||
25 | struct thread; | ||
25 | 26 | ||
26 | extern regex_t parent_regex; | 27 | extern regex_t parent_regex; |
27 | extern const char *sort_order; | 28 | extern const char *sort_order; |
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/strlist.c b/tools/perf/util/strlist.c index 0d3dfcb919b4..9de5434bb49e 100644 --- a/tools/perf/util/strlist.c +++ b/tools/perf/util/strlist.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <stdio.h> | 10 | #include <stdio.h> |
11 | #include <stdlib.h> | 11 | #include <stdlib.h> |
12 | #include <string.h> | 12 | #include <string.h> |
13 | #include <unistd.h> | ||
13 | 14 | ||
14 | static | 15 | static |
15 | struct rb_node *strlist__node_new(struct rblist *rblist, const void *entry) | 16 | struct rb_node *strlist__node_new(struct rblist *rblist, const void *entry) |
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/time-utils.c b/tools/perf/util/time-utils.c index d1b21c72206d..5b5d0214debd 100644 --- a/tools/perf/util/time-utils.c +++ b/tools/perf/util/time-utils.c | |||
@@ -117,3 +117,28 @@ bool perf_time__skip_sample(struct perf_time_interval *ptime, u64 timestamp) | |||
117 | 117 | ||
118 | return false; | 118 | return false; |
119 | } | 119 | } |
120 | |||
121 | int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz) | ||
122 | { | ||
123 | u64 sec = timestamp / NSEC_PER_SEC; | ||
124 | u64 usec = (timestamp % NSEC_PER_SEC) / NSEC_PER_USEC; | ||
125 | |||
126 | return scnprintf(buf, sz, "%"PRIu64".%06"PRIu64, sec, usec); | ||
127 | } | ||
128 | |||
129 | int fetch_current_timestamp(char *buf, size_t sz) | ||
130 | { | ||
131 | struct timeval tv; | ||
132 | struct tm tm; | ||
133 | char dt[32]; | ||
134 | |||
135 | if (gettimeofday(&tv, NULL) || !localtime_r(&tv.tv_sec, &tm)) | ||
136 | return -1; | ||
137 | |||
138 | if (!strftime(dt, sizeof(dt), "%Y%m%d%H%M%S", &tm)) | ||
139 | return -1; | ||
140 | |||
141 | scnprintf(buf, sz, "%s%02u", dt, (unsigned)tv.tv_usec / 10000); | ||
142 | |||
143 | return 0; | ||
144 | } | ||
diff --git a/tools/perf/util/time-utils.h b/tools/perf/util/time-utils.h index c1f197c4af6c..8656be08513b 100644 --- a/tools/perf/util/time-utils.h +++ b/tools/perf/util/time-utils.h | |||
@@ -1,6 +1,9 @@ | |||
1 | #ifndef _TIME_UTILS_H_ | 1 | #ifndef _TIME_UTILS_H_ |
2 | #define _TIME_UTILS_H_ | 2 | #define _TIME_UTILS_H_ |
3 | 3 | ||
4 | #include <stddef.h> | ||
5 | #include <linux/types.h> | ||
6 | |||
4 | struct perf_time_interval { | 7 | struct perf_time_interval { |
5 | u64 start, end; | 8 | u64 start, end; |
6 | }; | 9 | }; |
@@ -11,4 +14,8 @@ int perf_time__parse_str(struct perf_time_interval *ptime, const char *ostr); | |||
11 | 14 | ||
12 | bool perf_time__skip_sample(struct perf_time_interval *ptime, u64 timestamp); | 15 | bool perf_time__skip_sample(struct perf_time_interval *ptime, u64 timestamp); |
13 | 16 | ||
17 | int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz); | ||
18 | |||
19 | int fetch_current_timestamp(char *buf, size_t sz); | ||
20 | |||
14 | #endif | 21 | #endif |
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index b2940c88734a..9bdfb78a9a35 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h | |||
@@ -5,7 +5,7 @@ | |||
5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
6 | #include <stddef.h> | 6 | #include <stddef.h> |
7 | #include <stdbool.h> | 7 | #include <stdbool.h> |
8 | #include <termios.h> | 8 | #include <sys/ioctl.h> |
9 | 9 | ||
10 | struct perf_evlist; | 10 | struct perf_evlist; |
11 | struct perf_evsel; | 11 | struct perf_evsel; |
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/units.c b/tools/perf/util/units.c new file mode 100644 index 000000000000..f6a2a3d117d5 --- /dev/null +++ b/tools/perf/util/units.c | |||
@@ -0,0 +1,39 @@ | |||
1 | #include "units.h" | ||
2 | #include <inttypes.h> | ||
3 | #include <linux/kernel.h> | ||
4 | #include <linux/time64.h> | ||
5 | |||
6 | unsigned long convert_unit(unsigned long value, char *unit) | ||
7 | { | ||
8 | *unit = ' '; | ||
9 | |||
10 | if (value > 1000) { | ||
11 | value /= 1000; | ||
12 | *unit = 'K'; | ||
13 | } | ||
14 | |||
15 | if (value > 1000) { | ||
16 | value /= 1000; | ||
17 | *unit = 'M'; | ||
18 | } | ||
19 | |||
20 | if (value > 1000) { | ||
21 | value /= 1000; | ||
22 | *unit = 'G'; | ||
23 | } | ||
24 | |||
25 | return value; | ||
26 | } | ||
27 | |||
28 | int unit_number__scnprintf(char *buf, size_t size, u64 n) | ||
29 | { | ||
30 | char unit[4] = "BKMG"; | ||
31 | int i = 0; | ||
32 | |||
33 | while (((n / 1024) > 1) && (i < 3)) { | ||
34 | n /= 1024; | ||
35 | i++; | ||
36 | } | ||
37 | |||
38 | return scnprintf(buf, size, "%" PRIu64 "%c", n, unit[i]); | ||
39 | } | ||
diff --git a/tools/perf/util/units.h b/tools/perf/util/units.h new file mode 100644 index 000000000000..3ed7774afaa9 --- /dev/null +++ b/tools/perf/util/units.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef PERF_UNIT_H | ||
2 | #define PERF_UNIT_H | ||
3 | |||
4 | #include <stddef.h> | ||
5 | #include <linux/types.h> | ||
6 | |||
7 | unsigned long convert_unit(unsigned long value, char *unit); | ||
8 | int unit_number__scnprintf(char *buf, size_t size, u64 n); | ||
9 | |||
10 | #endif /* PERF_UNIT_H */ | ||
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-libdw.h b/tools/perf/util/unwind-libdw.h index 58328669ed16..4a2b269a7b3b 100644 --- a/tools/perf/util/unwind-libdw.h +++ b/tools/perf/util/unwind-libdw.h | |||
@@ -2,10 +2,12 @@ | |||
2 | #define __PERF_UNWIND_LIBDW_H | 2 | #define __PERF_UNWIND_LIBDW_H |
3 | 3 | ||
4 | #include <elfutils/libdwfl.h> | 4 | #include <elfutils/libdwfl.h> |
5 | #include "event.h" | ||
6 | #include "thread.h" | ||
7 | #include "unwind.h" | 5 | #include "unwind.h" |
8 | 6 | ||
7 | struct machine; | ||
8 | struct perf_sample; | ||
9 | struct thread; | ||
10 | |||
9 | bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg); | 11 | bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg); |
10 | 12 | ||
11 | struct unwind_info { | 13 | struct unwind_info { |
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/unwind.h b/tools/perf/util/unwind.h index 61fb1e90ff51..bfbdcc6198c9 100644 --- a/tools/perf/util/unwind.h +++ b/tools/perf/util/unwind.h | |||
@@ -1,10 +1,13 @@ | |||
1 | #ifndef __UNWIND_H | 1 | #ifndef __UNWIND_H |
2 | #define __UNWIND_H | 2 | #define __UNWIND_H |
3 | 3 | ||
4 | #include <linux/compiler.h> | ||
4 | #include <linux/types.h> | 5 | #include <linux/types.h> |
5 | #include "event.h" | 6 | |
6 | #include "symbol.h" | 7 | struct map; |
7 | #include "thread.h" | 8 | struct perf_sample; |
9 | struct symbol; | ||
10 | struct thread; | ||
8 | 11 | ||
9 | struct unwind_entry { | 12 | struct unwind_entry { |
10 | struct map *map; | 13 | struct map *map; |
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 6097d87429e2..6450c75a6f5b 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -3,10 +3,11 @@ | |||
3 | #include "debug.h" | 3 | #include "debug.h" |
4 | #include <api/fs/fs.h> | 4 | #include <api/fs/fs.h> |
5 | #include <sys/mman.h> | 5 | #include <sys/mman.h> |
6 | #include <sys/stat.h> | ||
6 | #include <sys/utsname.h> | 7 | #include <sys/utsname.h> |
7 | #ifdef HAVE_BACKTRACE_SUPPORT | 8 | #include <dirent.h> |
8 | #include <execinfo.h> | 9 | #include <inttypes.h> |
9 | #endif | 10 | #include <signal.h> |
10 | #include <stdio.h> | 11 | #include <stdio.h> |
11 | #include <stdlib.h> | 12 | #include <stdlib.h> |
12 | #include <string.h> | 13 | #include <string.h> |
@@ -17,24 +18,8 @@ | |||
17 | #include <linux/log2.h> | 18 | #include <linux/log2.h> |
18 | #include <linux/time64.h> | 19 | #include <linux/time64.h> |
19 | #include <unistd.h> | 20 | #include <unistd.h> |
20 | #include "callchain.h" | ||
21 | #include "strlist.h" | 21 | #include "strlist.h" |
22 | 22 | ||
23 | #define CALLCHAIN_PARAM_DEFAULT \ | ||
24 | .mode = CHAIN_GRAPH_ABS, \ | ||
25 | .min_percent = 0.5, \ | ||
26 | .order = ORDER_CALLEE, \ | ||
27 | .key = CCKEY_FUNCTION, \ | ||
28 | .value = CCVAL_PERCENT, \ | ||
29 | |||
30 | struct callchain_param callchain_param = { | ||
31 | CALLCHAIN_PARAM_DEFAULT | ||
32 | }; | ||
33 | |||
34 | struct callchain_param callchain_param_default = { | ||
35 | CALLCHAIN_PARAM_DEFAULT | ||
36 | }; | ||
37 | |||
38 | /* | 23 | /* |
39 | * XXX We need to find a better place for these things... | 24 | * XXX We need to find a better place for these things... |
40 | */ | 25 | */ |
@@ -269,28 +254,6 @@ int copyfile(const char *from, const char *to) | |||
269 | return copyfile_mode(from, to, 0755); | 254 | return copyfile_mode(from, to, 0755); |
270 | } | 255 | } |
271 | 256 | ||
272 | unsigned long convert_unit(unsigned long value, char *unit) | ||
273 | { | ||
274 | *unit = ' '; | ||
275 | |||
276 | if (value > 1000) { | ||
277 | value /= 1000; | ||
278 | *unit = 'K'; | ||
279 | } | ||
280 | |||
281 | if (value > 1000) { | ||
282 | value /= 1000; | ||
283 | *unit = 'M'; | ||
284 | } | ||
285 | |||
286 | if (value > 1000) { | ||
287 | value /= 1000; | ||
288 | *unit = 'G'; | ||
289 | } | ||
290 | |||
291 | return value; | ||
292 | } | ||
293 | |||
294 | static ssize_t ion(bool is_read, int fd, void *buf, size_t n) | 257 | static ssize_t ion(bool is_read, int fd, void *buf, size_t n) |
295 | { | 258 | { |
296 | void *buf_start = buf; | 259 | void *buf_start = buf; |
@@ -372,42 +335,6 @@ int hex2u64(const char *ptr, u64 *long_val) | |||
372 | return p - ptr; | 335 | return p - ptr; |
373 | } | 336 | } |
374 | 337 | ||
375 | /* Obtain a backtrace and print it to stdout. */ | ||
376 | #ifdef HAVE_BACKTRACE_SUPPORT | ||
377 | void dump_stack(void) | ||
378 | { | ||
379 | void *array[16]; | ||
380 | size_t size = backtrace(array, ARRAY_SIZE(array)); | ||
381 | char **strings = backtrace_symbols(array, size); | ||
382 | size_t i; | ||
383 | |||
384 | printf("Obtained %zd stack frames.\n", size); | ||
385 | |||
386 | for (i = 0; i < size; i++) | ||
387 | printf("%s\n", strings[i]); | ||
388 | |||
389 | free(strings); | ||
390 | } | ||
391 | #else | ||
392 | void dump_stack(void) {} | ||
393 | #endif | ||
394 | |||
395 | void sighandler_dump_stack(int sig) | ||
396 | { | ||
397 | psignal(sig, "perf"); | ||
398 | dump_stack(); | ||
399 | signal(sig, SIG_DFL); | ||
400 | raise(sig); | ||
401 | } | ||
402 | |||
403 | int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz) | ||
404 | { | ||
405 | u64 sec = timestamp / NSEC_PER_SEC; | ||
406 | u64 usec = (timestamp % NSEC_PER_SEC) / NSEC_PER_USEC; | ||
407 | |||
408 | return scnprintf(buf, sz, "%"PRIu64".%06"PRIu64, sec, usec); | ||
409 | } | ||
410 | |||
411 | unsigned long parse_tag_value(const char *str, struct parse_tag *tags) | 338 | unsigned long parse_tag_value(const char *str, struct parse_tag *tags) |
412 | { | 339 | { |
413 | struct parse_tag *i = tags; | 340 | struct parse_tag *i = tags; |
@@ -435,108 +362,6 @@ unsigned long parse_tag_value(const char *str, struct parse_tag *tags) | |||
435 | return (unsigned long) -1; | 362 | return (unsigned long) -1; |
436 | } | 363 | } |
437 | 364 | ||
438 | int get_stack_size(const char *str, unsigned long *_size) | ||
439 | { | ||
440 | char *endptr; | ||
441 | unsigned long size; | ||
442 | unsigned long max_size = round_down(USHRT_MAX, sizeof(u64)); | ||
443 | |||
444 | size = strtoul(str, &endptr, 0); | ||
445 | |||
446 | do { | ||
447 | if (*endptr) | ||
448 | break; | ||
449 | |||
450 | size = round_up(size, sizeof(u64)); | ||
451 | if (!size || size > max_size) | ||
452 | break; | ||
453 | |||
454 | *_size = size; | ||
455 | return 0; | ||
456 | |||
457 | } while (0); | ||
458 | |||
459 | pr_err("callchain: Incorrect stack dump size (max %ld): %s\n", | ||
460 | max_size, str); | ||
461 | return -1; | ||
462 | } | ||
463 | |||
464 | int parse_callchain_record(const char *arg, struct callchain_param *param) | ||
465 | { | ||
466 | char *tok, *name, *saveptr = NULL; | ||
467 | char *buf; | ||
468 | int ret = -1; | ||
469 | |||
470 | /* We need buffer that we know we can write to. */ | ||
471 | buf = malloc(strlen(arg) + 1); | ||
472 | if (!buf) | ||
473 | return -ENOMEM; | ||
474 | |||
475 | strcpy(buf, arg); | ||
476 | |||
477 | tok = strtok_r((char *)buf, ",", &saveptr); | ||
478 | name = tok ? : (char *)buf; | ||
479 | |||
480 | do { | ||
481 | /* Framepointer style */ | ||
482 | if (!strncmp(name, "fp", sizeof("fp"))) { | ||
483 | if (!strtok_r(NULL, ",", &saveptr)) { | ||
484 | param->record_mode = CALLCHAIN_FP; | ||
485 | ret = 0; | ||
486 | } else | ||
487 | pr_err("callchain: No more arguments " | ||
488 | "needed for --call-graph fp\n"); | ||
489 | break; | ||
490 | |||
491 | /* Dwarf style */ | ||
492 | } else if (!strncmp(name, "dwarf", sizeof("dwarf"))) { | ||
493 | const unsigned long default_stack_dump_size = 8192; | ||
494 | |||
495 | ret = 0; | ||
496 | param->record_mode = CALLCHAIN_DWARF; | ||
497 | param->dump_size = default_stack_dump_size; | ||
498 | |||
499 | tok = strtok_r(NULL, ",", &saveptr); | ||
500 | if (tok) { | ||
501 | unsigned long size = 0; | ||
502 | |||
503 | ret = get_stack_size(tok, &size); | ||
504 | param->dump_size = size; | ||
505 | } | ||
506 | } else if (!strncmp(name, "lbr", sizeof("lbr"))) { | ||
507 | if (!strtok_r(NULL, ",", &saveptr)) { | ||
508 | param->record_mode = CALLCHAIN_LBR; | ||
509 | ret = 0; | ||
510 | } else | ||
511 | pr_err("callchain: No more arguments " | ||
512 | "needed for --call-graph lbr\n"); | ||
513 | break; | ||
514 | } else { | ||
515 | pr_err("callchain: Unknown --call-graph option " | ||
516 | "value: %s\n", arg); | ||
517 | break; | ||
518 | } | ||
519 | |||
520 | } while (0); | ||
521 | |||
522 | free(buf); | ||
523 | return ret; | ||
524 | } | ||
525 | |||
526 | const char *get_filename_for_perf_kvm(void) | ||
527 | { | ||
528 | const char *filename; | ||
529 | |||
530 | if (perf_host && !perf_guest) | ||
531 | filename = strdup("perf.data.host"); | ||
532 | else if (!perf_host && perf_guest) | ||
533 | filename = strdup("perf.data.guest"); | ||
534 | else | ||
535 | filename = strdup("perf.data.kvm"); | ||
536 | |||
537 | return filename; | ||
538 | } | ||
539 | |||
540 | int perf_event_paranoid(void) | 365 | int perf_event_paranoid(void) |
541 | { | 366 | { |
542 | int value; | 367 | int value; |
@@ -711,95 +536,3 @@ out: | |||
711 | 536 | ||
712 | return tip; | 537 | return tip; |
713 | } | 538 | } |
714 | |||
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) | ||
726 | { | ||
727 | struct timeval tv; | ||
728 | struct tm tm; | ||
729 | char dt[32]; | ||
730 | |||
731 | if (gettimeofday(&tv, NULL) || !localtime_r(&tv.tv_sec, &tm)) | ||
732 | return -1; | ||
733 | |||
734 | if (!strftime(dt, sizeof(dt), "%Y%m%d%H%M%S", &tm)) | ||
735 | return -1; | ||
736 | |||
737 | scnprintf(buf, sz, "%s%02u", dt, (unsigned)tv.tv_usec / 10000); | ||
738 | |||
739 | return 0; | ||
740 | } | ||
741 | |||
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) | ||
795 | { | ||
796 | char unit[4] = "BKMG"; | ||
797 | int i = 0; | ||
798 | |||
799 | while (((n / 1024) > 1) && (i < 3)) { | ||
800 | n /= 1024; | ||
801 | i++; | ||
802 | } | ||
803 | |||
804 | return scnprintf(buf, size, "%" PRIu64 "%c", n, unit[i]); | ||
805 | } | ||
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 7cf5752b38fd..3852b6d3270a 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -1,126 +1,21 @@ | |||
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 */ |
43 | #define _DEFAULT_SOURCE 1 | 7 | #define _DEFAULT_SOURCE 1 |
44 | #define HAS_BOOL | 8 | #define HAS_BOOL |
45 | 9 | ||
46 | #include <unistd.h> | ||
47 | #include <stdio.h> | ||
48 | #include <sys/stat.h> | ||
49 | #include <sys/statfs.h> | ||
50 | #include <fcntl.h> | 10 | #include <fcntl.h> |
51 | #include <stdbool.h> | 11 | #include <stdbool.h> |
52 | #include <stddef.h> | 12 | #include <stddef.h> |
53 | #include <stdlib.h> | 13 | #include <stdlib.h> |
54 | #include <stdarg.h> | 14 | #include <stdarg.h> |
55 | #include <string.h> | ||
56 | #include <term.h> | ||
57 | #include <errno.h> | ||
58 | #include <limits.h> | ||
59 | #include <sys/param.h> | ||
60 | #include <sys/types.h> | ||
61 | #include <dirent.h> | ||
62 | #include <sys/time.h> | ||
63 | #include <time.h> | ||
64 | #include <signal.h> | ||
65 | #include <fnmatch.h> | ||
66 | #include <assert.h> | ||
67 | #include <regex.h> | ||
68 | #include <utime.h> | ||
69 | #include <sys/wait.h> | ||
70 | #include <poll.h> | ||
71 | #include <sys/socket.h> | ||
72 | #include <sys/ioctl.h> | ||
73 | #include <inttypes.h> | ||
74 | #include <linux/kernel.h> | ||
75 | #include <linux/types.h> | 15 | #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 | 16 | ||
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[]; | 17 | extern char buildid_dir[]; |
88 | 18 | ||
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 | |||
120 | #ifndef is_dir_sep | ||
121 | #define is_dir_sep(c) ((c) == '/') | ||
122 | #endif | ||
123 | |||
124 | #ifdef __GNUC__ | 19 | #ifdef __GNUC__ |
125 | #define NORETURN __attribute__((__noreturn__)) | 20 | #define NORETURN __attribute__((__noreturn__)) |
126 | #else | 21 | #else |
@@ -143,22 +38,6 @@ void set_warning_routine(void (*routine)(const char *err, va_list params)); | |||
143 | int prefixcmp(const char *str, const char *prefix); | 38 | int prefixcmp(const char *str, const char *prefix); |
144 | void set_buildid_dir(const char *dir); | 39 | void set_buildid_dir(const char *dir); |
145 | 40 | ||
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) | 41 | static inline void *zalloc(size_t size) |
163 | { | 42 | { |
164 | return calloc(1, size); | 43 | return calloc(1, size); |
@@ -166,47 +45,8 @@ static inline void *zalloc(size_t size) | |||
166 | 45 | ||
167 | #define zfree(ptr) ({ free(*ptr); *ptr = NULL; }) | 46 | #define zfree(ptr) ({ free(*ptr); *ptr = NULL; }) |
168 | 47 | ||
169 | /* Sane ctype - no locale, and works with signed chars */ | 48 | struct dirent; |
170 | #undef isascii | 49 | 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 | 50 | ||
211 | int mkdir_p(char *path, mode_t mode); | 51 | int mkdir_p(char *path, mode_t mode); |
212 | int rm_rf(const char *path); | 52 | int rm_rf(const char *path); |
@@ -216,19 +56,6 @@ int copyfile(const char *from, const char *to); | |||
216 | int copyfile_mode(const char *from, const char *to, mode_t mode); | 56 | 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); | 57 | int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 size); |
218 | 58 | ||
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); | ||
232 | ssize_t readn(int fd, void *buf, size_t n); | 59 | ssize_t readn(int fd, void *buf, size_t n); |
233 | ssize_t writen(int fd, void *buf, size_t n); | 60 | ssize_t writen(int fd, void *buf, size_t n); |
234 | 61 | ||
@@ -236,23 +63,9 @@ struct perf_event_attr; | |||
236 | 63 | ||
237 | void event_attr_init(struct perf_event_attr *attr); | 64 | void event_attr_init(struct perf_event_attr *attr); |
238 | 65 | ||
239 | #define _STR(x) #x | ||
240 | #define STR(x) _STR(x) | ||
241 | |||
242 | size_t hex_width(u64 v); | 66 | size_t hex_width(u64 v); |
243 | int hex2u64(const char *ptr, u64 *val); | 67 | int hex2u64(const char *ptr, u64 *val); |
244 | 68 | ||
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); | ||
254 | void sighandler_dump_stack(int sig); | ||
255 | |||
256 | extern unsigned int page_size; | 69 | extern unsigned int page_size; |
257 | extern int cacheline_size; | 70 | extern int cacheline_size; |
258 | extern int sysctl_perf_event_max_stack; | 71 | extern int sysctl_perf_event_max_stack; |
@@ -265,63 +78,13 @@ struct parse_tag { | |||
265 | 78 | ||
266 | unsigned long parse_tag_value(const char *str, struct parse_tag *tags); | 79 | unsigned long parse_tag_value(const char *str, struct parse_tag *tags); |
267 | 80 | ||
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); | 81 | int perf_event_paranoid(void); |
296 | 82 | ||
297 | void mem_bswap_64(void *src, int byte_size); | 83 | void mem_bswap_64(void *src, int byte_size); |
298 | void mem_bswap_32(void *src, int byte_size); | 84 | void mem_bswap_32(void *src, int byte_size); |
299 | 85 | ||
300 | const char *get_filename_for_perf_kvm(void); | ||
301 | bool find_process(const char *name); | 86 | bool find_process(const char *name); |
302 | 87 | ||
303 | #ifdef HAVE_ZLIB_SUPPORT | ||
304 | int gzip_decompress_to_file(const char *input, int output_fd); | ||
305 | #endif | ||
306 | |||
307 | #ifdef HAVE_LZMA_SUPPORT | ||
308 | int lzma_decompress_to_file(const char *input, int output_fd); | ||
309 | #endif | ||
310 | |||
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); | ||
324 | |||
325 | int fetch_kernel_version(unsigned int *puint, | 88 | int fetch_kernel_version(unsigned int *puint, |
326 | char *str, size_t str_sz); | 89 | char *str, size_t str_sz); |
327 | #define KVER_VERSION(x) (((x) >> 16) & 0xff) | 90 | #define KVER_VERSION(x) (((x) >> 16) & 0xff) |
@@ -331,53 +94,9 @@ int fetch_kernel_version(unsigned int *puint, | |||
331 | #define KVER_PARAM(x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x) | 94 | #define KVER_PARAM(x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x) |
332 | 95 | ||
333 | const char *perf_tip(const char *dirpath); | 96 | 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); | ||
336 | |||
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 | 97 | ||
358 | #ifndef HAVE_SCHED_GETCPU_SUPPORT | 98 | #ifndef HAVE_SCHED_GETCPU_SUPPORT |
359 | int sched_getcpu(void); | 99 | int sched_getcpu(void); |
360 | #endif | 100 | #endif |
361 | 101 | ||
362 | int is_printable_array(char *p, unsigned int len); | ||
363 | |||
364 | int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz); | ||
365 | |||
366 | int unit_number__scnprintf(char *buf, size_t size, u64 n); | ||
367 | |||
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 */ | 102 | #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> |
diff --git a/tools/perf/util/xyarray.c b/tools/perf/util/xyarray.c index c10ba41ef3f6..7251fdbabced 100644 --- a/tools/perf/util/xyarray.c +++ b/tools/perf/util/xyarray.c | |||
@@ -1,5 +1,7 @@ | |||
1 | #include "xyarray.h" | 1 | #include "xyarray.h" |
2 | #include "util.h" | 2 | #include "util.h" |
3 | #include <stdlib.h> | ||
4 | #include <string.h> | ||
3 | 5 | ||
4 | struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size) | 6 | struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size) |
5 | { | 7 | { |
diff --git a/tools/perf/util/zlib.c b/tools/perf/util/zlib.c index 495a449fc25c..1329d843eb7b 100644 --- a/tools/perf/util/zlib.c +++ b/tools/perf/util/zlib.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <sys/mman.h> | 4 | #include <sys/mman.h> |
5 | #include <zlib.h> | 5 | #include <zlib.h> |
6 | 6 | ||
7 | #include "util/compress.h" | ||
7 | #include "util/util.h" | 8 | #include "util/util.h" |
8 | #include "util/debug.h" | 9 | #include "util/debug.h" |
9 | 10 | ||