summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/oprofile/oprofile/xml_callgraph_details.patch
blob: e5ab3d916e2d5a4f4876ac67b2eeca49ac7d0e3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
Work in Progress- This patch breaks output_symbol_bytes
---
 ChangeLog                     |    9 +++++++++
 libpp/callgraph_container.cpp |   10 ++++++++--
 libpp/callgraph_container.h   |   14 ++++++++++----
 libpp/format_output.cpp       |   30 +++++++++++++++++++++++++-----
 libpp/format_output.h         |    6 +++---
 pp/opreport.cpp               |    5 +++--
 pp/opreport_options.cpp       |    4 ++--
 7 files changed, 60 insertions(+), 18 deletions(-)

Index: oprofile1/pp/opreport.cpp
===================================================================
--- oprofile1.orig/pp/opreport.cpp	2007-05-24 15:32:20.000000000 +0100
+++ oprofile1/pp/opreport.cpp	2007-05-24 20:07:14.000000000 +0100
@@ -555,10 +555,11 @@ int opreport(options::spec const & spec)
 
 		output_diff_symbols(pc1, pc2, multiple_apps);
 	} else if (options::callgraph) {
-		callgraph_container cg_container;
+		callgraph_container cg_container(options::debug_info,
+						 options::details);
 		cg_container.populate(options::archive_path, iprofiles,
 			options::extra_found_images,
-			options::debug_info, options::threshold,
+			options::threshold,
 			options::merge_by.lib, options::symbol_filter);
 
 		output_cg_symbols(cg_container, multiple_apps);
Index: oprofile1/ChangeLog
===================================================================
--- oprofile1.orig/ChangeLog	2007-05-24 18:30:47.000000000 +0100
+++ oprofile1/ChangeLog	2007-05-24 20:07:14.000000000 +0100
@@ -1,5 +1,14 @@
 2007-05-24  Richard Purdie  <rpurdie@openedhand.com>
 
+	* libpp/callgraph_container.cpp:
+	* libpp/callgraph_container.h:
+	* libpp/format_output.cpp:
+	* libpp/format_output.h:
+	* pp/opreport.cpp:
+	* pp/opreport_options.cpp: Add callgraph XML detail support
+
+2007-05-24  Richard Purdie  <rpurdie@openedhand.com>
+
 	* events/arm/xscale1/events:
 	* events/arm/xscale2/events: Add extra Xscale PMU event definitions
 
Index: oprofile1/libpp/callgraph_container.cpp
===================================================================
--- oprofile1.orig/libpp/callgraph_container.cpp	2007-05-24 15:32:20.000000000 +0100
+++ oprofile1/libpp/callgraph_container.cpp	2007-05-24 20:07:14.000000000 +0100
@@ -391,15 +391,21 @@ const symbol_collection & arc_recorder::
 	return cg_syms;
 }
 
