diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/perf/Makefile | 52 | ||||
| -rw-r--r-- | tools/perf/builtin-buildid-list.c | 2 | ||||
| -rw-r--r-- | tools/perf/builtin-diff.c | 3 | ||||
| -rw-r--r-- | tools/perf/builtin-kmem.c | 4 | ||||
| -rw-r--r-- | tools/perf/builtin-record.c | 14 | ||||
| -rw-r--r-- | tools/perf/builtin-report.c | 3 | ||||
| -rw-r--r-- | tools/perf/builtin-trace.c | 4 | ||||
| -rw-r--r-- | tools/perf/design.txt | 8 |
8 files changed, 56 insertions, 34 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 4390d225686d..2e7fa3a06806 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
| @@ -250,7 +250,19 @@ PTHREAD_LIBS = -lpthread | |||
| 250 | # explicitly what architecture to check for. Fix this up for yours.. | 250 | # explicitly what architecture to check for. Fix this up for yours.. |
| 251 | SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ | 251 | SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ |
| 252 | 252 | ||
| 253 | ifeq ($(shell sh -c "echo 'int foo(void) {char X[2]; return 3;}' | $(CC) -x c -c -Werror -fstack-protector-all - -o /dev/null "$(QUIET_STDERR)" && echo y"), y) | 253 | ifeq ($(V), 2) |
| 254 | QUIET_STDERR = ">/dev/null" | ||
| 255 | else | ||
| 256 | QUIET_STDERR = ">/dev/null 2>&1" | ||
| 257 | endif | ||
| 258 | |||
| 259 | BITBUCKET = "/dev/null" | ||
| 260 | |||
| 261 | ifneq ($(shell sh -c "(echo '\#include <stdio.h>'; echo 'int main(void) { return puts(\"hi\"); }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) "$(QUIET_STDERR)" && echo y"), y) | ||
| 262 | BITBUCKET = .perf.dev.null | ||
| 263 | endif | ||
| 264 | |||
| 265 | ifeq ($(shell sh -c "echo 'int foo(void) {char X[2]; return 3;}' | $(CC) -x c -c -Werror -fstack-protector-all - -o $(BITBUCKET) "$(QUIET_STDERR)" && echo y"), y) | ||
| 254 | CFLAGS := $(CFLAGS) -fstack-protector-all | 266 | CFLAGS := $(CFLAGS) -fstack-protector-all |
| 255 | endif | 267 | endif |
| 256 | 268 | ||
| @@ -343,13 +355,18 @@ LIB_H += util/include/linux/string.h | |||
| 343 | LIB_H += util/include/linux/types.h | 355 | LIB_H += util/include/linux/types.h |
| 344 | LIB_H += util/include/asm/asm-offsets.h | 356 | LIB_H += util/include/asm/asm-offsets.h |
| 345 | LIB_H += util/include/asm/bitops.h | 357 | LIB_H += util/include/asm/bitops.h |
| 358 | LIB_H += util/include/asm/bug.h | ||
| 346 | LIB_H += util/include/asm/byteorder.h | 359 | LIB_H += util/include/asm/byteorder.h |
| 347 | LIB_H += util/include/asm/swab.h | 360 | LIB_H += util/include/asm/swab.h |
| 348 | LIB_H += util/include/asm/system.h | 361 | LIB_H += util/include/asm/system.h |
| 349 | LIB_H += util/include/asm/uaccess.h | 362 | LIB_H += util/include/asm/uaccess.h |
| 350 | LIB_H += perf.h | 363 | LIB_H += perf.h |
| 364 | LIB_H += util/cache.h | ||
| 365 | LIB_H += util/callchain.h | ||
| 366 | LIB_H += util/debug.h | ||
| 351 | LIB_H += util/debugfs.h | 367 | LIB_H += util/debugfs.h |
| 352 | LIB_H += util/event.h | 368 | LIB_H += util/event.h |
| 369 | LIB_H += util/exec_cmd.h | ||
| 353 | LIB_H += util/types.h | 370 | LIB_H += util/types.h |
| 354 | LIB_H += util/levenshtein.h | 371 | LIB_H += util/levenshtein.h |
| 355 | LIB_H += util/parse-options.h | 372 | LIB_H += util/parse-options.h |
| @@ -362,6 +379,7 @@ LIB_H += util/session.h | |||
| 362 | LIB_H += util/strbuf.h | 379 | LIB_H += util/strbuf.h |
| 363 | LIB_H += util/string.h | 380 | LIB_H += util/string.h |
| 364 | LIB_H += util/strlist.h | 381 | LIB_H += util/strlist.h |
| 382 | LIB_H += util/svghelper.h | ||
| 365 | LIB_H += util/run-command.h | 383 | LIB_H += util/run-command.h |
| 366 | LIB_H += util/sigchain.h | 384 | LIB_H += util/sigchain.h |
| 367 | LIB_H += util/symbol.h | 385 | LIB_H += util/symbol.h |
| @@ -370,6 +388,8 @@ LIB_H += util/values.h | |||
| 370 | LIB_H += util/sort.h | 388 | LIB_H += util/sort.h |
| 371 | LIB_H += util/hist.h | 389 | LIB_H += util/hist.h |
| 372 | LIB_H += util/thread.h | 390 | LIB_H += util/thread.h |
| 391 | LIB_H += util/trace-event.h | ||
| 392 | LIB_H += util/trace-event-perl.h | ||
| 373 | LIB_H += util/probe-finder.h | 393 | LIB_H += util/probe-finder.h |
| 374 | LIB_H += util/probe-event.h | 394 | LIB_H += util/probe-event.h |
| 375 | 395 | ||
| @@ -443,11 +463,6 @@ BUILTIN_OBJS += builtin-kmem.o | |||
| 443 | 463 | ||
| 444 | PERFLIBS = $(LIB_FILE) | 464 | PERFLIBS = $(LIB_FILE) |
| 445 | 465 | ||
| 446 | ifeq ($(V), 2) | ||
| 447 | QUIET_STDERR = ">/dev/null" | ||
| 448 | else | ||
| 449 | QUIET_STDERR = ">/dev/null 2>&1" | ||
| 450 | endif | ||
| 451 | # | 466 | # |
| 452 | # Platform specific tweaks | 467 | # Platform specific tweaks |
| 453 | # | 468 | # |
| @@ -475,19 +490,19 @@ ifeq ($(uname_S),Darwin) | |||
| 475 | PTHREAD_LIBS = | 490 | PTHREAD_LIBS = |
| 476 | endif | 491 | endif |
| 477 | 492 | ||
| 478 | 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) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) | 493 | 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 $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) |
| 479 | ifneq ($(shell sh -c "(echo '\#include <gnu/libc-version.h>'; echo 'int main(void) { const char * version = gnu_get_libc_version(); return (long)version; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) | 494 | ifneq ($(shell sh -c "(echo '\#include <gnu/libc-version.h>'; echo 'int main(void) { const char * version = gnu_get_libc_version(); return (long)version; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) |
| 480 | msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); | 495 | msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); |
| 481 | endif | 496 | endif |
| 482 | 497 | ||
| 483 | 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) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) | 498 | 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 $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) |
| 484 | BASIC_CFLAGS += -DLIBELF_NO_MMAP | 499 | BASIC_CFLAGS += -DLIBELF_NO_MMAP |
| 485 | endif | 500 | endif |
| 486 | else | 501 | else |
| 487 | msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]); | 502 | msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]); |
| 488 | endif | 503 | endif |
| 489 | 504 | ||
| 490 | ifneq ($(shell sh -c "(echo '\#ifndef _MIPS_SZLONG'; echo '\#define _MIPS_SZLONG 0'; echo '\#endif'; echo '\#include <dwarf.h>'; echo '\#include <libdwarf.h>'; echo 'int main(void) { Dwarf_Debug dbg; Dwarf_Error err; Dwarf_Ranges *rng; dwarf_init(0, DW_DLC_READ, 0, 0, &dbg, &err); dwarf_get_ranges(dbg, 0, &rng, 0, 0, &err); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/libdwarf -ldwarf -lelf -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) | 505 | ifneq ($(shell sh -c "(echo '\#ifndef _MIPS_SZLONG'; echo '\#define _MIPS_SZLONG 0'; echo '\#endif'; echo '\#include <dwarf.h>'; echo '\#include <libdwarf.h>'; echo 'int main(void) { Dwarf_Debug dbg; Dwarf_Error err; Dwarf_Ranges *rng; dwarf_init(0, DW_DLC_READ, 0, 0, &dbg, &err); dwarf_get_ranges(dbg, 0, &rng, 0, 0, &err); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/libdwarf -ldwarf -lelf -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y) |
| 491 | msg := $(warning No libdwarf.h found or old libdwarf.h found, disables dwarf support. Please install libdwarf-dev/libdwarf-devel >= 20081231); | 506 | msg := $(warning No libdwarf.h found or old libdwarf.h found, disables dwarf support. Please install libdwarf-dev/libdwarf-devel >= 20081231); |
| 492 | BASIC_CFLAGS += -DNO_LIBDWARF | 507 | BASIC_CFLAGS += -DNO_LIBDWARF |
| 493 | else | 508 | else |
| @@ -501,7 +516,7 @@ PERL_EMBED_LDOPTS = `perl -MExtUtils::Embed -e ldopts 2>/dev/null` | |||
| 501 | PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` | 516 | PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` |
| 502 | endif | 517 | endif |
| 503 | 518 | ||
| 504 | ifneq ($(shell sh -c "(echo '\#include <EXTERN.h>'; echo '\#include <perl.h>'; echo 'int main(void) { perl_alloc(); return 0; }') | $(CC) -x c - $(PERL_EMBED_CCOPTS) -o /dev/null $(PERL_EMBED_LDOPTS) > /dev/null 2>&1 && echo y"), y) | 519 | ifneq ($(shell sh -c "(echo '\#include <EXTERN.h>'; echo '\#include <perl.h>'; echo 'int main(void) { perl_alloc(); return 0; }') | $(CC) -x c - $(PERL_EMBED_CCOPTS) -o $(BITBUCKET) $(PERL_EMBED_LDOPTS) > /dev/null 2>&1 && echo y"), y) |
| 505 | BASIC_CFLAGS += -DNO_LIBPERL | 520 | BASIC_CFLAGS += -DNO_LIBPERL |
| 506 | else | 521 | else |
| 507 | ALL_LDFLAGS += $(PERL_EMBED_LDOPTS) | 522 | ALL_LDFLAGS += $(PERL_EMBED_LDOPTS) |
| @@ -511,20 +526,20 @@ endif | |||
| 511 | ifdef NO_DEMANGLE | 526 | ifdef NO_DEMANGLE |
| 512 | BASIC_CFLAGS += -DNO_DEMANGLE | 527 | BASIC_CFLAGS += -DNO_DEMANGLE |
| 513 | else | 528 | else |
| 514 | has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) -lbfd "$(QUIET_STDERR)" && echo y") | 529 | has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd "$(QUIET_STDERR)" && echo y") |
| 515 | 530 | ||
| 516 | ifeq ($(has_bfd),y) | 531 | ifeq ($(has_bfd),y) |
| 517 | EXTLIBS += -lbfd | 532 | EXTLIBS += -lbfd |
| 518 | else | 533 | else |
| 519 | has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty "$(QUIET_STDERR)" && echo y") | 534 | has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty "$(QUIET_STDERR)" && echo y") |
| 520 | ifeq ($(has_bfd_iberty),y) | 535 | ifeq ($(has_bfd_iberty),y) |
| 521 | EXTLIBS += -lbfd -liberty | 536 | EXTLIBS += -lbfd -liberty |
| 522 | else | 537 | else |
| 523 | has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty -lz "$(QUIET_STDERR)" && echo y") | 538 | has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty -lz "$(QUIET_STDERR)" && echo y") |
| 524 | ifeq ($(has_bfd_iberty_z),y) | 539 | ifeq ($(has_bfd_iberty_z),y) |
| 525 | EXTLIBS += -lbfd -liberty -lz | 540 | EXTLIBS += -lbfd -liberty -lz |
| 526 | else | 541 | else |
| 527 | has_cplus_demangle := $(shell sh -c "(echo 'extern char *cplus_demangle(const char *, int);'; echo 'int main(void) { cplus_demangle(0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) -liberty "$(QUIET_STDERR)" && echo y") | 542 | has_cplus_demangle := $(shell sh -c "(echo 'extern char *cplus_demangle(const char *, int);'; echo 'int main(void) { cplus_demangle(0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -liberty "$(QUIET_STDERR)" && echo y") |
| 528 | ifeq ($(has_cplus_demangle),y) | 543 | ifeq ($(has_cplus_demangle),y) |
| 529 | EXTLIBS += -liberty | 544 | EXTLIBS += -liberty |
| 530 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE | 545 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE |
| @@ -772,7 +787,7 @@ export TAR INSTALL DESTDIR SHELL_PATH | |||
| 772 | 787 | ||
| 773 | SHELL = $(SHELL_PATH) | 788 | SHELL = $(SHELL_PATH) |
| 774 | 789 | ||
| 775 | all:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) PERF-BUILD-OPTIONS | 790 | all:: .perf.dev.null shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) PERF-BUILD-OPTIONS |
| 776 | ifneq (,$X) | 791 | ifneq (,$X) |
| 777 | $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), test '$p' -ef '$p$X' || $(RM) '$p';) | 792 | $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) perf$X)), test '$p' -ef '$p$X' || $(RM) '$p';) |
| 778 | endif | 793 | endif |
| @@ -1099,6 +1114,11 @@ clean: | |||
| 1099 | .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS | 1114 | .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS |
| 1100 | .PHONY: .FORCE-PERF-BUILD-OPTIONS | 1115 | .PHONY: .FORCE-PERF-BUILD-OPTIONS |
| 1101 | 1116 | ||
| 1117 | .perf.dev.null: | ||
| 1118 | touch .perf.dev.null | ||
| 1119 | |||
| 1120 | .INTERMEDIATE: .perf.dev.null | ||
| 1121 | |||
| 1102 | ### Make sure built-ins do not have dups and listed in perf.c | 1122 | ### Make sure built-ins do not have dups and listed in perf.c |
| 1103 | # | 1123 | # |
| 1104 | check-builtins:: | 1124 | check-builtins:: |
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index e693e6777af5..1e99ac806913 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | static char const *input_name = "perf.data"; | 17 | static char const *input_name = "perf.data"; |
| 18 | static int force; | 18 | static int force; |
| 19 | 19 | ||
| 20 | static const char *const buildid_list_usage[] = { | 20 | static const char * const buildid_list_usage[] = { |
| 21 | "perf buildid-list [<options>]", | 21 | "perf buildid-list [<options>]", |
| 22 | NULL | 22 | NULL |
| 23 | }; | 23 | }; |
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 4d33b55d5584..bd71b8ceafb7 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
| @@ -189,8 +189,9 @@ out_delete: | |||
| 189 | return ret; | 189 | return ret; |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | static const char *const diff_usage[] = { | 192 | static const char * const diff_usage[] = { |
| 193 | "perf diff [<options>] [old_file] [new_file]", | 193 | "perf diff [<options>] [old_file] [new_file]", |
| 194 | NULL, | ||
| 194 | }; | 195 | }; |
| 195 | 196 | ||
| 196 | static const struct option options[] = { | 197 | static const struct option options[] = { |
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index fc21ad79dd83..7ceb7416c316 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c | |||
| @@ -137,7 +137,7 @@ static void insert_alloc_stat(unsigned long call_site, unsigned long ptr, | |||
| 137 | if (data && data->ptr == ptr) { | 137 | if (data && data->ptr == ptr) { |
| 138 | data->hit++; | 138 | data->hit++; |
| 139 | data->bytes_req += bytes_req; | 139 | data->bytes_req += bytes_req; |
| 140 | data->bytes_alloc += bytes_req; | 140 | data->bytes_alloc += bytes_alloc; |
| 141 | } else { | 141 | } else { |
| 142 | data = malloc(sizeof(*data)); | 142 | data = malloc(sizeof(*data)); |
| 143 | if (!data) | 143 | if (!data) |
| @@ -177,7 +177,7 @@ static void insert_caller_stat(unsigned long call_site, | |||
| 177 | if (data && data->call_site == call_site) { | 177 | if (data && data->call_site == call_site) { |
| 178 | data->hit++; | 178 | data->hit++; |
| 179 | data->bytes_req += bytes_req; | 179 | data->bytes_req += bytes_req; |
| 180 | data->bytes_alloc += bytes_req; | 180 | data->bytes_alloc += bytes_alloc; |
| 181 | } else { | 181 | } else { |
| 182 | data = malloc(sizeof(*data)); | 182 | data = malloc(sizeof(*data)); |
| 183 | if (!data) | 183 | if (!data) |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 63136d0534d4..265425322734 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
| @@ -402,7 +402,7 @@ static void atexit_header(void) | |||
| 402 | perf_header__write(&session->header, output, true); | 402 | perf_header__write(&session->header, output, true); |
| 403 | } | 403 | } |
| 404 | 404 | ||
| 405 | static int __cmd_record(int argc __used, const char **argv) | 405 | static int __cmd_record(int argc, const char **argv) |
| 406 | { | 406 | { |
| 407 | int i, counter; | 407 | int i, counter; |
| 408 | struct stat st; | 408 | struct stat st; |
| @@ -411,6 +411,7 @@ static int __cmd_record(int argc __used, const char **argv) | |||
| 411 | int err; | 411 | int err; |
| 412 | unsigned long waking = 0; | 412 | unsigned long waking = 0; |
| 413 | int child_ready_pipe[2], go_pipe[2]; | 413 | int child_ready_pipe[2], go_pipe[2]; |
| 414 | const bool forks = target_pid == -1 && argc > 0; | ||
| 414 | char buf; | 415 | char buf; |
| 415 | 416 | ||
| 416 | page_size = sysconf(_SC_PAGE_SIZE); | 417 | page_size = sysconf(_SC_PAGE_SIZE); |
| @@ -422,7 +423,7 @@ static int __cmd_record(int argc __used, const char **argv) | |||
| 422 | signal(SIGCHLD, sig_handler); | 423 | signal(SIGCHLD, sig_handler); |
| 423 | signal(SIGINT, sig_handler); | 424 | signal(SIGINT, sig_handler); |
| 424 | 425 | ||
| 425 | if (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0) { | 426 | if (forks && (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0)) { |
| 426 | perror("failed to create pipes"); | 427 | perror("failed to create pipes"); |
| 427 | exit(-1); | 428 | exit(-1); |
| 428 | } | 429 | } |
| @@ -483,7 +484,7 @@ static int __cmd_record(int argc __used, const char **argv) | |||
| 483 | 484 | ||
| 484 | atexit(atexit_header); | 485 | atexit(atexit_header); |
| 485 | 486 | ||
| 486 | if (target_pid == -1) { | 487 | if (forks) { |
| 487 | pid = fork(); | 488 | pid = fork(); |
| 488 | if (pid < 0) { | 489 | if (pid < 0) { |
| 489 | perror("failed to fork"); | 490 | perror("failed to fork"); |
| @@ -550,7 +551,7 @@ static int __cmd_record(int argc __used, const char **argv) | |||
| 550 | return err; | 551 | return err; |
| 551 | } | 552 | } |
| 552 | 553 | ||
| 553 | if (!system_wide) | 554 | if (!system_wide && profile_cpu == -1) |
| 554 | event__synthesize_thread(pid, process_synthesized_event, | 555 | event__synthesize_thread(pid, process_synthesized_event, |
| 555 | session); | 556 | session); |
| 556 | else | 557 | else |
| @@ -569,7 +570,8 @@ static int __cmd_record(int argc __used, const char **argv) | |||
| 569 | /* | 570 | /* |
| 570 | * Let the child rip | 571 | * Let the child rip |
| 571 | */ | 572 | */ |
| 572 | close(go_pipe[1]); | 573 | if (forks) |
| 574 | close(go_pipe[1]); | ||
| 573 | 575 | ||
| 574 | for (;;) { | 576 | for (;;) { |
| 575 | int hits = samples; | 577 | int hits = samples; |
| @@ -667,7 +669,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) | |||
| 667 | 669 | ||
| 668 | argc = parse_options(argc, argv, options, record_usage, | 670 | argc = parse_options(argc, argv, options, record_usage, |
| 669 | PARSE_OPT_STOP_AT_NON_OPTION); | 671 | PARSE_OPT_STOP_AT_NON_OPTION); |
| 670 | if (!argc && target_pid == -1 && (!system_wide || profile_cpu == -1)) | 672 | if (!argc && target_pid == -1 && !system_wide && profile_cpu == -1) |
| 671 | usage_with_options(record_usage, options); | 673 | usage_with_options(record_usage, options); |
| 672 | 674 | ||
| 673 | symbol__init(); | 675 | symbol__init(); |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 5c2ab5357ec6..db10c0e8ecae 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
| @@ -294,8 +294,7 @@ setup: | |||
| 294 | return 0; | 294 | return 0; |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | //static const char * const report_usage[] = { | 297 | static const char * const report_usage[] = { |
| 298 | const char * const report_usage[] = { | ||
| 299 | "perf report [<options>] <command>", | 298 | "perf report [<options>] <command>", |
| 300 | NULL | 299 | NULL |
| 301 | }; | 300 | }; |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index e2285e28720f..574a215e800b 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
| @@ -512,7 +512,7 @@ static char *get_script_path(const char *script_root, const char *suffix) | |||
| 512 | return path; | 512 | return path; |
| 513 | } | 513 | } |
| 514 | 514 | ||
| 515 | static const char * const annotate_usage[] = { | 515 | static const char * const trace_usage[] = { |
| 516 | "perf trace [<options>] <command>", | 516 | "perf trace [<options>] <command>", |
| 517 | NULL | 517 | NULL |
| 518 | }; | 518 | }; |
| @@ -581,7 +581,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used) | |||
| 581 | 581 | ||
| 582 | setup_scripting(); | 582 | setup_scripting(); |
| 583 | 583 | ||
| 584 | argc = parse_options(argc, argv, options, annotate_usage, | 584 | argc = parse_options(argc, argv, options, trace_usage, |
| 585 | PARSE_OPT_STOP_AT_NON_OPTION); | 585 | PARSE_OPT_STOP_AT_NON_OPTION); |
| 586 | 586 | ||
| 587 | if (symbol__init() < 0) | 587 | if (symbol__init() < 0) |
diff --git a/tools/perf/design.txt b/tools/perf/design.txt index f000c30877ac..8d0de5130db3 100644 --- a/tools/perf/design.txt +++ b/tools/perf/design.txt | |||
| @@ -21,7 +21,7 @@ There's one file descriptor per virtual counter used. | |||
| 21 | The special file descriptor is opened via the perf_event_open() | 21 | The special file descriptor is opened via the perf_event_open() |
| 22 | system call: | 22 | system call: |
| 23 | 23 | ||
| 24 | int sys_perf_event_open(struct perf_event_hw_event *hw_event_uptr, | 24 | int sys_perf_event_open(struct perf_event_attr *hw_event_uptr, |
| 25 | pid_t pid, int cpu, int group_fd, | 25 | pid_t pid, int cpu, int group_fd, |
| 26 | unsigned long flags); | 26 | unsigned long flags); |
| 27 | 27 | ||
| @@ -32,9 +32,9 @@ can be used to set the blocking mode, etc. | |||
| 32 | Multiple counters can be kept open at a time, and the counters | 32 | Multiple counters can be kept open at a time, and the counters |
| 33 | can be poll()ed. | 33 | can be poll()ed. |
| 34 | 34 | ||
| 35 | When creating a new counter fd, 'perf_event_hw_event' is: | 35 | When creating a new counter fd, 'perf_event_attr' is: |
| 36 | 36 | ||
| 37 | struct perf_event_hw_event { | 37 | struct perf_event_attr { |
| 38 | /* | 38 | /* |
| 39 | * The MSB of the config word signifies if the rest contains cpu | 39 | * The MSB of the config word signifies if the rest contains cpu |
| 40 | * specific (raw) counter configuration data, if unset, the next | 40 | * specific (raw) counter configuration data, if unset, the next |
| @@ -399,7 +399,7 @@ Notification of new events is possible through poll()/select()/epoll() and | |||
| 399 | fcntl() managing signals. | 399 | fcntl() managing signals. |
| 400 | 400 | ||
| 401 | Normally a notification is generated for every page filled, however one can | 401 | Normally a notification is generated for every page filled, however one can |
| 402 | additionally set perf_event_hw_event.wakeup_events to generate one every | 402 | additionally set perf_event_attr.wakeup_events to generate one every |
| 403 | so many counter overflow events. | 403 | so many counter overflow events. |
| 404 | 404 | ||
| 405 | Future work will include a splice() interface to the ring-buffer. | 405 | Future work will include a splice() interface to the ring-buffer. |
