aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/perf.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-11-17 04:16:43 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-17 04:17:47 -0500
commita7b63425a41cd6a8d50f76fef0660c5110f97e91 (patch)
treebe17ee121f1c8814d8d39c9f3e0205d9397fab54 /tools/perf/perf.c
parent35039eb6b199749943547c8572be6604edf00229 (diff)
parent3726cc75e581c157202da93bb2333cce25c15c98 (diff)
Merge branch 'perf/core' into perf/probes
Resolved merge conflict in tools/perf/Makefile Merge reason: we want to queue up a dependent patch. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/perf.c')
-rw-r--r--tools/perf/perf.c46
1 files changed, 8 insertions, 38 deletions
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 9cafe5463266..89b82acac7d9 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -14,6 +14,7 @@
14#include "util/run-command.h" 14#include "util/run-command.h"
15#include "util/parse-events.h" 15#include "util/parse-events.h"
16#include "util/string.h" 16#include "util/string.h"
17#include "util/debugfs.h"
17 18
18const char perf_usage_string[] = 19const char perf_usage_string[] =
19 "perf [--version] [--help] COMMAND [ARGS]"; 20 "perf [--version] [--help] COMMAND [ARGS]";
@@ -286,8 +287,10 @@ static void handle_internal_command(int argc, const char **argv)
286 static struct cmd_struct commands[] = { 287 static struct cmd_struct commands[] = {
287 { "help", cmd_help, 0 }, 288 { "help", cmd_help, 0 },
288 { "list", cmd_list, 0 }, 289 { "list", cmd_list, 0 },
290 { "buildid-list", cmd_buildid_list, 0 },
289 { "record", cmd_record, 0 }, 291 { "record", cmd_record, 0 },
290 { "report", cmd_report, 0 }, 292 { "report", cmd_report, 0 },
293 { "bench", cmd_bench, 0 },
291 { "stat", cmd_stat, 0 }, 294 { "stat", cmd_stat, 0 },
292 { "timechart", cmd_timechart, 0 }, 295 { "timechart", cmd_timechart, 0 },
293 { "top", cmd_top, 0 }, 296 { "top", cmd_top, 0 },
@@ -383,45 +386,12 @@ static int run_argv(int *argcp, const char ***argv)
383/* mini /proc/mounts parser: searching for "^blah /mount/point debugfs" */ 386/* mini /proc/mounts parser: searching for "^blah /mount/point debugfs" */
384static void get_debugfs_mntpt(void) 387static void get_debugfs_mntpt(void)
385{ 388{
386 FILE *file; 389 const char *path = debugfs_find_mountpoint();
387 char fs_type[100];
388 char debugfs[MAXPATHLEN];
389 390
390 /* 391 if (path)
391 * try the standard location 392 strncpy(debugfs_mntpt, path, sizeof(debugfs_mntpt));
392 */ 393 else
393 if (valid_debugfs_mount("/sys/kernel/debug/") == 0) { 394 debugfs_mntpt[0] = '\0';
394 strcpy(debugfs_mntpt, "/sys/kernel/debug/");
395 return;
396 }
397
398 /*
399 * try the sane location
400 */
401 if (valid_debugfs_mount("/debug/") == 0) {
402 strcpy(debugfs_mntpt, "/debug/");
403 return;
404 }
405
406 /*
407 * give up and parse /proc/mounts
408 */
409 file = fopen("/proc/mounts", "r");
410 if (file == NULL)
411 return;
412
413 while (fscanf(file, "%*s %"
414 STR(MAXPATHLEN)
415 "s %99s %*s %*d %*d\n",
416 debugfs, fs_type) == 2) {
417 if (strcmp(fs_type, "debugfs") == 0)
418 break;
419 }
420 fclose(file);
421 if (strcmp(fs_type, "debugfs") == 0) {
422 strncpy(debugfs_mntpt, debugfs, MAXPATHLEN);
423 debugfs_mntpt[MAXPATHLEN - 1] = '\0';
424 }
425} 395}
426 396
427int main(int argc, const char **argv) 397int main(int argc, const char **argv)