Merge lp:~mhr3/libunity/easy-tracing into lp:libunity
- easy-tracing
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Michal Hruby |
Approved revision: | 311 |
Merged at revision: | 306 |
Proposed branch: | lp:~mhr3/libunity/easy-tracing |
Merge into: | lp:libunity |
Diff against target: |
619 lines (+295/-36) 14 files modified
debian/libunity9.symbols (+1/-0) src/unity-aggregator-scope-private.vala (+20/-9) src/unity-deprecated-scope-impl.vala (+3/-2) src/unity-models.vala (+3/-0) src/unity-scope-dbus-impl.vala (+2/-2) src/unity-scope-tracker.vala (+3/-2) src/unity-search.vala (+2/-4) src/unity-synchronizer.vala (+6/-3) src/unity-trace.c (+3/-5) src/unity-trace.h (+3/-1) test/vala/Makefile.am (+8/-1) test/vala/test-results-synchronizer.vala (+1/-1) tools/capture-trace.py (+225/-0) tools/unity-tool.vala (+15/-6) |
To merge this branch: | bzr merge lp:~mhr3/libunity/easy-tracing |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Paweł Stołowski (community) | Approve | ||
Review via email: mp+189497@code.launchpad.net |
Commit message
Make tracing easy.
Description of the change
Make tracing easy using new capture_trace.py script in tools/.
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:303
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:304
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:306
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:308
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:309
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Paweł Stołowski (stolowski) wrote : | # |
Nice stuff, +1!
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:310
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:311
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Michal Hruby (mhr3) wrote : | # |
Looks like unrelated race in Dee that caused a failure here.
Preview Diff
1 | === modified file 'debian/libunity9.symbols' | |||
2 | --- debian/libunity9.symbols 2013-10-24 15:19:00 +0000 | |||
3 | +++ debian/libunity9.symbols 2013-10-25 14:15:10 +0000 | |||
4 | @@ -689,6 +689,7 @@ | |||
5 | 689 | unity_string_array_wrapper_take_strings@Base 4.0.6 | 689 | unity_string_array_wrapper_take_strings@Base 4.0.6 |
6 | 690 | unity_trace_log_object_real@Base 5.0.0 | 690 | unity_trace_log_object_real@Base 5.0.0 |
7 | 691 | unity_trace_log_object_va@Base 5.0.0 | 691 | unity_trace_log_object_va@Base 5.0.0 |
8 | 692 | unity_trace_tracepoint_va@Base 0replaceme | ||
9 | 692 | unity_track_metadata_construct@Base 4.0.0 | 693 | unity_track_metadata_construct@Base 4.0.0 |
10 | 693 | unity_track_metadata_construct_full@Base 5.92.0 | 694 | unity_track_metadata_construct_full@Base 5.92.0 |
11 | 694 | unity_track_metadata_get_album@Base 4.0.0 | 695 | unity_track_metadata_get_album@Base 4.0.0 |
12 | 695 | 696 | ||
13 | === modified file 'src/unity-aggregator-scope-private.vala' | |||
14 | --- src/unity-aggregator-scope-private.vala 2013-10-24 11:27:10 +0000 | |||
15 | +++ src/unity-aggregator-scope-private.vala 2013-10-25 14:15:10 +0000 | |||
16 | @@ -1194,13 +1194,13 @@ | |||
17 | 1194 | if (measure_requests) search_start_time = get_monotonic_time (); | 1194 | if (measure_requests) search_start_time = get_monotonic_time (); |
18 | 1195 | int64 search_end_time = search_start_time; | 1195 | int64 search_end_time = search_start_time; |
19 | 1196 | 1196 | ||
20 | 1197 | Unity.Trace.tracepoint ("%s run start: %s", Log.METHOD, owner.id); | ||
21 | 1198 | |||
22 | 1199 | var glib_cancellable = search_cancellable.get_gcancellable (); | 1197 | var glib_cancellable = search_cancellable.get_gcancellable (); |
23 | 1200 | ulong canc_sig_id = 0; | 1198 | ulong canc_sig_id = 0; |
24 | 1201 | uint canc_src_id = 0; | 1199 | uint canc_src_id = 0; |
25 | 1202 | bool was_cancelled = false; | 1200 | bool was_cancelled = false; |
26 | 1203 | 1201 | ||
27 | 1202 | Unity.Trace.tracepoint ("search:start::scope=%s;query=%s", owner.id, search_string); | ||
28 | 1203 | |||
29 | 1204 | // danger ahead, we're running the search in (possibly) different thread | 1204 | // danger ahead, we're running the search in (possibly) different thread |
30 | 1205 | // and at the same time waiting for the cancellable while holding | 1205 | // and at the same time waiting for the cancellable while holding |
31 | 1206 | // channel lock (ChannelState set to SEARCH_ACTIVE), other searches won't | 1206 | // channel lock (ChannelState set to SEARCH_ACTIVE), other searches won't |
32 | @@ -1246,6 +1246,8 @@ | |||
33 | 1246 | yield; | 1246 | yield; |
34 | 1247 | } | 1247 | } |
35 | 1248 | 1248 | ||
36 | 1249 | Unity.Trace.tracepoint ("search:end::scope=%s;query=%s", owner.id, search_string); | ||
37 | 1250 | |||
38 | 1249 | if (search_cancellable.is_cancelled ()) | 1251 | if (search_cancellable.is_cancelled ()) |
39 | 1250 | { | 1252 | { |
40 | 1251 | throw new ScopeError.SEARCH_CANCELLED ("Search '%s' was cancelled", search_string); | 1253 | throw new ScopeError.SEARCH_CANCELLED ("Search '%s' was cancelled", search_string); |
41 | @@ -1262,8 +1264,6 @@ | |||
42 | 1262 | response.insert (key, variant); | 1264 | response.insert (key, variant); |
43 | 1263 | } | 1265 | } |
44 | 1264 | 1266 | ||
45 | 1265 | Unity.Trace.tracepoint ("%s run end: %s", Log.METHOD, owner.id); | ||
46 | 1266 | |||
47 | 1267 | result_set.flush (); | 1267 | result_set.flush (); |
48 | 1268 | response[SEARCH_SEQNUM_HINT] = new Variant.uint64 (channel.get_last_seqnum ()); | 1268 | response[SEARCH_SEQNUM_HINT] = new Variant.uint64 (channel.get_last_seqnum ()); |
49 | 1269 | if (measure_requests) | 1269 | if (measure_requests) |
50 | @@ -1351,10 +1351,21 @@ | |||
51 | 1351 | if (category_merger is CategoryMergerByScope) | 1351 | if (category_merger is CategoryMergerByScope) |
52 | 1352 | (category_merger as CategoryMergerByScope).add_scope_mapping (owner, master_scope_id); | 1352 | (category_merger as CategoryMergerByScope).add_scope_mapping (owner, master_scope_id); |
53 | 1353 | 1353 | ||
58 | 1354 | var channel = get_channel_by_id (channel_id); | 1354 | Unity.Trace.tracepoint ("push:start::scope=%s;target=%s;query=%s", |
59 | 1355 | yield _scopes.push_wrapper (channel, search_string, ChannelType.GLOBAL, | 1355 | master_scope_id, scope_id, search_string); |
60 | 1356 | master_scope_id, scope_id, | 1356 | |
61 | 1357 | results_model, category_ids, cancellable); | 1357 | try |
62 | 1358 | { | ||
63 | 1359 | var channel = get_channel_by_id (channel_id); | ||
64 | 1360 | yield _scopes.push_wrapper (channel, search_string, ChannelType.GLOBAL, | ||
65 | 1361 | master_scope_id, scope_id, | ||
66 | 1362 | results_model, category_ids, cancellable); | ||
67 | 1363 | } | ||
68 | 1364 | finally | ||
69 | 1365 | { | ||
70 | 1366 | Unity.Trace.tracepoint ("push:end::scope=%s;target=%s;query=%s", | ||
71 | 1367 | master_scope_id, scope_id, search_string); | ||
72 | 1368 | } | ||
73 | 1358 | } | 1369 | } |
74 | 1359 | 1370 | ||
75 | 1360 | public void push_filter_settings (string channel_id, FilterSet filters) | 1371 | public void push_filter_settings (string channel_id, FilterSet filters) |
76 | @@ -1456,7 +1467,7 @@ | |||
77 | 1456 | } | 1467 | } |
78 | 1457 | 1468 | ||
79 | 1458 | _channels[channel.id] = channel; | 1469 | _channels[channel.id] = channel; |
81 | 1459 | _scopes.register_channel (channel.id, channel.backend_model, merge_strategy); | 1470 | _scopes.register_channel (owner.id, channel.id, channel.backend_model, merge_strategy); |
82 | 1460 | 1471 | ||
83 | 1461 | out_hints = new HashTable<string, Variant> (str_hash, str_equal); | 1472 | out_hints = new HashTable<string, Variant> (str_hash, str_equal); |
84 | 1462 | out_hints[CHANNEL_SWARM_NAME_HINT] = new Variant.string (model_name); | 1473 | out_hints[CHANNEL_SWARM_NAME_HINT] = new Variant.string (model_name); |
85 | 1463 | 1474 | ||
86 | === modified file 'src/unity-deprecated-scope-impl.vala' | |||
87 | --- src/unity-deprecated-scope-impl.vala 2013-09-24 08:57:39 +0000 | |||
88 | +++ src/unity-deprecated-scope-impl.vala 2013-10-25 14:15:10 +0000 | |||
89 | @@ -491,7 +491,7 @@ | |||
90 | 491 | if (measure_requests) search_start_time = get_monotonic_time (); | 491 | if (measure_requests) search_start_time = get_monotonic_time (); |
91 | 492 | int64 search_end_time = search_start_time; | 492 | int64 search_end_time = search_start_time; |
92 | 493 | 493 | ||
94 | 494 | Unity.Trace.tracepoint ("%s run start: %s", Log.METHOD, owner.id); | 494 | Unity.Trace.tracepoint ("search:start::scope=%s", owner.id); |
95 | 495 | 495 | ||
96 | 496 | new_search.run_async (() => | 496 | new_search.run_async (() => |
97 | 497 | { | 497 | { |
98 | @@ -506,7 +506,8 @@ | |||
99 | 506 | result[SEARCH_SEQNUM_HINT] = new Variant.uint64 (channel.get_last_seqnum ()); | 506 | result[SEARCH_SEQNUM_HINT] = new Variant.uint64 (channel.get_last_seqnum ()); |
100 | 507 | } | 507 | } |
101 | 508 | 508 | ||
103 | 509 | Unity.Trace.tracepoint ("%s run end: %s", Log.METHOD, owner.id); | 509 | Unity.Trace.tracepoint ("search:end::scope=%s", owner.id); |
104 | 510 | |||
105 | 510 | if (measure_requests) | 511 | if (measure_requests) |
106 | 511 | { | 512 | { |
107 | 512 | int64 delta_us = search_end_time - search_start_time; | 513 | int64 delta_us = search_end_time - search_start_time; |
108 | 513 | 514 | ||
109 | === modified file 'src/unity-models.vala' | |||
110 | --- src/unity-models.vala 2013-07-17 15:18:49 +0000 | |||
111 | +++ src/unity-models.vala 2013-10-25 14:15:10 +0000 | |||
112 | @@ -119,6 +119,7 @@ | |||
113 | 119 | var sm = flush_model as Dee.SharedModel; | 119 | var sm = flush_model as Dee.SharedModel; |
114 | 120 | if (sm != null) | 120 | if (sm != null) |
115 | 121 | { | 121 | { |
116 | 122 | Unity.Trace.tracepoint ("flush::%s", sm.get_swarm_name ()); | ||
117 | 122 | sm.flush_revision_queue (); | 123 | sm.flush_revision_queue (); |
118 | 123 | } | 124 | } |
119 | 124 | } | 125 | } |
120 | @@ -195,6 +196,7 @@ | |||
121 | 195 | return; | 196 | return; |
122 | 196 | } | 197 | } |
123 | 197 | 198 | ||
124 | 199 | Unity.Trace.tracepoint ("diff:start::%s", get_swarm_name ()); | ||
125 | 198 | var script = Utils.Diff.run ((int) this_rows, (int) target_rows, | 200 | var script = Utils.Diff.run ((int) this_rows, (int) target_rows, |
126 | 199 | (index_a, index_b) => | 201 | (index_a, index_b) => |
127 | 200 | { | 202 | { |
128 | @@ -249,6 +251,7 @@ | |||
129 | 249 | } | 251 | } |
130 | 250 | } | 252 | } |
131 | 251 | } | 253 | } |
132 | 254 | Unity.Trace.tracepoint ("diff:end::%s", get_swarm_name ()); | ||
133 | 252 | 255 | ||
134 | 253 | assert (get_n_rows () == target_model.get_n_rows ()); | 256 | assert (get_n_rows () == target_model.get_n_rows ()); |
135 | 254 | } | 257 | } |
136 | 255 | 258 | ||
137 | === modified file 'src/unity-scope-dbus-impl.vala' | |||
138 | --- src/unity-scope-dbus-impl.vala 2013-09-24 08:57:39 +0000 | |||
139 | +++ src/unity-scope-dbus-impl.vala 2013-10-25 14:15:10 +0000 | |||
140 | @@ -566,7 +566,7 @@ | |||
141 | 566 | if (measure_requests) search_start_time = get_monotonic_time (); | 566 | if (measure_requests) search_start_time = get_monotonic_time (); |
142 | 567 | int64 search_end_time = search_start_time; | 567 | int64 search_end_time = search_start_time; |
143 | 568 | 568 | ||
145 | 569 | Unity.Trace.tracepoint ("%s run start: %s", Log.METHOD, _dbus_name); | 569 | Unity.Trace.tracepoint ("search:start::scope=%s;query=%s", _dbus_name, normalized_query); |
146 | 570 | 570 | ||
147 | 571 | if (force_sync_requests) | 571 | if (force_sync_requests) |
148 | 572 | { | 572 | { |
149 | @@ -590,7 +590,7 @@ | |||
150 | 590 | yield; | 590 | yield; |
151 | 591 | } | 591 | } |
152 | 592 | 592 | ||
154 | 593 | Unity.Trace.tracepoint ("%s run end: %s", Log.METHOD, _dbus_name); | 593 | Unity.Trace.tracepoint ("search:end::scope=%s;query=%s", _dbus_name, normalized_query); |
155 | 594 | 594 | ||
156 | 595 | // FIXME: handle no-reply-hint etc! | 595 | // FIXME: handle no-reply-hint etc! |
157 | 596 | if (!cancellable.is_cancelled ()) | 596 | if (!cancellable.is_cancelled ()) |
158 | 597 | 597 | ||
159 | === modified file 'src/unity-scope-tracker.vala' | |||
160 | --- src/unity-scope-tracker.vala 2013-09-24 08:57:39 +0000 | |||
161 | +++ src/unity-scope-tracker.vala 2013-10-25 14:15:10 +0000 | |||
162 | @@ -224,12 +224,13 @@ | |||
163 | 224 | return "%p::%d".printf (proxy, (int) channel_type); | 224 | return "%p::%d".printf (proxy, (int) channel_type); |
164 | 225 | } | 225 | } |
165 | 226 | 226 | ||
167 | 227 | public void register_channel (string master_channel_id, | 227 | public void register_channel (string owner_scope_id, |
168 | 228 | string master_channel_id, | ||
169 | 228 | Dee.SerializableModel model, | 229 | Dee.SerializableModel model, |
170 | 229 | MergeStrategy merge_strategy) | 230 | MergeStrategy merge_strategy) |
171 | 230 | { | 231 | { |
172 | 231 | // create new synchronizer for this channel | 232 | // create new synchronizer for this channel |
174 | 232 | var synchronizer = new ResultsSynchronizer (model); | 233 | var synchronizer = new ResultsSynchronizer (model, owner_scope_id); |
175 | 233 | synchronizer.merge_strategy = merge_strategy; | 234 | synchronizer.merge_strategy = merge_strategy; |
176 | 234 | synchronizers[master_channel_id] = synchronizer; | 235 | synchronizers[master_channel_id] = synchronizer; |
177 | 235 | } | 236 | } |
178 | 236 | 237 | ||
179 | === modified file 'src/unity-search.vala' | |||
180 | --- src/unity-search.vala 2013-07-22 14:02:05 +0000 | |||
181 | +++ src/unity-search.vala 2013-10-25 14:15:10 +0000 | |||
182 | @@ -176,10 +176,10 @@ | |||
183 | 176 | } | 176 | } |
184 | 177 | var agg_scope = owner as AggregatorScope; | 177 | var agg_scope = owner as AggregatorScope; |
185 | 178 | var canc = search_context.cancellable.get_gcancellable (); | 178 | var canc = search_context.cancellable.get_gcancellable (); |
187 | 179 | Unity.Trace.tracepoint ("%s start: %s, query=%s", Log.METHOD, scope_id, search_string); | 179 | Unity.Trace.tracepoint ("subsearch:start::scope=%s;target=%s;query=%s", agg_scope.id, scope_id, search_string); |
188 | 180 | var res = yield agg_scope.search_scope (this, scope_id, search_string, | 180 | var res = yield agg_scope.search_scope (this, scope_id, search_string, |
189 | 181 | search_type, hints, canc); | 181 | search_type, hints, canc); |
191 | 182 | Unity.Trace.tracepoint ("%s end: %s, query=%s", Log.METHOD, scope_id, search_string); | 182 | Unity.Trace.tracepoint ("subsearch:end::scope=%s;target=%s;query=%s", agg_scope.id, scope_id, search_string); |
192 | 183 | return res; | 183 | return res; |
193 | 184 | } | 184 | } |
194 | 185 | 185 | ||
195 | @@ -190,11 +190,9 @@ | |||
196 | 190 | if (search_context.cancellable.is_cancelled ()) return; | 190 | if (search_context.cancellable.is_cancelled ()) return; |
197 | 191 | var agg_scope = owner as AggregatorScope; | 191 | var agg_scope = owner as AggregatorScope; |
198 | 192 | var canc = search_context.cancellable.get_gcancellable (); | 192 | var canc = search_context.cancellable.get_gcancellable (); |
199 | 193 | Unity.Trace.tracepoint ("%s start: %s", Log.METHOD, scope_id); | ||
200 | 194 | yield agg_scope.push_results (channel_id, search_string, | 193 | yield agg_scope.push_results (channel_id, search_string, |
201 | 195 | scope_id, results_model, | 194 | scope_id, results_model, |
202 | 196 | category_ids, canc); | 195 | category_ids, canc); |
203 | 197 | Unity.Trace.tracepoint ("%s end: %s", Log.METHOD, scope_id); | ||
204 | 198 | } | 196 | } |
205 | 199 | 197 | ||
206 | 200 | public void push_filter_settings (FilterSet filters) | 198 | public void push_filter_settings (FilterSet filters) |
207 | 201 | 199 | ||
208 | === modified file 'src/unity-synchronizer.vala' | |||
209 | --- src/unity-synchronizer.vala 2013-05-10 12:14:18 +0000 | |||
210 | +++ src/unity-synchronizer.vala 2013-10-25 14:15:10 +0000 | |||
211 | @@ -38,6 +38,7 @@ | |||
212 | 38 | } | 38 | } |
213 | 39 | 39 | ||
214 | 40 | public unowned Dee.Model receiver { get; construct; } | 40 | public unowned Dee.Model receiver { get; construct; } |
215 | 41 | public string owner_scope_id { get; construct; } | ||
216 | 41 | public MergeStrategy merge_strategy { get; set; } | 42 | public MergeStrategy merge_strategy { get; set; } |
217 | 42 | 43 | ||
218 | 43 | private Gee.Set<Dee.Model> _providers; | 44 | private Gee.Set<Dee.Model> _providers; |
219 | @@ -50,9 +51,9 @@ | |||
220 | 50 | private Quark scope_id_quark = Quark.from_string ("scope-id"); | 51 | private Quark scope_id_quark = Quark.from_string ("scope-id"); |
221 | 51 | private uint _clear_seq_num = 1; | 52 | private uint _clear_seq_num = 1; |
222 | 52 | 53 | ||
224 | 53 | internal ResultsSynchronizer (Dee.Model receiver) | 54 | internal ResultsSynchronizer (Dee.Model receiver, string scope_id) |
225 | 54 | { | 55 | { |
227 | 55 | Object (receiver:receiver); | 56 | Object (receiver:receiver, owner_scope_id: scope_id); |
228 | 56 | } | 57 | } |
229 | 57 | 58 | ||
230 | 58 | construct | 59 | construct |
231 | @@ -184,9 +185,11 @@ | |||
232 | 184 | private void transaction_finished (Dee.SharedModel model, | 185 | private void transaction_finished (Dee.SharedModel model, |
233 | 185 | uint64 begin_sn, uint64 end_sn) | 186 | uint64 begin_sn, uint64 end_sn) |
234 | 186 | { | 187 | { |
235 | 188 | unowned string scope_id = model.get_qdata<string> (scope_id_quark); | ||
236 | 189 | Unity.Trace.tracepoint ("changeset::scope=%s;target=%s", owner_scope_id, scope_id); | ||
237 | 187 | if (model in _providers) | 190 | if (model in _providers) |
238 | 188 | { | 191 | { |
240 | 189 | transaction_complete (model, model.get_qdata<string> (scope_id_quark)); | 192 | transaction_complete (model, scope_id); |
241 | 190 | } | 193 | } |
242 | 191 | } | 194 | } |
243 | 192 | 195 | ||
244 | 193 | 196 | ||
245 | === modified file 'src/unity-trace.c' | |||
246 | --- src/unity-trace.c 2013-04-04 06:49:22 +0000 | |||
247 | +++ src/unity-trace.c 2013-10-25 14:15:10 +0000 | |||
248 | @@ -58,14 +58,12 @@ | |||
249 | 58 | va_end (args); | 58 | va_end (args); |
250 | 59 | } | 59 | } |
251 | 60 | 60 | ||
252 | 61 | #ifdef ENABLE_LTTNG | ||
253 | 62 | |||
254 | 63 | void | 61 | void |
256 | 64 | unity_trace_tracepoint_real (const gchar *format, va_list args) | 62 | unity_trace_tracepoint_va (const gchar *format, va_list args) |
257 | 65 | { | 63 | { |
258 | 64 | #ifdef ENABLE_LTTNG | ||
259 | 66 | gchar *tmp = g_strdup_vprintf (format, args); | 65 | gchar *tmp = g_strdup_vprintf (format, args); |
260 | 67 | tracepoint (libunity, message, tmp); | 66 | tracepoint (libunity, message, tmp); |
261 | 68 | g_free (tmp); | 67 | g_free (tmp); |
262 | 68 | #endif | ||
263 | 69 | } | 69 | } |
264 | 70 | |||
265 | 71 | #endif | ||
266 | 72 | 70 | ||
267 | === modified file 'src/unity-trace.h' | |||
268 | --- src/unity-trace.h 2013-04-04 11:47:25 +0000 | |||
269 | +++ src/unity-trace.h 2013-10-25 14:15:10 +0000 | |||
270 | @@ -90,11 +90,13 @@ | |||
271 | 90 | #endif /* ENABLE_UNITY_TRACE_LOG */ | 90 | #endif /* ENABLE_UNITY_TRACE_LOG */ |
272 | 91 | 91 | ||
273 | 92 | #ifdef ENABLE_LTTNG | 92 | #ifdef ENABLE_LTTNG |
274 | 93 | void unity_trace_tracepoint_va (const gchar *format, va_list args); | ||
275 | 94 | |||
276 | 93 | static void unity_trace_tracepoint (const gchar *format, ...) | 95 | static void unity_trace_tracepoint (const gchar *format, ...) |
277 | 94 | { | 96 | { |
278 | 95 | va_list args; | 97 | va_list args; |
279 | 96 | va_start (args, format); | 98 | va_start (args, format); |
281 | 97 | unity_trace_tracepoint_real (format, args); | 99 | unity_trace_tracepoint_va (format, args); |
282 | 98 | va_end (args); | 100 | va_end (args); |
283 | 99 | } | 101 | } |
284 | 100 | #else | 102 | #else |
285 | 101 | 103 | ||
286 | === modified file 'test/vala/Makefile.am' | |||
287 | --- test/vala/Makefile.am 2013-07-04 23:07:03 +0000 | |||
288 | +++ test/vala/Makefile.am 2013-10-25 14:15:10 +0000 | |||
289 | @@ -52,7 +52,12 @@ | |||
290 | 52 | $(top_builddir)/src/libunity.la \ | 52 | $(top_builddir)/src/libunity.la \ |
291 | 53 | $(top_builddir)/protocol/libunity-protocol-private.la \ | 53 | $(top_builddir)/protocol/libunity-protocol-private.la \ |
292 | 54 | $(top_builddir)/extras/libunity-extras.la \ | 54 | $(top_builddir)/extras/libunity-extras.la \ |
294 | 55 | $(LIBUNITY_LIBS) | 55 | $(LIBUNITY_LIBS) \ |
295 | 56 | $(NULL) | ||
296 | 57 | |||
297 | 58 | if ENABLE_LTTNG | ||
298 | 59 | test_libs += -lurcu-bp | ||
299 | 60 | endif | ||
300 | 56 | 61 | ||
301 | 57 | TEST_PROGS += test-vala test-scope test-blacklist-crash test-extras | 62 | TEST_PROGS += test-vala test-scope test-blacklist-crash test-extras |
302 | 58 | 63 | ||
303 | @@ -86,6 +91,8 @@ | |||
304 | 86 | nodist_test_blacklist_crash_SOURCES = $(test_blacklist_crash_VALASOURCES:.vala=.c) | 91 | nodist_test_blacklist_crash_SOURCES = $(test_blacklist_crash_VALASOURCES:.vala=.c) |
305 | 87 | 92 | ||
306 | 88 | test_extras_LDADD = $(test_libs) | 93 | test_extras_LDADD = $(test_libs) |
307 | 94 | test_extras_LDFLAGS = -static | ||
308 | 95 | |||
309 | 89 | test_extras_VALASOURCES = \ | 96 | test_extras_VALASOURCES = \ |
310 | 90 | test-preview-player-iface.vala \ | 97 | test-preview-player-iface.vala \ |
311 | 91 | test-utils.vala \ | 98 | test-utils.vala \ |
312 | 92 | 99 | ||
313 | === modified file 'test/vala/test-results-synchronizer.vala' | |||
314 | --- test/vala/test-results-synchronizer.vala 2013-02-26 14:04:40 +0000 | |||
315 | +++ test/vala/test-results-synchronizer.vala 2013-10-25 14:15:10 +0000 | |||
316 | @@ -40,7 +40,7 @@ | |||
317 | 40 | var provider2 = new Dee.SequenceModel (); | 40 | var provider2 = new Dee.SequenceModel (); |
318 | 41 | provider2.set_schema_full (RESULTS_SCHEMA); | 41 | provider2.set_schema_full (RESULTS_SCHEMA); |
319 | 42 | provider2.set_data<string> ("scope-id", "scope2"); | 42 | provider2.set_data<string> ("scope-id", "scope2"); |
321 | 43 | var res_sync = new Internal.ResultsSynchronizer (receiver); | 43 | var res_sync = new Internal.ResultsSynchronizer (receiver, "master.scope"); |
322 | 44 | res_sync.add_provider (provider1, "scope1"); | 44 | res_sync.add_provider (provider1, "scope1"); |
323 | 45 | res_sync.add_provider (provider2, "scope2"); | 45 | res_sync.add_provider (provider2, "scope2"); |
324 | 46 | 46 | ||
325 | 47 | 47 | ||
326 | === added file 'tools/capture-trace.py' | |||
327 | --- tools/capture-trace.py 1970-01-01 00:00:00 +0000 | |||
328 | +++ tools/capture-trace.py 2013-10-25 14:15:10 +0000 | |||
329 | @@ -0,0 +1,225 @@ | |||
330 | 1 | #!/usr/bin/env python | ||
331 | 2 | |||
332 | 3 | import os, sys | ||
333 | 4 | import subprocess | ||
334 | 5 | import re | ||
335 | 6 | |||
336 | 7 | """ | ||
337 | 8 | # This script has two modes of operation: | ||
338 | 9 | # | ||
339 | 10 | # 1) Capture a trace and generate a html visualization. | ||
340 | 11 | # To use this mode just run `./capture_trace.py`. This will setup a lttng | ||
341 | 12 | # session, enable all userspace trace events and spawns a subshell where | ||
342 | 13 | # you can for example run libunity-tool to perform a search on a scope. | ||
343 | 14 | # When the subshell exits, tracing is stopped and visualization is generated. | ||
344 | 15 | # | ||
345 | 16 | # 2) Only generate a html visualization of a previously captured trace. | ||
346 | 17 | # Use `./capture_trace.py /path/to/lttng/trace_dir`. | ||
347 | 18 | # | ||
348 | 19 | # Note that use use the first mode you need to have lttng installed | ||
349 | 20 | # and libunity compiled with --enable-lttng option. | ||
350 | 21 | # Required packages (besides requirements for libunity's --enable-lttng): | ||
351 | 22 | # sudo apt-get install lttng-tools babeltrace | ||
352 | 23 | """ | ||
353 | 24 | |||
354 | 25 | """ | ||
355 | 26 | # --- Manually capturing a trace | ||
356 | 27 | # lttng create session_name | ||
357 | 28 | # lttng enable-event -u -a | ||
358 | 29 | # lttng start | ||
359 | 30 | # --- start home scope with lttng-enabled branch of libunity, perform a search | ||
360 | 31 | # lttng stop | ||
361 | 32 | # lttng destroy | ||
362 | 33 | # --- view the trace in cli | ||
363 | 34 | # babeltrace ~/lttng_traces/<session_name dir> | ||
364 | 35 | """ | ||
365 | 36 | def capture_lttng_trace(): | ||
366 | 37 | session = subprocess.check_output(["lttng", "create", "libunity-trace"], stdin=subprocess.PIPE) | ||
367 | 38 | trace_started = False | ||
368 | 39 | try: | ||
369 | 40 | subprocess.check_output(["lttng", "enable-event", "-u", "-a"], stdin=subprocess.PIPE) | ||
370 | 41 | subprocess.check_output(["lttng", "start"], stdin=subprocess.PIPE) | ||
371 | 42 | trace_started = True | ||
372 | 43 | sys.stderr.write("Trace running... Close this sub-shell with Ctrl+D to finish\n") | ||
373 | 44 | subprocess.check_call(["bash"]) # let this inherit our stdin | ||
374 | 45 | except subprocess.CalledProcessError as cpe: | ||
375 | 46 | if trace_started: | ||
376 | 47 | # bash will return non-zero exit code if you for example Ctrl+C | ||
377 | 48 | # a program within it, let's just ignore those errors | ||
378 | 49 | msg = "Warning: subshell returned error: " + str(cpe.returncode) | ||
379 | 50 | sys.stderr.write(msg + "\n") | ||
380 | 51 | else: raise | ||
381 | 52 | finally: | ||
382 | 53 | if trace_started: | ||
383 | 54 | subprocess.check_output(["lttng", "stop"], stdin=subprocess.PIPE) | ||
384 | 55 | subprocess.check_output(["lttng", "destroy", "libunity-trace"], stdin=subprocess.PIPE) | ||
385 | 56 | |||
386 | 57 | match = re.findall(r'Traces will be written in (.+)', session) | ||
387 | 58 | if len(match) > 0: return match[0] | ||
388 | 59 | return None | ||
389 | 60 | |||
390 | 61 | # trace event example | ||
391 | 62 | """ | ||
392 | 63 | [20:00:30.697493680] (+0.000014138) miso-ThinkPad:unity-scope-hom:26439 libunity:message: { cpu_id = 0 }, { message = "flush::com.canonical.Unity.Master.Scope.home.T296521243842038" } | ||
393 | 64 | """ | ||
394 | 65 | |||
395 | 66 | def parse_trace_line(line): | ||
396 | 67 | pattern = re.compile(r'^\[(?P<timestamp>[0-9:\.]+)\].+?{ message = "(?P<msg>[^"]+)"') | ||
397 | 68 | match = pattern.match(line) | ||
398 | 69 | timestamp = match.group("timestamp") | ||
399 | 70 | msg = match.group("msg") | ||
400 | 71 | msg_parts = msg.split("::", 2) | ||
401 | 72 | if len(msg_parts) > 1: | ||
402 | 73 | msg_type = msg_parts[0] | ||
403 | 74 | msg = {} | ||
404 | 75 | for kv in msg_parts[1].split(";"): | ||
405 | 76 | items = kv.split("=", 2) | ||
406 | 77 | if len(items) > 1: | ||
407 | 78 | msg[items[0]] = items[1] | ||
408 | 79 | else: | ||
409 | 80 | msg['content'] = items[0] | ||
410 | 81 | else: | ||
411 | 82 | msg_type = "other" | ||
412 | 83 | msg = {'content': msg} | ||
413 | 84 | |||
414 | 85 | return (timestamp, msg_type, msg) | ||
415 | 86 | |||
416 | 87 | def find_end_event(events, searched_event, event_type): | ||
417 | 88 | for i in range(len(events)): | ||
418 | 89 | event = events[i] | ||
419 | 90 | if event[1] == event_type and event[2] == searched_event[2]: | ||
420 | 91 | return i | ||
421 | 92 | return -1 | ||
422 | 93 | |||
423 | 94 | def pair_events(events): | ||
424 | 95 | paired = [] | ||
425 | 96 | i = 0 | ||
426 | 97 | while i < len(events): | ||
427 | 98 | event = events[i] | ||
428 | 99 | event_type = event[1] | ||
429 | 100 | if event_type.endswith(":start"): | ||
430 | 101 | group = event[1].split(":", 2)[0] | ||
431 | 102 | j = find_end_event(events[i+1:], event, group + ":end") | ||
432 | 103 | if j >= 0: | ||
433 | 104 | end_event = events.pop(i+j+1) | ||
434 | 105 | paired.append((event, end_event)) | ||
435 | 106 | i = i+1 | ||
436 | 107 | continue | ||
437 | 108 | paired.append((event, None)) | ||
438 | 109 | i = i+1 | ||
439 | 110 | |||
440 | 111 | return paired | ||
441 | 112 | |||
442 | 113 | COLOR_FOR_EVENT = { | ||
443 | 114 | 'search': "'#394a6b'", | ||
444 | 115 | 'subsearch': "'#109618'", | ||
445 | 116 | 'changeset': "'#990099'", | ||
446 | 117 | 'diff': "'#e57357'", | ||
447 | 118 | 'flush': "'#ff9900'", | ||
448 | 119 | 'push': "'#0099c6'" | ||
449 | 120 | } | ||
450 | 121 | |||
451 | 122 | def produce_html(trace_name, pairs): | ||
452 | 123 | base = """<html><head><title>%s</title></head><body> | ||
453 | 124 | <script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization', | ||
454 | 125 | 'version':'1','packages':['timeline']}]}"></script> | ||
455 | 126 | <script type="text/javascript"> | ||
456 | 127 | |||
457 | 128 | google.setOnLoadCallback(drawChart); | ||
458 | 129 | function drawChart() { | ||
459 | 130 | var dataTable = new google.visualization.DataTable(); | ||
460 | 131 | |||
461 | 132 | dataTable.addColumn({ type: 'string', id: 'group' }); | ||
462 | 133 | dataTable.addColumn({ type: 'string', id: 'id' }); | ||
463 | 134 | dataTable.addColumn({ type: 'string', id: 'data' }); | ||
464 | 135 | dataTable.addColumn({ type: 'datetime', id: 'Start' }); | ||
465 | 136 | dataTable.addColumn({ type: 'datetime', id: 'End' }); | ||
466 | 137 | |||
467 | 138 | dataTable.addRows([ | ||
468 | 139 | %s | ||
469 | 140 | ]); | ||
470 | 141 | |||
471 | 142 | var view = new google.visualization.DataView(dataTable); | ||
472 | 143 | view.setColumns([0,1,3,4]); | ||
473 | 144 | |||
474 | 145 | var container = document.getElementById('example2.1'); | ||
475 | 146 | var chart = new google.visualization.Timeline(container); | ||
476 | 147 | |||
477 | 148 | chart.draw(view); | ||
478 | 149 | } | ||
479 | 150 | </script> | ||
480 | 151 | |||
481 | 152 | <div id="example2.1" style="height: 100%%;"></div> | ||
482 | 153 | </body></html>""" | ||
483 | 154 | rows = [] | ||
484 | 155 | colors = [] | ||
485 | 156 | for pair in pairs: | ||
486 | 157 | (start_event, end_event) = pair | ||
487 | 158 | (timestamp, event_type, metadata) = start_event | ||
488 | 159 | has_end_ts = end_event is not None | ||
489 | 160 | |||
490 | 161 | group = event_type if not event_type.endswith(":start") else event_type.split(":", 2)[0] | ||
491 | 162 | color = COLOR_FOR_EVENT[group] if group in COLOR_FOR_EVENT else "'#c60000'" | ||
492 | 163 | has_scope_id = 'scope' in metadata | ||
493 | 164 | scope_id = metadata['scope'] if has_scope_id else metadata['content'] | ||
494 | 165 | if has_scope_id: del metadata['scope'] | ||
495 | 166 | else: | ||
496 | 167 | if group in ['changeset', 'flush', 'diff']: | ||
497 | 168 | match = re.match(r'com.canonical.Unity\.Master\.Scope\.(\w+)\.T', scope_id) | ||
498 | 169 | if match: scope_id = "%s.scope" % match.group(1) | ||
499 | 170 | data = str(metadata).replace("'", "\\'") | ||
500 | 171 | |||
501 | 172 | # we're loosing our lovely nanosecond precision :( | ||
502 | 173 | map_to_int = lambda x: int(x[0:3]) | ||
503 | 174 | start_date = map(map_to_int, re.findall(r'\d+', timestamp)) | ||
504 | 175 | end_date = start_date | ||
505 | 176 | if has_end_ts: | ||
506 | 177 | end_date = map(map_to_int, re.findall(r'\d+', end_event[0])) | ||
507 | 178 | |||
508 | 179 | event_name = "%s - %s" % (group, metadata['target']) if 'target' in metadata else group | ||
509 | 180 | data_tuple = (scope_id, group, data, ",".join(map(str,start_date)), ",".join(map(str, end_date))) | ||
510 | 181 | data_format = "[ '%s', '%s', '%s', new Date(0,0,0,%s), new Date(0,0,0,%s) ]" | ||
511 | 182 | data_row = data_format % data_tuple | ||
512 | 183 | rows.append(data_row) | ||
513 | 184 | colors.append(color) | ||
514 | 185 | return base % ("Analysis of %s" % trace_name, ",\n".join(rows)) | ||
515 | 186 | |||
516 | 187 | def get_events_from_babeltrace(trace_dir): | ||
517 | 188 | events = [] | ||
518 | 189 | all_events = subprocess.check_output(["babeltrace", trace_dir]) | ||
519 | 190 | lines = filter(None, all_events.split("\n")) | ||
520 | 191 | for line in lines: | ||
521 | 192 | event = parse_trace_line(line) | ||
522 | 193 | events.append(event) | ||
523 | 194 | return events | ||
524 | 195 | |||
525 | 196 | def main(args): | ||
526 | 197 | output_name = None | ||
527 | 198 | if len(args) > 1: | ||
528 | 199 | trace_dir = args[1] | ||
529 | 200 | else: | ||
530 | 201 | trace_dir = capture_lttng_trace() | ||
531 | 202 | |||
532 | 203 | if trace_dir: | ||
533 | 204 | basename = os.path.basename(trace_dir) | ||
534 | 205 | if not basename: | ||
535 | 206 | basename = os.path.basename(os.path.dirname(trace_dir)) | ||
536 | 207 | output_name = "%s.html" % basename | ||
537 | 208 | |||
538 | 209 | events = get_events_from_babeltrace(trace_dir) | ||
539 | 210 | if len(events) == 0: | ||
540 | 211 | raise RuntimeError("There are 0 events in the trace") | ||
541 | 212 | pairs = pair_events(events) | ||
542 | 213 | html = produce_html(trace_dir, pairs) | ||
543 | 214 | |||
544 | 215 | if output_name: | ||
545 | 216 | sys.stderr.write("Writing output to '%s'\n" % output_name) | ||
546 | 217 | f = open(output_name, 'w') | ||
547 | 218 | f.write(html) | ||
548 | 219 | f.close() | ||
549 | 220 | else: | ||
550 | 221 | print html | ||
551 | 222 | |||
552 | 223 | if __name__ == "__main__": | ||
553 | 224 | main (sys.argv) | ||
554 | 225 | |||
555 | 0 | 226 | ||
556 | === modified file 'tools/unity-tool.vala' | |||
557 | --- tools/unity-tool.vala 2013-10-04 16:08:32 +0000 | |||
558 | +++ tools/unity-tool.vala 2013-10-25 14:15:10 +0000 | |||
559 | @@ -35,6 +35,7 @@ | |||
560 | 35 | public static bool print_search_reply; | 35 | public static bool print_search_reply; |
561 | 36 | public static bool dump_results; | 36 | public static bool dump_results; |
562 | 37 | public static bool dump_filters; | 37 | public static bool dump_filters; |
563 | 38 | public static bool diff_changes; | ||
564 | 38 | 39 | ||
565 | 39 | public static bool test_server_mode; | 40 | public static bool test_server_mode; |
566 | 40 | public static string[] test_cases; | 41 | public static string[] test_cases; |
567 | @@ -104,6 +105,10 @@ | |||
568 | 104 | "Use private channel for results transfer", null | 105 | "Use private channel for results transfer", null |
569 | 105 | }, | 106 | }, |
570 | 106 | { | 107 | { |
571 | 108 | "diff-changes", 'd', 0, OptionArg.NONE, out Options.diff_changes, | ||
572 | 109 | "Use diff channel", null | ||
573 | 110 | }, | ||
574 | 111 | { | ||
575 | 107 | "test-server-mode", 0, 0, OptionArg.NONE, out Options.test_server_mode, | 112 | "test-server-mode", 0, 0, OptionArg.NONE, out Options.test_server_mode, |
576 | 108 | "Run a collection of test scripts", null | 113 | "Run a collection of test scripts", null |
577 | 109 | }, | 114 | }, |
578 | @@ -238,12 +243,10 @@ | |||
579 | 238 | // Get proxy | 243 | // Get proxy |
580 | 239 | string channel_id; | 244 | string channel_id; |
581 | 240 | Dee.SerializableModel results_model; | 245 | Dee.SerializableModel results_model; |
582 | 241 | var flags = Options.private_channel ? | ||
583 | 242 | ChannelFlags.PRIVATE : ChannelFlags.NONE; | ||
584 | 243 | var proxy = get_scope_proxy (Options.scope_dbus_name, | 246 | var proxy = get_scope_proxy (Options.scope_dbus_name, |
585 | 244 | Options.scope_dbus_path, | 247 | Options.scope_dbus_path, |
586 | 245 | (ChannelType) Options.search_type, | 248 | (ChannelType) Options.search_type, |
588 | 246 | flags, | 249 | get_global_channel_flags (), |
589 | 247 | out channel_id, out results_model); | 250 | out channel_id, out results_model); |
590 | 248 | 251 | ||
591 | 249 | // Performing search | 252 | // Performing search |
592 | @@ -508,18 +511,24 @@ | |||
593 | 508 | return Test.run (); | 511 | return Test.run (); |
594 | 509 | } | 512 | } |
595 | 510 | 513 | ||
596 | 514 | private static ChannelFlags get_global_channel_flags () | ||
597 | 515 | { | ||
598 | 516 | var flags = ChannelFlags.NONE; | ||
599 | 517 | if (Options.private_channel) flags |= ChannelFlags.PRIVATE; | ||
600 | 518 | if (Options.diff_changes) flags |= ChannelFlags.DIFF_CHANGES; | ||
601 | 519 | return flags; | ||
602 | 520 | } | ||
603 | 521 | |||
604 | 511 | private static void call_scope_search (string search_string, | 522 | private static void call_scope_search (string search_string, |
605 | 512 | int search_type) | 523 | int search_type) |
606 | 513 | { | 524 | { |
607 | 514 | string channel_id; | 525 | string channel_id; |
608 | 515 | Dee.SerializableModel results_model; | 526 | Dee.SerializableModel results_model; |
609 | 516 | 527 | ||
610 | 517 | var flags = Options.private_channel ? | ||
611 | 518 | ChannelFlags.PRIVATE : ChannelFlags.NONE; | ||
612 | 519 | var proxy = get_scope_proxy (Options.scope_dbus_name, | 528 | var proxy = get_scope_proxy (Options.scope_dbus_name, |
613 | 520 | Options.scope_dbus_path, | 529 | Options.scope_dbus_path, |
614 | 521 | (ChannelType) search_type, | 530 | (ChannelType) search_type, |
616 | 522 | flags, | 531 | get_global_channel_flags (), |
617 | 523 | out channel_id, out results_model); | 532 | out channel_id, out results_model); |
618 | 524 | 533 | ||
619 | 525 | var ml = new MainLoop (); | 534 | var ml = new MainLoop (); |
PASSED: Continuous integration, rev:302 10.97.0. 26:8080/ job/libunity- ci/125/ 10.97.0. 26:8080/ job/libunity- saucy-amd64- ci/110 10.97.0. 26:8080/ job/libunity- saucy-armhf- ci/110 10.97.0. 26:8080/ job/libunity- saucy-i386- ci/110
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: 10.97.0. 26:8080/ job/libunity- ci/125/ rebuild
http://