perf tools: Add kallsyms__get_function_start()
Separate out the logic used to find the start address of the reference symbol used to track kernel relocation. kallsyms__get_function_start() is used in subsequent patches. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Tested-by: Jiri Olsa <jolsa@redhat.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1391004884-10334-3-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
9176753d1e
commit
29b596b574
|
@ -470,6 +470,17 @@ static int find_symbol_cb(void *arg, const char *name, char type,
|
|||
return 1;
|
||||
}
|
||||
|
||||
u64 kallsyms__get_function_start(const char *kallsyms_filename,
|
||||
const char *symbol_name)
|
||||
{
|
||||
struct process_symbol_args args = { .name = symbol_name, };
|
||||
|
||||
if (kallsyms__parse(kallsyms_filename, &args, find_symbol_cb) <= 0)
|
||||
return 0;
|
||||
|
||||
return args.start;
|
||||
}
|
||||
|
||||
int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
|
||||
perf_event__handler_t process,
|
||||
struct machine *machine,
|
||||
|
@ -480,13 +491,13 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
|
|||
char path[PATH_MAX];
|
||||
char name_buff[PATH_MAX];
|
||||
struct map *map;
|
||||
u64 start;
|
||||
int err;
|
||||
/*
|
||||
* We should get this from /sys/kernel/sections/.text, but till that is
|
||||
* available use this, and after it is use this as a fallback for older
|
||||
* kernels.
|
||||
*/
|
||||
struct process_symbol_args args = { .name = symbol_name, };
|
||||
union perf_event *event = zalloc((sizeof(event->mmap) +
|
||||
machine->id_hdr_size));
|
||||
if (event == NULL) {
|
||||
|
@ -513,7 +524,8 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
|
|||
}
|
||||
}
|
||||
|
||||
if (kallsyms__parse(filename, &args, find_symbol_cb) <= 0) {
|
||||
start = kallsyms__get_function_start(filename, symbol_name);
|
||||
if (!start) {
|
||||
free(event);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
@ -525,7 +537,7 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
|
|||
event->mmap.header.type = PERF_RECORD_MMAP;
|
||||
event->mmap.header.size = (sizeof(event->mmap) -
|
||||
(sizeof(event->mmap.filename) - size) + machine->id_hdr_size);
|
||||
event->mmap.pgoff = args.start;
|
||||
event->mmap.pgoff = start;
|
||||
event->mmap.start = map->start;
|
||||
event->mmap.len = map->end - event->mmap.start;
|
||||
event->mmap.pid = machine->pid;
|
||||
|
|
|
@ -279,4 +279,7 @@ size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp);
|
|||
size_t perf_event__fprintf_task(union perf_event *event, FILE *fp);
|
||||
size_t perf_event__fprintf(union perf_event *event, FILE *fp);
|
||||
|
||||
u64 kallsyms__get_function_start(const char *kallsyms_filename,
|
||||
const char *symbol_name);
|
||||
|
||||
#endif /* __PERF_RECORD_H */
|
||||
|
|
Loading…
Reference in a new issue