diff options
author | Olof Johansson <olof@lixom.net> | 2017-05-19 02:54:47 -0400 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2017-05-19 02:54:47 -0400 |
commit | 5252d73756f318f182f2316acd78a6532041414d (patch) | |
tree | b082478fca4f00f599bb2ed1547b2652c2bea155 /tools/perf | |
parent | e84188852a7239d7a144af12f7e5dac8fa88600b (diff) | |
parent | 2ea659a9ef488125eb46da6eb571de5eae5c43f6 (diff) |
Merge tag 'v4.12-rc1' into fixes
We've received a few fixes branches with -rc1 as base, but our contents was
still at pre-rc1. Merge it in expliticly to make 'git merge --log' clear on
hat was actually merged.
Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'tools/perf')
40 files changed, 230 insertions, 157 deletions
diff --git a/tools/perf/Documentation/perf-c2c.txt b/tools/perf/Documentation/perf-c2c.txt index 2da07e51e119..822414235170 100644 --- a/tools/perf/Documentation/perf-c2c.txt +++ b/tools/perf/Documentation/perf-c2c.txt | |||
@@ -76,7 +76,7 @@ REPORT OPTIONS | |||
76 | 76 | ||
77 | -c:: | 77 | -c:: |
78 | --coalesce:: | 78 | --coalesce:: |
79 | Specify sorintg fields for single cacheline display. | 79 | Specify sorting fields for single cacheline display. |
80 | Following fields are available: tid,pid,iaddr,dso | 80 | Following fields are available: tid,pid,iaddr,dso |
81 | (see COALESCE) | 81 | (see COALESCE) |
82 | 82 | ||
@@ -106,7 +106,7 @@ REPORT OPTIONS | |||
106 | 106 | ||
107 | -d:: | 107 | -d:: |
108 | --display:: | 108 | --display:: |
109 | Siwtch to HITM type (rmt, lcl) to display and sort on. Total HITMs as default. | 109 | Switch to HITM type (rmt, lcl) to display and sort on. Total HITMs as default. |
110 | 110 | ||
111 | C2C RECORD | 111 | C2C RECORD |
112 | ---------- | 112 | ---------- |
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index ea3789d05e5e..b0e9e921d534 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt | |||
@@ -225,7 +225,7 @@ OPTIONS | |||
225 | the libunwind or libdw library) should be used instead. | 225 | the libunwind or libdw library) should be used instead. |
226 | Using the "lbr" method doesn't require any compiler options. It | 226 | Using the "lbr" method doesn't require any compiler options. It |
227 | will produce call graphs from the hardware LBR registers. The | 227 | will produce call graphs from the hardware LBR registers. The |
228 | main limition is that it is only available on new Intel | 228 | main limitation is that it is only available on new Intel |
229 | platforms, such as Haswell. It can only get user call chain. It | 229 | platforms, such as Haswell. It can only get user call chain. It |
230 | doesn't work with branch stack sampling at the same time. | 230 | doesn't work with branch stack sampling at the same time. |
231 | 231 | ||
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index 37a175914157..9fa84617181e 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt | |||
@@ -182,7 +182,7 @@ OPTIONS | |||
182 | --parent=<regex>:: | 182 | --parent=<regex>:: |
183 | A regex filter to identify parent. The parent is a caller of this | 183 | A regex filter to identify parent. The parent is a caller of this |
184 | function and searched through the callchain, thus it requires callchain | 184 | function and searched through the callchain, thus it requires callchain |
185 | information recorded. The pattern is in the exteneded regex format and | 185 | information recorded. The pattern is in the extended regex format and |
186 | defaults to "\^sys_|^do_page_fault", see '--sort parent'. | 186 | defaults to "\^sys_|^do_page_fault", see '--sort parent'. |
187 | 187 | ||
188 | -x:: | 188 | -x:: |
@@ -207,8 +207,8 @@ OPTIONS | |||
207 | -g:: | 207 | -g:: |
208 | --call-graph=<print_type,threshold[,print_limit],order,sort_key[,branch],value>:: | 208 | --call-graph=<print_type,threshold[,print_limit],order,sort_key[,branch],value>:: |
209 | Display call chains using type, min percent threshold, print limit, | 209 | Display call chains using type, min percent threshold, print limit, |
210 | call order, sort key, optional branch and value. Note that ordering of | 210 | call order, sort key, optional branch and value. Note that ordering |
211 | parameters is not fixed so any parement can be given in an arbitraty order. | 211 | is not fixed so any parameter can be given in an arbitrary order. |
212 | One exception is the print_limit which should be preceded by threshold. | 212 | One exception is the print_limit which should be preceded by threshold. |
213 | 213 | ||
214 | print_type can be either: | 214 | print_type can be either: |
diff --git a/tools/perf/Documentation/perf.data-file-format.txt b/tools/perf/Documentation/perf.data-file-format.txt index fa2a9132f0a9..de8b39dda7b8 100644 --- a/tools/perf/Documentation/perf.data-file-format.txt +++ b/tools/perf/Documentation/perf.data-file-format.txt | |||
@@ -270,7 +270,7 @@ When the event stream contains multiple events each event is identified | |||
270 | by an ID. This can be either through the PERF_SAMPLE_ID or the | 270 | by an ID. This can be either through the PERF_SAMPLE_ID or the |
271 | PERF_SAMPLE_IDENTIFIER header. The PERF_SAMPLE_IDENTIFIER header is | 271 | PERF_SAMPLE_IDENTIFIER header. The PERF_SAMPLE_IDENTIFIER header is |
272 | at a fixed offset from the event header, which allows reliable | 272 | at a fixed offset from the event header, which allows reliable |
273 | parsing of the header. Relying on ID may be ambigious. | 273 | parsing of the header. Relying on ID may be ambiguous. |
274 | IDENTIFIER is only supported by newer Linux kernels. | 274 | IDENTIFIER is only supported by newer Linux kernels. |
275 | 275 | ||
276 | Perf record specific events: | 276 | Perf record specific events: |
@@ -288,7 +288,7 @@ struct attr_event { | |||
288 | uint64_t id[]; | 288 | uint64_t id[]; |
289 | }; | 289 | }; |
290 | 290 | ||
291 | PERF_RECORD_HEADER_EVENT_TYPE = 65, /* depreceated */ | 291 | PERF_RECORD_HEADER_EVENT_TYPE = 65, /* deprecated */ |
292 | 292 | ||
293 | #define MAX_EVENT_NAME 64 | 293 | #define MAX_EVENT_NAME 64 |
294 | 294 | ||
diff --git a/tools/perf/Documentation/tips.txt b/tools/perf/Documentation/tips.txt index 170b0289a7bc..db0ca3063eae 100644 --- a/tools/perf/Documentation/tips.txt +++ b/tools/perf/Documentation/tips.txt | |||
@@ -23,7 +23,7 @@ For memory address profiling, try: perf mem record / perf mem report | |||
23 | For tracepoint events, try: perf report -s trace_fields | 23 | For tracepoint events, try: perf report -s trace_fields |
24 | To record callchains for each sample: perf record -g | 24 | To record callchains for each sample: perf record -g |
25 | To record every process run by a user: perf record -u <user> | 25 | To record every process run by a user: perf record -u <user> |
26 | Skip collecing build-id when recording: perf record -B | 26 | Skip collecting build-id when recording: perf record -B |
27 | To change sampling frequency to 100 Hz: perf record -F 100 | 27 | To change sampling frequency to 100 Hz: perf record -F 100 |
28 | See assembly instructions with percentage: perf annotate <symbol> | 28 | See assembly instructions with percentage: perf annotate <symbol> |
29 | If you prefer Intel style assembly, try: perf annotate -M intel | 29 | If you prefer Intel style assembly, try: perf annotate -M intel |
diff --git a/tools/perf/arch/arm64/annotate/instructions.c b/tools/perf/arch/arm64/annotate/instructions.c index 44eafd6f2d50..8f1908756cb6 100644 --- a/tools/perf/arch/arm64/annotate/instructions.c +++ b/tools/perf/arch/arm64/annotate/instructions.c | |||
@@ -50,7 +50,7 @@ static int arm64__annotate_init(struct arch *arch) | |||
50 | arch->initialized = true; | 50 | arch->initialized = true; |
51 | arch->priv = arm; | 51 | arch->priv = arm; |
52 | arch->associate_instruction_ops = arm64__associate_instruction_ops; | 52 | arch->associate_instruction_ops = arm64__associate_instruction_ops; |
53 | arch->objdump.comment_char = ';'; | 53 | arch->objdump.comment_char = '/'; |
54 | arch->objdump.skip_functions_char = '+'; | 54 | arch->objdump.skip_functions_char = '+'; |
55 | return 0; | 55 | return 0; |
56 | 56 | ||
diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c index 39dbe512b9fc..bf9a2594572c 100644 --- a/tools/perf/arch/powerpc/util/sym-handling.c +++ b/tools/perf/arch/powerpc/util/sym-handling.c | |||
@@ -52,6 +52,18 @@ int arch__compare_symbol_names(const char *namea, const char *nameb) | |||
52 | 52 | ||
53 | return strcmp(namea, nameb); | 53 | return strcmp(namea, nameb); |
54 | } | 54 | } |
55 | |||
56 | int arch__compare_symbol_names_n(const char *namea, const char *nameb, | ||
57 | unsigned int n) | ||
58 | { | ||
59 | /* Skip over initial dot */ | ||
60 | if (*namea == '.') | ||
61 | namea++; | ||
62 | if (*nameb == '.') | ||
63 | nameb++; | ||
64 | |||
65 | return strncmp(namea, nameb, n); | ||
66 | } | ||
55 | #endif | 67 | #endif |
56 | 68 | ||
57 | #if defined(_CALL_ELF) && _CALL_ELF == 2 | 69 | #if defined(_CALL_ELF) && _CALL_ELF == 2 |
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index 64b44e81c771..9eba7f1add1f 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c | |||
@@ -49,19 +49,22 @@ static bool same_kallsyms_reloc(const char *from_dir, char *to_dir) | |||
49 | char to[PATH_MAX]; | 49 | char to[PATH_MAX]; |
50 | const char *name; | 50 | const char *name; |
51 | u64 addr1 = 0, addr2 = 0; | 51 | u64 addr1 = 0, addr2 = 0; |
52 | int i; | 52 | int i, err = -1; |
53 | 53 | ||
54 | scnprintf(from, sizeof(from), "%s/kallsyms", from_dir); | 54 | scnprintf(from, sizeof(from), "%s/kallsyms", from_dir); |
55 | scnprintf(to, sizeof(to), "%s/kallsyms", to_dir); | 55 | scnprintf(to, sizeof(to), "%s/kallsyms", to_dir); |
56 | 56 | ||
57 | for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) { | 57 | for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) { |
58 | addr1 = kallsyms__get_function_start(from, name); | 58 | err = kallsyms__get_function_start(from, name, &addr1); |
59 | if (addr1) | 59 | if (!err) |
60 | break; | 60 | break; |
61 | } | 61 | } |
62 | 62 | ||
63 | if (name) | 63 | if (err) |
64 | addr2 = kallsyms__get_function_start(to, name); | 64 | return false; |
65 | |||
66 | if (kallsyms__get_function_start(to, name, &addr2)) | ||
67 | return false; | ||
65 | 68 | ||
66 | return addr1 == addr2; | 69 | return addr1 == addr2; |
67 | } | 70 | } |
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index e33b4acece90..620a467ee304 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "tool.h" | 27 | #include "tool.h" |
28 | #include "data.h" | 28 | #include "data.h" |
29 | #include "sort.h" | 29 | #include "sort.h" |
30 | #include "event.h" | ||
30 | #include "evlist.h" | 31 | #include "evlist.h" |
31 | #include "evsel.h" | 32 | #include "evsel.h" |
32 | #include <asm/bug.h> | 33 | #include <asm/bug.h> |
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c index 55f04f85b049..80668fa7556e 100644 --- a/tools/perf/builtin-config.c +++ b/tools/perf/builtin-config.c | |||
@@ -159,6 +159,7 @@ int cmd_config(int argc, const char **argv) | |||
159 | int i, ret = 0; | 159 | int i, ret = 0; |
160 | struct perf_config_set *set; | 160 | struct perf_config_set *set; |
161 | char *user_config = mkpath("%s/.perfconfig", getenv("HOME")); | 161 | char *user_config = mkpath("%s/.perfconfig", getenv("HOME")); |
162 | const char *config_filename; | ||
162 | 163 | ||
163 | argc = parse_options(argc, argv, config_options, config_usage, | 164 | argc = parse_options(argc, argv, config_options, config_usage, |
164 | PARSE_OPT_STOP_AT_NON_OPTION); | 165 | PARSE_OPT_STOP_AT_NON_OPTION); |
@@ -175,6 +176,11 @@ int cmd_config(int argc, const char **argv) | |||
175 | else if (use_user_config) | 176 | else if (use_user_config) |
176 | config_exclusive_filename = user_config; | 177 | config_exclusive_filename = user_config; |
177 | 178 | ||
179 | if (!config_exclusive_filename) | ||
180 | config_filename = user_config; | ||
181 | else | ||
182 | config_filename = config_exclusive_filename; | ||
183 | |||
178 | /* | 184 | /* |
179 | * At only 'config' sub-command, individually use the config set | 185 | * At only 'config' sub-command, individually use the config set |
180 | * because of reinitializing with options config file location. | 186 | * because of reinitializing with options config file location. |
@@ -192,13 +198,9 @@ int cmd_config(int argc, const char **argv) | |||
192 | parse_options_usage(config_usage, config_options, "l", 1); | 198 | parse_options_usage(config_usage, config_options, "l", 1); |
193 | } else { | 199 | } else { |
194 | ret = show_config(set); | 200 | ret = show_config(set); |
195 | if (ret < 0) { | 201 | if (ret < 0) |
196 | const char * config_filename = config_exclusive_filename; | ||
197 | if (!config_exclusive_filename) | ||
198 | config_filename = user_config; | ||
199 | pr_err("Nothing configured, " | 202 | pr_err("Nothing configured, " |
200 | "please check your %s \n", config_filename); | 203 | "please check your %s \n", config_filename); |
201 | } | ||
202 | } | 204 | } |
203 | break; | 205 | break; |
204 | default: | 206 | default: |
@@ -221,13 +223,8 @@ int cmd_config(int argc, const char **argv) | |||
221 | 223 | ||
222 | if (value == NULL) | 224 | if (value == NULL) |
223 | ret = show_spec_config(set, var); | 225 | ret = show_spec_config(set, var); |
224 | else { | 226 | else |
225 | const char *config_filename = config_exclusive_filename; | ||
226 | |||
227 | if (!config_exclusive_filename) | ||
228 | config_filename = user_config; | ||
229 | ret = set_config(set, config_filename, var, value); | 227 | ret = set_config(set, config_filename, var, value); |
230 | } | ||
231 | free(arg); | 228 | free(arg); |
232 | } | 229 | } |
233 | } else | 230 | } else |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 7ab42b8311a1..10b6362ca0bf 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -27,13 +27,13 @@ | |||
27 | #include "util/drv_configs.h" | 27 | #include "util/drv_configs.h" |
28 | #include "util/evlist.h" | 28 | #include "util/evlist.h" |
29 | #include "util/evsel.h" | 29 | #include "util/evsel.h" |
30 | #include "util/event.h" | ||
30 | #include "util/machine.h" | 31 | #include "util/machine.h" |
31 | #include "util/session.h" | 32 | #include "util/session.h" |
32 | #include "util/symbol.h" | 33 | #include "util/symbol.h" |
33 | #include "util/thread.h" | 34 | #include "util/thread.h" |
34 | #include "util/thread_map.h" | 35 | #include "util/thread_map.h" |
35 | #include "util/top.h" | 36 | #include "util/top.h" |
36 | #include "util/util.h" | ||
37 | #include <linux/rbtree.h> | 37 | #include <linux/rbtree.h> |
38 | #include <subcmd/parse-options.h> | 38 | #include <subcmd/parse-options.h> |
39 | #include "util/parse-events.h" | 39 | #include "util/parse-events.h" |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index eaa66fb57347..d014350adc52 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include "builtin.h" | 21 | #include "builtin.h" |
22 | #include "util/color.h" | 22 | #include "util/color.h" |
23 | #include "util/debug.h" | 23 | #include "util/debug.h" |
24 | #include "util/event.h" | ||
24 | #include "util/evlist.h" | 25 | #include "util/evlist.h" |
25 | #include <subcmd/exec-cmd.h> | 26 | #include <subcmd/exec-cmd.h> |
26 | #include "util/machine.h" | 27 | #include "util/machine.h" |
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 4cc6960f6226..628a5e412cb1 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <subcmd/parse-options.h> | 17 | #include <subcmd/parse-options.h> |
18 | #include "util/bpf-loader.h" | 18 | #include "util/bpf-loader.h" |
19 | #include "util/debug.h" | 19 | #include "util/debug.h" |
20 | #include "util/event.h" | ||
20 | #include <api/fs/fs.h> | 21 | #include <api/fs/fs.h> |
21 | #include <api/fs/tracing_path.h> | 22 | #include <api/fs/tracing_path.h> |
22 | #include <errno.h> | 23 | #include <errno.h> |
diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c index 70918b986568..d549a9f2c41b 100644 --- a/tools/perf/tests/hists_cumulate.c +++ b/tools/perf/tests/hists_cumulate.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include "perf.h" | 1 | #include "perf.h" |
2 | #include "util/debug.h" | 2 | #include "util/debug.h" |
3 | #include "util/event.h" | ||
3 | #include "util/symbol.h" | 4 | #include "util/symbol.h" |
4 | #include "util/sort.h" | 5 | #include "util/sort.h" |
5 | #include "util/evsel.h" | 6 | #include "util/evsel.h" |
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c index f171b2da4899..df9c91f49af1 100644 --- a/tools/perf/tests/hists_filter.c +++ b/tools/perf/tests/hists_filter.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "util/symbol.h" | 3 | #include "util/symbol.h" |
4 | #include "util/sort.h" | 4 | #include "util/sort.h" |
5 | #include "util/evsel.h" | 5 | #include "util/evsel.h" |
6 | #include "util/event.h" | ||
6 | #include "util/evlist.h" | 7 | #include "util/evlist.h" |
7 | #include "util/machine.h" | 8 | #include "util/machine.h" |
8 | #include "util/thread.h" | 9 | #include "util/thread.h" |
diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c index cdf0dde5fe97..06e5080182d3 100644 --- a/tools/perf/tests/hists_output.c +++ b/tools/perf/tests/hists_output.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include "perf.h" | 1 | #include "perf.h" |
2 | #include "util/debug.h" | 2 | #include "util/debug.h" |
3 | #include "util/event.h" | ||
3 | #include "util/symbol.h" | 4 | #include "util/symbol.h" |
4 | #include "util/sort.h" | 5 | #include "util/sort.h" |
5 | #include "util/evsel.h" | 6 | #include "util/evsel.h" |
diff --git a/tools/perf/tests/kmod-path.c b/tools/perf/tests/kmod-path.c index 76f41f249944..6cd9e5107f77 100644 --- a/tools/perf/tests/kmod-path.c +++ b/tools/perf/tests/kmod-path.c | |||
@@ -61,6 +61,7 @@ int test__kmod_path__parse(int subtest __maybe_unused) | |||
61 | M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_KERNEL, true); | 61 | M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_KERNEL, true); |
62 | M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_USER, false); | 62 | M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_USER, false); |
63 | 63 | ||
64 | #ifdef HAVE_ZLIB_SUPPORT | ||
64 | /* path alloc_name alloc_ext kmod comp name ext */ | 65 | /* path alloc_name alloc_ext kmod comp name ext */ |
65 | T("/xxxx/xxxx/x.ko.gz", true , true , true, true, "[x]", "gz"); | 66 | T("/xxxx/xxxx/x.ko.gz", true , true , true, true, "[x]", "gz"); |
66 | T("/xxxx/xxxx/x.ko.gz", false , true , true, true, NULL , "gz"); | 67 | T("/xxxx/xxxx/x.ko.gz", false , true , true, true, NULL , "gz"); |
@@ -96,6 +97,7 @@ int test__kmod_path__parse(int subtest __maybe_unused) | |||
96 | M("x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true); | 97 | M("x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true); |
97 | M("x.ko.gz", PERF_RECORD_MISC_KERNEL, true); | 98 | M("x.ko.gz", PERF_RECORD_MISC_KERNEL, true); |
98 | M("x.ko.gz", PERF_RECORD_MISC_USER, false); | 99 | M("x.ko.gz", PERF_RECORD_MISC_USER, false); |
100 | #endif | ||
99 | 101 | ||
100 | /* path alloc_name alloc_ext kmod comp name ext */ | 102 | /* path alloc_name alloc_ext kmod comp name ext */ |
101 | T("[test_module]", true , true , true, false, "[test_module]", NULL); | 103 | T("[test_module]", true , true , true, false, "[test_module]", NULL); |
diff --git a/tools/perf/tests/sdt.c b/tools/perf/tests/sdt.c index f73b3c5e125d..06eda675ae2c 100644 --- a/tools/perf/tests/sdt.c +++ b/tools/perf/tests/sdt.c | |||
@@ -1,7 +1,6 @@ | |||
1 | #include <errno.h> | 1 | #include <errno.h> |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <sys/epoll.h> | 3 | #include <sys/epoll.h> |
4 | #include <util/util.h> | ||
5 | #include <util/evlist.h> | 4 | #include <util/evlist.h> |
6 | #include <linux/filter.h> | 5 | #include <linux/filter.h> |
7 | #include "tests.h" | 6 | #include "tests.h" |
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c index 5ea0b40c4fc2..caf1ce6f5152 100644 --- a/tools/perf/ui/setup.c +++ b/tools/perf/ui/setup.c | |||
@@ -10,7 +10,10 @@ pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; | |||
10 | void *perf_gtk_handle; | 10 | void *perf_gtk_handle; |
11 | int use_browser = -1; | 11 | int use_browser = -1; |
12 | 12 | ||
13 | #define PERF_GTK_DSO "libperf-gtk.so" | ||
14 | |||
13 | #ifdef HAVE_GTK2_SUPPORT | 15 | #ifdef HAVE_GTK2_SUPPORT |
16 | |||
14 | static int setup_gtk_browser(void) | 17 | static int setup_gtk_browser(void) |
15 | { | 18 | { |
16 | int (*perf_ui_init)(void); | 19 | int (*perf_ui_init)(void); |
diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 069583bdc670..79dea95a7f68 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build | |||
@@ -13,6 +13,7 @@ libperf-y += find_bit.o | |||
13 | libperf-y += kallsyms.o | 13 | libperf-y += kallsyms.o |
14 | libperf-y += levenshtein.o | 14 | libperf-y += levenshtein.o |
15 | libperf-y += llvm-utils.o | 15 | libperf-y += llvm-utils.o |
16 | libperf-y += memswap.o | ||
16 | libperf-y += parse-events.o | 17 | libperf-y += parse-events.o |
17 | libperf-y += perf_regs.o | 18 | libperf-y += perf_regs.o |
18 | libperf-y += path.o | 19 | libperf-y += path.o |
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index a96081121179..8a89b195c1fc 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h | |||
@@ -44,6 +44,10 @@ bool build_id_cache__cached(const char *sbuild_id); | |||
44 | int build_id_cache__add_s(const char *sbuild_id, | 44 | int build_id_cache__add_s(const char *sbuild_id, |
45 | const char *name, bool is_kallsyms, bool is_vdso); | 45 | const char *name, bool is_kallsyms, bool is_vdso); |
46 | int build_id_cache__remove_s(const char *sbuild_id); | 46 | int build_id_cache__remove_s(const char *sbuild_id); |
47 | |||
48 | extern char buildid_dir[]; | ||
49 | |||
50 | void set_buildid_dir(const char *dir); | ||
47 | void disable_buildid_cache(void); | 51 | void disable_buildid_cache(void); |
48 | 52 | ||
49 | #endif | 53 | #endif |
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 142835c0ca0a..dc5c3bb69d73 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <unistd.h> | 8 | #include <unistd.h> |
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 <api/fs/fs.h> | 10 | #include <api/fs/fs.h> |
11 | #include <linux/perf_event.h> | ||
11 | #include "event.h" | 12 | #include "event.h" |
12 | #include "debug.h" | 13 | #include "debug.h" |
13 | #include "hist.h" | 14 | #include "hist.h" |
@@ -767,15 +768,16 @@ static int find_symbol_cb(void *arg, const char *name, char type, | |||
767 | return 1; | 768 | return 1; |
768 | } | 769 | } |
769 | 770 | ||
770 | u64 kallsyms__get_function_start(const char *kallsyms_filename, | 771 | int kallsyms__get_function_start(const char *kallsyms_filename, |
771 | const char *symbol_name) | 772 | const char *symbol_name, u64 *addr) |
772 | { | 773 | { |
773 | struct process_symbol_args args = { .name = symbol_name, }; | 774 | struct process_symbol_args args = { .name = symbol_name, }; |
774 | 775 | ||
775 | if (kallsyms__parse(kallsyms_filename, &args, find_symbol_cb) <= 0) | 776 | if (kallsyms__parse(kallsyms_filename, &args, find_symbol_cb) <= 0) |
776 | return 0; | 777 | return -1; |
777 | 778 | ||
778 | return args.start; | 779 | *addr = args.start; |
780 | return 0; | ||
779 | } | 781 | } |
780 | 782 | ||
781 | int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, | 783 | int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, |
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index db2de6413518..7c3fa1c8cbcd 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h | |||
@@ -229,7 +229,7 @@ struct build_id_event { | |||
229 | enum perf_user_event_type { /* above any possible kernel type */ | 229 | enum perf_user_event_type { /* above any possible kernel type */ |
230 | PERF_RECORD_USER_TYPE_START = 64, | 230 | PERF_RECORD_USER_TYPE_START = 64, |
231 | PERF_RECORD_HEADER_ATTR = 64, | 231 | PERF_RECORD_HEADER_ATTR = 64, |
232 | PERF_RECORD_HEADER_EVENT_TYPE = 65, /* depreceated */ | 232 | PERF_RECORD_HEADER_EVENT_TYPE = 65, /* deprecated */ |
233 | PERF_RECORD_HEADER_TRACING_DATA = 66, | 233 | PERF_RECORD_HEADER_TRACING_DATA = 66, |
234 | PERF_RECORD_HEADER_BUILD_ID = 67, | 234 | PERF_RECORD_HEADER_BUILD_ID = 67, |
235 | PERF_RECORD_FINISHED_ROUND = 68, | 235 | PERF_RECORD_FINISHED_ROUND = 68, |
@@ -675,10 +675,18 @@ size_t perf_event__fprintf_cpu_map(union perf_event *event, FILE *fp); | |||
675 | size_t perf_event__fprintf_namespaces(union perf_event *event, FILE *fp); | 675 | size_t perf_event__fprintf_namespaces(union perf_event *event, FILE *fp); |
676 | size_t perf_event__fprintf(union perf_event *event, FILE *fp); | 676 | size_t perf_event__fprintf(union perf_event *event, FILE *fp); |
677 | 677 | ||
678 | u64 kallsyms__get_function_start(const char *kallsyms_filename, | 678 | int kallsyms__get_function_start(const char *kallsyms_filename, |
679 | const char *symbol_name); | 679 | const char *symbol_name, u64 *addr); |
680 | 680 | ||
681 | void *cpu_map_data__alloc(struct cpu_map *map, size_t *size, u16 *type, int *max); | 681 | void *cpu_map_data__alloc(struct cpu_map *map, size_t *size, u16 *type, int *max); |
682 | void cpu_map_data__synthesize(struct cpu_map_data *data, struct cpu_map *map, | 682 | void cpu_map_data__synthesize(struct cpu_map_data *data, struct cpu_map *map, |
683 | u16 type, int max); | 683 | u16 type, int max); |
684 | |||
685 | void event_attr_init(struct perf_event_attr *attr); | ||
686 | |||
687 | int perf_event_paranoid(void); | ||
688 | |||
689 | extern int sysctl_perf_event_max_stack; | ||
690 | extern int sysctl_perf_event_max_contexts_per_stack; | ||
691 | |||
684 | #endif /* __PERF_RECORD_H */ | 692 | #endif /* __PERF_RECORD_H */ |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 0e879097adfb..e4f7902d5afa 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include "asm/bug.h" | 21 | #include "asm/bug.h" |
22 | #include "callchain.h" | 22 | #include "callchain.h" |
23 | #include "cgroup.h" | 23 | #include "cgroup.h" |
24 | #include "event.h" | ||
24 | #include "evsel.h" | 25 | #include "evsel.h" |
25 | #include "evlist.h" | 26 | #include "evlist.h" |
26 | #include "util.h" | 27 | #include "util.h" |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 948b2c5efb65..314a07151fb7 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include "evlist.h" | 19 | #include "evlist.h" |
20 | #include "evsel.h" | 20 | #include "evsel.h" |
21 | #include "header.h" | 21 | #include "header.h" |
22 | #include "memswap.h" | ||
22 | #include "../perf.h" | 23 | #include "../perf.h" |
23 | #include "trace-event.h" | 24 | #include "trace-event.h" |
24 | #include "session.h" | 25 | #include "session.h" |
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index bdd4a28c6cee..4c7718f87a08 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "../perf.h" | 23 | #include "../perf.h" |
24 | #include "session.h" | 24 | #include "session.h" |
25 | #include "machine.h" | 25 | #include "machine.h" |
26 | #include "memswap.h" | ||
26 | #include "sort.h" | 27 | #include "sort.h" |
27 | #include "tool.h" | 28 | #include "tool.h" |
28 | #include "event.h" | 29 | #include "event.h" |
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 7a47f52ccfcc..d97e014c3df3 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
@@ -796,11 +796,11 @@ const char *ref_reloc_sym_names[] = {"_text", "_stext", NULL}; | |||
796 | * Returns the name of the start symbol in *symbol_name. Pass in NULL as | 796 | * Returns the name of the start symbol in *symbol_name. Pass in NULL as |
797 | * symbol_name if it's not that important. | 797 | * symbol_name if it's not that important. |
798 | */ | 798 | */ |
799 | static u64 machine__get_running_kernel_start(struct machine *machine, | 799 | static int machine__get_running_kernel_start(struct machine *machine, |
800 | const char **symbol_name) | 800 | const char **symbol_name, u64 *start) |
801 | { | 801 | { |
802 | char filename[PATH_MAX]; | 802 | char filename[PATH_MAX]; |
803 | int i; | 803 | int i, err = -1; |
804 | const char *name; | 804 | const char *name; |
805 | u64 addr = 0; | 805 | u64 addr = 0; |
806 | 806 | ||
@@ -810,21 +810,28 @@ static u64 machine__get_running_kernel_start(struct machine *machine, | |||
810 | return 0; | 810 | return 0; |
811 | 811 | ||
812 | for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) { | 812 | for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) { |
813 | addr = kallsyms__get_function_start(filename, name); | 813 | err = kallsyms__get_function_start(filename, name, &addr); |
814 | if (addr) | 814 | if (!err) |
815 | break; | 815 | break; |
816 | } | 816 | } |
817 | 817 | ||
818 | if (err) | ||
819 | return -1; | ||
820 | |||
818 | if (symbol_name) | 821 | if (symbol_name) |
819 | *symbol_name = name; | 822 | *symbol_name = name; |
820 | 823 | ||
821 | return addr; | 824 | *start = addr; |
825 | return 0; | ||
822 | } | 826 | } |
823 | 827 | ||
824 | int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel) | 828 | int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel) |
825 | { | 829 | { |
826 | int type; | 830 | int type; |
827 | u64 start = machine__get_running_kernel_start(machine, NULL); | 831 | u64 start = 0; |
832 | |||
833 | if (machine__get_running_kernel_start(machine, NULL, &start)) | ||
834 | return -1; | ||
828 | 835 | ||
829 | /* In case of renewal the kernel map, destroy previous one */ | 836 | /* In case of renewal the kernel map, destroy previous one */ |
830 | machine__destroy_kernel_maps(machine); | 837 | machine__destroy_kernel_maps(machine); |
@@ -1185,8 +1192,8 @@ static int machine__create_modules(struct machine *machine) | |||
1185 | int machine__create_kernel_maps(struct machine *machine) | 1192 | int machine__create_kernel_maps(struct machine *machine) |
1186 | { | 1193 | { |
1187 | struct dso *kernel = machine__get_kernel(machine); | 1194 | struct dso *kernel = machine__get_kernel(machine); |
1188 | const char *name; | 1195 | const char *name = NULL; |
1189 | u64 addr; | 1196 | u64 addr = 0; |
1190 | int ret; | 1197 | int ret; |
1191 | 1198 | ||
1192 | if (kernel == NULL) | 1199 | if (kernel == NULL) |
@@ -1211,8 +1218,7 @@ int machine__create_kernel_maps(struct machine *machine) | |||
1211 | */ | 1218 | */ |
1212 | map_groups__fixup_end(&machine->kmaps); | 1219 | map_groups__fixup_end(&machine->kmaps); |
1213 | 1220 | ||
1214 | addr = machine__get_running_kernel_start(machine, &name); | 1221 | if (machine__get_running_kernel_start(machine, &name, &addr)) { |
1215 | if (!addr) { | ||
1216 | } else if (maps__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, name, addr)) { | 1222 | } else if (maps__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, name, addr)) { |
1217 | machine__destroy_kernel_maps(machine); | 1223 | machine__destroy_kernel_maps(machine); |
1218 | return -1; | 1224 | return -1; |
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index ebfa5d92358a..2179b2deb730 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
@@ -325,11 +325,6 @@ int map__load(struct map *map) | |||
325 | return 0; | 325 | return 0; |
326 | } | 326 | } |
327 | 327 | ||
328 | int __weak arch__compare_symbol_names(const char *namea, const char *nameb) | ||
329 | { | ||
330 | return strcmp(namea, nameb); | ||
331 | } | ||
332 | |||
333 | struct symbol *map__find_symbol(struct map *map, u64 addr) | 328 | struct symbol *map__find_symbol(struct map *map, u64 addr) |
334 | { | 329 | { |
335 | if (map__load(map) < 0) | 330 | if (map__load(map) < 0) |
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index c8a5a644c0a9..f9e8ac8a52cd 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h | |||
@@ -130,13 +130,14 @@ struct thread; | |||
130 | */ | 130 | */ |
131 | #define __map__for_each_symbol_by_name(map, sym_name, pos) \ | 131 | #define __map__for_each_symbol_by_name(map, sym_name, pos) \ |
132 | for (pos = map__find_symbol_by_name(map, sym_name); \ | 132 | for (pos = map__find_symbol_by_name(map, sym_name); \ |
133 | pos && arch__compare_symbol_names(pos->name, sym_name) == 0; \ | 133 | pos && \ |
134 | !symbol__match_symbol_name(pos->name, sym_name, \ | ||
135 | SYMBOL_TAG_INCLUDE__DEFAULT_ONLY); \ | ||
134 | pos = symbol__next_by_name(pos)) | 136 | pos = symbol__next_by_name(pos)) |
135 | 137 | ||
136 | #define map__for_each_symbol_by_name(map, sym_name, pos) \ | 138 | #define map__for_each_symbol_by_name(map, sym_name, pos) \ |
137 | __map__for_each_symbol_by_name(map, sym_name, (pos)) | 139 | __map__for_each_symbol_by_name(map, sym_name, (pos)) |
138 | 140 | ||
139 | int arch__compare_symbol_names(const char *namea, const char *nameb); | ||
140 | void map__init(struct map *map, enum map_type type, | 141 | void map__init(struct map *map, enum map_type type, |
141 | u64 start, u64 end, u64 pgoff, struct dso *dso); | 142 | u64 start, u64 end, u64 pgoff, struct dso *dso); |
142 | struct map *map__new(struct machine *machine, u64 start, u64 len, | 143 | struct map *map__new(struct machine *machine, u64 start, u64 len, |
diff --git a/tools/perf/util/memswap.c b/tools/perf/util/memswap.c new file mode 100644 index 000000000000..55f7faa8d9ec --- /dev/null +++ b/tools/perf/util/memswap.c | |||
@@ -0,0 +1,24 @@ | |||
1 | #include <byteswap.h> | ||
2 | #include "memswap.h" | ||
3 | #include <linux/types.h> | ||
4 | |||
5 | void mem_bswap_32(void *src, int byte_size) | ||
6 | { | ||
7 | u32 *m = src; | ||
8 | while (byte_size > 0) { | ||
9 | *m = bswap_32(*m); | ||
10 | byte_size -= sizeof(u32); | ||
11 | ++m; | ||
12 | } | ||
13 | } | ||
14 | |||
15 | void mem_bswap_64(void *src, int byte_size) | ||
16 | { | ||
17 | u64 *m = src; | ||
18 | |||
19 | while (byte_size > 0) { | ||
20 | *m = bswap_64(*m); | ||
21 | byte_size -= sizeof(u64); | ||
22 | ++m; | ||
23 | } | ||
24 | } | ||
diff --git a/tools/perf/util/memswap.h b/tools/perf/util/memswap.h new file mode 100644 index 000000000000..7d1b1c34bb57 --- /dev/null +++ b/tools/perf/util/memswap.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef PERF_MEMSWAP_H_ | ||
2 | #define PERF_MEMSWAP_H_ | ||
3 | |||
4 | void mem_bswap_64(void *src, int byte_size); | ||
5 | void mem_bswap_32(void *src, int byte_size); | ||
6 | |||
7 | #endif /* PERF_MEMSWAP_H_ */ | ||
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c index 2b12bdb3ce33..7b79c413486b 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c | |||
@@ -28,7 +28,9 @@ | |||
28 | #include <linux/bitmap.h> | 28 | #include <linux/bitmap.h> |
29 | #include <linux/time64.h> | 29 | #include <linux/time64.h> |
30 | 30 | ||
31 | #include "../util.h" | 31 | #include <stdbool.h> |
32 | /* perl needs the following define, right after including stdbool.h */ | ||
33 | #define HAS_BOOL | ||
32 | #include <EXTERN.h> | 34 | #include <EXTERN.h> |
33 | #include <perl.h> | 35 | #include <perl.h> |
34 | 36 | ||
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 3041c6b98191..7dc1096264c5 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include "evlist.h" | 12 | #include "evlist.h" |
13 | #include "evsel.h" | 13 | #include "evsel.h" |
14 | #include "memswap.h" | ||
14 | #include "session.h" | 15 | #include "session.h" |
15 | #include "tool.h" | 16 | #include "tool.h" |
16 | #include "sort.h" | 17 | #include "sort.h" |
diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c index e91b5e86f027..aafe908b82b5 100644 --- a/tools/perf/util/strbuf.c +++ b/tools/perf/util/strbuf.c | |||
@@ -3,15 +3,6 @@ | |||
3 | #include <linux/kernel.h> | 3 | #include <linux/kernel.h> |
4 | #include <errno.h> | 4 | #include <errno.h> |
5 | 5 | ||
6 | int prefixcmp(const char *str, const char *prefix) | ||
7 | { | ||
8 | for (; ; str++, prefix++) | ||
9 | if (!*prefix) | ||
10 | return 0; | ||
11 | else if (*str != *prefix) | ||
12 | return (unsigned char)*prefix - (unsigned char)*str; | ||
13 | } | ||
14 | |||
15 | /* | 6 | /* |
16 | * Used as the default ->buf value, so that people can always assume | 7 | * Used as the default ->buf value, so that people can always assume |
17 | * buf is non NULL and ->buf is NUL terminated even for a freshly | 8 | * buf is non NULL and ->buf is NUL terminated even for a freshly |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 2cb7665e9973..8f2b068ff756 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -90,6 +90,17 @@ static int prefix_underscores_count(const char *str) | |||
90 | return tail - str; | 90 | return tail - str; |
91 | } | 91 | } |
92 | 92 | ||
93 | int __weak arch__compare_symbol_names(const char *namea, const char *nameb) | ||
94 | { | ||
95 | return strcmp(namea, nameb); | ||
96 | } | ||
97 | |||
98 | int __weak arch__compare_symbol_names_n(const char *namea, const char *nameb, | ||
99 | unsigned int n) | ||
100 | { | ||
101 | return strncmp(namea, nameb, n); | ||
102 | } | ||
103 | |||
93 | int __weak arch__choose_best_symbol(struct symbol *syma, | 104 | int __weak arch__choose_best_symbol(struct symbol *syma, |
94 | struct symbol *symb __maybe_unused) | 105 | struct symbol *symb __maybe_unused) |
95 | { | 106 | { |
@@ -399,8 +410,26 @@ static void symbols__sort_by_name(struct rb_root *symbols, | |||
399 | } | 410 | } |
400 | } | 411 | } |
401 | 412 | ||
413 | int symbol__match_symbol_name(const char *name, const char *str, | ||
414 | enum symbol_tag_include includes) | ||
415 | { | ||
416 | const char *versioning; | ||
417 | |||
418 | if (includes == SYMBOL_TAG_INCLUDE__DEFAULT_ONLY && | ||
419 | (versioning = strstr(name, "@@"))) { | ||
420 | int len = strlen(str); | ||
421 | |||
422 | if (len < versioning - name) | ||
423 | len = versioning - name; | ||
424 | |||
425 | return arch__compare_symbol_names_n(name, str, len); | ||
426 | } else | ||
427 | return arch__compare_symbol_names(name, str); | ||
428 | } | ||
429 | |||
402 | static struct symbol *symbols__find_by_name(struct rb_root *symbols, | 430 | static struct symbol *symbols__find_by_name(struct rb_root *symbols, |
403 | const char *name) | 431 | const char *name, |
432 | enum symbol_tag_include includes) | ||
404 | { | 433 | { |
405 | struct rb_node *n; | 434 | struct rb_node *n; |
406 | struct symbol_name_rb_node *s = NULL; | 435 | struct symbol_name_rb_node *s = NULL; |
@@ -414,11 +443,11 @@ static struct symbol *symbols__find_by_name(struct rb_root *symbols, | |||
414 | int cmp; | 443 | int cmp; |
415 | 444 | ||
416 | s = rb_entry(n, struct symbol_name_rb_node, rb_node); | 445 | s = rb_entry(n, struct symbol_name_rb_node, rb_node); |
417 | cmp = arch__compare_symbol_names(name, s->sym.name); | 446 | cmp = symbol__match_symbol_name(s->sym.name, name, includes); |
418 | 447 | ||
419 | if (cmp < 0) | 448 | if (cmp > 0) |
420 | n = n->rb_left; | 449 | n = n->rb_left; |
421 | else if (cmp > 0) | 450 | else if (cmp < 0) |
422 | n = n->rb_right; | 451 | n = n->rb_right; |
423 | else | 452 | else |
424 | break; | 453 | break; |
@@ -427,16 +456,17 @@ static struct symbol *symbols__find_by_name(struct rb_root *symbols, | |||
427 | if (n == NULL) | 456 | if (n == NULL) |
428 | return NULL; | 457 | return NULL; |
429 | 458 | ||
430 | /* return first symbol that has same name (if any) */ | 459 | if (includes != SYMBOL_TAG_INCLUDE__DEFAULT_ONLY) |
431 | for (n = rb_prev(n); n; n = rb_prev(n)) { | 460 | /* return first symbol that has same name (if any) */ |
432 | struct symbol_name_rb_node *tmp; | 461 | for (n = rb_prev(n); n; n = rb_prev(n)) { |
462 | struct symbol_name_rb_node *tmp; | ||
433 | 463 | ||
434 | tmp = rb_entry(n, struct symbol_name_rb_node, rb_node); | 464 | tmp = rb_entry(n, struct symbol_name_rb_node, rb_node); |
435 | if (arch__compare_symbol_names(tmp->sym.name, s->sym.name)) | 465 | if (arch__compare_symbol_names(tmp->sym.name, s->sym.name)) |
436 | break; | 466 | break; |
437 | 467 | ||
438 | s = tmp; | 468 | s = tmp; |
439 | } | 469 | } |
440 | 470 | ||
441 | return &s->sym; | 471 | return &s->sym; |
442 | } | 472 | } |
@@ -466,7 +496,7 @@ void dso__insert_symbol(struct dso *dso, enum map_type type, struct symbol *sym) | |||
466 | struct symbol *dso__find_symbol(struct dso *dso, | 496 | struct symbol *dso__find_symbol(struct dso *dso, |
467 | enum map_type type, u64 addr) | 497 | enum map_type type, u64 addr) |
468 | { | 498 | { |
469 | if (dso->last_find_result[type].addr != addr) { | 499 | if (dso->last_find_result[type].addr != addr || dso->last_find_result[type].symbol == NULL) { |
470 | dso->last_find_result[type].addr = addr; | 500 | dso->last_find_result[type].addr = addr; |
471 | dso->last_find_result[type].symbol = symbols__find(&dso->symbols[type], addr); | 501 | dso->last_find_result[type].symbol = symbols__find(&dso->symbols[type], addr); |
472 | } | 502 | } |
@@ -503,7 +533,12 @@ struct symbol *symbol__next_by_name(struct symbol *sym) | |||
503 | struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type, | 533 | struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type, |
504 | const char *name) | 534 | const char *name) |
505 | { | 535 | { |
506 | return symbols__find_by_name(&dso->symbol_names[type], name); | 536 | struct symbol *s = symbols__find_by_name(&dso->symbol_names[type], name, |
537 | SYMBOL_TAG_INCLUDE__NONE); | ||
538 | if (!s) | ||
539 | s = symbols__find_by_name(&dso->symbol_names[type], name, | ||
540 | SYMBOL_TAG_INCLUDE__DEFAULT_ONLY); | ||
541 | return s; | ||
507 | } | 542 | } |
508 | 543 | ||
509 | void dso__sort_by_name(struct dso *dso, enum map_type type) | 544 | void dso__sort_by_name(struct dso *dso, enum map_type type) |
@@ -1075,8 +1110,9 @@ static int validate_kcore_addresses(const char *kallsyms_filename, | |||
1075 | if (kmap->ref_reloc_sym && kmap->ref_reloc_sym->name) { | 1110 | if (kmap->ref_reloc_sym && kmap->ref_reloc_sym->name) { |
1076 | u64 start; | 1111 | u64 start; |
1077 | 1112 | ||
1078 | start = kallsyms__get_function_start(kallsyms_filename, | 1113 | if (kallsyms__get_function_start(kallsyms_filename, |
1079 | kmap->ref_reloc_sym->name); | 1114 | kmap->ref_reloc_sym->name, &start)) |
1115 | return -ENOENT; | ||
1080 | if (start != kmap->ref_reloc_sym->addr) | 1116 | if (start != kmap->ref_reloc_sym->addr) |
1081 | return -EINVAL; | 1117 | return -EINVAL; |
1082 | } | 1118 | } |
@@ -1248,9 +1284,7 @@ static int kallsyms__delta(struct map *map, const char *filename, u64 *delta) | |||
1248 | if (!kmap->ref_reloc_sym || !kmap->ref_reloc_sym->name) | 1284 | if (!kmap->ref_reloc_sym || !kmap->ref_reloc_sym->name) |
1249 | return 0; | 1285 | return 0; |
1250 | 1286 | ||
1251 | addr = kallsyms__get_function_start(filename, | 1287 | if (kallsyms__get_function_start(filename, kmap->ref_reloc_sym->name, &addr)) |
1252 | kmap->ref_reloc_sym->name); | ||
1253 | if (!addr) | ||
1254 | return -1; | 1288 | return -1; |
1255 | 1289 | ||
1256 | *delta = addr - kmap->ref_reloc_sym->addr; | 1290 | *delta = addr - kmap->ref_reloc_sym->addr; |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 7acd70fce68e..41ebba9a2eb2 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -348,8 +348,19 @@ void arch__sym_update(struct symbol *s, GElf_Sym *sym); | |||
348 | #define SYMBOL_A 0 | 348 | #define SYMBOL_A 0 |
349 | #define SYMBOL_B 1 | 349 | #define SYMBOL_B 1 |
350 | 350 | ||
351 | int arch__compare_symbol_names(const char *namea, const char *nameb); | ||
352 | int arch__compare_symbol_names_n(const char *namea, const char *nameb, | ||
353 | unsigned int n); | ||
351 | int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb); | 354 | int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb); |
352 | 355 | ||
356 | enum symbol_tag_include { | ||
357 | SYMBOL_TAG_INCLUDE__NONE = 0, | ||
358 | SYMBOL_TAG_INCLUDE__DEFAULT_ONLY | ||
359 | }; | ||
360 | |||
361 | int symbol__match_symbol_name(const char *namea, const char *nameb, | ||
362 | enum symbol_tag_include includes); | ||
363 | |||
353 | /* structure containing an SDT note's info */ | 364 | /* structure containing an SDT note's info */ |
354 | struct sdt_note { | 365 | struct sdt_note { |
355 | char *name; /* name of the note*/ | 366 | char *name; /* name of the note*/ |
diff --git a/tools/perf/util/units.c b/tools/perf/util/units.c index f6a2a3d117d5..4767ec2c5ef6 100644 --- a/tools/perf/util/units.c +++ b/tools/perf/util/units.c | |||
@@ -1,8 +1,37 @@ | |||
1 | #include "units.h" | 1 | #include "units.h" |
2 | #include <inttypes.h> | 2 | #include <inttypes.h> |
3 | #include <limits.h> | ||
4 | #include <stdlib.h> | ||
5 | #include <string.h> | ||
3 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
4 | #include <linux/time64.h> | 7 | #include <linux/time64.h> |
5 | 8 | ||
9 | unsigned long parse_tag_value(const char *str, struct parse_tag *tags) | ||
10 | { | ||
11 | struct parse_tag *i = tags; | ||
12 | |||
13 | while (i->tag) { | ||
14 | char *s = strchr(str, i->tag); | ||
15 | |||
16 | if (s) { | ||
17 | unsigned long int value; | ||
18 | char *endptr; | ||
19 | |||
20 | value = strtoul(str, &endptr, 10); | ||
21 | if (s != endptr) | ||
22 | break; | ||
23 | |||
24 | if (value > ULONG_MAX / i->mult) | ||
25 | break; | ||
26 | value *= i->mult; | ||
27 | return value; | ||
28 | } | ||
29 | i++; | ||
30 | } | ||
31 | |||
32 | return (unsigned long) -1; | ||
33 | } | ||
34 | |||
6 | unsigned long convert_unit(unsigned long value, char *unit) | 35 | unsigned long convert_unit(unsigned long value, char *unit) |
7 | { | 36 | { |
8 | *unit = ' '; | 37 | *unit = ' '; |
diff --git a/tools/perf/util/units.h b/tools/perf/util/units.h index 3ed7774afaa9..f02c87317150 100644 --- a/tools/perf/util/units.h +++ b/tools/perf/util/units.h | |||
@@ -4,6 +4,13 @@ | |||
4 | #include <stddef.h> | 4 | #include <stddef.h> |
5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
6 | 6 | ||
7 | struct parse_tag { | ||
8 | char tag; | ||
9 | int mult; | ||
10 | }; | ||
11 | |||
12 | unsigned long parse_tag_value(const char *str, struct parse_tag *tags); | ||
13 | |||
7 | unsigned long convert_unit(unsigned long value, char *unit); | 14 | unsigned long convert_unit(unsigned long value, char *unit); |
8 | int unit_number__scnprintf(char *buf, size_t size, u64 n); | 15 | int unit_number__scnprintf(char *buf, size_t size, u64 n); |
9 | 16 | ||
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 6450c75a6f5b..28c9f335006c 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <string.h> | 13 | #include <string.h> |
14 | #include <errno.h> | 14 | #include <errno.h> |
15 | #include <limits.h> | 15 | #include <limits.h> |
16 | #include <byteswap.h> | ||
17 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
18 | #include <linux/log2.h> | 17 | #include <linux/log2.h> |
19 | #include <linux/time64.h> | 18 | #include <linux/time64.h> |
@@ -335,33 +334,6 @@ int hex2u64(const char *ptr, u64 *long_val) | |||
335 | return p - ptr; | 334 | return p - ptr; |
336 | } | 335 | } |
337 | 336 | ||
338 | unsigned long parse_tag_value(const char *str, struct parse_tag *tags) | ||
339 | { | ||
340 | struct parse_tag *i = tags; | ||
341 | |||
342 | while (i->tag) { | ||
343 | char *s; | ||
344 | |||
345 | s = strchr(str, i->tag); | ||
346 | if (s) { | ||
347 | unsigned long int value; | ||
348 | char *endptr; | ||
349 | |||
350 | value = strtoul(str, &endptr, 10); | ||
351 | if (s != endptr) | ||
352 | break; | ||
353 | |||
354 | if (value > ULONG_MAX / i->mult) | ||
355 | break; | ||
356 | value *= i->mult; | ||
357 | return value; | ||
358 | } | ||
359 | i++; | ||
360 | } | ||
361 | |||
362 | return (unsigned long) -1; | ||
363 | } | ||
364 | |||
365 | int perf_event_paranoid(void) | 337 | int perf_event_paranoid(void) |
366 | { | 338 | { |
367 | int value; | 339 | int value; |
@@ -372,27 +344,6 @@ int perf_event_paranoid(void) | |||
372 | return value; | 344 | return value; |
373 | } | 345 | } |
374 | 346 | ||
375 | void mem_bswap_32(void *src, int byte_size) | ||
376 | { | ||
377 | u32 *m = src; | ||
378 | while (byte_size > 0) { | ||
379 | *m = bswap_32(*m); | ||
380 | byte_size -= sizeof(u32); | ||
381 | ++m; | ||
382 | } | ||
383 | } | ||
384 | |||
385 | void mem_bswap_64(void *src, int byte_size) | ||
386 | { | ||
387 | u64 *m = src; | ||
388 | |||
389 | while (byte_size > 0) { | ||
390 | *m = bswap_64(*m); | ||
391 | byte_size -= sizeof(u64); | ||
392 | ++m; | ||
393 | } | ||
394 | } | ||
395 | |||
396 | bool find_process(const char *name) | 347 | bool find_process(const char *name) |
397 | { | 348 | { |
398 | size_t len = strlen(name); | 349 | size_t len = strlen(name); |
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 3852b6d3270a..5dfb9bb6482d 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -5,7 +5,6 @@ | |||
5 | #define _BSD_SOURCE 1 | 5 | #define _BSD_SOURCE 1 |
6 | /* glibc 2.20 deprecates _BSD_SOURCE in favour of _DEFAULT_SOURCE */ | 6 | /* glibc 2.20 deprecates _BSD_SOURCE in favour of _DEFAULT_SOURCE */ |
7 | #define _DEFAULT_SOURCE 1 | 7 | #define _DEFAULT_SOURCE 1 |
8 | #define HAS_BOOL | ||
9 | 8 | ||
10 | #include <fcntl.h> | 9 | #include <fcntl.h> |
11 | #include <stdbool.h> | 10 | #include <stdbool.h> |
@@ -14,8 +13,6 @@ | |||
14 | #include <stdarg.h> | 13 | #include <stdarg.h> |
15 | #include <linux/types.h> | 14 | #include <linux/types.h> |
16 | 15 | ||
17 | extern char buildid_dir[]; | ||
18 | |||
19 | #ifdef __GNUC__ | 16 | #ifdef __GNUC__ |
20 | #define NORETURN __attribute__((__noreturn__)) | 17 | #define NORETURN __attribute__((__noreturn__)) |
21 | #else | 18 | #else |
@@ -25,8 +22,6 @@ extern char buildid_dir[]; | |||
25 | #endif | 22 | #endif |
26 | #endif | 23 | #endif |
27 | 24 | ||
28 | #define PERF_GTK_DSO "libperf-gtk.so" | ||
29 | |||
30 | /* General helper functions */ | 25 | /* General helper functions */ |
31 | void usage(const char *err) NORETURN; | 26 | void usage(const char *err) NORETURN; |
32 | void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2))); | 27 | void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2))); |
@@ -35,9 +30,6 @@ void warning(const char *err, ...) __attribute__((format (printf, 1, 2))); | |||
35 | 30 | ||
36 | void set_warning_routine(void (*routine)(const char *err, va_list params)); | 31 | void set_warning_routine(void (*routine)(const char *err, va_list params)); |
37 | 32 | ||
38 | int prefixcmp(const char *str, const char *prefix); | ||
39 | void set_buildid_dir(const char *dir); | ||
40 | |||
41 | static inline void *zalloc(size_t size) | 33 | static inline void *zalloc(size_t size) |
42 | { | 34 | { |
43 | return calloc(1, size); | 35 | return calloc(1, size); |
@@ -59,29 +51,11 @@ int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 si | |||
59 | ssize_t readn(int fd, void *buf, size_t n); | 51 | ssize_t readn(int fd, void *buf, size_t n); |
60 | ssize_t writen(int fd, void *buf, size_t n); | 52 | ssize_t writen(int fd, void *buf, size_t n); |
61 | 53 | ||
62 | struct perf_event_attr; | ||
63 | |||
64 | void event_attr_init(struct perf_event_attr *attr); | ||
65 | |||
66 | size_t hex_width(u64 v); | 54 | size_t hex_width(u64 v); |
67 | int hex2u64(const char *ptr, u64 *val); | 55 | int hex2u64(const char *ptr, u64 *val); |
68 | 56 | ||
69 | extern unsigned int page_size; | 57 | extern unsigned int page_size; |
70 | extern int cacheline_size; | 58 | extern int cacheline_size; |
71 | extern int sysctl_perf_event_max_stack; | ||
72 | extern int sysctl_perf_event_max_contexts_per_stack; | ||
73 | |||
74 | struct parse_tag { | ||
75 | char tag; | ||
76 | int mult; | ||
77 | }; | ||
78 | |||
79 | unsigned long parse_tag_value(const char *str, struct parse_tag *tags); | ||
80 | |||
81 | int perf_event_paranoid(void); | ||
82 | |||
83 | void mem_bswap_64(void *src, int byte_size); | ||
84 | void mem_bswap_32(void *src, int byte_size); | ||
85 | 59 | ||
86 | bool find_process(const char *name); | 60 | bool find_process(const char *name); |
87 | 61 | ||