.. | .. |
---|
1 | | -// SPDX-License-Identifier: GPL-2.0 |
---|
2 | 1 | /* |
---|
3 | 2 | * perf.c |
---|
4 | 3 | * |
---|
.. | .. |
---|
8 | 7 | * perf top, perf record, perf report, etc.) are started. |
---|
9 | 8 | */ |
---|
10 | 9 | #include "builtin.h" |
---|
| 10 | +#include "perf.h" |
---|
11 | 11 | |
---|
| 12 | +#include "util/build-id.h" |
---|
| 13 | +#include "util/cache.h" |
---|
12 | 14 | #include "util/env.h" |
---|
| 15 | +#include <internal/lib.h> // page_size |
---|
13 | 16 | #include <subcmd/exec-cmd.h> |
---|
14 | 17 | #include "util/config.h" |
---|
15 | 18 | #include <subcmd/run-command.h> |
---|
.. | .. |
---|
18 | 21 | #include "util/bpf-loader.h" |
---|
19 | 22 | #include "util/debug.h" |
---|
20 | 23 | #include "util/event.h" |
---|
| 24 | +#include "util/util.h" // usage() |
---|
| 25 | +#include "ui/ui.h" |
---|
| 26 | +#include "perf-sys.h" |
---|
21 | 27 | #include <api/fs/fs.h> |
---|
22 | 28 | #include <api/fs/tracing_path.h> |
---|
| 29 | +#include <perf/core.h> |
---|
23 | 30 | #include <errno.h> |
---|
24 | 31 | #include <pthread.h> |
---|
25 | 32 | #include <signal.h> |
---|
.. | .. |
---|
29 | 36 | #include <sys/stat.h> |
---|
30 | 37 | #include <unistd.h> |
---|
31 | 38 | #include <linux/kernel.h> |
---|
| 39 | +#include <linux/string.h> |
---|
| 40 | +#include <linux/zalloc.h> |
---|
32 | 41 | |
---|
33 | 42 | const char perf_usage_string[] = |
---|
34 | 43 | "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]"; |
---|
.. | .. |
---|
298 | 307 | use_pager = 1; |
---|
299 | 308 | commit_pager_choice(); |
---|
300 | 309 | |
---|
| 310 | + perf_env__init(&perf_env); |
---|
301 | 311 | perf_env__set_cmdline(&perf_env, argc, argv); |
---|
302 | 312 | status = p->fn(argc, argv); |
---|
303 | 313 | perf_config__exit(); |
---|
.. | .. |
---|
420 | 430 | pthread_sigmask(SIG_UNBLOCK, &set, NULL); |
---|
421 | 431 | } |
---|
422 | 432 | |
---|
| 433 | +static int libperf_print(enum libperf_print_level level, |
---|
| 434 | + const char *fmt, va_list ap) |
---|
| 435 | +{ |
---|
| 436 | + return veprintf(level, verbose, fmt, ap); |
---|
| 437 | +} |
---|
| 438 | + |
---|
423 | 439 | int main(int argc, const char **argv) |
---|
424 | 440 | { |
---|
425 | 441 | int err; |
---|
.. | .. |
---|
430 | 446 | exec_cmd_init("perf", PREFIX, PERF_EXEC_PATH, EXEC_PATH_ENVIRONMENT); |
---|
431 | 447 | pager_init(PERF_PAGER_ENVIRONMENT); |
---|
432 | 448 | |
---|
433 | | - /* The page_size is placed in util object. */ |
---|
434 | | - page_size = sysconf(_SC_PAGE_SIZE); |
---|
| 449 | + libperf_init(libperf_print); |
---|
435 | 450 | |
---|
436 | 451 | cmd = extract_argv0_path(argv[0]); |
---|
437 | 452 | if (!cmd) |
---|