hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/tools/perf/util/config.c
....@@ -11,18 +11,23 @@
1111 */
1212 #include <errno.h>
1313 #include <sys/param.h>
14
-#include "util.h"
1514 #include "cache.h"
15
+#include "callchain.h"
1616 #include <subcmd/exec-cmd.h>
17
+#include "util/event.h" /* proc_map_timeout */
1718 #include "util/hist.h" /* perf_hist_config */
1819 #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"
1923 #include "config.h"
2024 #include <sys/types.h>
2125 #include <sys/stat.h>
26
+#include <stdlib.h>
2227 #include <unistd.h>
2328 #include <linux/string.h>
24
-
25
-#include "sane_ctype.h"
29
+#include <linux/zalloc.h>
30
+#include <linux/ctype.h>
2631
2732 #define MAXNAME (256)
2833
....@@ -369,6 +374,18 @@
369374 return 0;
370375 }
371376
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
+
372389 static int perf_config_bool_or_int(const char *name, const char *value, int *is_bool)
373390 {
374391 int ret;
....@@ -419,6 +436,9 @@
419436 static int perf_default_core_config(const char *var __maybe_unused,
420437 const char *value __maybe_unused)
421438 {
439
+ if (!strcmp(var, "core.proc-map-timeout"))
440
+ proc_map_timeout = strtoul(value, NULL, 10);
441
+
422442 /* Add other config variables here. */
423443 return 0;
424444 }
....@@ -429,6 +449,15 @@
429449 if (!strcmp(var, "ui.show-headers"))
430450 symbol_conf.show_hist_headers = perf_config_bool(var, value);
431451
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. */
432461 return 0;
433462 }
434463
....@@ -453,11 +482,14 @@
453482 if (strstarts(var, "buildid."))
454483 return perf_buildid_config(var, value);
455484
485
+ if (strstarts(var, "stat."))
486
+ return perf_stat_config(var, value);
487
+
456488 /* Add other config variables here. */
457489 return 0;
458490 }
459491
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)
461493 {
462494 int ret;
463495 FILE *f = fopen(filename, "r");
....@@ -734,11 +766,15 @@
734766 if (ret < 0) {
735767 pr_err("Error: wrong config key-value pair %s=%s\n",
736768 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;
738774 }
739775 }
740776 }
741
-
777
+out:
742778 return ret;
743779 }
744780
....@@ -810,14 +846,14 @@
810846 void set_buildid_dir(const char *dir)
811847 {
812848 if (dir)
813
- scnprintf(buildid_dir, MAXPATHLEN-1, "%s", dir);
849
+ scnprintf(buildid_dir, MAXPATHLEN, "%s", dir);
814850
815851 /* default to $HOME/.debug */
816852 if (buildid_dir[0] == '\0') {
817853 char *home = getenv("HOME");
818854
819855 if (home) {
820
- snprintf(buildid_dir, MAXPATHLEN-1, "%s/%s",
856
+ snprintf(buildid_dir, MAXPATHLEN, "%s/%s",
821857 home, DEBUG_CACHE_DIR);
822858 } else {
823859 strncpy(buildid_dir, DEBUG_CACHE_DIR, MAXPATHLEN-1);