diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2016-09-26 15:47:03 -0400 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2016-09-26 15:47:03 -0400 |
| commit | 1e1b37273cf719545da50b76f214f983a710aaf4 (patch) | |
| tree | 033f6062325ef7aaeefe8559bb409ab7d2be3c76 /tools/perf | |
| parent | c183a603e8d8a5a189729b77d0c623a3d5950e5f (diff) | |
| parent | c291b015158577be533dd5a959dfc09bab119eed (diff) | |
Merge branch 'x86/urgent' into x86/apic
Bring in the upstream modifications so we can fixup the silent merge
conflict which is introduced by this merge.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'tools/perf')
| -rw-r--r-- | tools/perf/arch/powerpc/util/sym-handling.c | 2 | ||||
| -rw-r--r-- | tools/perf/arch/x86/util/intel-pt.c | 6 | ||||
| -rw-r--r-- | tools/perf/builtin-mem.c | 3 | ||||
| -rw-r--r-- | tools/perf/builtin-script.c | 13 | ||||
| -rw-r--r-- | tools/perf/util/evsel.c | 6 | ||||
| -rw-r--r-- | tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 44 | ||||
| -rw-r--r-- | tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c | 24 | ||||
| -rw-r--r-- | tools/perf/util/jitdump.c | 1 | ||||
| -rw-r--r-- | tools/perf/util/probe-file.c | 36 | ||||
| -rw-r--r-- | tools/perf/util/symbol-elf.c | 3 | ||||
| -rw-r--r-- | tools/perf/util/unwind-libdw.c | 2 | ||||
| -rw-r--r-- | tools/perf/util/unwind-libunwind-local.c | 2 |
12 files changed, 97 insertions, 45 deletions
diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c index 8d4dc97d80ba..35745a733100 100644 --- a/tools/perf/arch/powerpc/util/sym-handling.c +++ b/tools/perf/arch/powerpc/util/sym-handling.c | |||
| @@ -97,6 +97,7 @@ void arch__fix_tev_from_maps(struct perf_probe_event *pev, | |||
| 97 | } | 97 | } |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | #ifdef HAVE_LIBELF_SUPPORT | ||
| 100 | void arch__post_process_probe_trace_events(struct perf_probe_event *pev, | 101 | void arch__post_process_probe_trace_events(struct perf_probe_event *pev, |
| 101 | int ntevs) | 102 | int ntevs) |
| 102 | { | 103 | { |
| @@ -118,5 +119,6 @@ void arch__post_process_probe_trace_events(struct perf_probe_event *pev, | |||
| 118 | } | 119 | } |
| 119 | } | 120 | } |
| 120 | } | 121 | } |
| 122 | #endif /* HAVE_LIBELF_SUPPORT */ | ||
| 121 | 123 | ||
| 122 | #endif | 124 | #endif |
diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c index fb51457ba338..a2412e9d883b 100644 --- a/tools/perf/arch/x86/util/intel-pt.c +++ b/tools/perf/arch/x86/util/intel-pt.c | |||
| @@ -501,7 +501,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, | |||
| 501 | struct intel_pt_recording *ptr = | 501 | struct intel_pt_recording *ptr = |
| 502 | container_of(itr, struct intel_pt_recording, itr); | 502 | container_of(itr, struct intel_pt_recording, itr); |
| 503 | struct perf_pmu *intel_pt_pmu = ptr->intel_pt_pmu; | 503 | struct perf_pmu *intel_pt_pmu = ptr->intel_pt_pmu; |
| 504 | bool have_timing_info; | 504 | bool have_timing_info, need_immediate = false; |
| 505 | struct perf_evsel *evsel, *intel_pt_evsel = NULL; | 505 | struct perf_evsel *evsel, *intel_pt_evsel = NULL; |
| 506 | const struct cpu_map *cpus = evlist->cpus; | 506 | const struct cpu_map *cpus = evlist->cpus; |
| 507 | bool privileged = geteuid() == 0 || perf_event_paranoid() < 0; | 507 | bool privileged = geteuid() == 0 || perf_event_paranoid() < 0; |
| @@ -655,6 +655,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, | |||
| 655 | ptr->have_sched_switch = 3; | 655 | ptr->have_sched_switch = 3; |
| 656 | } else { | 656 | } else { |
| 657 | opts->record_switch_events = true; | 657 | opts->record_switch_events = true; |
| 658 | need_immediate = true; | ||
| 658 | if (cpu_wide) | 659 | if (cpu_wide) |
| 659 | ptr->have_sched_switch = 3; | 660 | ptr->have_sched_switch = 3; |
| 660 | else | 661 | else |
| @@ -700,6 +701,9 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, | |||
| 700 | tracking_evsel->attr.freq = 0; | 701 | tracking_evsel->attr.freq = 0; |
| 701 | tracking_evsel->attr.sample_period = 1; | 702 | tracking_evsel->attr.sample_period = 1; |
| 702 | 703 | ||
| 704 | if (need_immediate) | ||
| 705 | tracking_evsel->immediate = true; | ||
| 706 | |||
| 703 | /* In per-cpu case, always need the time of mmap events etc */ | 707 | /* In per-cpu case, always need the time of mmap events etc */ |
| 704 | if (!cpu_map__empty(cpus)) { | 708 | if (!cpu_map__empty(cpus)) { |
| 705 | perf_evsel__set_sample_bit(tracking_evsel, TIME); | 709 | perf_evsel__set_sample_bit(tracking_evsel, TIME); |
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index d608a2c9e48c..d1ce29be560e 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c | |||
| @@ -88,6 +88,9 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem) | |||
| 88 | if (mem->operation & MEM_OPERATION_LOAD) | 88 | if (mem->operation & MEM_OPERATION_LOAD) |
| 89 | perf_mem_events[PERF_MEM_EVENTS__LOAD].record = true; | 89 | perf_mem_events[PERF_MEM_EVENTS__LOAD].record = true; |
| 90 | 90 | ||
| 91 | if (mem->operation & MEM_OPERATION_STORE) | ||
| 92 | perf_mem_events[PERF_MEM_EVENTS__STORE].record = true; | ||
| 93 | |||
| 91 | if (perf_mem_events[PERF_MEM_EVENTS__LOAD].record) | 94 | if (perf_mem_events[PERF_MEM_EVENTS__LOAD].record) |
| 92 | rec_argv[i++] = "-W"; | 95 | rec_argv[i++] = "-W"; |
| 93 | 96 | ||
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 9c640a8081c7..c859e59dfe3e 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
| @@ -371,14 +371,16 @@ static int perf_session__check_output_opt(struct perf_session *session) | |||
| 371 | 371 | ||
| 372 | if (!no_callchain) { | 372 | if (!no_callchain) { |
| 373 | bool use_callchain = false; | 373 | bool use_callchain = false; |
| 374 | bool not_pipe = false; | ||
| 374 | 375 | ||
| 375 | evlist__for_each_entry(session->evlist, evsel) { | 376 | evlist__for_each_entry(session->evlist, evsel) { |
| 377 | not_pipe = true; | ||
| 376 | if (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) { | 378 | if (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) { |
| 377 | use_callchain = true; | 379 | use_callchain = true; |
| 378 | break; | 380 | break; |
| 379 | } | 381 | } |
| 380 | } | 382 | } |
| 381 | if (!use_callchain) | 383 | if (not_pipe && !use_callchain) |
| 382 | symbol_conf.use_callchain = false; | 384 | symbol_conf.use_callchain = false; |
| 383 | } | 385 | } |
| 384 | 386 | ||
| @@ -1690,8 +1692,13 @@ static int list_available_scripts(const struct option *opt __maybe_unused, | |||
| 1690 | snprintf(scripts_path, MAXPATHLEN, "%s/scripts", get_argv_exec_path()); | 1692 | snprintf(scripts_path, MAXPATHLEN, "%s/scripts", get_argv_exec_path()); |
| 1691 | 1693 | ||
| 1692 | scripts_dir = opendir(scripts_path); | 1694 | scripts_dir = opendir(scripts_path); |
| 1693 | if (!scripts_dir) | 1695 | if (!scripts_dir) { |
| 1694 | return -1; | 1696 | fprintf(stdout, |
| 1697 | "open(%s) failed.\n" | ||
| 1698 | "Check \"PERF_EXEC_PATH\" env to set scripts dir.\n", | ||
| 1699 | scripts_path); | ||
| 1700 | exit(-1); | ||
| 1701 | } | ||
| 1695 | 1702 | ||
| 1696 | for_each_lang(scripts_path, scripts_dir, lang_dirent) { | 1703 | for_each_lang(scripts_path, scripts_dir, lang_dirent) { |
| 1697 | snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, | 1704 | snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index d9b80ef881cd..21fd573106ed 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
| @@ -507,17 +507,17 @@ static int __perf_evsel__hw_cache_name(u64 config, char *bf, size_t size) | |||
| 507 | u8 op, result, type = (config >> 0) & 0xff; | 507 | u8 op, result, type = (config >> 0) & 0xff; |
| 508 | const char *err = "unknown-ext-hardware-cache-type"; | 508 | const char *err = "unknown-ext-hardware-cache-type"; |
| 509 | 509 | ||
| 510 | if (type > PERF_COUNT_HW_CACHE_MAX) | 510 | if (type >= PERF_COUNT_HW_CACHE_MAX) |
| 511 | goto out_err; | 511 | goto out_err; |
| 512 | 512 | ||
| 513 | op = (config >> 8) & 0xff; | 513 | op = (config >> 8) & 0xff; |
| 514 | err = "unknown-ext-hardware-cache-op"; | 514 | err = "unknown-ext-hardware-cache-op"; |
| 515 | if (op > PERF_COUNT_HW_CACHE_OP_MAX) | 515 | if (op >= PERF_COUNT_HW_CACHE_OP_MAX) |
| 516 | goto out_err; | 516 | goto out_err; |
| 517 | 517 | ||
| 518 | result = (config >> 16) & 0xff; | 518 | result = (config >> 16) & 0xff; |
| 519 | err = "unknown-ext-hardware-cache-result"; | 519 | err = "unknown-ext-hardware-cache-result"; |
| 520 | if (result > PERF_COUNT_HW_CACHE_RESULT_MAX) | 520 | if (result >= PERF_COUNT_HW_CACHE_RESULT_MAX) |
| 521 | goto out_err; | 521 | goto out_err; |
| 522 | 522 | ||
| 523 | err = "invalid-cache"; | 523 | err = "invalid-cache"; |
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c index 9c8f15da86ce..8ff6c6a61291 100644 --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | |||
| @@ -123,8 +123,6 @@ struct intel_pt_decoder { | |||
| 123 | bool have_calc_cyc_to_tsc; | 123 | bool have_calc_cyc_to_tsc; |
| 124 | int exec_mode; | 124 | int exec_mode; |
| 125 | unsigned int insn_bytes; | 125 | unsigned int insn_bytes; |
| 126 | uint64_t sign_bit; | ||
| 127 | uint64_t sign_bits; | ||
| 128 | uint64_t period; | 126 | uint64_t period; |
| 129 | enum intel_pt_period_type period_type; | 127 | enum intel_pt_period_type period_type; |
| 130 | uint64_t tot_insn_cnt; | 128 | uint64_t tot_insn_cnt; |
| @@ -191,9 +189,6 @@ struct intel_pt_decoder *intel_pt_decoder_new(struct intel_pt_params *params) | |||
| 191 | decoder->data = params->data; | 189 | decoder->data = params->data; |
| 192 | decoder->return_compression = params->return_compression; | 190 | decoder->return_compression = params->return_compression; |
| 193 | 191 | ||
| 194 | decoder->sign_bit = (uint64_t)1 << 47; | ||
| 195 | decoder->sign_bits = ~(((uint64_t)1 << 48) - 1); | ||
| 196 | |||
| 197 | decoder->period = params->period; | 192 | decoder->period = params->period; |
| 198 | decoder->period_type = params->period_type; | 193 | decoder->period_type = params->period_type; |
| 199 | 194 | ||
| @@ -362,21 +357,30 @@ int intel_pt__strerror(int code, char *buf, size_t buflen) | |||
| 362 | return 0; | 357 | return 0; |
| 363 | } | 358 | } |
| 364 | 359 | ||
| 365 | static uint64_t intel_pt_calc_ip(struct intel_pt_decoder *decoder, | 360 | static uint64_t intel_pt_calc_ip(const struct intel_pt_pkt *packet, |
| 366 | const struct intel_pt_pkt *packet, | ||
| 367 | uint64_t last_ip) | 361 | uint64_t last_ip) |
| 368 | { | 362 | { |
| 369 | uint64_t ip; | 363 | uint64_t ip; |
| 370 | 364 | ||
| 371 | switch (packet->count) { | 365 | switch (packet->count) { |
| 372 | case 2: | 366 | case 1: |
| 373 | ip = (last_ip & (uint64_t)0xffffffffffff0000ULL) | | 367 | ip = (last_ip & (uint64_t)0xffffffffffff0000ULL) | |
| 374 | packet->payload; | 368 | packet->payload; |
| 375 | break; | 369 | break; |
| 376 | case 4: | 370 | case 2: |
| 377 | ip = (last_ip & (uint64_t)0xffffffff00000000ULL) | | 371 | ip = (last_ip & (uint64_t)0xffffffff00000000ULL) | |
| 378 | packet->payload; | 372 | packet->payload; |
| 379 | break; | 373 | break; |
| 374 | case 3: | ||
| 375 | ip = packet->payload; | ||
| 376 | /* Sign-extend 6-byte ip */ | ||
| 377 | if (ip & (uint64_t)0x800000000000ULL) | ||
| 378 | ip |= (uint64_t)0xffff000000000000ULL; | ||
| 379 | break; | ||
| 380 | case 4: | ||
| 381 | ip = (last_ip & (uint64_t)0xffff000000000000ULL) | | ||
| 382 | packet->payload; | ||
| 383 | break; | ||
| 380 | case 6: | 384 | case 6: |
| 381 | ip = packet->payload; | 385 | ip = packet->payload; |
| 382 | break; | 386 | break; |
| @@ -384,16 +388,12 @@ static uint64_t intel_pt_calc_ip(struct intel_pt_decoder *decoder, | |||
| 384 | return 0; | 388 | return 0; |
| 385 | } | 389 | } |
| 386 | 390 | ||
| 387 | if (ip & decoder->sign_bit) | ||
| 388 | return ip | decoder->sign_bits; | ||
| 389 | |||
| 390 | return ip; | 391 | return ip; |
| 391 | } | 392 | } |
| 392 | 393 | ||
| 393 | static inline void intel_pt_set_last_ip(struct intel_pt_decoder *decoder) | 394 | static inline void intel_pt_set_last_ip(struct intel_pt_decoder *decoder) |
| 394 | { | 395 | { |
| 395 | decoder->last_ip = intel_pt_calc_ip(decoder, &decoder->packet, | 396 | decoder->last_ip = intel_pt_calc_ip(&decoder->packet, decoder->last_ip); |
| 396 | decoder->last_ip); | ||
| 397 | } | 397 | } |
| 398 | 398 | ||
| 399 | static inline void intel_pt_set_ip(struct intel_pt_decoder *decoder) | 399 | static inline void intel_pt_set_ip(struct intel_pt_decoder *decoder) |
| @@ -1657,6 +1657,12 @@ next: | |||
| 1657 | } | 1657 | } |
| 1658 | } | 1658 | } |
| 1659 | 1659 | ||
| 1660 | static inline bool intel_pt_have_ip(struct intel_pt_decoder *decoder) | ||
| 1661 | { | ||
| 1662 | return decoder->last_ip || decoder->packet.count == 0 || | ||
| 1663 | decoder->packet.count == 3 || decoder->packet.count == 6; | ||
| 1664 | } | ||
| 1665 | |||
| 1660 | /* Walk PSB+ packets to get in sync. */ | 1666 | /* Walk PSB+ packets to get in sync. */ |
| 1661 | static int intel_pt_walk_psb(struct intel_pt_decoder *decoder) | 1667 | static int intel_pt_walk_psb(struct intel_pt_decoder *decoder) |
| 1662 | { | 1668 | { |
| @@ -1677,8 +1683,7 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder) | |||
| 1677 | 1683 | ||
| 1678 | case INTEL_PT_FUP: | 1684 | case INTEL_PT_FUP: |
| 1679 | decoder->pge = true; | 1685 | decoder->pge = true; |
| 1680 | if (decoder->last_ip || decoder->packet.count == 6 || | 1686 | if (intel_pt_have_ip(decoder)) { |
| 1681 | decoder->packet.count == 0) { | ||
| 1682 | uint64_t current_ip = decoder->ip; | 1687 | uint64_t current_ip = decoder->ip; |
| 1683 | 1688 | ||
| 1684 | intel_pt_set_ip(decoder); | 1689 | intel_pt_set_ip(decoder); |
| @@ -1767,8 +1772,7 @@ static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder) | |||
| 1767 | case INTEL_PT_TIP_PGE: | 1772 | case INTEL_PT_TIP_PGE: |
| 1768 | case INTEL_PT_TIP: | 1773 | case INTEL_PT_TIP: |
| 1769 | decoder->pge = decoder->packet.type != INTEL_PT_TIP_PGD; | 1774 | decoder->pge = decoder->packet.type != INTEL_PT_TIP_PGD; |
| 1770 | if (decoder->last_ip || decoder->packet.count == 6 || | 1775 | if (intel_pt_have_ip(decoder)) |
| 1771 | decoder->packet.count == 0) | ||
| 1772 | intel_pt_set_ip(decoder); | 1776 | intel_pt_set_ip(decoder); |
| 1773 | if (decoder->ip) | 1777 | if (decoder->ip) |
| 1774 | return 0; | 1778 | return 0; |
| @@ -1776,9 +1780,7 @@ static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder) | |||
| 1776 | 1780 | ||
| 1777 | case INTEL_PT_FUP: | 1781 | case INTEL_PT_FUP: |
| 1778 | if (decoder->overflow) { | 1782 | if (decoder->overflow) { |
| 1779 | if (decoder->last_ip || | 1783 | if (intel_pt_have_ip(decoder)) |
| 1780 | decoder->packet.count == 6 || | ||
| 1781 | decoder->packet.count == 0) | ||
| 1782 | intel_pt_set_ip(decoder); | 1784 | intel_pt_set_ip(decoder); |
| 1783 | if (decoder->ip) | 1785 | if (decoder->ip) |
| 1784 | return 0; | 1786 | return 0; |
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c index b1257c816310..4f7b32020487 100644 --- a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c +++ b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c | |||
| @@ -292,36 +292,46 @@ static int intel_pt_get_ip(enum intel_pt_pkt_type type, unsigned int byte, | |||
| 292 | const unsigned char *buf, size_t len, | 292 | const unsigned char *buf, size_t len, |
| 293 | struct intel_pt_pkt *packet) | 293 | struct intel_pt_pkt *packet) |
| 294 | { | 294 | { |
| 295 | switch (byte >> 5) { | 295 | int ip_len; |
| 296 | |||
| 297 | packet->count = byte >> 5; | ||
| 298 | |||
| 299 | switch (packet->count) { | ||
| 296 | case 0: | 300 | case 0: |
| 297 | packet->count = 0; | 301 | ip_len = 0; |
| 298 | break; | 302 | break; |
| 299 | case 1: | 303 | case 1: |
| 300 | if (len < 3) | 304 | if (len < 3) |
| 301 | return INTEL_PT_NEED_MORE_BYTES; | 305 | return INTEL_PT_NEED_MORE_BYTES; |
| 302 | packet->count = 2; | 306 | ip_len = 2; |
| 303 | packet->payload = le16_to_cpu(*(uint16_t *)(buf + 1)); | 307 | packet->payload = le16_to_cpu(*(uint16_t *)(buf + 1)); |
| 304 | break; | 308 | break; |
| 305 | case 2: | 309 | case 2: |
| 306 | if (len < 5) | 310 | if (len < 5) |
| 307 | return INTEL_PT_NEED_MORE_BYTES; | 311 | return INTEL_PT_NEED_MORE_BYTES; |
| 308 | packet->count = 4; | 312 | ip_len = 4; |
| 309 | packet->payload = le32_to_cpu(*(uint32_t *)(buf + 1)); | 313 | packet->payload = le32_to_cpu(*(uint32_t *)(buf + 1)); |
| 310 | break; | 314 | break; |
| 311 | case 3: | 315 | case 3: |
| 312 | case 6: | 316 | case 4: |
| 313 | if (len < 7) | 317 | if (len < 7) |
| 314 | return INTEL_PT_NEED_MORE_BYTES; | 318 | return INTEL_PT_NEED_MORE_BYTES; |
| 315 | packet->count = 6; | 319 | ip_len = 6; |
| 316 | memcpy_le64(&packet->payload, buf + 1, 6); | 320 | memcpy_le64(&packet->payload, buf + 1, 6); |
| 317 | break; | 321 | break; |
| 322 | case 6: | ||
| 323 | if (len < 9) | ||
| 324 | return INTEL_PT_NEED_MORE_BYTES; | ||
| 325 | ip_len = 8; | ||
| 326 | packet->payload = le64_to_cpu(*(uint64_t *)(buf + 1)); | ||
| 327 | break; | ||
| 318 | default: | 328 | default: |
| 319 | return INTEL_PT_BAD_PACKET; | 329 | return INTEL_PT_BAD_PACKET; |
| 320 | } | 330 | } |
| 321 | 331 | ||
| 322 | packet->type = type; | 332 | packet->type = type; |
| 323 | 333 | ||
| 324 | return packet->count + 1; | 334 | return ip_len + 1; |
| 325 | } | 335 | } |
| 326 | 336 | ||
| 327 | static int intel_pt_get_mode(const unsigned char *buf, size_t len, | 337 | static int intel_pt_get_mode(const unsigned char *buf, size_t len, |
diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index 9f3305f6b6d5..95f0884aae02 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | #include <sys/sysmacros.h> | ||
| 1 | #include <sys/types.h> | 2 | #include <sys/types.h> |
| 2 | #include <stdio.h> | 3 | #include <stdio.h> |
| 3 | #include <stdlib.h> | 4 | #include <stdlib.h> |
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 9aed9c332da6..9c3b9ed5b3c3 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c | |||
| @@ -133,7 +133,7 @@ int probe_file__open_both(int *kfd, int *ufd, int flag) | |||
| 133 | /* Get raw string list of current kprobe_events or uprobe_events */ | 133 | /* Get raw string list of current kprobe_events or uprobe_events */ |
| 134 | struct strlist *probe_file__get_rawlist(int fd) | 134 | struct strlist *probe_file__get_rawlist(int fd) |
| 135 | { | 135 | { |
| 136 | int ret, idx; | 136 | int ret, idx, fddup; |
| 137 | FILE *fp; | 137 | FILE *fp; |
| 138 | char buf[MAX_CMDLEN]; | 138 | char buf[MAX_CMDLEN]; |
| 139 | char *p; | 139 | char *p; |
| @@ -143,8 +143,17 @@ struct strlist *probe_file__get_rawlist(int fd) | |||
| 143 | return NULL; | 143 | return NULL; |
| 144 | 144 | ||
| 145 | sl = strlist__new(NULL, NULL); | 145 | sl = strlist__new(NULL, NULL); |
| 146 | if (sl == NULL) | ||
| 147 | return NULL; | ||
| 148 | |||
| 149 | fddup = dup(fd); | ||
| 150 | if (fddup < 0) | ||
| 151 | goto out_free_sl; | ||
| 152 | |||
| 153 | fp = fdopen(fddup, "r"); | ||
| 154 | if (!fp) | ||
| 155 | goto out_close_fddup; | ||
| 146 | 156 | ||
| 147 | fp = fdopen(dup(fd), "r"); | ||
| 148 | while (!feof(fp)) { | 157 | while (!feof(fp)) { |
| 149 | p = fgets(buf, MAX_CMDLEN, fp); | 158 | p = fgets(buf, MAX_CMDLEN, fp); |
| 150 | if (!p) | 159 | if (!p) |
| @@ -156,13 +165,21 @@ struct strlist *probe_file__get_rawlist(int fd) | |||
| 156 | ret = strlist__add(sl, buf); | 165 | ret = strlist__add(sl, buf); |
| 157 | if (ret < 0) { | 166 | if (ret < 0) { |
| 158 | pr_debug("strlist__add failed (%d)\n", ret); | 167 | pr_debug("strlist__add failed (%d)\n", ret); |
| 159 | strlist__delete(sl); | 168 | goto out_close_fp; |
| 160 | return NULL; | ||
| 161 | } | 169 | } |
| 162 | } | 170 | } |
| 163 | fclose(fp); | 171 | fclose(fp); |
| 164 | 172 | ||
| 165 | return sl; | 173 | return sl; |
| 174 | |||
| 175 | out_close_fp: | ||
| 176 | fclose(fp); | ||
| 177 | goto out_free_sl; | ||
| 178 | out_close_fddup: | ||
| 179 | close(fddup); | ||
| 180 | out_free_sl: | ||
| 181 | strlist__delete(sl); | ||
| 182 | return NULL; | ||
| 166 | } | 183 | } |
| 167 | 184 | ||
| 168 | static struct strlist *__probe_file__get_namelist(int fd, bool include_group) | 185 | static struct strlist *__probe_file__get_namelist(int fd, bool include_group) |
| @@ -447,12 +464,17 @@ static int probe_cache__load(struct probe_cache *pcache) | |||
| 447 | { | 464 | { |
| 448 | struct probe_cache_entry *entry = NULL; | 465 | struct probe_cache_entry *entry = NULL; |
| 449 | char buf[MAX_CMDLEN], *p; | 466 | char buf[MAX_CMDLEN], *p; |
| 450 | int ret = 0; | 467 | int ret = 0, fddup; |
| 451 | FILE *fp; | 468 | FILE *fp; |
| 452 | 469 | ||
| 453 | fp = fdopen(dup(pcache->fd), "r"); | 470 | fddup = dup(pcache->fd); |
| 454 | if (!fp) | 471 | if (fddup < 0) |
| 472 | return -errno; | ||
| 473 | fp = fdopen(fddup, "r"); | ||
| 474 | if (!fp) { | ||
| 475 | close(fddup); | ||
| 455 | return -EINVAL; | 476 | return -EINVAL; |
| 477 | } | ||
| 456 | 478 | ||
| 457 | while (!feof(fp)) { | 479 | while (!feof(fp)) { |
| 458 | if (!fgets(buf, MAX_CMDLEN, fp)) | 480 | if (!fgets(buf, MAX_CMDLEN, fp)) |
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index a34321e9b44d..a811c13a74d6 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c | |||
| @@ -837,7 +837,8 @@ int dso__load_sym(struct dso *dso, struct map *map, | |||
| 837 | sec = syms_ss->symtab; | 837 | sec = syms_ss->symtab; |
| 838 | shdr = syms_ss->symshdr; | 838 | shdr = syms_ss->symshdr; |
| 839 | 839 | ||
| 840 | if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL)) | 840 | if (elf_section_by_name(runtime_ss->elf, &runtime_ss->ehdr, &tshdr, |
| 841 | ".text", NULL)) | ||
| 841 | dso->text_offset = tshdr.sh_addr - tshdr.sh_offset; | 842 | dso->text_offset = tshdr.sh_addr - tshdr.sh_offset; |
| 842 | 843 | ||
| 843 | if (runtime_ss->opdsec) | 844 | if (runtime_ss->opdsec) |
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c index cf5e250bc78e..783a53fb7a4e 100644 --- a/tools/perf/util/unwind-libdw.c +++ b/tools/perf/util/unwind-libdw.c | |||
| @@ -66,7 +66,7 @@ static int entry(u64 ip, struct unwind_info *ui) | |||
| 66 | if (__report_module(&al, ip, ui)) | 66 | if (__report_module(&al, ip, ui)) |
| 67 | return -1; | 67 | return -1; |
| 68 | 68 | ||
| 69 | e->ip = ip; | 69 | e->ip = al.addr; |
| 70 | e->map = al.map; | 70 | e->map = al.map; |
| 71 | e->sym = al.sym; | 71 | e->sym = al.sym; |
| 72 | 72 | ||
diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c index 97c0f8fc5561..20c2e5743903 100644 --- a/tools/perf/util/unwind-libunwind-local.c +++ b/tools/perf/util/unwind-libunwind-local.c | |||
| @@ -542,7 +542,7 @@ static int entry(u64 ip, struct thread *thread, | |||
| 542 | thread__find_addr_location(thread, PERF_RECORD_MISC_USER, | 542 | thread__find_addr_location(thread, PERF_RECORD_MISC_USER, |
| 543 | MAP__FUNCTION, ip, &al); | 543 | MAP__FUNCTION, ip, &al); |
| 544 | 544 | ||
| 545 | e.ip = ip; | 545 | e.ip = al.addr; |
| 546 | e.map = al.map; | 546 | e.map = al.map; |
| 547 | e.sym = al.sym; | 547 | e.sym = al.sym; |
| 548 | 548 | ||