+callgraph_container::callgraph_container(bool debug_info, bool need_details)
+	:
+	pc(debug_info, need_details),
+	debug_info(debug_info)
+{
+}
+
 
 void callgraph_container::populate(string const & archive_path, 
    list<inverted_profile> const & iprofiles,
-   extra_images const & extra, bool debug_info, double threshold,
+   extra_images const & extra, double threshold,
    bool merge_lib, string_filter const & sym_filter)
 {
 	// non callgraph samples container, we record sample at symbol level
 	// not at vma level.
-	profile_container pc(debug_info, false);
 
 	list<inverted_profile>::const_iterator it;
 	list<inverted_profile>::const_iterator const end = iprofiles.end();
Index: oprofile1/libpp/callgraph_container.h
===================================================================
--- oprofile1.orig/libpp/callgraph_container.h	2007-05-24 15:32:20.000000000 +0100
+++ oprofile1/libpp/callgraph_container.h	2007-05-24 20:07:14.000000000 +0100
@@ -19,8 +19,8 @@
 #include "symbol.h"
 #include "symbol_functors.h"
 #include "string_filter.h"
+#include "profile_container.h"
 
-class profile_container;
 class inverted_profile;
 class profile_t;
 class extra_images;
@@ -103,6 +103,8 @@ private:
  */
 class callgraph_container {
 public:
+	callgraph_container(bool debug_info, bool need_details);
+
 	/**
 	 * Populate the container, must be called once only.
 	 * @param archive_path  oparchive prefix path
@@ -118,9 +120,8 @@ public:
 	 */
 	void populate(std::string const & archive_path,
 		      std::list<inverted_profile> const & iprofiles,
-		      extra_images const & extra, bool debug_info,
-		      double threshold, bool merge_lib,
-		      string_filter const & sym_filter);
+		      extra_images const & extra, double threshold,
+		      bool merge_lib, string_filter const & sym_filter);
 
 	/// return hint on how data must be displayed.
 	column_flags output_hint() const;
@@ -131,6 +132,9 @@ public:
 	// return all the cg symbols
 	const symbol_collection & get_symbols() const;
 
+	// profile container callgraph is based on
+	profile_container pc;
+
 private:
 	/**
 	 * Record caller/callee for one cg file
@@ -162,6 +166,8 @@ private:
 		      profile_container const & pc, bool debug_info,
 		      bool merge_lib);
 
+	bool debug_info;
+
 	/// record all main symbols
 	void add_symbols(profile_container const & pc);
 
Index: oprofile1/pp/opreport_options.cpp
===================================================================
--- oprofile1.orig/pp/opreport_options.cpp	2007-05-24 15:32:20.000000000 +0100
+++ oprofile1/pp/opreport_options.cpp	2007-05-24 20:07:14.000000000 +0100
@@ -165,8 +165,8 @@ void check_options(bool diff)
 
 	if (callgraph) {
 		symbols = true;
-		if (details) {
-			cerr << "--callgraph is incompatible with --details" << endl;
+		if (details && !xml) {
+			cerr << "--callgraph is incompatible with --details without --xml" << endl;
 			do_exit = true;
 		}
 
Index: oprofile1/libpp/format_output.cpp
===================================================================
--- oprofile1.orig/libpp/format_output.cpp	2007-05-24 15:32:20.000000000 +0100
+++ oprofile1/libpp/format_output.cpp	2007-05-24 20:07:14.000000000 +0100
@@ -594,9 +594,9 @@ xml_formatter::
 xml_formatter(profile_container const * p,
 		symbol_collection & s)
 	:
+	need_details(false),
 	profile(p),
-	symbols(s),
-	need_details(false)
+	symbols(s)
 {
 	if (profile)
 		counts.total = profile->samples_count();
@@ -673,8 +673,8 @@ void xml_formatter::output_symbol_data(o
 			if (name.size() > 0 && name[0] != '?') {
 				output_attribute(out, datum, ff_vma, STARTING_ADDR);
 
-				if (need_details)
-					xml_support->output_symbol_bytes(bytes_out, symb, sd_it->second);
+				//if (need_details)
+				//	xml_support->output_symbol_bytes(bytes_out, symb, sd_it->second);
 			}
 			out << close_element();
 
@@ -843,7 +843,7 @@ output_attribute(ostream & out, field_da
 xml_cg_formatter::
 xml_cg_formatter(callgraph_container const * cg, symbol_collection & s)
 	:
-	xml_formatter(0, s),
+	xml_formatter(&cg->pc, s),
 	callgraph(cg)
 {
 	counts.total = callgraph->samples_count();
@@ -946,6 +946,26 @@ output_symbol(ostream & out,
 
 	out << init_attr(ID_REF, indx);
 
+	if (need_details) {
+		ostringstream details;
+		symbol_details_t & sd = symbol_details[indx];
+		size_t const detail_lo = sd.index;
+
+		string detail_str = output_symbol_details(symb, sd.index, lo, hi);
+
+		if (detail_str.size() > 0) {
+			if (sd.id < 0)
+				sd.id = indx;
+			details << detail_str;
+		}
+
+		if (sd.index > detail_lo) {
+			sd.details = sd.details + details.str();
+			out << init_attr(DETAIL_LO, detail_lo);
+			out << init_attr(DETAIL_HI, sd.index-1);
+		}
+	}
+
 	out << close_element(NONE, true);
 
 	out << open_element(CALLERS);
Index: oprofile1/libpp/format_output.h
===================================================================
--- oprofile1.orig/libpp/format_output.h	2007-05-24 15:32:20.000000000 +0100
+++ oprofile1/libpp/format_output.h	2007-05-24 20:07:14.000000000 +0100
@@ -249,6 +249,9 @@ public:
 	// output SymbolData XML elements
 	void output_symbol_data(std::ostream & out);
 
+	/// true if we need to show details for each symbols
+	bool need_details;
+
 private:
 	/// container we work from
 	profile_container const * profile;
@@ -256,9 +259,6 @@ private:
 	// ordered collection of symbols associated with this profile
 	symbol_collection & symbols;
 
-	/// true if we need to show details for each symbols
-	bool need_details;
-
 	// count of DetailData items output so far
 	size_t detail_count;