-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux…
…/kernel/git/acme/linux into perf/core Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: Fixes: * Fix inverted error verification bug in thread__fork, from David Ahern. New features: * Shell completion for 'perf kvm', from Ramkumar Ramachandra. Refactorings: * Get rid of panic() like calls in libtraceevent, from Namyung Kim. * Start carving out symbol parsing routines from perf, just moving routines to topic files in tools/lib/symbol/, tools that want to use it need to integrate it directly, i.e. no tools/lib/symbol/Makefile is provided. * Assorted refactoring patches, moving code around and adding utility evlist methods that will be used in the IPT patchset, from Adrian Hunter. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
- Loading branch information
Showing
21 changed files
with
550 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "symbol/kallsyms.h" | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int kallsyms__parse(const char *filename, void *arg, | ||
int (*process_symbol)(void *arg, const char *name, | ||
char type, u64 start)) | ||
{ | ||
char *line = NULL; | ||
size_t n; | ||
int err = -1; | ||
FILE *file = fopen(filename, "r"); | ||
|
||
if (file == NULL) | ||
goto out_failure; | ||
|
||
err = 0; | ||
|
||
while (!feof(file)) { | ||
u64 start; | ||
int line_len, len; | ||
char symbol_type; | ||
char *symbol_name; | ||
|
||
line_len = getline(&line, &n, file); | ||
if (line_len < 0 || !line) | ||
break; | ||
|
||
line[--line_len] = '\0'; /* \n */ | ||
|
||
len = hex2u64(line, &start); | ||
|
||
len++; | ||
if (len + 2 >= line_len) | ||
continue; | ||
|
||
symbol_type = line[len]; | ||
len += 2; | ||
symbol_name = line + len; | ||
len = line_len - len; | ||
|
||
if (len >= KSYM_NAME_LEN) { | ||
err = -1; | ||
break; | ||
} | ||
|
||
err = process_symbol(arg, symbol_name, symbol_type, start); | ||
if (err) | ||
break; | ||
} | ||
|
||
free(line); | ||
fclose(file); | ||
return err; | ||
|
||
out_failure: | ||
return -1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef __TOOLS_KALLSYMS_H_ | ||
#define __TOOLS_KALLSYMS_H_ 1 | ||
|
||
#include <elf.h> | ||
#include <linux/ctype.h> | ||
#include <linux/types.h> | ||
|
||
#ifndef KSYM_NAME_LEN | ||
#define KSYM_NAME_LEN 256 | ||
#endif | ||
|
||
static inline u8 kallsyms2elf_type(char type) | ||
{ | ||
if (type == 'W') | ||
return STB_WEAK; | ||
|
||
return isupper(type) ? STB_GLOBAL : STB_LOCAL; | ||
} | ||
|
||
int kallsyms__parse(const char *filename, void *arg, | ||
int (*process_symbol)(void *arg, const char *name, | ||
char type, u64 start)); | ||
|
||
#endif /* __TOOLS_KALLSYMS_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.