OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // | 2 // |
3 // Tests of profiles generator and utilities. | 3 // Tests of profiles generator and utilities. |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 #include "profile-generator-inl.h" | 6 #include "profile-generator-inl.h" |
7 #include "cctest.h" | 7 #include "cctest.h" |
8 | 8 |
9 namespace i = v8::internal; | 9 namespace i = v8::internal; |
10 | 10 |
11 using i::CodeEntry; | 11 using i::CodeEntry; |
12 using i::CodeMap; | 12 using i::CodeMap; |
| 13 using i::CpuProfilesCollection; |
13 using i::ProfileNode; | 14 using i::ProfileNode; |
14 using i::ProfileTree; | 15 using i::ProfileTree; |
15 using i::StaticNameCodeEntry; | 16 using i::ProfileGenerator; |
| 17 using i::TickSample; |
16 using i::Vector; | 18 using i::Vector; |
17 | 19 |
18 | 20 |
19 TEST(ProfileNodeFindOrAddChild) { | 21 TEST(ProfileNodeFindOrAddChild) { |
20 ProfileNode node(NULL); | 22 ProfileNode node(NULL); |
21 StaticNameCodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 23 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa", "", 0); |
22 ProfileNode* childNode1 = node.FindOrAddChild(&entry1); | 24 ProfileNode* childNode1 = node.FindOrAddChild(&entry1); |
23 CHECK_NE(NULL, childNode1); | 25 CHECK_NE(NULL, childNode1); |
24 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 26 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); |
25 StaticNameCodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 27 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb", "", 0); |
26 ProfileNode* childNode2 = node.FindOrAddChild(&entry2); | 28 ProfileNode* childNode2 = node.FindOrAddChild(&entry2); |
27 CHECK_NE(NULL, childNode2); | 29 CHECK_NE(NULL, childNode2); |
28 CHECK_NE(childNode1, childNode2); | 30 CHECK_NE(childNode1, childNode2); |
29 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 31 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); |
30 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); | 32 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); |
31 StaticNameCodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 33 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc", "", 0); |
32 ProfileNode* childNode3 = node.FindOrAddChild(&entry3); | 34 ProfileNode* childNode3 = node.FindOrAddChild(&entry3); |
33 CHECK_NE(NULL, childNode3); | 35 CHECK_NE(NULL, childNode3); |
34 CHECK_NE(childNode1, childNode3); | 36 CHECK_NE(childNode1, childNode3); |
35 CHECK_NE(childNode2, childNode3); | 37 CHECK_NE(childNode2, childNode3); |
36 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 38 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); |
37 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); | 39 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); |
38 CHECK_EQ(childNode3, node.FindOrAddChild(&entry3)); | 40 CHECK_EQ(childNode3, node.FindOrAddChild(&entry3)); |
39 } | 41 } |
40 | 42 |
41 | 43 |
(...skipping 20 matching lines...) Expand all Loading... |
62 return node; | 64 return node; |
63 } | 65 } |
64 | 66 |
65 private: | 67 private: |
66 ProfileTree* tree_; | 68 ProfileTree* tree_; |
67 }; | 69 }; |
68 | 70 |
69 } // namespace | 71 } // namespace |
70 | 72 |
71 TEST(ProfileTreeAddPathFromStart) { | 73 TEST(ProfileTreeAddPathFromStart) { |
72 StaticNameCodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 74 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa", "", 0); |
73 StaticNameCodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 75 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb", "", 0); |
74 StaticNameCodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 76 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc", "", 0); |
75 ProfileTree tree; | 77 ProfileTree tree; |
76 ProfileTreeTestHelper helper(&tree); | 78 ProfileTreeTestHelper helper(&tree); |
77 CHECK_EQ(NULL, helper.Walk(&entry1)); | 79 CHECK_EQ(NULL, helper.Walk(&entry1)); |
78 CHECK_EQ(NULL, helper.Walk(&entry2)); | 80 CHECK_EQ(NULL, helper.Walk(&entry2)); |
79 CHECK_EQ(NULL, helper.Walk(&entry3)); | 81 CHECK_EQ(NULL, helper.Walk(&entry3)); |
80 | 82 |
81 CodeEntry* path[] = {NULL, &entry1, NULL, &entry2, NULL, NULL, &entry3, NULL}; | 83 CodeEntry* path[] = {NULL, &entry1, NULL, &entry2, NULL, NULL, &entry3, NULL}; |
82 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); | 84 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); |
83 tree.AddPathFromStart(path_vec); | 85 tree.AddPathFromStart(path_vec); |
84 CHECK_EQ(NULL, helper.Walk(&entry2)); | 86 CHECK_EQ(NULL, helper.Walk(&entry2)); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 CHECK_EQ(2, node3->self_ticks()); | 131 CHECK_EQ(2, node3->self_ticks()); |
130 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2); | 132 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2); |
131 CHECK_NE(NULL, node4); | 133 CHECK_NE(NULL, node4); |
132 CHECK_NE(node3, node4); | 134 CHECK_NE(node3, node4); |
133 CHECK_EQ(0, node4->total_ticks()); | 135 CHECK_EQ(0, node4->total_ticks()); |
134 CHECK_EQ(1, node4->self_ticks()); | 136 CHECK_EQ(1, node4->self_ticks()); |
135 } | 137 } |
136 | 138 |
137 | 139 |
138 TEST(ProfileTreeAddPathFromEnd) { | 140 TEST(ProfileTreeAddPathFromEnd) { |
139 StaticNameCodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 141 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa", "", 0); |
140 StaticNameCodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 142 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb", "", 0); |
141 StaticNameCodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 143 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc", "", 0); |
142 ProfileTree tree; | 144 ProfileTree tree; |
143 ProfileTreeTestHelper helper(&tree); | 145 ProfileTreeTestHelper helper(&tree); |
144 CHECK_EQ(NULL, helper.Walk(&entry1)); | 146 CHECK_EQ(NULL, helper.Walk(&entry1)); |
145 CHECK_EQ(NULL, helper.Walk(&entry2)); | 147 CHECK_EQ(NULL, helper.Walk(&entry2)); |
146 CHECK_EQ(NULL, helper.Walk(&entry3)); | 148 CHECK_EQ(NULL, helper.Walk(&entry3)); |
147 | 149 |
148 CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL}; | 150 CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL}; |
149 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); | 151 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); |
150 tree.AddPathFromEnd(path_vec); | 152 tree.AddPathFromEnd(path_vec); |
151 CHECK_EQ(NULL, helper.Walk(&entry2)); | 153 CHECK_EQ(NULL, helper.Walk(&entry2)); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 empty_tree.CalculateTotalTicks(); | 211 empty_tree.CalculateTotalTicks(); |
210 CHECK_EQ(0, empty_tree.root()->total_ticks()); | 212 CHECK_EQ(0, empty_tree.root()->total_ticks()); |
211 CHECK_EQ(0, empty_tree.root()->self_ticks()); | 213 CHECK_EQ(0, empty_tree.root()->self_ticks()); |
212 empty_tree.root()->IncrementSelfTicks(); | 214 empty_tree.root()->IncrementSelfTicks(); |
213 CHECK_EQ(0, empty_tree.root()->total_ticks()); | 215 CHECK_EQ(0, empty_tree.root()->total_ticks()); |
214 CHECK_EQ(1, empty_tree.root()->self_ticks()); | 216 CHECK_EQ(1, empty_tree.root()->self_ticks()); |
215 empty_tree.CalculateTotalTicks(); | 217 empty_tree.CalculateTotalTicks(); |
216 CHECK_EQ(1, empty_tree.root()->total_ticks()); | 218 CHECK_EQ(1, empty_tree.root()->total_ticks()); |
217 CHECK_EQ(1, empty_tree.root()->self_ticks()); | 219 CHECK_EQ(1, empty_tree.root()->self_ticks()); |
218 | 220 |
219 StaticNameCodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 221 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa", "", 0); |
220 StaticNameCodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 222 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb", "", 0); |
221 CodeEntry* e1_path[] = {&entry1}; | 223 CodeEntry* e1_path[] = {&entry1}; |
222 Vector<CodeEntry*> e1_path_vec( | 224 Vector<CodeEntry*> e1_path_vec( |
223 e1_path, sizeof(e1_path) / sizeof(e1_path[0])); | 225 e1_path, sizeof(e1_path) / sizeof(e1_path[0])); |
224 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; | 226 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; |
225 Vector<CodeEntry*> e1_e2_path_vec( | 227 Vector<CodeEntry*> e1_e2_path_vec( |
226 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); | 228 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); |
227 | 229 |
228 ProfileTree flat_tree; | 230 ProfileTree flat_tree; |
229 ProfileTreeTestHelper flat_helper(&flat_tree); | 231 ProfileTreeTestHelper flat_helper(&flat_tree); |
230 flat_tree.AddPathFromStart(e1_path_vec); | 232 flat_tree.AddPathFromStart(e1_path_vec); |
(...skipping 17 matching lines...) Expand all Loading... |
248 CHECK_EQ(5, flat_tree.root()->total_ticks()); | 250 CHECK_EQ(5, flat_tree.root()->total_ticks()); |
249 CHECK_EQ(0, flat_tree.root()->self_ticks()); | 251 CHECK_EQ(0, flat_tree.root()->self_ticks()); |
250 CHECK_EQ(5, node1->total_ticks()); | 252 CHECK_EQ(5, node1->total_ticks()); |
251 CHECK_EQ(2, node1->self_ticks()); | 253 CHECK_EQ(2, node1->self_ticks()); |
252 CHECK_EQ(3, node2->total_ticks()); | 254 CHECK_EQ(3, node2->total_ticks()); |
253 CHECK_EQ(3, node2->self_ticks()); | 255 CHECK_EQ(3, node2->self_ticks()); |
254 | 256 |
255 CodeEntry* e2_path[] = {&entry2}; | 257 CodeEntry* e2_path[] = {&entry2}; |
256 Vector<CodeEntry*> e2_path_vec( | 258 Vector<CodeEntry*> e2_path_vec( |
257 e2_path, sizeof(e2_path) / sizeof(e2_path[0])); | 259 e2_path, sizeof(e2_path) / sizeof(e2_path[0])); |
258 StaticNameCodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 260 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc", "", 0); |
259 CodeEntry* e3_path[] = {&entry3}; | 261 CodeEntry* e3_path[] = {&entry3}; |
260 Vector<CodeEntry*> e3_path_vec( | 262 Vector<CodeEntry*> e3_path_vec( |
261 e3_path, sizeof(e3_path) / sizeof(e3_path[0])); | 263 e3_path, sizeof(e3_path) / sizeof(e3_path[0])); |
262 | 264 |
263 ProfileTree wide_tree; | 265 ProfileTree wide_tree; |
264 ProfileTreeTestHelper wide_helper(&wide_tree); | 266 ProfileTreeTestHelper wide_helper(&wide_tree); |
265 wide_tree.AddPathFromStart(e1_path_vec); | 267 wide_tree.AddPathFromStart(e1_path_vec); |
266 wide_tree.AddPathFromStart(e1_path_vec); | 268 wide_tree.AddPathFromStart(e1_path_vec); |
267 wide_tree.AddPathFromStart(e1_e2_path_vec); | 269 wide_tree.AddPathFromStart(e1_e2_path_vec); |
268 wide_tree.AddPathFromStart(e2_path_vec); | 270 wide_tree.AddPathFromStart(e2_path_vec); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 CHECK_EQ(4, node3->self_ticks()); | 311 CHECK_EQ(4, node3->self_ticks()); |
310 } | 312 } |
311 | 313 |
312 | 314 |
313 static inline i::Address ToAddress(int n) { | 315 static inline i::Address ToAddress(int n) { |
314 return reinterpret_cast<i::Address>(n); | 316 return reinterpret_cast<i::Address>(n); |
315 } | 317 } |
316 | 318 |
317 TEST(CodeMapAddCode) { | 319 TEST(CodeMapAddCode) { |
318 CodeMap code_map; | 320 CodeMap code_map; |
319 StaticNameCodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 321 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa", "", 0); |
320 StaticNameCodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 322 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb", "", 0); |
321 StaticNameCodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 323 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc", "", 0); |
322 StaticNameCodeEntry entry4(i::Logger::FUNCTION_TAG, "ddd"); | 324 CodeEntry entry4(i::Logger::FUNCTION_TAG, "ddd", "", 0); |
323 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); | 325 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); |
324 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); | 326 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); |
325 code_map.AddCode(ToAddress(0x1900), &entry3, 0x50); | 327 code_map.AddCode(ToAddress(0x1900), &entry3, 0x50); |
326 code_map.AddCode(ToAddress(0x1950), &entry4, 0x10); | 328 code_map.AddCode(ToAddress(0x1950), &entry4, 0x10); |
327 CHECK_EQ(NULL, code_map.FindEntry(0)); | 329 CHECK_EQ(NULL, code_map.FindEntry(0)); |
328 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500 - 1))); | 330 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500 - 1))); |
329 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); | 331 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); |
330 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x100))); | 332 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x100))); |
331 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x200 - 1))); | 333 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x200 - 1))); |
332 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); | 334 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); |
333 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x50))); | 335 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x50))); |
334 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x100 - 1))); | 336 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x100 - 1))); |
335 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700 + 0x100))); | 337 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700 + 0x100))); |
336 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1900 - 1))); | 338 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1900 - 1))); |
337 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900))); | 339 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900))); |
338 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900 + 0x28))); | 340 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900 + 0x28))); |
339 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950))); | 341 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950))); |
340 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x7))); | 342 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x7))); |
341 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x10 - 1))); | 343 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x10 - 1))); |
342 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1950 + 0x10))); | 344 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1950 + 0x10))); |
343 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0xFFFFFFFF))); | 345 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0xFFFFFFFF))); |
344 } | 346 } |
345 | 347 |
346 | 348 |
347 TEST(CodeMapMoveAndDeleteCode) { | 349 TEST(CodeMapMoveAndDeleteCode) { |
348 CodeMap code_map; | 350 CodeMap code_map; |
349 StaticNameCodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 351 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa", "", 0); |
350 StaticNameCodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 352 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb", "", 0); |
351 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); | 353 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); |
352 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); | 354 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); |
353 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); | 355 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); |
354 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); | 356 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); |
355 code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1800)); | 357 code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1800)); |
356 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500))); | 358 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500))); |
357 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); | 359 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); |
358 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1800))); | 360 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1800))); |
359 code_map.DeleteCode(ToAddress(0x1700)); | 361 code_map.DeleteCode(ToAddress(0x1700)); |
360 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700))); | 362 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700))); |
361 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1800))); | 363 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1800))); |
362 } | 364 } |
| 365 |
| 366 |
| 367 TEST(RecordTickSample) { |
| 368 CpuProfilesCollection profiles; |
| 369 profiles.AddProfile(0); |
| 370 ProfileGenerator generator(&profiles); |
| 371 CodeEntry* entry1 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); |
| 372 CodeEntry* entry2 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); |
| 373 CodeEntry* entry3 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc"); |
| 374 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); |
| 375 generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); |
| 376 generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); |
| 377 |
| 378 ProfileTreeTestHelper top_down_test_helper(profiles.profile()->top_down()); |
| 379 CHECK_EQ(NULL, top_down_test_helper.Walk(entry1)); |
| 380 CHECK_EQ(NULL, top_down_test_helper.Walk(entry2)); |
| 381 CHECK_EQ(NULL, top_down_test_helper.Walk(entry3)); |
| 382 |
| 383 // We are building the following calls tree: |
| 384 // -> aaa - sample1 |
| 385 // aaa -> bbb -> ccc - sample2 |
| 386 // -> ccc -> aaa - sample3 |
| 387 TickSample sample1; |
| 388 sample1.pc = ToAddress(0x1600); |
| 389 sample1.function = ToAddress(0x1500); |
| 390 sample1.stack[0] = ToAddress(0x1510); |
| 391 sample1.frames_count = 1; |
| 392 generator.RecordTickSample(sample1); |
| 393 TickSample sample2; |
| 394 sample2.pc = ToAddress(0x1925); |
| 395 sample2.function = ToAddress(0x1900); |
| 396 sample2.stack[0] = ToAddress(0x1780); |
| 397 sample2.stack[1] = ToAddress(0x10000); // non-existent. |
| 398 sample2.stack[2] = ToAddress(0x1620); |
| 399 sample2.frames_count = 3; |
| 400 generator.RecordTickSample(sample2); |
| 401 TickSample sample3; |
| 402 sample3.pc = ToAddress(0x1510); |
| 403 sample3.function = ToAddress(0x1500); |
| 404 sample3.stack[0] = ToAddress(0x1910); |
| 405 sample3.stack[1] = ToAddress(0x1610); |
| 406 sample3.frames_count = 2; |
| 407 generator.RecordTickSample(sample3); |
| 408 |
| 409 ProfileNode* node1 = top_down_test_helper.Walk(entry1); |
| 410 CHECK_NE(NULL, node1); |
| 411 CHECK_EQ(entry1, node1->entry()); |
| 412 ProfileNode* node2 = top_down_test_helper.Walk(entry1, entry1); |
| 413 CHECK_NE(NULL, node2); |
| 414 CHECK_EQ(entry1, node2->entry()); |
| 415 // ProfileNode* node3 = top_down_test_helper.Walk(entry1, entry2, entry3); |
| 416 // CHECK_NE(NULL, node3); |
| 417 // CHECK_EQ(entry2, node3->entry()); |
| 418 ProfileNode* node4 = top_down_test_helper.Walk(entry1, entry3, entry1); |
| 419 CHECK_NE(NULL, node4); |
| 420 CHECK_EQ(entry1, node4->entry()); |
| 421 } |
OLD | NEW |