diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-05-21 11:49:57 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-05-21 11:49:57 -0400 |
commit | ff5f149b6aec8edbfa3698721667acd043009a33 (patch) | |
tree | d052553eb296dfee3f01b1cb2b717cb7ccf3127a /tools/perf/util/probe-finder.c | |
parent | f0218b3e9974f06014b61be8987159f4a20e011e (diff) | |
parent | 580d607cd666dfabfc1c7b0fb08c8ac690c7c87f (diff) |
Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip into trace/tip/tracing/core-7
Conflicts:
include/linux/ftrace_event.h
include/trace/ftrace.h
kernel/trace/trace_event_perf.c
kernel/trace/trace_kprobe.c
kernel/trace/trace_syscalls.c
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
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); |