diff options
Diffstat (limited to 'tools/perf/util/config.c')
-rw-r--r-- | tools/perf/util/config.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 1e5e2e5af6b1..57ff826f150b 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c | |||
@@ -222,7 +222,8 @@ static int perf_parse_file(config_fn_t fn, void *data) | |||
222 | const unsigned char *bomptr = utf8_bom; | 222 | const unsigned char *bomptr = utf8_bom; |
223 | 223 | ||
224 | for (;;) { | 224 | for (;;) { |
225 | int c = get_next_char(); | 225 | int line, c = get_next_char(); |
226 | |||
226 | if (bomptr && *bomptr) { | 227 | if (bomptr && *bomptr) { |
227 | /* We are at the file beginning; skip UTF8-encoded BOM | 228 | /* We are at the file beginning; skip UTF8-encoded BOM |
228 | * if present. Sane editors won't put this in on their | 229 | * if present. Sane editors won't put this in on their |
@@ -261,8 +262,16 @@ static int perf_parse_file(config_fn_t fn, void *data) | |||
261 | if (!isalpha(c)) | 262 | if (!isalpha(c)) |
262 | break; | 263 | break; |
263 | var[baselen] = tolower(c); | 264 | var[baselen] = tolower(c); |
264 | if (get_value(fn, data, var, baselen+1) < 0) | 265 | |
266 | /* | ||
267 | * The get_value function might or might not reach the '\n', | ||
268 | * so saving the current line number for error reporting. | ||
269 | */ | ||
270 | line = config_linenr; | ||
271 | if (get_value(fn, data, var, baselen+1) < 0) { | ||
272 | config_linenr = line; | ||
265 | break; | 273 | break; |
274 | } | ||
266 | } | 275 | } |
267 | die("bad config file line %d in %s", config_linenr, config_file_name); | 276 | die("bad config file line %d in %s", config_linenr, config_file_name); |
268 | } | 277 | } |
@@ -286,6 +295,21 @@ static int parse_unit_factor(const char *end, unsigned long *val) | |||
286 | return 0; | 295 | return 0; |
287 | } | 296 | } |
288 | 297 | ||
298 | static int perf_parse_llong(const char *value, long long *ret) | ||
299 | { | ||
300 | if (value && *value) { | ||
301 | char *end; | ||
302 | long long val = strtoll(value, &end, 0); | ||
303 | unsigned long factor = 1; | ||
304 | |||
305 | if (!parse_unit_factor(end, &factor)) | ||
306 | return 0; | ||
307 | *ret = val * factor; | ||
308 | return 1; | ||
309 | } | ||
310 | return 0; | ||
311 | } | ||
312 | |||
289 | static int perf_parse_long(const char *value, long *ret) | 313 | static int perf_parse_long(const char *value, long *ret) |
290 | { | 314 | { |
291 | if (value && *value) { | 315 | if (value && *value) { |
@@ -307,6 +331,15 @@ static void die_bad_config(const char *name) | |||
307 | die("bad config value for '%s'", name); | 331 | die("bad config value for '%s'", name); |
308 | } | 332 | } |
309 | 333 | ||
334 | u64 perf_config_u64(const char *name, const char *value) | ||
335 | { | ||
336 | long long ret = 0; | ||
337 | |||
338 | if (!perf_parse_llong(value, &ret)) | ||
339 | die_bad_config(name); | ||
340 | return (u64) ret; | ||
341 | } | ||
342 | |||
310 | int perf_config_int(const char *name, const char *value) | 343 | int perf_config_int(const char *name, const char *value) |
311 | { | 344 | { |
312 | long ret = 0; | 345 | long ret = 0; |
@@ -372,6 +405,9 @@ int perf_default_config(const char *var, const char *value, | |||
372 | if (!prefixcmp(var, "ui.")) | 405 | if (!prefixcmp(var, "ui.")) |
373 | return perf_ui_config(var, value); | 406 | return perf_ui_config(var, value); |
374 | 407 | ||
408 | if (!prefixcmp(var, "call-graph.")) | ||
409 | return perf_callchain_config(var, value); | ||
410 | |||
375 | /* Add other config variables here. */ | 411 | /* Add other config variables here. */ |
376 | return 0; | 412 | return 0; |
377 | } | 413 | } |