diff options
Diffstat (limited to 'meta/packages/oprofile/oprofile/cg_collection.patch')
-rw-r--r-- | meta/packages/oprofile/oprofile/cg_collection.patch | 289 |
1 files changed, 289 insertions, 0 deletions
diff --git a/meta/packages/oprofile/oprofile/cg_collection.patch b/meta/packages/oprofile/oprofile/cg_collection.patch new file mode 100644 index 0000000000..a87ec72477 --- /dev/null +++ b/meta/packages/oprofile/oprofile/cg_collection.patch | |||
@@ -0,0 +1,289 @@ | |||
1 | ChangeLog | 12 ++++++++++++ | ||
2 | libpp/callgraph_container.cpp | 21 +++++++++++++-------- | ||
3 | libpp/callgraph_container.h | 7 ++++--- | ||
4 | libpp/format_output.cpp | 22 +++++++++++----------- | ||
5 | libpp/format_output.h | 2 +- | ||
6 | libpp/symbol.h | 14 ++++++++------ | ||
7 | libpp/symbol_sort.cpp | 17 ----------------- | ||
8 | libpp/symbol_sort.h | 6 ------ | ||
9 | pp/opreport.cpp | 3 ++- | ||
10 | 9 files changed, 51 insertions(+), 53 deletions(-) | ||
11 | |||
12 | Index: oprofile/libpp/callgraph_container.cpp | ||
13 | =================================================================== | ||
14 | --- oprofile.orig/libpp/callgraph_container.cpp | ||
15 | +++ oprofile/libpp/callgraph_container.cpp | ||
16 | @@ -379,12 +379,15 @@ process(count_array_t total, double thre | ||
17 | |||
18 | process_children(sym, threshold); | ||
19 | |||
20 | - cg_syms.push_back(sym); | ||
21 | + cg_syms_objs.push_back(sym); | ||
22 | } | ||
23 | + | ||
24 | + for (unsigned int i = 0; i < cg_syms_objs.size(); i++) | ||
25 | + cg_syms.push_back(&cg_syms_objs[i]); | ||
26 | } | ||
27 | |||
28 | |||
29 | -cg_collection arc_recorder::get_symbols() const | ||
30 | +symbol_collection arc_recorder::get_symbols() const | ||
31 | { | ||
32 | return cg_syms; | ||
33 | } | ||
34 | @@ -580,12 +583,14 @@ column_flags callgraph_container::output | ||
35 | column_flags output_hints = cf_none; | ||
36 | |||
37 | // FIXME: costly: must we access directly recorder map ? | ||
38 | - cg_collection syms = recorder.get_symbols(); | ||
39 | + symbol_collection syms = recorder.get_symbols(); | ||
40 | |||
41 | - cg_collection::const_iterator it; | ||
42 | - cg_collection::const_iterator const end = syms.end(); | ||
43 | - for (it = syms.begin(); it != end; ++it) | ||
44 | - output_hints = it->output_hint(output_hints); | ||
45 | + symbol_collection::iterator it; | ||
46 | + symbol_collection::iterator const end = syms.end(); | ||
47 | + for (it = syms.begin(); it != end; ++it) { | ||
48 | + cg_symbol const *cg_symb = dynamic_cast<const cg_symbol *>(*it); | ||
49 | + output_hints = cg_symb->output_hint(output_hints); | ||
50 | + } | ||
51 | |||
52 | return output_hints; | ||
53 | } | ||
54 | @@ -597,7 +602,7 @@ count_array_t callgraph_container::sampl | ||
55 | } | ||
56 | |||
57 | |||
58 | -cg_collection callgraph_container::get_symbols() const | ||
59 | +symbol_collection callgraph_container::get_symbols() const | ||
60 | { | ||
61 | return recorder.get_symbols(); | ||
62 | } | ||
63 | Index: oprofile/libpp/callgraph_container.h | ||
64 | =================================================================== | ||
65 | --- oprofile.orig/libpp/callgraph_container.h | ||
66 | +++ oprofile/libpp/callgraph_container.h | ||
67 | @@ -53,7 +53,7 @@ public: | ||
68 | count_array_t const & arc_count); | ||
69 | |||
70 | /// return all the cg symbols | ||
71 | - cg_collection get_symbols() const; | ||
72 | + symbol_collection get_symbols() const; | ||
73 | |||
74 | /** | ||
75 | * After population, build the final output, and do | ||
76 | @@ -91,7 +91,8 @@ private: | ||
77 | map_t sym_map; | ||
78 | |||
79 | /// final output data | ||
80 | - cg_collection cg_syms; | ||
81 | + symbol_collection cg_syms; | ||
82 | + cg_collection_objs cg_syms_objs; | ||
83 | }; | ||
84 | |||
85 | |||
86 | @@ -126,7 +127,7 @@ public: | ||
87 | count_array_t samples_count() const; | ||
88 | |||
89 | // return all the cg symbols | ||
90 | - cg_collection get_symbols() const; | ||
91 | + symbol_collection get_symbols() const; | ||
92 | |||
93 | private: | ||
94 | /** | ||
95 | Index: oprofile/libpp/format_output.cpp | ||
96 | =================================================================== | ||
97 | --- oprofile.orig/libpp/format_output.cpp | ||
98 | +++ oprofile/libpp/format_output.cpp | ||
99 | @@ -489,7 +489,7 @@ cg_formatter::cg_formatter(callgraph_con | ||
100 | } | ||
101 | |||
102 | |||
103 | -void cg_formatter::output(ostream & out, cg_collection const & syms) | ||
104 | +void cg_formatter::output(ostream & out, symbol_collection const & syms) | ||
105 | { | ||
106 | // amount of spacing prefixing child and parent lines | ||
107 | string const child_parent_prefix(" "); | ||
108 | @@ -498,37 +498,37 @@ void cg_formatter::output(ostream & out, | ||
109 | |||
110 | out << string(79, '-') << endl; | ||
111 | |||
112 | - cg_collection::const_iterator it; | ||
113 | - cg_collection::const_iterator end = syms.end(); | ||
114 | + symbol_collection::const_iterator it; | ||
115 | + symbol_collection::const_iterator end = syms.end(); | ||
116 | |||
117 | for (it = syms.begin(); it < end; ++it) { | ||
118 | - cg_symbol const & sym = *it; | ||
119 | + cg_symbol const *sym = dynamic_cast<const cg_symbol *>(*it); | ||
120 | |||
121 | cg_symbol::children::const_iterator cit; | ||
122 | - cg_symbol::children::const_iterator cend = sym.callers.end(); | ||
123 | + cg_symbol::children::const_iterator cend = sym->callers.end(); | ||
124 | |||
125 | counts_t c; | ||
126 | if (global_percent) | ||
127 | c.total = counts.total; | ||
128 | else | ||
129 | - c.total = sym.total_caller_count; | ||
130 | + c.total = sym->total_caller_count; | ||
131 | |||
132 | - for (cit = sym.callers.begin(); cit != cend; ++cit) { | ||
133 | + for (cit = sym->callers.begin(); cit != cend; ++cit) { | ||
134 | out << child_parent_prefix; | ||
135 | do_output(out, *cit, cit->sample, c); | ||
136 | } | ||
137 | |||
138 | - do_output(out, sym, sym.sample, counts); | ||
139 | + do_output(out, *sym, sym->sample, counts); | ||
140 | |||
141 | c = counts_t(); | ||
142 | if (global_percent) | ||
143 | c.total = counts.total; | ||
144 | else | ||
145 | - c.total = sym.total_callee_count; | ||
146 | + c.total = sym->total_callee_count; | ||
147 | |||
148 | - cend = sym.callees.end(); | ||
149 | + cend = sym->callees.end(); | ||
150 | |||
151 | - for (cit = sym.callees.begin(); cit != cend; ++cit) { | ||
152 | + for (cit = sym->callees.begin(); cit != cend; ++cit) { | ||
153 | out << child_parent_prefix; | ||
154 | do_output(out, *cit, cit->sample, c); | ||
155 | } | ||
156 | Index: oprofile/libpp/symbol.h | ||
157 | =================================================================== | ||
158 | --- oprofile.orig/libpp/symbol.h | ||
159 | +++ oprofile/libpp/symbol.h | ||
160 | @@ -56,8 +56,11 @@ struct sample_entry { | ||
161 | |||
162 | |||
163 | /// associate a symbol with a file location, samples count and vma address | ||
164 | -struct symbol_entry { | ||
165 | +class symbol_entry { | ||
166 | +public: | ||
167 | symbol_entry() : size(0) {} | ||
168 | + virtual ~symbol_entry() {} | ||
169 | + | ||
170 | /// which image this symbol belongs to | ||
171 | image_name_id image_name; | ||
172 | /// owning application name: identical to image name if profiling | ||
173 | @@ -93,7 +96,8 @@ typedef std::vector<symbol_entry const * | ||
174 | * the sample counts replaced with the relevant arc counts, whilst | ||
175 | * the cg_symbol retains its self count. | ||
176 | */ | ||
177 | -struct cg_symbol : public symbol_entry { | ||
178 | +class cg_symbol : public symbol_entry { | ||
179 | +public: | ||
180 | cg_symbol(symbol_entry const & sym) : symbol_entry(sym) {} | ||
181 | |||
182 | typedef std::vector<symbol_entry> children; | ||
183 | @@ -109,10 +113,8 @@ struct cg_symbol : public symbol_entry { | ||
184 | count_array_t total_callee_count; | ||
185 | }; | ||
186 | |||
187 | - | ||
188 | -/// a collection of sorted callgraph symbols | ||
189 | -typedef std::vector<cg_symbol> cg_collection; | ||
190 | - | ||
191 | +/// a collection of sorted callgraph symbol objects | ||
192 | +typedef std::vector<cg_symbol> cg_collection_objs; | ||
193 | |||
194 | /// for storing diff %ages | ||
195 | typedef growable_vector<double> diff_array_t; | ||
196 | Index: oprofile/libpp/symbol_sort.cpp | ||
197 | =================================================================== | ||
198 | --- oprofile.orig/libpp/symbol_sort.cpp | ||
199 | +++ oprofile/libpp/symbol_sort.cpp | ||
200 | @@ -146,23 +146,6 @@ sort(symbol_collection & syms, bool reve | ||
201 | |||
202 | |||
203 | void sort_options:: | ||
204 | -sort(cg_collection & syms, bool reverse_sort, bool lf) const | ||
205 | -{ | ||
206 | - long_filenames = lf; | ||
207 | - | ||
208 | - vector<sort_order> sort_option(options); | ||
209 | - for (sort_order cur = first; cur != last; cur = sort_order(cur + 1)) { | ||
210 | - if (find(sort_option.begin(), sort_option.end(), cur) == | ||
211 | - sort_option.end()) | ||
212 | - sort_option.push_back(cur); | ||
213 | - } | ||
214 | - | ||
215 | - stable_sort(syms.begin(), syms.end(), | ||
216 | - symbol_compare(sort_option, reverse_sort)); | ||
217 | -} | ||
218 | - | ||
219 | - | ||
220 | -void sort_options:: | ||
221 | sort(diff_collection & syms, bool reverse_sort, bool lf) const | ||
222 | { | ||
223 | long_filenames = lf; | ||
224 | Index: oprofile/libpp/symbol_sort.h | ||
225 | =================================================================== | ||
226 | --- oprofile.orig/libpp/symbol_sort.h | ||
227 | +++ oprofile/libpp/symbol_sort.h | ||
228 | @@ -44,12 +44,6 @@ struct sort_options { | ||
229 | /** | ||
230 | * Sort the given container by the given criteria. | ||
231 | */ | ||
232 | - void sort(cg_collection & syms, bool reverse_sort, | ||
233 | - bool long_filenames) const; | ||
234 | - | ||
235 | - /** | ||
236 | - * Sort the given container by the given criteria. | ||
237 | - */ | ||
238 | void sort(diff_collection & syms, bool reverse_sort, | ||
239 | bool long_filenames) const; | ||
240 | |||
241 | Index: oprofile/pp/opreport.cpp | ||
242 | =================================================================== | ||
243 | --- oprofile.orig/pp/opreport.cpp | ||
244 | +++ oprofile/pp/opreport.cpp | ||
245 | @@ -445,7 +445,8 @@ void output_cg_symbols(callgraph_contain | ||
246 | { | ||
247 | column_flags output_hints = cg.output_hint(); | ||
248 | |||
249 | - cg_collection symbols = cg.get_symbols(); | ||
250 | + symbol_collection symbols = cg.get_symbols(); | ||
251 | + | ||
252 | options::sort_by.sort(symbols, options::reverse_sort, | ||
253 | options::long_filenames); | ||
254 | |||
255 | Index: oprofile/ChangeLog | ||
256 | =================================================================== | ||
257 | --- oprofile.orig/ChangeLog | ||
258 | +++ oprofile/ChangeLog | ||
259 | @@ -1,5 +1,17 @@ | ||
260 | 2007-05-09 Richard Purdie <rpurdie@openedhand.com> | ||
261 | |||
262 | + * libpp/callgraph_container.cpp: | ||
263 | + * libpp/callgraph_container.h: | ||
264 | + * libpp/format_output.cpp: | ||
265 | + * libpp/format_output.h: | ||
266 | + * libpp/symbol.h: | ||
267 | + * libpp/symbol_sort.cpp: | ||
268 | + * libpp/symbol_sort.h: | ||
269 | + * pp/opreport.cpp: Convert cg_collection to symbol_collection and use | ||
270 | + dynamic casting allowing more code reuse for callgraphs | ||
271 | + | ||
272 | +2007-05-09 Richard Purdie <rpurdie@openedhand.com> | ||
273 | + | ||
274 | * oparchive.cpp: | ||
275 | * oparchive_options.cpp: | ||
276 | * oparchive_options.h: Add --list-files option to list all files that | ||
277 | Index: oprofile/libpp/format_output.h | ||
278 | =================================================================== | ||
279 | --- oprofile.orig/libpp/format_output.h | ||
280 | +++ oprofile/libpp/format_output.h | ||
281 | @@ -201,7 +201,7 @@ public: | ||
282 | |||
283 | /** output callgraph information according to the previously format | ||
284 | * specifier set by call(s) to add_format() */ | ||
285 | - void output(std::ostream & out, cg_collection const & syms); | ||
286 | + void output(std::ostream & out, symbol_collection const & syms); | ||
287 | }; | ||
288 | |||
289 | /// class to output a columned format symbols plus diff values | ||