aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/session.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-02-03 13:52:00 -0500
committerIngo Molnar <mingo@elte.hu>2010-02-04 03:33:24 -0500
commit9de89fe7c577847877ae00ea1aa6315559b10243 (patch)
tree523bcd2c2b1e2a839100b472ff864860cdc8caeb /tools/perf/util/session.c
parentb8f46c5a34fa64fd456295388d18f50ae69d9f37 (diff)
perf symbols: Remove perf_session usage in symbols layer
I noticed while writing the first test in 'perf regtest' that to just test the symbol handling routines one needs to create a perf session, that is a layer centered on a perf.data file, events, etc, so I untied these layers. This reduces the complexity for the users as the number of parameters to most of the symbols and session APIs now was reduced while not adding more state to all the map instances by only having data that is needed to split the kernel (kallsyms and ELF symtab sections) maps and do vmlinux relocation on the main kernel map. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1265223128-11786-1-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r--tools/perf/util/session.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index cf91d099f0aa..aa8a03120bbd 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -53,6 +53,11 @@ out_close:
53 return -1; 53 return -1;
54} 54}
55 55
56static inline int perf_session__create_kernel_maps(struct perf_session *self)
57{
58 return map_groups__create_kernel_maps(&self->kmaps, self->vmlinux_maps);
59}
60
56struct perf_session *perf_session__new(const char *filename, int mode, bool force) 61struct perf_session *perf_session__new(const char *filename, int mode, bool force)
57{ 62{
58 size_t len = filename ? strlen(filename) + 1 : 0; 63 size_t len = filename ? strlen(filename) + 1 : 0;
@@ -507,6 +512,7 @@ int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,
507 u64 addr) 512 u64 addr)
508{ 513{
509 char *bracket; 514 char *bracket;
515 enum map_type i;
510 516
511 self->ref_reloc_sym.name = strdup(symbol_name); 517 self->ref_reloc_sym.name = strdup(symbol_name);
512 if (self->ref_reloc_sym.name == NULL) 518 if (self->ref_reloc_sym.name == NULL)
@@ -517,6 +523,12 @@ int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,
517 *bracket = '\0'; 523 *bracket = '\0';
518 524
519 self->ref_reloc_sym.addr = addr; 525 self->ref_reloc_sym.addr = addr;
526
527 for (i = 0; i < MAP__NR_TYPES; ++i) {
528 struct kmap *kmap = map__kmap(self->vmlinux_maps[i]);
529 kmap->ref_reloc_sym = &self->ref_reloc_sym;
530 }
531
520 return 0; 532 return 0;
521} 533}
522 534
@@ -530,20 +542,21 @@ static u64 map__reloc_unmap_ip(struct map *map, u64 ip)
530 return ip - (s64)map->pgoff; 542 return ip - (s64)map->pgoff;
531} 543}
532 544
533void perf_session__reloc_vmlinux_maps(struct perf_session *self, 545void map__reloc_vmlinux(struct map *self)
534 u64 unrelocated_addr)
535{ 546{
536 enum map_type type; 547 struct kmap *kmap = map__kmap(self);
537 s64 reloc = unrelocated_addr - self->ref_reloc_sym.addr; 548 s64 reloc;
538 549
539 if (!reloc) 550 if (!kmap->ref_reloc_sym || !kmap->ref_reloc_sym->unrelocated_addr)
540 return; 551 return;
541 552
542 for (type = 0; type < MAP__NR_TYPES; ++type) { 553 reloc = (kmap->ref_reloc_sym->unrelocated_addr -
543 struct map *map = self->vmlinux_maps[type]; 554 kmap->ref_reloc_sym->addr);
544 555
545 map->map_ip = map__reloc_map_ip; 556 if (!reloc)
546 map->unmap_ip = map__reloc_unmap_ip; 557 return;
547 map->pgoff = reloc; 558
548 } 559 self->map_ip = map__reloc_map_ip;
560 self->unmap_ip = map__reloc_unmap_ip;
561 self->pgoff = reloc;
549} 562}