diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/Makefile | 30 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-sched.c | 4 | ||||
-rw-r--r-- | tools/perf/builtin-timechart.c | 28 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 4 | ||||
-rwxr-xr-x | tools/perf/util/PERF-VERSION-GEN | 2 | ||||
-rw-r--r-- | tools/perf/util/parse-events.c | 5 | ||||
-rw-r--r-- | tools/perf/util/svghelper.c | 2 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 6 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 10 | ||||
-rw-r--r-- | tools/perf/util/trace-event-parse.c | 8 |
11 files changed, 75 insertions, 26 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 5881943f0c34..7e190d522cd5 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -157,11 +157,18 @@ uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not') | |||
157 | uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not') | 157 | uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not') |
158 | uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not') | 158 | uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not') |
159 | 159 | ||
160 | # If we're on a 64-bit kernel, use -m64 | 160 | # |
161 | ifndef NO_64BIT | 161 | # Add -m32 for cross-builds: |
162 | ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M)) | 162 | # |
163 | M64 := -m64 | 163 | ifdef NO_64BIT |
164 | endif | 164 | MBITS := -m32 |
165 | else | ||
166 | # | ||
167 | # If we're on a 64-bit kernel, use -m64: | ||
168 | # | ||
169 | ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M)) | ||
170 | MBITS := -m64 | ||
171 | endif | ||
165 | endif | 172 | endif |
166 | 173 | ||
167 | # CFLAGS and LDFLAGS are for the users to override from the command line. | 174 | # CFLAGS and LDFLAGS are for the users to override from the command line. |
@@ -170,8 +177,7 @@ endif | |||
170 | # Include saner warnings here, which can catch bugs: | 177 | # Include saner warnings here, which can catch bugs: |
171 | # | 178 | # |
172 | 179 | ||
173 | EXTRA_WARNINGS := -Wcast-align | 180 | EXTRA_WARNINGS := -Wformat |
174 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat | ||
175 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security | 181 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security |
176 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k | 182 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k |
177 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow | 183 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow |
@@ -194,7 +200,7 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition | |||
194 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes | 200 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes |
195 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement | 201 | EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement |
196 | 202 | ||
197 | CFLAGS = $(M64) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) | 203 | CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) |
198 | LDFLAGS = -lpthread -lrt -lelf -lm | 204 | LDFLAGS = -lpthread -lrt -lelf -lm |
199 | ALL_CFLAGS = $(CFLAGS) | 205 | ALL_CFLAGS = $(CFLAGS) |
200 | ALL_LDFLAGS = $(LDFLAGS) | 206 | ALL_LDFLAGS = $(LDFLAGS) |
@@ -415,8 +421,12 @@ ifeq ($(uname_S),Darwin) | |||
415 | PTHREAD_LIBS = | 421 | PTHREAD_LIBS = |
416 | endif | 422 | endif |
417 | 423 | ||
418 | ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y) | 424 | ifeq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y) |
419 | msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel); | 425 | ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y) |
426 | BASIC_CFLAGS += -DLIBELF_NO_MMAP | ||
427 | endif | ||
428 | else | ||
429 | msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]); | ||
420 | endif | 430 | endif |
421 | 431 | ||
422 | ifdef NO_DEMANGLE | 432 | ifdef NO_DEMANGLE |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 3eeef339c787..a4be453fc8a9 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -426,7 +426,7 @@ try_again: | |||
426 | if (fd[nr_cpu][counter] < 0) { | 426 | if (fd[nr_cpu][counter] < 0) { |
427 | int err = errno; | 427 | int err = errno; |
428 | 428 | ||
429 | if (err == EPERM) | 429 | if (err == EPERM || err == EACCES) |
430 | die("Permission error - are you root?\n"); | 430 | die("Permission error - are you root?\n"); |
431 | else if (err == ENODEV && profile_cpu != -1) | 431 | else if (err == ENODEV && profile_cpu != -1) |
432 | die("No such device - did you specify an out-of-range profile CPU?\n"); | 432 | die("No such device - did you specify an out-of-range profile CPU?\n"); |
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index ea9c15c0cdfe..ce2d5be4f30e 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -1287,7 +1287,7 @@ static struct sort_dimension *available_sorts[] = { | |||
1287 | 1287 | ||
1288 | static LIST_HEAD(sort_list); | 1288 | static LIST_HEAD(sort_list); |
1289 | 1289 | ||
1290 | static int sort_dimension__add(char *tok, struct list_head *list) | 1290 | static int sort_dimension__add(const char *tok, struct list_head *list) |
1291 | { | 1291 | { |
1292 | int i; | 1292 | int i; |
1293 | 1293 | ||
@@ -1917,7 +1917,7 @@ static void setup_sorting(void) | |||
1917 | 1917 | ||
1918 | free(str); | 1918 | free(str); |
1919 | 1919 | ||
1920 | sort_dimension__add((char *)"pid", &cmp_pid); | 1920 | sort_dimension__add("pid", &cmp_pid); |
1921 | } | 1921 | } |
1922 | 1922 | ||
1923 | static const char *record_args[] = { | 1923 | static const char *record_args[] = { |
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 702d8fe58fbc..e8a510d935e5 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c | |||
@@ -765,19 +765,40 @@ static void draw_wakeups(void) | |||
765 | if (c->Y && c->start_time <= we->time && c->end_time >= we->time) { | 765 | if (c->Y && c->start_time <= we->time && c->end_time >= we->time) { |
766 | if (p->pid == we->waker) { | 766 | if (p->pid == we->waker) { |
767 | from = c->Y; | 767 | from = c->Y; |
768 | task_from = c->comm; | 768 | task_from = strdup(c->comm); |
769 | } | 769 | } |
770 | if (p->pid == we->wakee) { | 770 | if (p->pid == we->wakee) { |
771 | to = c->Y; | 771 | to = c->Y; |
772 | task_to = c->comm; | 772 | task_to = strdup(c->comm); |
773 | } | 773 | } |
774 | } | 774 | } |
775 | c = c->next; | 775 | c = c->next; |
776 | } | 776 | } |
777 | c = p->all; | ||
778 | while (c) { | ||
779 | if (p->pid == we->waker && !from) { | ||
780 | from = c->Y; | ||
781 | task_from = strdup(c->comm); | ||
782 | } | ||
783 | if (p->pid == we->wakee && !to) { | ||
784 | to = c->Y; | ||
785 | task_to = strdup(c->comm); | ||
786 | } | ||
787 | c = c->next; | ||
788 | } | ||
777 | } | 789 | } |
778 | p = p->next; | 790 | p = p->next; |
779 | } | 791 | } |
780 | 792 | ||
793 | if (!task_from) { | ||
794 | task_from = malloc(40); | ||
795 | sprintf(task_from, "[%i]", we->waker); | ||
796 | } | ||
797 | if (!task_to) { | ||
798 | task_to = malloc(40); | ||
799 | sprintf(task_to, "[%i]", we->wakee); | ||
800 | } | ||
801 | |||
781 | if (we->waker == -1) | 802 | if (we->waker == -1) |
782 | svg_interrupt(we->time, to); | 803 | svg_interrupt(we->time, to); |
783 | else if (from && to && abs(from - to) == 1) | 804 | else if (from && to && abs(from - to) == 1) |
@@ -785,6 +806,9 @@ static void draw_wakeups(void) | |||
785 | else | 806 | else |
786 | svg_partial_wakeline(we->time, from, task_from, to, task_to); | 807 | svg_partial_wakeline(we->time, from, task_from, to, task_to); |
787 | we = we->next; | 808 | we = we->next; |
809 | |||
810 | free(task_from); | ||
811 | free(task_to); | ||
788 | } | 812 | } |
789 | } | 813 | } |
790 | 814 | ||
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 37512e936235..e23bc74e734f 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -686,6 +686,8 @@ static void handle_keypress(int c) | |||
686 | switch (c) { | 686 | switch (c) { |
687 | case 'd': | 687 | case 'd': |
688 | prompt_integer(&delay_secs, "Enter display delay"); | 688 | prompt_integer(&delay_secs, "Enter display delay"); |
689 | if (delay_secs < 1) | ||
690 | delay_secs = 1; | ||
689 | break; | 691 | break; |
690 | case 'e': | 692 | case 'e': |
691 | prompt_integer(&print_entries, "Enter display entries (lines)"); | 693 | prompt_integer(&print_entries, "Enter display entries (lines)"); |
@@ -1025,7 +1027,7 @@ try_again: | |||
1025 | if (fd[i][counter] < 0) { | 1027 | if (fd[i][counter] < 0) { |
1026 | int err = errno; | 1028 | int err = errno; |
1027 | 1029 | ||
1028 | if (err == EPERM) | 1030 | if (err == EPERM || err == EACCES) |
1029 | die("No permission - are you root?\n"); | 1031 | die("No permission - are you root?\n"); |
1030 | /* | 1032 | /* |
1031 | * If it's cycles then fall back to hrtimer | 1033 | * If it's cycles then fall back to hrtimer |
diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN index c561d1538c03..54552a00a117 100755 --- a/tools/perf/util/PERF-VERSION-GEN +++ b/tools/perf/util/PERF-VERSION-GEN | |||
@@ -1,7 +1,7 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | GVF=PERF-VERSION-FILE | 3 | GVF=PERF-VERSION-FILE |
4 | DEF_VER=v0.0.1.PERF | 4 | DEF_VER=v0.0.2.PERF |
5 | 5 | ||
6 | LF=' | 6 | LF=' |
7 | ' | 7 | ' |
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 87c424de79ee..8cfb48cbbea0 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -691,7 +691,10 @@ static void store_event_type(const char *orgname) | |||
691 | FILE *file; | 691 | FILE *file; |
692 | int id; | 692 | int id; |
693 | 693 | ||
694 | sprintf(filename, "/sys/kernel/debug/tracing/events/%s/id", orgname); | 694 | sprintf(filename, "%s/", debugfs_path); |
695 | strncat(filename, orgname, strlen(orgname)); | ||
696 | strcat(filename, "/id"); | ||
697 | |||
695 | c = strchr(filename, ':'); | 698 | c = strchr(filename, ':'); |
696 | if (c) | 699 | if (c) |
697 | *c = '/'; | 700 | *c = '/'; |
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c index 856655d8b0b8..b3637db025a2 100644 --- a/tools/perf/util/svghelper.c +++ b/tools/perf/util/svghelper.c | |||
@@ -103,7 +103,7 @@ void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end) | |||
103 | fprintf(svgfile, " rect.process2 { fill:rgb(180,180,180); fill-opacity:0.9; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); | 103 | fprintf(svgfile, " rect.process2 { fill:rgb(180,180,180); fill-opacity:0.9; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); |
104 | fprintf(svgfile, " rect.sample { fill:rgb( 0, 0,255); fill-opacity:0.8; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); | 104 | fprintf(svgfile, " rect.sample { fill:rgb( 0, 0,255); fill-opacity:0.8; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); |
105 | fprintf(svgfile, " rect.blocked { fill:rgb(255, 0, 0); fill-opacity:0.5; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); | 105 | fprintf(svgfile, " rect.blocked { fill:rgb(255, 0, 0); fill-opacity:0.5; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); |
106 | fprintf(svgfile, " rect.waiting { fill:rgb(214,214, 0); fill-opacity:0.3; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); | 106 | fprintf(svgfile, " rect.waiting { fill:rgb(224,214, 0); fill-opacity:0.8; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); |
107 | fprintf(svgfile, " rect.WAITING { fill:rgb(255,214, 48); fill-opacity:0.6; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); | 107 | fprintf(svgfile, " rect.WAITING { fill:rgb(255,214, 48); fill-opacity:0.6; stroke-width:0; stroke:rgb( 0, 0, 0); } \n"); |
108 | fprintf(svgfile, " rect.cpu { fill:rgb(192,192,192); fill-opacity:0.2; stroke-width:0.5; stroke:rgb(128,128,128); } \n"); | 108 | fprintf(svgfile, " rect.cpu { fill:rgb(192,192,192); fill-opacity:0.2; stroke-width:0.5; stroke:rgb(128,128,128); } \n"); |
109 | fprintf(svgfile, " rect.pstate { fill:rgb(128,128,128); fill-opacity:0.8; stroke-width:0; } \n"); | 109 | fprintf(svgfile, " rect.pstate { fill:rgb(128,128,128); fill-opacity:0.8; stroke-width:0; } \n"); |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 47ea0609a760..226f44a2357d 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -413,7 +413,7 @@ static int dso__synthesize_plt_symbols(struct dso *self, int v) | |||
413 | if (fd < 0) | 413 | if (fd < 0) |
414 | goto out; | 414 | goto out; |
415 | 415 | ||
416 | elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); | 416 | elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL); |
417 | if (elf == NULL) | 417 | if (elf == NULL) |
418 | goto out_close; | 418 | goto out_close; |
419 | 419 | ||
@@ -533,7 +533,7 @@ static int dso__load_sym(struct dso *self, int fd, const char *name, | |||
533 | Elf *elf; | 533 | Elf *elf; |
534 | int nr = 0, kernel = !strcmp("[kernel]", self->name); | 534 | int nr = 0, kernel = !strcmp("[kernel]", self->name); |
535 | 535 | ||
536 | elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); | 536 | elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL); |
537 | if (elf == NULL) { | 537 | if (elf == NULL) { |
538 | if (v) | 538 | if (v) |
539 | fprintf(stderr, "%s: cannot read %s ELF file.\n", | 539 | fprintf(stderr, "%s: cannot read %s ELF file.\n", |
@@ -675,7 +675,7 @@ static char *dso__read_build_id(struct dso *self, int v) | |||
675 | if (fd < 0) | 675 | if (fd < 0) |
676 | goto out; | 676 | goto out; |
677 | 677 | ||
678 | elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); | 678 | elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL); |
679 | if (elf == NULL) { | 679 | if (elf == NULL) { |
680 | if (v) | 680 | if (v) |
681 | fprintf(stderr, "%s: cannot read %s ELF file.\n", | 681 | fprintf(stderr, "%s: cannot read %s ELF file.\n", |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 6e8490716408..829da9edba64 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -27,6 +27,16 @@ static inline char *bfd_demangle(void __used *v, const char __used *c, | |||
27 | #endif | 27 | #endif |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | /* | ||
31 | * libelf 0.8.x and earlier do not support ELF_C_READ_MMAP; | ||
32 | * for newer versions we can use mmap to reduce memory usage: | ||
33 | */ | ||
34 | #ifdef LIBELF_NO_MMAP | ||
35 | # define PERF_ELF_C_READ_MMAP ELF_C_READ | ||
36 | #else | ||
37 | # define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP | ||
38 | #endif | ||
39 | |||
30 | #ifndef DMGL_PARAMS | 40 | #ifndef DMGL_PARAMS |
31 | #define DMGL_PARAMS (1 << 0) /* Include function args */ | 41 | #define DMGL_PARAMS (1 << 0) /* Include function args */ |
32 | #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ | 42 | #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ |
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index 55b41b9e3834..55c9659a56e2 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c | |||
@@ -618,7 +618,7 @@ static int test_type(enum event_type type, enum event_type expect) | |||
618 | } | 618 | } |
619 | 619 | ||
620 | static int test_type_token(enum event_type type, char *token, | 620 | static int test_type_token(enum event_type type, char *token, |
621 | enum event_type expect, char *expect_tok) | 621 | enum event_type expect, const char *expect_tok) |
622 | { | 622 | { |
623 | if (type != expect) { | 623 | if (type != expect) { |
624 | die("Error: expected type %d but read %d", | 624 | die("Error: expected type %d but read %d", |
@@ -650,7 +650,7 @@ static int read_expect_type(enum event_type expect, char **tok) | |||
650 | return __read_expect_type(expect, tok, 1); | 650 | return __read_expect_type(expect, tok, 1); |
651 | } | 651 | } |
652 | 652 | ||
653 | static int __read_expected(enum event_type expect, char *str, int newline_ok) | 653 | static int __read_expected(enum event_type expect, const char *str, int newline_ok) |
654 | { | 654 | { |
655 | enum event_type type; | 655 | enum event_type type; |
656 | char *token; | 656 | char *token; |
@@ -668,12 +668,12 @@ static int __read_expected(enum event_type expect, char *str, int newline_ok) | |||
668 | return 0; | 668 | return 0; |
669 | } | 669 | } |
670 | 670 | ||
671 | static int read_expected(enum event_type expect, char *str) | 671 | static int read_expected(enum event_type expect, const char *str) |
672 | { | 672 | { |
673 | return __read_expected(expect, str, 1); | 673 | return __read_expected(expect, str, 1); |
674 | } | 674 | } |
675 | 675 | ||
676 | static int read_expected_item(enum event_type expect, char *str) | 676 | static int read_expected_item(enum event_type expect, const char *str) |
677 | { | 677 | { |
678 | return __read_expected(expect, str, 0); | 678 | return __read_expected(expect, str, 0); |
679 | } | 679 | } |