diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-27 18:23:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-27 18:23:47 -0400 |
commit | c5617b200ac52e35f7e8cf05a17b0a2d50f6b3e9 (patch) | |
tree | 40d5e99660c77c5791392d349a93113c044dbf14 /tools/perf/util/probe-finder.c | |
parent | cad719d86e9dbd06634eaba6401e022c8101d6b2 (diff) | |
parent | 49c177461bfbedeccbab22bf3905db2f9da7f1c3 (diff) |
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (61 commits)
tracing: Add __used annotation to event variable
perf, trace: Fix !x86 build bug
perf report: Support multiple events on the TUI
perf annotate: Fix up usage of the build id cache
x86/mmiotrace: Remove redundant instruction prefix checks
perf annotate: Add TUI interface
perf tui: Remove annotate from popup menu after failure
perf report: Don't start the TUI if -D is used
perf: Fix getline undeclared
perf: Optimize perf_tp_event_match()
perf: Remove more code from the fastpath
perf: Optimize the !vmalloc backed buffer
perf: Optimize perf_output_copy()
perf: Fix wakeup storm for RO mmap()s
perf-record: Share per-cpu buffers
perf-record: Remove -M
perf: Ensure that IOC_OUTPUT isn't used to create multi-writer buffers
perf, trace: Optimize tracepoints by using per-tracepoint-per-cpu hlist to track events
perf, trace: Optimize tracepoints by removing IRQ-disable from perf/tracepoint interaction
perf tui: Allow disabling the TUI on a per command basis in ~/.perfconfig
...
Diffstat (limited to 'tools/perf/util/probe-finder.c')
-rw-r--r-- | tools/perf/util/probe-finder.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 562b1443e785..d964cb199c67 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -668,6 +668,7 @@ static int convert_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf) | |||
668 | ret = dwarf_getlocation_addr(&fb_attr, pf->addr, &pf->fb_ops, &nops, 1); | 668 | ret = dwarf_getlocation_addr(&fb_attr, pf->addr, &pf->fb_ops, &nops, 1); |
669 | if (ret <= 0 || nops == 0) { | 669 | if (ret <= 0 || nops == 0) { |
670 | pf->fb_ops = NULL; | 670 | pf->fb_ops = NULL; |
671 | #if _ELFUTILS_PREREQ(0, 142) | ||
671 | } else if (nops == 1 && pf->fb_ops[0].atom == DW_OP_call_frame_cfa && | 672 | } else if (nops == 1 && pf->fb_ops[0].atom == DW_OP_call_frame_cfa && |
672 | pf->cfi != NULL) { | 673 | pf->cfi != NULL) { |
673 | Dwarf_Frame *frame; | 674 | Dwarf_Frame *frame; |
@@ -677,6 +678,7 @@ static int convert_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf) | |||
677 | (uintmax_t)pf->addr); | 678 | (uintmax_t)pf->addr); |
678 | return -ENOENT; | 679 | return -ENOENT; |
679 | } | 680 | } |
681 | #endif | ||
680 | } | 682 | } |
681 | 683 | ||
682 | /* Find each argument */ | 684 | /* Find each argument */ |
@@ -741,32 +743,36 @@ static int find_lazy_match_lines(struct list_head *head, | |||
741 | const char *fname, const char *pat) | 743 | const char *fname, const char *pat) |
742 | { | 744 | { |
743 | char *fbuf, *p1, *p2; | 745 | char *fbuf, *p1, *p2; |
744 | int fd, ret, line, nlines = 0; | 746 | int fd, line, nlines = -1; |
745 | struct stat st; | 747 | struct stat st; |
746 | 748 | ||
747 | fd = open(fname, O_RDONLY); | 749 | fd = open(fname, O_RDONLY); |
748 | if (fd < 0) { | 750 | if (fd < 0) { |
749 | pr_warning("Failed to open %s: %s\n", fname, strerror(-fd)); | 751 | pr_warning("Failed to open %s: %s\n", fname, strerror(-fd)); |
750 | return fd; | 752 | return -errno; |
751 | } | 753 | } |
752 | 754 | ||
753 | ret = fstat(fd, &st); | 755 | if (fstat(fd, &st) < 0) { |
754 | if (ret < 0) { | ||
755 | pr_warning("Failed to get the size of %s: %s\n", | 756 | pr_warning("Failed to get the size of %s: %s\n", |
756 | fname, strerror(errno)); | 757 | fname, strerror(errno)); |
757 | return ret; | 758 | nlines = -errno; |
759 | goto out_close; | ||
758 | } | 760 | } |
759 | fbuf = xmalloc(st.st_size + 2); | 761 | |
760 | ret = read(fd, fbuf, st.st_size); | 762 | nlines = -ENOMEM; |
761 | if (ret < 0) { | 763 | fbuf = malloc(st.st_size + 2); |
764 | if (fbuf == NULL) | ||
765 | goto out_close; | ||
766 | if (read(fd, fbuf, st.st_size) < 0) { | ||
762 | pr_warning("Failed to read %s: %s\n", fname, strerror(errno)); | 767 | pr_warning("Failed to read %s: %s\n", fname, strerror(errno)); |
763 | return ret; | 768 | nlines = -errno; |
769 | goto out_free_fbuf; | ||
764 | } | 770 | } |
765 | close(fd); | ||
766 | fbuf[st.st_size] = '\n'; /* Dummy line */ | 771 | fbuf[st.st_size] = '\n'; /* Dummy line */ |
767 | fbuf[st.st_size + 1] = '\0'; | 772 | fbuf[st.st_size + 1] = '\0'; |
768 | p1 = fbuf; | 773 | p1 = fbuf; |
769 | line = 1; | 774 | line = 1; |
775 | nlines = 0; | ||
770 | while ((p2 = strchr(p1, '\n')) != NULL) { | 776 | while ((p2 = strchr(p1, '\n')) != NULL) { |
771 | *p2 = '\0'; | 777 | *p2 = '\0'; |
772 | if (strlazymatch(p1, pat)) { | 778 | if (strlazymatch(p1, pat)) { |
@@ -776,7 +782,10 @@ static int find_lazy_match_lines(struct list_head *head, | |||
776 | line++; | 782 | line++; |
777 | p1 = p2 + 1; | 783 | p1 = p2 + 1; |
778 | } | 784 | } |
785 | out_free_fbuf: | ||
779 | free(fbuf); | 786 | free(fbuf); |
787 | out_close: | ||
788 | close(fd); | ||
780 | return nlines; | 789 | return nlines; |
781 | } | 790 | } |
782 | 791 | ||
@@ -953,11 +962,15 @@ int find_kprobe_trace_events(int fd, struct perf_probe_event *pev, | |||
953 | if (!dbg) { | 962 | if (!dbg) { |
954 | pr_warning("No dwarf info found in the vmlinux - " | 963 | pr_warning("No dwarf info found in the vmlinux - " |
955 | "please rebuild with CONFIG_DEBUG_INFO=y.\n"); | 964 | "please rebuild with CONFIG_DEBUG_INFO=y.\n"); |
965 | free(pf.tevs); | ||
966 | *tevs = NULL; | ||
956 | return -EBADF; | 967 | return -EBADF; |
957 | } | 968 | } |
958 | 969 | ||
970 | #if _ELFUTILS_PREREQ(0, 142) | ||
959 | /* Get the call frame information from this dwarf */ | 971 | /* Get the call frame information from this dwarf */ |
960 | pf.cfi = dwarf_getcfi(dbg); | 972 | pf.cfi = dwarf_getcfi(dbg); |
973 | #endif | ||
961 | 974 | ||
962 | off = 0; | 975 | off = 0; |
963 | line_list__init(&pf.lcache); | 976 | line_list__init(&pf.lcache); |