.. | .. |
---|
11 | 11 | */ |
---|
12 | 12 | #include <errno.h> |
---|
13 | 13 | #include <sys/param.h> |
---|
14 | | -#include "util.h" |
---|
15 | 14 | #include "cache.h" |
---|
| 15 | +#include "callchain.h" |
---|
16 | 16 | #include <subcmd/exec-cmd.h> |
---|
| 17 | +#include "util/event.h" /* proc_map_timeout */ |
---|
17 | 18 | #include "util/hist.h" /* perf_hist_config */ |
---|
18 | 19 | #include "util/llvm-utils.h" /* perf_llvm_config */ |
---|
| 20 | +#include "util/stat.h" /* perf_stat__set_big_num */ |
---|
| 21 | +#include "build-id.h" |
---|
| 22 | +#include "debug.h" |
---|
19 | 23 | #include "config.h" |
---|
20 | 24 | #include <sys/types.h> |
---|
21 | 25 | #include <sys/stat.h> |
---|
| 26 | +#include <stdlib.h> |
---|
22 | 27 | #include <unistd.h> |
---|
23 | 28 | #include <linux/string.h> |
---|
24 | | - |
---|
25 | | -#include "sane_ctype.h" |
---|
| 29 | +#include <linux/zalloc.h> |
---|
| 30 | +#include <linux/ctype.h> |
---|
26 | 31 | |
---|
27 | 32 | #define MAXNAME (256) |
---|
28 | 33 | |
---|
.. | .. |
---|
369 | 374 | return 0; |
---|
370 | 375 | } |
---|
371 | 376 | |
---|
| 377 | +int perf_config_u8(u8 *dest, const char *name, const char *value) |
---|
| 378 | +{ |
---|
| 379 | + long ret = 0; |
---|
| 380 | + |
---|
| 381 | + if (!perf_parse_long(value, &ret)) { |
---|
| 382 | + bad_config(name); |
---|
| 383 | + return -1; |
---|
| 384 | + } |
---|
| 385 | + *dest = ret; |
---|
| 386 | + return 0; |
---|
| 387 | +} |
---|
| 388 | + |
---|
372 | 389 | static int perf_config_bool_or_int(const char *name, const char *value, int *is_bool) |
---|
373 | 390 | { |
---|
374 | 391 | int ret; |
---|
.. | .. |
---|
419 | 436 | static int perf_default_core_config(const char *var __maybe_unused, |
---|
420 | 437 | const char *value __maybe_unused) |
---|
421 | 438 | { |
---|
| 439 | + if (!strcmp(var, "core.proc-map-timeout")) |
---|
| 440 | + proc_map_timeout = strtoul(value, NULL, 10); |
---|
| 441 | + |
---|
422 | 442 | /* Add other config variables here. */ |
---|
423 | 443 | return 0; |
---|
424 | 444 | } |
---|
.. | .. |
---|
429 | 449 | if (!strcmp(var, "ui.show-headers")) |
---|
430 | 450 | symbol_conf.show_hist_headers = perf_config_bool(var, value); |
---|
431 | 451 | |
---|
| 452 | + return 0; |
---|
| 453 | +} |
---|
| 454 | + |
---|
| 455 | +static int perf_stat_config(const char *var, const char *value) |
---|
| 456 | +{ |
---|
| 457 | + if (!strcmp(var, "stat.big-num")) |
---|
| 458 | + perf_stat__set_big_num(perf_config_bool(var, value)); |
---|
| 459 | + |
---|
| 460 | + /* Add other config variables here. */ |
---|
432 | 461 | return 0; |
---|
433 | 462 | } |
---|
434 | 463 | |
---|
.. | .. |
---|
453 | 482 | if (strstarts(var, "buildid.")) |
---|
454 | 483 | return perf_buildid_config(var, value); |
---|
455 | 484 | |
---|
| 485 | + if (strstarts(var, "stat.")) |
---|
| 486 | + return perf_stat_config(var, value); |
---|
| 487 | + |
---|
456 | 488 | /* Add other config variables here. */ |
---|
457 | 489 | return 0; |
---|
458 | 490 | } |
---|
459 | 491 | |
---|
460 | | -static int perf_config_from_file(config_fn_t fn, const char *filename, void *data) |
---|
| 492 | +int perf_config_from_file(config_fn_t fn, const char *filename, void *data) |
---|
461 | 493 | { |
---|
462 | 494 | int ret; |
---|
463 | 495 | FILE *f = fopen(filename, "r"); |
---|
.. | .. |
---|
734 | 766 | if (ret < 0) { |
---|
735 | 767 | pr_err("Error: wrong config key-value pair %s=%s\n", |
---|
736 | 768 | key, value); |
---|
737 | | - break; |
---|
| 769 | + /* |
---|
| 770 | + * Can't be just a 'break', as perf_config_set__for_each_entry() |
---|
| 771 | + * expands to two nested for() loops. |
---|
| 772 | + */ |
---|
| 773 | + goto out; |
---|
738 | 774 | } |
---|
739 | 775 | } |
---|
740 | 776 | } |
---|
741 | | - |
---|
| 777 | +out: |
---|
742 | 778 | return ret; |
---|
743 | 779 | } |
---|
744 | 780 | |
---|
.. | .. |
---|
810 | 846 | void set_buildid_dir(const char *dir) |
---|
811 | 847 | { |
---|
812 | 848 | if (dir) |
---|
813 | | - scnprintf(buildid_dir, MAXPATHLEN-1, "%s", dir); |
---|
| 849 | + scnprintf(buildid_dir, MAXPATHLEN, "%s", dir); |
---|
814 | 850 | |
---|
815 | 851 | /* default to $HOME/.debug */ |
---|
816 | 852 | if (buildid_dir[0] == '\0') { |
---|
817 | 853 | char *home = getenv("HOME"); |
---|
818 | 854 | |
---|
819 | 855 | if (home) { |
---|
820 | | - snprintf(buildid_dir, MAXPATHLEN-1, "%s/%s", |
---|
| 856 | + snprintf(buildid_dir, MAXPATHLEN, "%s/%s", |
---|
821 | 857 | home, DEBUG_CACHE_DIR); |
---|
822 | 858 | } else { |
---|
823 | 859 | strncpy(buildid_dir, DEBUG_CACHE_DIR, MAXPATHLEN-1); |
---|