diff options
Diffstat (limited to 'tools/perf/perf.c')
-rw-r--r-- | tools/perf/perf.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index a929618b8eb6..aaee0a782747 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
@@ -454,11 +454,12 @@ static void handle_internal_command(int argc, const char **argv) | |||
454 | 454 | ||
455 | static void execv_dashed_external(const char **argv) | 455 | static void execv_dashed_external(const char **argv) |
456 | { | 456 | { |
457 | struct strbuf cmd = STRBUF_INIT; | 457 | char *cmd; |
458 | const char *tmp; | 458 | const char *tmp; |
459 | int status; | 459 | int status; |
460 | 460 | ||
461 | strbuf_addf(&cmd, "perf-%s", argv[0]); | 461 | if (asprintf(&cmd, "perf-%s", argv[0]) < 0) |
462 | goto do_die; | ||
462 | 463 | ||
463 | /* | 464 | /* |
464 | * argv[0] must be the perf command, but the argv array | 465 | * argv[0] must be the perf command, but the argv array |
@@ -467,7 +468,7 @@ static void execv_dashed_external(const char **argv) | |||
467 | * restore it on error. | 468 | * restore it on error. |
468 | */ | 469 | */ |
469 | tmp = argv[0]; | 470 | tmp = argv[0]; |
470 | argv[0] = cmd.buf; | 471 | argv[0] = cmd; |
471 | 472 | ||
472 | /* | 473 | /* |
473 | * if we fail because the command is not found, it is | 474 | * if we fail because the command is not found, it is |
@@ -475,15 +476,16 @@ static void execv_dashed_external(const char **argv) | |||
475 | */ | 476 | */ |
476 | status = run_command_v_opt(argv, 0); | 477 | status = run_command_v_opt(argv, 0); |
477 | if (status != -ERR_RUN_COMMAND_EXEC) { | 478 | if (status != -ERR_RUN_COMMAND_EXEC) { |
478 | if (IS_RUN_COMMAND_ERR(status)) | 479 | if (IS_RUN_COMMAND_ERR(status)) { |
480 | do_die: | ||
479 | die("unable to run '%s'", argv[0]); | 481 | die("unable to run '%s'", argv[0]); |
482 | } | ||
480 | exit(-status); | 483 | exit(-status); |
481 | } | 484 | } |
482 | errno = ENOENT; /* as if we called execvp */ | 485 | errno = ENOENT; /* as if we called execvp */ |
483 | 486 | ||
484 | argv[0] = tmp; | 487 | argv[0] = tmp; |
485 | 488 | zfree(&cmd); | |
486 | strbuf_release(&cmd); | ||
487 | } | 489 | } |
488 | 490 | ||
489 | static int run_argv(int *argcp, const char ***argv) | 491 | static int run_argv(int *argcp, const char ***argv) |
@@ -546,6 +548,8 @@ int main(int argc, const char **argv) | |||
546 | 548 | ||
547 | srandom(time(NULL)); | 549 | srandom(time(NULL)); |
548 | 550 | ||
551 | perf_config(perf_default_config, NULL); | ||
552 | |||
549 | /* get debugfs/tracefs mount point from /proc/mounts */ | 553 | /* get debugfs/tracefs mount point from /proc/mounts */ |
550 | tracing_path_mount(); | 554 | tracing_path_mount(); |
551 | 555 | ||
@@ -613,6 +617,8 @@ int main(int argc, const char **argv) | |||
613 | */ | 617 | */ |
614 | pthread__block_sigwinch(); | 618 | pthread__block_sigwinch(); |
615 | 619 | ||
620 | perf_debug_setup(); | ||
621 | |||
616 | while (1) { | 622 | while (1) { |
617 | static int done_help; | 623 | static int done_help; |
618 | int was_alias = run_argv(&argc, &argv); | 624 | int was_alias = run_argv(&argc, &argv); |