aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-help.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-01 13:28:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-01 13:28:49 -0400
commit7e92daaefa68e5ef1e1732e45231e73adbb724e7 (patch)
tree8e7f8ac9d82654df4c65939c6682f95510e22977 /tools/perf/builtin-help.c
parent7a68294278ae714ce2632a54f0f46916dca64f56 (diff)
parent1d787d37c8ff6612b8151c6dff15bfa7347bcbdf (diff)
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf update from Ingo Molnar: "Lots of changes in this cycle as well, with hundreds of commits from over 30 contributors. Most of the activity was on the tooling side. Higher level changes: - New 'perf kvm' analysis tool, from Xiao Guangrong. - New 'perf trace' system-wide tracing tool - uprobes fixes + cleanups from Oleg Nesterov. - Lots of patches to make perf build on Android out of box, from Irina Tirdea - Extend ftrace function tracing utility to be more dynamic for its users. It allows for data passing to the callback functions, as well as reading regs as if a breakpoint were to trigger at function entry. The main goal of this patch series was to allow kprobes to use ftrace as an optimized probe point when a probe is placed on an ftrace nop. With lots of help from Masami Hiramatsu, and going through lots of iterations, we finally came up with a good solution. - Add cpumask for uncore pmu, use it in 'stat', from Yan, Zheng. - Various tracing updates from Steve Rostedt - Clean up and improve 'perf sched' performance by elliminating lots of needless calls to libtraceevent. - Event group parsing support, from Jiri Olsa - UI/gtk refactorings and improvements from Namhyung Kim - Add support for non-tracepoint events in perf script python, from Feng Tang - Add --symbols to 'script', similar to the one in 'report', from Feng Tang. Infrastructure enhancements and fixes: - Convert the trace builtins to use the growing evsel/evlist tracepoint infrastructure, removing several open coded constructs like switch like series of strcmp to dispatch events, etc. Basically what had already been showcased in 'perf sched'. - Add evsel constructor for tracepoints, that uses libtraceevent just to parse the /format events file, use it in a new 'perf test' to make sure the libtraceevent format parsing regressions can be more readily caught. - Some strange errors were happening in some builds, but not on the next, reported by several people, problem was some parser related files, generated during the build, didn't had proper make deps, fix from Eric Sandeen. - Introduce struct and cache information about the environment where a perf.data file was captured, from Namhyung Kim. - Fix handling of unresolved samples when --symbols is used in 'report', from Feng Tang. - Add union member access support to 'probe', from Hyeoncheol Lee. - Fixups to die() removal, from Namhyung Kim. - Render fixes for the TUI, from Namhyung Kim. - Don't enable annotation in non symbolic view, from Namhyung Kim. - Fix pipe mode in 'report', from Namhyung Kim. - Move related stats code from stat to util/, will be used by the 'stat' kvm tool, from Xiao Guangrong. - Remove die()/exit() calls from several tools. - Resolve vdso callchains, from Jiri Olsa - Don't pass const char pointers to basename, so that we can unconditionally use libgen.h and thus avoid ifdef BIONIC lines, from David Ahern - Refactor hist formatting so that it can be reused with the GTK browser, From Namhyung Kim - Fix build for another rbtree.c change, from Adrian Hunter. - Make 'perf diff' command work with evsel hists, from Jiri Olsa. - Use the only field_sep var that is set up: symbol_conf.field_sep, fix from Jiri Olsa. - .gitignore compiled python binaries, from Namhyung Kim. - Get rid of die() in more libtraceevent places, from Namhyung Kim. - Rename libtraceevent 'private' struct member to 'priv' so that it works in C++, from Steven Rostedt - Remove lots of exit()/die() calls from tools so that the main perf exit routine can take place, from David Ahern - Fix x86 build on x86-64, from David Ahern. - {int,str,rb}list fixes from Suzuki K Poulose - perf.data header fixes from Namhyung Kim - Allow user to indicate objdump path, needed in cross environments, from Maciek Borzecki - Fix hardware cache event name generation, fix from Jiri Olsa - Add round trip test for sw, hw and cache event names, catching the problem Jiri fixed, after Jiri's patch, the test passes successfully. - Clean target should do clean for lib/traceevent too, fix from David Ahern - Check the right variable for allocation failure, fix from Namhyung Kim - Set up evsel->tp_format regardless of evsel->name being set already, fix from Namhyung Kim - Oprofile fixes from Robert Richter. - Remove perf_event_attr needless version inflation, from Jiri Olsa - Introduce libtraceevent strerror like error reporting facility, from Namhyung Kim - Add pmu mappings to perf.data header and use event names from cmd line, from Robert Richter - Fix include order for bison/flex-generated C files, from Ben Hutchings - Build fixes and documentation corrections from David Ahern - Assorted cleanups from Robert Richter - Let O= makes handle relative paths, from Steven Rostedt - perf script python fixes, from Feng Tang. - Initial bash completion support, from Frederic Weisbecker - Allow building without libelf, from Namhyung Kim. - Support DWARF CFI based unwind to have callchains when %bp based unwinding is not possible, from Jiri Olsa. - Symbol resolution fixes, while fixing support PPC64 files with an .opt ELF section was the end goal, several fixes for code that handles all architectures and cleanups are included, from Cody Schafer. - Assorted fixes for Documentation and build in 32 bit, from Robert Richter - Cache the libtraceevent event_format associated to each evsel early, so that we avoid relookups, i.e. calling pevent_find_event repeatedly when processing tracepoint events. [ This is to reduce the surface contact with libtraceevents and make clear what is that the perf tools needs from that lib: so far parsing the common and per event fields. ] - Don't stop the build if the audit libraries are not installed, fix from Namhyung Kim. - Fix bfd.h/libbfd detection with recent binutils, from Markus Trippelsdorf. - Improve warning message when libunwind devel packages not present, from Jiri Olsa" * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (282 commits) perf trace: Add aliases for some syscalls perf probe: Print an enum type variable in "enum variable-name" format when showing accessible variables perf tools: Check libaudit availability for perf-trace builtin perf hists: Add missing period_* fields when collapsing a hist entry perf trace: New tool perf evsel: Export the event_format constructor perf evsel: Introduce rawptr() method perf tools: Use perf_evsel__newtp in the event parser perf evsel: The tracepoint constructor should store sys:name perf evlist: Introduce set_filter() method perf evlist: Renane set_filters method to apply_filters perf test: Add test to check we correctly parse and match syscall open parms perf evsel: Handle endianity in intval method perf evsel: Know if byte swap is needed perf tools: Allow handling a NULL cpu_map as meaning "all cpus" perf evsel: Improve tracepoint constructor setup tools lib traceevent: Fix error path on pevent_parse_event perf test: Fix build failure trace: Move trace event enable from fs_initcall to core_initcall tracing: Add an option for disabling markers ...
Diffstat (limited to 'tools/perf/builtin-help.c')
-rw-r--r--tools/perf/builtin-help.c50
1 files changed, 35 insertions, 15 deletions
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 6d5a8a7faf48..25c8b942ff85 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -24,13 +24,14 @@ static struct man_viewer_info_list {
24} *man_viewer_info_list; 24} *man_viewer_info_list;
25 25
26enum help_format { 26enum help_format {
27 HELP_FORMAT_NONE,
27 HELP_FORMAT_MAN, 28 HELP_FORMAT_MAN,
28 HELP_FORMAT_INFO, 29 HELP_FORMAT_INFO,
29 HELP_FORMAT_WEB, 30 HELP_FORMAT_WEB,
30}; 31};
31 32
32static bool show_all = false; 33static bool show_all = false;
33static enum help_format help_format = HELP_FORMAT_MAN; 34static enum help_format help_format = HELP_FORMAT_NONE;
34static struct option builtin_help_options[] = { 35static struct option builtin_help_options[] = {
35 OPT_BOOLEAN('a', "all", &show_all, "print all available commands"), 36 OPT_BOOLEAN('a', "all", &show_all, "print all available commands"),
36 OPT_SET_UINT('m', "man", &help_format, "show man page", HELP_FORMAT_MAN), 37 OPT_SET_UINT('m', "man", &help_format, "show man page", HELP_FORMAT_MAN),
@@ -54,7 +55,9 @@ static enum help_format parse_help_format(const char *format)
54 return HELP_FORMAT_INFO; 55 return HELP_FORMAT_INFO;
55 if (!strcmp(format, "web") || !strcmp(format, "html")) 56 if (!strcmp(format, "web") || !strcmp(format, "html"))
56 return HELP_FORMAT_WEB; 57 return HELP_FORMAT_WEB;
57 die("unrecognized help format '%s'", format); 58
59 pr_err("unrecognized help format '%s'", format);
60 return HELP_FORMAT_NONE;
58} 61}
59 62
60static const char *get_man_viewer_info(const char *name) 63static const char *get_man_viewer_info(const char *name)
@@ -259,6 +262,8 @@ static int perf_help_config(const char *var, const char *value, void *cb)
259 if (!value) 262 if (!value)
260 return config_error_nonbool(var); 263 return config_error_nonbool(var);
261 help_format = parse_help_format(value); 264 help_format = parse_help_format(value);
265 if (help_format == HELP_FORMAT_NONE)
266 return -1;
262 return 0; 267 return 0;
263 } 268 }
264 if (!strcmp(var, "man.viewer")) { 269 if (!strcmp(var, "man.viewer")) {
@@ -352,7 +357,7 @@ static void exec_viewer(const char *name, const char *page)
352 warning("'%s': unknown man viewer.", name); 357 warning("'%s': unknown man viewer.", name);
353} 358}
354 359
355static void show_man_page(const char *perf_cmd) 360static int show_man_page(const char *perf_cmd)
356{ 361{
357 struct man_viewer_list *viewer; 362 struct man_viewer_list *viewer;
358 const char *page = cmd_to_page(perf_cmd); 363 const char *page = cmd_to_page(perf_cmd);
@@ -365,28 +370,35 @@ static void show_man_page(const char *perf_cmd)
365 if (fallback) 370 if (fallback)
366 exec_viewer(fallback, page); 371 exec_viewer(fallback, page);
367 exec_viewer("man", page); 372 exec_viewer("man", page);
368 die("no man viewer handled the request"); 373
374 pr_err("no man viewer handled the request");
375 return -1;
369} 376}
370 377
371static void show_info_page(const char *perf_cmd) 378static int show_info_page(const char *perf_cmd)
372{ 379{
373 const char *page = cmd_to_page(perf_cmd); 380 const char *page = cmd_to_page(perf_cmd);
374 setenv("INFOPATH", system_path(PERF_INFO_PATH), 1); 381 setenv("INFOPATH", system_path(PERF_INFO_PATH), 1);
375 execlp("info", "info", "perfman", page, NULL); 382 execlp("info", "info", "perfman", page, NULL);
383 return -1;
376} 384}
377 385
378static void get_html_page_path(struct strbuf *page_path, const char *page) 386static int get_html_page_path(struct strbuf *page_path, const char *page)
379{ 387{
380 struct stat st; 388 struct stat st;
381 const char *html_path = system_path(PERF_HTML_PATH); 389 const char *html_path = system_path(PERF_HTML_PATH);
382 390
383 /* Check that we have a perf documentation directory. */ 391 /* Check that we have a perf documentation directory. */
384 if (stat(mkpath("%s/perf.html", html_path), &st) 392 if (stat(mkpath("%s/perf.html", html_path), &st)
385 || !S_ISREG(st.st_mode)) 393 || !S_ISREG(st.st_mode)) {
386 die("'%s': not a documentation directory.", html_path); 394 pr_err("'%s': not a documentation directory.", html_path);
395 return -1;
396 }
387 397
388 strbuf_init(page_path, 0); 398 strbuf_init(page_path, 0);
389 strbuf_addf(page_path, "%s/%s.html", html_path, page); 399 strbuf_addf(page_path, "%s/%s.html", html_path, page);
400
401 return 0;
390} 402}
391 403
392/* 404/*
@@ -401,19 +413,23 @@ static void open_html(const char *path)
401} 413}
402#endif 414#endif
403 415
404static void show_html_page(const char *perf_cmd) 416static int show_html_page(const char *perf_cmd)
405{ 417{
406 const char *page = cmd_to_page(perf_cmd); 418 const char *page = cmd_to_page(perf_cmd);
407 struct strbuf page_path; /* it leaks but we exec bellow */ 419 struct strbuf page_path; /* it leaks but we exec bellow */
408 420
409 get_html_page_path(&page_path, page); 421 if (get_html_page_path(&page_path, page) != 0)
422 return -1;
410 423
411 open_html(page_path.buf); 424 open_html(page_path.buf);
425
426 return 0;
412} 427}
413 428
414int cmd_help(int argc, const char **argv, const char *prefix __used) 429int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)
415{ 430{
416 const char *alias; 431 const char *alias;
432 int rc = 0;
417 433
418 load_command_list("perf-", &main_cmds, &other_cmds); 434 load_command_list("perf-", &main_cmds, &other_cmds);
419 435
@@ -444,16 +460,20 @@ int cmd_help(int argc, const char **argv, const char *prefix __used)
444 460
445 switch (help_format) { 461 switch (help_format) {
446 case HELP_FORMAT_MAN: 462 case HELP_FORMAT_MAN:
447 show_man_page(argv[0]); 463 rc = show_man_page(argv[0]);
448 break; 464 break;
449 case HELP_FORMAT_INFO: 465 case HELP_FORMAT_INFO:
450 show_info_page(argv[0]); 466 rc = show_info_page(argv[0]);
451 break; 467 break;
452 case HELP_FORMAT_WEB: 468 case HELP_FORMAT_WEB:
453 show_html_page(argv[0]); 469 rc = show_html_page(argv[0]);
470 break;
471 case HELP_FORMAT_NONE:
472 /* fall-through */
454 default: 473 default:
474 rc = -1;
455 break; 475 break;
456 } 476 }
457 477
458 return 0; 478 return rc;
459} 479}