diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-05-27 02:38:48 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-05-27 03:10:37 -0400 |
commit | af83632f98aefd1ae4d8ca3c7c285ccf6a7d3956 (patch) | |
tree | 2bed3ef8037644f03c7bc30447b44585cb01d83e /Documentation | |
parent | 03f6316d32738ec5eda2e6f628c12d1c01e61a87 (diff) |
perf report: Only load text symbols from kallsyms, fix
- allow 'W' symbols too
- Convert initializations to C99 style
- whitespace cleanups
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: John Kacur <jkacur@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <20090526222155.GJ4424@ghostprotocols.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/perf_counter/builtin-report.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c index a55f15d7651d..ed3da9d61985 100644 --- a/Documentation/perf_counter/builtin-report.c +++ b/Documentation/perf_counter/builtin-report.c | |||
@@ -384,21 +384,26 @@ int hex2long(char *ptr, unsigned long *long_val) | |||
384 | 384 | ||
385 | static int load_kallsyms(void) | 385 | static int load_kallsyms(void) |
386 | { | 386 | { |
387 | struct rb_node *nd, *prevnd; | ||
388 | char *line = NULL; | ||
389 | FILE *file; | ||
390 | size_t n; | ||
391 | |||
387 | kernel_dso = dso__new("[kernel]"); | 392 | kernel_dso = dso__new("[kernel]"); |
388 | if (kernel_dso == NULL) | 393 | if (kernel_dso == NULL) |
389 | return -1; | 394 | return -1; |
390 | 395 | ||
391 | FILE *file = fopen("/proc/kallsyms", "r"); | 396 | file = fopen("/proc/kallsyms", "r"); |
392 | |||
393 | if (file == NULL) | 397 | if (file == NULL) |
394 | goto out_delete_dso; | 398 | goto out_delete_dso; |
395 | 399 | ||
396 | char *line = NULL; | ||
397 | size_t n; | ||
398 | |||
399 | while (!feof(file)) { | 400 | while (!feof(file)) { |
400 | unsigned long start; | 401 | unsigned long start; |
401 | int line_len = getline(&line, &n, file); | 402 | struct symbol *sym; |
403 | int line_len, len; | ||
404 | char symbol_type; | ||
405 | |||
406 | line_len = getline(&line, &n, file); | ||
402 | if (line_len < 0) | 407 | if (line_len < 0) |
403 | break; | 408 | break; |
404 | 409 | ||
@@ -407,22 +412,22 @@ static int load_kallsyms(void) | |||
407 | 412 | ||
408 | line[--line_len] = '\0'; /* \n */ | 413 | line[--line_len] = '\0'; /* \n */ |
409 | 414 | ||
410 | int len = hex2long(line, &start); | 415 | len = hex2long(line, &start); |
411 | 416 | ||
412 | len++; | 417 | len++; |
413 | if (len + 2 >= line_len) | 418 | if (len + 2 >= line_len) |
414 | continue; | 419 | continue; |
415 | 420 | ||
416 | char symbol_type = line[len]; | 421 | symbol_type = toupper(line[len]); |
417 | /* | 422 | /* |
418 | * We're interested only in code ('T'ext) | 423 | * We're interested only in code ('T'ext) |
419 | */ | 424 | */ |
420 | if (toupper(symbol_type) != 'T') | 425 | if (symbol_type != 'T' && symbol_type != 'W') |
421 | continue; | 426 | continue; |
422 | /* | 427 | /* |
423 | * Well fix up the end later, when we have all sorted. | 428 | * Well fix up the end later, when we have all sorted. |
424 | */ | 429 | */ |
425 | struct symbol *sym = symbol__new(start, 0xdead, line + len + 2); | 430 | sym = symbol__new(start, 0xdead, line + len + 2); |
426 | 431 | ||
427 | if (sym == NULL) | 432 | if (sym == NULL) |
428 | goto out_delete_dso; | 433 | goto out_delete_dso; |
@@ -434,7 +439,7 @@ static int load_kallsyms(void) | |||
434 | * Now that we have all sorted out, just set the ->end of all | 439 | * Now that we have all sorted out, just set the ->end of all |
435 | * symbols | 440 | * symbols |
436 | */ | 441 | */ |
437 | struct rb_node *nd, *prevnd = rb_first(&kernel_dso->syms); | 442 | prevnd = rb_first(&kernel_dso->syms); |
438 | 443 | ||
439 | if (prevnd == NULL) | 444 | if (prevnd == NULL) |
440 | goto out_delete_line; | 445 | goto out_delete_line; |
@@ -450,6 +455,7 @@ static int load_kallsyms(void) | |||
450 | dsos__add(kernel_dso); | 455 | dsos__add(kernel_dso); |
451 | free(line); | 456 | free(line); |
452 | fclose(file); | 457 | fclose(file); |
458 | |||
453 | return 0; | 459 | return 0; |
454 | 460 | ||
455 | out_delete_line: | 461 | out_delete_line: |