aboutsummaryrefslogtreecommitdiff
path: root/Documentation
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-05-27 08:38:48 +0200
committerIngo Molnar <mingo@elte.hu>2009-05-27 09:10:37 +0200
commitaf83632f98aefd1ae4d8ca3c7c285ccf6a7d3956 (patch)
tree2bed3ef8037644f03c7bc30447b44585cb01d83e /Documentation
parent03f6316d32738ec5eda2e6f628c12d1c01e61a87 (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.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c
index a55f15d7651..ed3da9d6198 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)
static int load_kallsyms(void)
{
+ struct rb_node *nd, *prevnd;
+ char *line = NULL;
+ FILE *file;
+ size_t n;
+
kernel_dso = dso__new("[kernel]");
if (kernel_dso == NULL)
return -1;
- FILE *file = fopen("/proc/kallsyms", "r");
-
+ file = fopen("/proc/kallsyms", "r");
if (file == NULL)
goto out_delete_dso;
- char *line = NULL;
- size_t n;
-
while (!feof(file)) {
unsigned long start;
- int line_len = getline(&line, &n, file);
+ struct symbol *sym;
+ int line_len, len;
+ char symbol_type;
+
+ line_len = getline(&line, &n, file);
if (line_len < 0)
break;
@@ -407,22 +412,22 @@ static int load_kallsyms(void)
line[--line_len] = '\0'; /* \n */
- int len = hex2long(line, &start);
-
+ len = hex2long(line, &start);
+
len++;
if (len + 2 >= line_len)
continue;
- char symbol_type = line[len];
+ symbol_type = toupper(line[len]);
/*
* We're interested only in code ('T'ext)
*/
- if (toupper(symbol_type) != 'T')
+ if (symbol_type != 'T' && symbol_type != 'W')
continue;
/*
* Well fix up the end later, when we have all sorted.
*/
- struct symbol *sym = symbol__new(start, 0xdead, line + len + 2);
+ sym = symbol__new(start, 0xdead, line + len + 2);
if (sym == NULL)
goto out_delete_dso;
@@ -434,7 +439,7 @@ static int load_kallsyms(void)
* Now that we have all sorted out, just set the ->end of all
* symbols
*/
- struct rb_node *nd, *prevnd = rb_first(&kernel_dso->syms);
+ prevnd = rb_first(&kernel_dso->syms);
if (prevnd == NULL)
goto out_delete_line;
@@ -450,6 +455,7 @@ static int load_kallsyms(void)
dsos__add(kernel_dso);
free(line);
fclose(file);
+
return 0;
out_delete_line: