aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-11-09 09:32:52 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-11-09 09:32:52 -0500
commit69d2591a829132492662bbfe164fcde5e44ad1c4 (patch)
tree980dd4ff2e59c021f63ca82ef13427f3a70a7656
parentbfaef4b46b17ff053dc38f979cec364b0715cabb (diff)
perf machine: Move more methods to machine.[ch]
This time out of map.[ch] mostly, just code move plus a buch of 'self' removal, using machine or machines instead. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.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 <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-j1vtux3vnu6wzmrjutpxnjcz@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/tests/builtin-test.c1
-rw-r--r--tools/perf/tests/dso-data.c1
-rw-r--r--tools/perf/util/dso.c1
-rw-r--r--tools/perf/util/machine.c183
-rw-r--r--tools/perf/util/machine.h131
-rw-r--r--tools/perf/util/map.c179
-rw-r--r--tools/perf/util/map.h93
-rw-r--r--tools/perf/util/session.h5
-rw-r--r--tools/perf/util/symbol.c1
-rw-r--r--tools/perf/util/symbol.h20
10 files changed, 318 insertions, 297 deletions
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 1aa9e9927043..b5a544d1b381 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -10,6 +10,7 @@
10#include "util/debug.h" 10#include "util/debug.h"
11#include "util/debugfs.h" 11#include "util/debugfs.h"
12#include "util/evlist.h" 12#include "util/evlist.h"
13#include "util/machine.h"
13#include "util/parse-options.h" 14#include "util/parse-options.h"
14#include "util/parse-events.h" 15#include "util/parse-events.h"
15#include "util/symbol.h" 16#include "util/symbol.h"
diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c
index c6caedeb1d6b..0cd42fc9bc13 100644
--- a/tools/perf/tests/dso-data.c
+++ b/tools/perf/tests/dso-data.c
@@ -6,6 +6,7 @@
6#include <fcntl.h> 6#include <fcntl.h>
7#include <string.h> 7#include <string.h>
8 8
9#include "machine.h"
9#include "symbol.h" 10#include "symbol.h"
10 11
11#define TEST_ASSERT_VAL(text, cond) \ 12#define TEST_ASSERT_VAL(text, cond) \
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index db24a3f0c820..d6d9a465acdb 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -1,5 +1,6 @@
1#include "symbol.h" 1#include "symbol.h"
2#include "dso.h" 2#include "dso.h"
3#include "machine.h"
3#include "util.h" 4#include "util.h"
4#include "debug.h" 5#include "debug.h"
5 6
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 4c6754ac6b20..1f09d0581e6b 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -2,9 +2,192 @@
2#include "event.h" 2#include "event.h"
3#include "machine.h" 3#include "machine.h"
4#include "map.h" 4#include "map.h"
5#include "strlist.h"
5#include "thread.h" 6#include "thread.h"
6#include <stdbool.h> 7#include <stdbool.h>
7 8
9int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
10{
11 map_groups__init(&machine->kmaps);
12 RB_CLEAR_NODE(&machine->rb_node);
13 INIT_LIST_HEAD(&machine->user_dsos);
14 INIT_LIST_HEAD(&machine->kernel_dsos);
15
16 machine->threads = RB_ROOT;
17 INIT_LIST_HEAD(&machine->dead_threads);
18 machine->last_match = NULL;
19
20 machine->kmaps.machine = machine;
21 machine->pid = pid;
22
23 machine->root_dir = strdup(root_dir);
24 if (machine->root_dir == NULL)
25 return -ENOMEM;
26
27 if (pid != HOST_KERNEL_ID) {
28 struct thread *thread = machine__findnew_thread(machine, pid);
29 char comm[64];
30
31 if (thread == NULL)
32 return -ENOMEM;
33
34 snprintf(comm, sizeof(comm), "[guest/%d]", pid);
35 thread__set_comm(thread, comm);
36 }
37
38 return 0;
39}
40
41static void dsos__delete(struct list_head *dsos)
42{
43 struct dso *pos, *n;
44
45 list_for_each_entry_safe(pos, n, dsos, node) {
46 list_del(&pos->node);
47 dso__delete(pos);
48 }
49}
50
51void machine__exit(struct machine *machine)
52{
53 map_groups__exit(&machine->kmaps);
54 dsos__delete(&machine->user_dsos);
55 dsos__delete(&machine->kernel_dsos);
56 free(machine->root_dir);
57 machine->root_dir = NULL;
58}
59
60void machine__delete(struct machine *machine)
61{
62 machine__exit(machine);
63 free(machine);
64}
65
66struct machine *machines__add(struct rb_root *machines, pid_t pid,
67 const char *root_dir)
68{
69 struct rb_node **p = &machines->rb_node;
70 struct rb_node *parent = NULL;
71 struct machine *pos, *machine = malloc(sizeof(*machine));
72
73 if (machine == NULL)
74 return NULL;
75
76 if (machine__init(machine, root_dir, pid) != 0) {
77 free(machine);
78 return NULL;
79 }
80
81 while (*p != NULL) {
82 parent = *p;
83 pos = rb_entry(parent, struct machine, rb_node);
84 if (pid < pos->pid)
85 p = &(*p)->rb_left;
86 else
87 p = &(*p)->rb_right;
88 }
89
90 rb_link_node(&machine->rb_node, parent, p);
91 rb_insert_color(&machine->rb_node, machines);
92
93 return machine;
94}
95
96struct machine *machines__find(struct rb_root *machines, pid_t pid)
97{
98 struct rb_node **p = &machines->rb_node;
99 struct rb_node *parent = NULL;
100 struct machine *machine;
101 struct machine *default_machine = NULL;
102
103 while (*p != NULL) {
104 parent = *p;
105 machine = rb_entry(parent, struct machine, rb_node);
106 if (pid < machine->pid)
107 p = &(*p)->rb_left;
108 else if (pid > machine->pid)
109 p = &(*p)->rb_right;
110 else
111 return machine;
112 if (!machine->pid)
113 default_machine = machine;
114 }
115
116 return default_machine;
117}
118
119struct machine *machines__findnew(struct rb_root *machines, pid_t pid)
120{
121 char path[PATH_MAX];
122 const char *root_dir = "";
123 struct machine *machine = machines__find(machines, pid);
124
125 if (machine && (machine->pid == pid))
126 goto out;
127
128 if ((pid != HOST_KERNEL_ID) &&
129 (pid != DEFAULT_GUEST_KERNEL_ID) &&
130 (symbol_conf.guestmount)) {
131 sprintf(path, "%s/%d", symbol_conf.guestmount, pid);
132 if (access(path, R_OK)) {
133 static struct strlist *seen;
134
135 if (!seen)
136 seen = strlist__new(true, NULL);
137
138 if (!strlist__has_entry(seen, path)) {
139 pr_err("Can't access file %s\n", path);
140 strlist__add(seen, path);
141 }
142 machine = NULL;
143 goto out;
144 }
145 root_dir = path;
146 }
147
148 machine = machines__add(machines, pid, root_dir);
149out:
150 return machine;
151}
152
153void machines__process(struct rb_root *machines,
154 machine__process_t process, void *data)
155{
156 struct rb_node *nd;
157
158 for (nd = rb_first(machines); nd; nd = rb_next(nd)) {
159 struct machine *pos = rb_entry(nd, struct machine, rb_node);
160 process(pos, data);
161 }
162}
163
164char *machine__mmap_name(struct machine *machine, char *bf, size_t size)
165{
166 if (machine__is_host(machine))
167 snprintf(bf, size, "[%s]", "kernel.kallsyms");
168 else if (machine__is_default_guest(machine))
169 snprintf(bf, size, "[%s]", "guest.kernel.kallsyms");
170 else {
171 snprintf(bf, size, "[%s.%d]", "guest.kernel.kallsyms",
172 machine->pid);
173 }
174
175 return bf;
176}
177
178void machines__set_id_hdr_size(struct rb_root *machines, u16 id_hdr_size)
179{
180 struct rb_node *node;
181 struct machine *machine;
182
183 for (node = rb_first(machines); node; node = rb_next(node)) {
184 machine = rb_entry(node, struct machine, rb_node);
185 machine->id_hdr_size = id_hdr_size;
186 }
187
188 return;
189}
190
8static struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, 191static struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid,
9 bool create) 192 bool create)
10{ 193{
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index df152f1768be..b7cde7467d55 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -2,11 +2,40 @@
2#define __PERF_MACHINE_H 2#define __PERF_MACHINE_H
3 3
4#include <sys/types.h> 4#include <sys/types.h>
5#include <linux/rbtree.h>
6#include "map.h"
5 7
8struct branch_stack;
9struct perf_evsel;
10struct perf_sample;
11struct symbol;
6struct thread; 12struct thread;
7struct machine;
8union perf_event; 13union perf_event;
9 14
15/* Native host kernel uses -1 as pid index in machine */
16#define HOST_KERNEL_ID (-1)
17#define DEFAULT_GUEST_KERNEL_ID (0)
18
19struct machine {
20 struct rb_node rb_node;
21 pid_t pid;
22 u16 id_hdr_size;
23 char *root_dir;
24 struct rb_root threads;
25 struct list_head dead_threads;
26 struct thread *last_match;
27 struct list_head user_dsos;
28 struct list_head kernel_dsos;
29 struct map_groups kmaps;
30 struct map *vmlinux_maps[MAP__NR_TYPES];
31};
32
33static inline
34struct map *machine__kernel_map(struct machine *machine, enum map_type type)
35{
36 return machine->vmlinux_maps[type];
37}
38
10struct thread *machine__find_thread(struct machine *machine, pid_t pid); 39struct thread *machine__find_thread(struct machine *machine, pid_t pid);
11 40
12int machine__process_comm_event(struct machine *machine, union perf_event *event); 41int machine__process_comm_event(struct machine *machine, union perf_event *event);
@@ -16,4 +45,104 @@ int machine__process_lost_event(struct machine *machine, union perf_event *event
16int machine__process_mmap_event(struct machine *machine, union perf_event *event); 45int machine__process_mmap_event(struct machine *machine, union perf_event *event);
17int machine__process_event(struct machine *machine, union perf_event *event); 46int machine__process_event(struct machine *machine, union perf_event *event);
18 47
48typedef void (*machine__process_t)(struct machine *machine, void *data);
49
50void machines__process(struct rb_root *machines,
51 machine__process_t process, void *data);
52
53struct machine *machines__add(struct rb_root *machines, pid_t pid,
54 const char *root_dir);
55struct machine *machines__find_host(struct rb_root *machines);
56struct machine *machines__find(struct rb_root *machines, pid_t pid);
57struct machine *machines__findnew(struct rb_root *machines, pid_t pid);
58
59void machines__set_id_hdr_size(struct rb_root *machines, u16 id_hdr_size);
60char *machine__mmap_name(struct machine *machine, char *bf, size_t size);
61
62int machine__init(struct machine *machine, const char *root_dir, pid_t pid);
63void machine__exit(struct machine *machine);
64void machine__delete(struct machine *machine);
65
66
67struct branch_info *machine__resolve_bstack(struct machine *machine,
68 struct thread *thread,
69 struct branch_stack *bs);
70int machine__resolve_callchain(struct machine *machine,
71 struct perf_evsel *evsel,
72 struct thread *thread,
73 struct perf_sample *sample,
74 struct symbol **parent);
75
76/*
77 * Default guest kernel is defined by parameter --guestkallsyms
78 * and --guestmodules
79 */
80static inline bool machine__is_default_guest(struct machine *machine)
81{
82 return machine ? machine->pid == DEFAULT_GUEST_KERNEL_ID : false;
83}
84
85static inline bool machine__is_host(struct machine *machine)
86{
87 return machine ? machine->pid == HOST_KERNEL_ID : false;
88}
89
90struct thread *machine__findnew_thread(struct machine *machine, pid_t pid);
91void machine__remove_thread(struct machine *machine, struct thread *th);
92
93size_t machine__fprintf(struct machine *machine, FILE *fp);
94
95static inline
96struct symbol *machine__find_kernel_symbol(struct machine *machine,
97 enum map_type type, u64 addr,
98 struct map **mapp,
99 symbol_filter_t filter)
100{
101 return map_groups__find_symbol(&machine->kmaps, type, addr,
102 mapp, filter);
103}
104
105static inline
106struct symbol *machine__find_kernel_function(struct machine *machine, u64 addr,
107 struct map **mapp,
108 symbol_filter_t filter)
109{
110 return machine__find_kernel_symbol(machine, MAP__FUNCTION, addr,
111 mapp, filter);
112}
113
114static inline
115struct symbol *machine__find_kernel_function_by_name(struct machine *machine,
116 const char *name,
117 struct map **mapp,
118 symbol_filter_t filter)
119{
120 return map_groups__find_function_by_name(&machine->kmaps, name, mapp,
121 filter);
122}
123
124struct map *machine__new_module(struct machine *machine, u64 start,
125 const char *filename);
126
127int machine__load_kallsyms(struct machine *machine, const char *filename,
128 enum map_type type, symbol_filter_t filter);
129int machine__load_vmlinux_path(struct machine *machine, enum map_type type,
130 symbol_filter_t filter);
131
132size_t machine__fprintf_dsos_buildid(struct machine *machine,
133 FILE *fp, bool with_hits);
134size_t machines__fprintf_dsos(struct rb_root *machines, FILE *fp);
135size_t machines__fprintf_dsos_buildid(struct rb_root *machines,
136 FILE *fp, bool with_hits);
137
138void machine__destroy_kernel_maps(struct machine *machine);
139int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel);
140int machine__create_kernel_maps(struct machine *machine);
141
142int machines__create_kernel_maps(struct rb_root *machines, pid_t pid);
143int machines__create_guest_kernel_maps(struct rb_root *machines);
144void machines__destroy_guest_kernel_maps(struct rb_root *machines);
145
146size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp);
147
19#endif /* __PERF_MACHINE_H */ 148#endif /* __PERF_MACHINE_H */
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 579187865f08..0328d45c4f2a 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -590,182 +590,3 @@ struct map *maps__find(struct rb_root *maps, u64 ip)
590 590
591 return NULL; 591 return NULL;
592} 592}
593
594int machine__init(struct machine *self, const char *root_dir, pid_t pid)
595{
596 map_groups__init(&self->kmaps);
597 RB_CLEAR_NODE(&self->rb_node);
598 INIT_LIST_HEAD(&self->user_dsos);
599 INIT_LIST_HEAD(&self->kernel_dsos);
600
601 self->threads = RB_ROOT;
602 INIT_LIST_HEAD(&self->dead_threads);
603 self->last_match = NULL;
604
605 self->kmaps.machine = self;
606 self->pid = pid;
607 self->root_dir = strdup(root_dir);
608 if (self->root_dir == NULL)
609 return -ENOMEM;
610
611 if (pid != HOST_KERNEL_ID) {
612 struct thread *thread = machine__findnew_thread(self, pid);
613 char comm[64];
614
615 if (thread == NULL)
616 return -ENOMEM;
617
618 snprintf(comm, sizeof(comm), "[guest/%d]", pid);
619 thread__set_comm(thread, comm);
620 }
621
622 return 0;
623}
624
625static void dsos__delete(struct list_head *self)
626{
627 struct dso *pos, *n;
628
629 list_for_each_entry_safe(pos, n, self, node) {
630 list_del(&pos->node);
631 dso__delete(pos);
632 }
633}
634
635void machine__exit(struct machine *self)
636{
637 map_groups__exit(&self->kmaps);
638 dsos__delete(&self->user_dsos);
639 dsos__delete(&self->kernel_dsos);
640 free(self->root_dir);
641 self->root_dir = NULL;
642}
643
644void machine__delete(struct machine *self)
645{
646 machine__exit(self);
647 free(self);
648}
649
650struct machine *machines__add(struct rb_root *self, pid_t pid,
651 const char *root_dir)
652{
653 struct rb_node **p = &self->rb_node;
654 struct rb_node *parent = NULL;
655 struct machine *pos, *machine = malloc(sizeof(*machine));
656
657 if (!machine)
658 return NULL;
659
660 if (machine__init(machine, root_dir, pid) != 0) {
661 free(machine);
662 return NULL;
663 }
664
665 while (*p != NULL) {
666 parent = *p;
667 pos = rb_entry(parent, struct machine, rb_node);
668 if (pid < pos->pid)
669 p = &(*p)->rb_left;
670 else
671 p = &(*p)->rb_right;
672 }
673
674 rb_link_node(&machine->rb_node, parent, p);
675 rb_insert_color(&machine->rb_node, self);
676
677 return machine;
678}
679
680struct machine *machines__find(struct rb_root *self, pid_t pid)
681{
682 struct rb_node **p = &self->rb_node;
683 struct rb_node *parent = NULL;
684 struct machine *machine;
685 struct machine *default_machine = NULL;
686
687 while (*p != NULL) {
688 parent = *p;
689 machine = rb_entry(parent, struct machine, rb_node);
690 if (pid < machine->pid)
691 p = &(*p)->rb_left;
692 else if (pid > machine->pid)
693 p = &(*p)->rb_right;
694 else
695 return machine;
696 if (!machine->pid)
697 default_machine = machine;
698 }
699
700 return default_machine;
701}
702
703struct machine *machines__findnew(struct rb_root *self, pid_t pid)
704{
705 char path[PATH_MAX];
706 const char *root_dir = "";
707 struct machine *machine = machines__find(self, pid);
708
709 if (machine && (machine->pid == pid))
710 goto out;
711
712 if ((pid != HOST_KERNEL_ID) &&
713 (pid != DEFAULT_GUEST_KERNEL_ID) &&
714 (symbol_conf.guestmount)) {
715 sprintf(path, "%s/%d", symbol_conf.guestmount, pid);
716 if (access(path, R_OK)) {
717 static struct strlist *seen;
718
719 if (!seen)
720 seen = strlist__new(true, NULL);
721
722 if (!strlist__has_entry(seen, path)) {
723 pr_err("Can't access file %s\n", path);
724 strlist__add(seen, path);
725 }
726 machine = NULL;
727 goto out;
728 }
729 root_dir = path;
730 }
731
732 machine = machines__add(self, pid, root_dir);
733
734out:
735 return machine;
736}
737
738void machines__process(struct rb_root *self, machine__process_t process, void *data)
739{
740 struct rb_node *nd;
741
742 for (nd = rb_first(self); nd; nd = rb_next(nd)) {
743 struct machine *pos = rb_entry(nd, struct machine, rb_node);
744 process(pos, data);
745 }
746}
747
748char *machine__mmap_name(struct machine *self, char *bf, size_t size)
749{
750 if (machine__is_host(self))
751 snprintf(bf, size, "[%s]", "kernel.kallsyms");
752 else if (machine__is_default_guest(self))
753 snprintf(bf, size, "[%s]", "guest.kernel.kallsyms");
754 else
755 snprintf(bf, size, "[%s.%d]", "guest.kernel.kallsyms", self->pid);
756
757 return bf;
758}
759
760void machines__set_id_hdr_size(struct rb_root *machines, u16 id_hdr_size)
761{
762 struct rb_node *node;
763 struct machine *machine;
764
765 for (node = rb_first(machines); node; node = rb_next(node)) {
766 machine = rb_entry(node, struct machine, rb_node);
767 machine->id_hdr_size = id_hdr_size;
768 }
769
770 return;
771}
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index d2250fc97e25..bcb39e2a6965 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -57,30 +57,6 @@ struct map_groups {
57 struct machine *machine; 57 struct machine *machine;
58}; 58};
59 59
60/* Native host kernel uses -1 as pid index in machine */
61#define HOST_KERNEL_ID (-1)
62#define DEFAULT_GUEST_KERNEL_ID (0)
63
64struct machine {
65 struct rb_node rb_node;
66 pid_t pid;
67 u16 id_hdr_size;
68 char *root_dir;
69 struct rb_root threads;
70 struct list_head dead_threads;
71 struct thread *last_match;
72 struct list_head user_dsos;
73 struct list_head kernel_dsos;
74 struct map_groups kmaps;
75 struct map *vmlinux_maps[MAP__NR_TYPES];
76};
77
78static inline
79struct map *machine__kernel_map(struct machine *self, enum map_type type)
80{
81 return self->vmlinux_maps[type];
82}
83
84static inline struct kmap *map__kmap(struct map *self) 60static inline struct kmap *map__kmap(struct map *self)
85{ 61{
86 return (struct kmap *)(self + 1); 62 return (struct kmap *)(self + 1);
@@ -143,44 +119,9 @@ int map_groups__clone(struct map_groups *mg,
143size_t map_groups__fprintf(struct map_groups *mg, int verbose, FILE *fp); 119size_t map_groups__fprintf(struct map_groups *mg, int verbose, FILE *fp);
144size_t map_groups__fprintf_maps(struct map_groups *mg, int verbose, FILE *fp); 120size_t map_groups__fprintf_maps(struct map_groups *mg, int verbose, FILE *fp);
145 121
146typedef void (*machine__process_t)(struct machine *self, void *data);
147
148void machines__process(struct rb_root *self, machine__process_t process, void *data);
149struct machine *machines__add(struct rb_root *self, pid_t pid,
150 const char *root_dir);
151struct machine *machines__find_host(struct rb_root *self);
152struct machine *machines__find(struct rb_root *self, pid_t pid);
153struct machine *machines__findnew(struct rb_root *self, pid_t pid);
154void machines__set_id_hdr_size(struct rb_root *self, u16 id_hdr_size);
155char *machine__mmap_name(struct machine *self, char *bf, size_t size);
156int machine__init(struct machine *self, const char *root_dir, pid_t pid);
157void machine__exit(struct machine *self);
158void machine__delete(struct machine *self);
159
160struct perf_evsel;
161struct perf_sample;
162int machine__resolve_callchain(struct machine *machine,
163 struct perf_evsel *evsel,
164 struct thread *thread,
165 struct perf_sample *sample,
166 struct symbol **parent);
167int maps__set_kallsyms_ref_reloc_sym(struct map **maps, const char *symbol_name, 122int maps__set_kallsyms_ref_reloc_sym(struct map **maps, const char *symbol_name,
168 u64 addr); 123 u64 addr);
169 124
170/*
171 * Default guest kernel is defined by parameter --guestkallsyms
172 * and --guestmodules
173 */
174static inline bool machine__is_default_guest(struct machine *self)
175{
176 return self ? self->pid == DEFAULT_GUEST_KERNEL_ID : false;
177}
178
179static inline bool machine__is_host(struct machine *self)
180{
181 return self ? self->pid == HOST_KERNEL_ID : false;
182}
183
184static inline void map_groups__insert(struct map_groups *mg, struct map *map) 125static inline void map_groups__insert(struct map_groups *mg, struct map *map)
185{ 126{
186 maps__insert(&mg->maps[map->type], map); 127 maps__insert(&mg->maps[map->type], map);
@@ -209,29 +150,6 @@ struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg,
209 struct map **mapp, 150 struct map **mapp,
210 symbol_filter_t filter); 151 symbol_filter_t filter);
211 152
212
213struct thread *machine__findnew_thread(struct machine *machine, pid_t pid);
214void machine__remove_thread(struct machine *machine, struct thread *th);
215
216size_t machine__fprintf(struct machine *machine, FILE *fp);
217
218static inline
219struct symbol *machine__find_kernel_symbol(struct machine *self,
220 enum map_type type, u64 addr,
221 struct map **mapp,
222 symbol_filter_t filter)
223{
224 return map_groups__find_symbol(&self->kmaps, type, addr, mapp, filter);
225}
226
227static inline
228struct symbol *machine__find_kernel_function(struct machine *self, u64 addr,
229 struct map **mapp,
230 symbol_filter_t filter)
231{
232 return machine__find_kernel_symbol(self, MAP__FUNCTION, addr, mapp, filter);
233}
234
235static inline 153static inline
236struct symbol *map_groups__find_function_by_name(struct map_groups *mg, 154struct symbol *map_groups__find_function_by_name(struct map_groups *mg,
237 const char *name, struct map **mapp, 155 const char *name, struct map **mapp,
@@ -240,22 +158,11 @@ struct symbol *map_groups__find_function_by_name(struct map_groups *mg,
240 return map_groups__find_symbol_by_name(mg, MAP__FUNCTION, name, mapp, filter); 158 return map_groups__find_symbol_by_name(mg, MAP__FUNCTION, name, mapp, filter);
241} 159}
242 160
243static inline
244struct symbol *machine__find_kernel_function_by_name(struct machine *self,
245 const char *name,
246 struct map **mapp,
247 symbol_filter_t filter)
248{
249 return map_groups__find_function_by_name(&self->kmaps, name, mapp,
250 filter);
251}
252
253int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, 161int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map,
254 int verbose, FILE *fp); 162 int verbose, FILE *fp);
255 163
256struct map *map_groups__find_by_name(struct map_groups *mg, 164struct map *map_groups__find_by_name(struct map_groups *mg,
257 enum map_type type, const char *name); 165 enum map_type type, const char *name);
258struct map *machine__new_module(struct machine *self, u64 start, const char *filename);
259 166
260void map_groups__flush(struct map_groups *mg); 167void map_groups__flush(struct map_groups *mg);
261 168
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index dd6426163ba6..18d1222b05a2 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -4,6 +4,7 @@
4#include "hist.h" 4#include "hist.h"
5#include "event.h" 5#include "event.h"
6#include "header.h" 6#include "header.h"
7#include "machine.h"
7#include "symbol.h" 8#include "symbol.h"
8#include "thread.h" 9#include "thread.h"
9#include <linux/rbtree.h> 10#include <linux/rbtree.h>
@@ -68,10 +69,6 @@ int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel
68 struct ip_callchain *chain, 69 struct ip_callchain *chain,
69 struct symbol **parent); 70 struct symbol **parent);
70 71
71struct branch_info *machine__resolve_bstack(struct machine *self,
72 struct thread *thread,
73 struct branch_stack *bs);
74
75bool perf_session__has_traces(struct perf_session *self, const char *msg); 72bool perf_session__has_traces(struct perf_session *self, const char *msg);
76 73
77void mem_bswap_64(void *src, int byte_size); 74void mem_bswap_64(void *src, int byte_size);
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 624c65e6ab98..295f8d4feedf 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -12,6 +12,7 @@
12#include "build-id.h" 12#include "build-id.h"
13#include "util.h" 13#include "util.h"
14#include "debug.h" 14#include "debug.h"
15#include "machine.h"
15#include "symbol.h" 16#include "symbol.h"
16#include "strlist.h" 17#include "strlist.h"
17 18
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 863b05bea5ff..04ccf2962080 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -200,16 +200,6 @@ int dso__load_vmlinux_path(struct dso *dso, struct map *map,
200 symbol_filter_t filter); 200 symbol_filter_t filter);
201int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map, 201int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map,
202 symbol_filter_t filter); 202 symbol_filter_t filter);
203int machine__load_kallsyms(struct machine *machine, const char *filename,
204 enum map_type type, symbol_filter_t filter);
205int machine__load_vmlinux_path(struct machine *machine, enum map_type type,
206 symbol_filter_t filter);
207
208size_t machine__fprintf_dsos_buildid(struct machine *machine,
209 FILE *fp, bool with_hits);
210size_t machines__fprintf_dsos(struct rb_root *machines, FILE *fp);
211size_t machines__fprintf_dsos_buildid(struct rb_root *machines,
212 FILE *fp, bool with_hits);
213 203
214struct symbol *dso__find_symbol(struct dso *dso, enum map_type type, 204struct symbol *dso__find_symbol(struct dso *dso, enum map_type type,
215 u64 addr); 205 u64 addr);
@@ -224,14 +214,6 @@ int kallsyms__parse(const char *filename, void *arg,
224int filename__read_debuglink(const char *filename, char *debuglink, 214int filename__read_debuglink(const char *filename, char *debuglink,
225 size_t size); 215 size_t size);
226 216
227void machine__destroy_kernel_maps(struct machine *machine);
228int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel);
229int machine__create_kernel_maps(struct machine *machine);
230
231int machines__create_kernel_maps(struct rb_root *machines, pid_t pid);
232int machines__create_guest_kernel_maps(struct rb_root *machines);
233void machines__destroy_guest_kernel_maps(struct rb_root *machines);
234
235int symbol__init(void); 217int symbol__init(void);
236void symbol__exit(void); 218void symbol__exit(void);
237void symbol__elf_init(void); 219void symbol__elf_init(void);
@@ -242,8 +224,6 @@ size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp);
242size_t symbol__fprintf(struct symbol *sym, FILE *fp); 224size_t symbol__fprintf(struct symbol *sym, FILE *fp);
243bool symbol_type__is_a(char symbol_type, enum map_type map_type); 225bool symbol_type__is_a(char symbol_type, enum map_type map_type);
244 226
245size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp);
246
247int dso__test_data(void); 227int dso__test_data(void);
248int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, 228int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
249 struct symsrc *runtime_ss, symbol_filter_t filter, 229 struct symsrc *runtime_ss, symbol_filter_t filter,