Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: runtime/vm/profiler_test.cc

Issue 2939853002: [fuchsia] Make profile processing resilient to bogus overlaps from dladdr. (Closed)
Patch Set: . Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/profiler_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/assert.h" 5 #include "platform/assert.h"
6 6
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/profiler.h" 10 #include "vm/profiler.h"
(...skipping 2791 matching lines...) Expand 10 before | Expand all | Expand 10 after
2802 EXPECT_SUBSTRING("\"inclusiveTicks\":[1,2]", js.ToCString()); 2802 EXPECT_SUBSTRING("\"inclusiveTicks\":[1,2]", js.ToCString());
2803 2803
2804 // Verify positions in main. 2804 // Verify positions in main.
2805 EXPECT_SUBSTRING("\"positions\":[\"TempMove\",39]", js.ToCString()); 2805 EXPECT_SUBSTRING("\"positions\":[\"TempMove\",39]", js.ToCString());
2806 // Verify exclusive ticks in main. 2806 // Verify exclusive ticks in main.
2807 EXPECT_SUBSTRING("\"exclusiveTicks\":[1,0]", js.ToCString()); 2807 EXPECT_SUBSTRING("\"exclusiveTicks\":[1,0]", js.ToCString());
2808 // Verify inclusive ticks in main. 2808 // Verify inclusive ticks in main.
2809 EXPECT_SUBSTRING("\"inclusiveTicks\":[1,2]", js.ToCString()); 2809 EXPECT_SUBSTRING("\"inclusiveTicks\":[1,2]", js.ToCString());
2810 } 2810 }
2811 2811
2812
2813 TEST_CASE(Profiler_ProfileCodeTableTest) {
2814 Zone* Z = Thread::Current()->zone();
2815
2816 ProfileCodeTable* table = new (Z) ProfileCodeTable();
2817 EXPECT_EQ(table->length(), 0);
2818 EXPECT_EQ(table->FindCodeForPC(42), static_cast<ProfileCode*>(NULL));
2819
2820 int64_t timestamp = 0;
2821 Code& null_code = Code::Handle(Z);
2822
2823 ProfileCode* code1 = new (Z)
2824 ProfileCode(ProfileCode::kNativeCode, 50, 60, timestamp, null_code);
2825 EXPECT_EQ(table->InsertCode(code1), 0);
2826 EXPECT_EQ(table->FindCodeForPC(0), static_cast<ProfileCode*>(NULL));
2827 EXPECT_EQ(table->FindCodeForPC(100), static_cast<ProfileCode*>(NULL));
2828 EXPECT_EQ(table->FindCodeForPC(50), code1);
2829 EXPECT_EQ(table->FindCodeForPC(55), code1);
2830 EXPECT_EQ(table->FindCodeForPC(59), code1);
2831 EXPECT_EQ(table->FindCodeForPC(60), static_cast<ProfileCode*>(NULL));
2832
2833 // Insert below all.
2834 ProfileCode* code2 = new (Z)
2835 ProfileCode(ProfileCode::kNativeCode, 10, 20, timestamp, null_code);
2836 EXPECT_EQ(table->InsertCode(code2), 0);
2837 EXPECT_EQ(table->FindCodeForPC(0), static_cast<ProfileCode*>(NULL));
2838 EXPECT_EQ(table->FindCodeForPC(100), static_cast<ProfileCode*>(NULL));
2839 EXPECT_EQ(table->FindCodeForPC(50), code1);
2840 EXPECT_EQ(table->FindCodeForPC(10), code2);
2841 EXPECT_EQ(table->FindCodeForPC(19), code2);
2842 EXPECT_EQ(table->FindCodeForPC(20), static_cast<ProfileCode*>(NULL));
2843
2844 // Insert above all.
2845 ProfileCode* code3 = new (Z)
2846 ProfileCode(ProfileCode::kNativeCode, 80, 90, timestamp, null_code);
2847 EXPECT_EQ(table->InsertCode(code3), 2);
2848 EXPECT_EQ(table->FindCodeForPC(0), static_cast<ProfileCode*>(NULL));
2849 EXPECT_EQ(table->FindCodeForPC(100), static_cast<ProfileCode*>(NULL));
2850 EXPECT_EQ(table->FindCodeForPC(50), code1);
2851 EXPECT_EQ(table->FindCodeForPC(10), code2);
2852 EXPECT_EQ(table->FindCodeForPC(80), code3);
2853 EXPECT_EQ(table->FindCodeForPC(89), code3);
2854 EXPECT_EQ(table->FindCodeForPC(90), static_cast<ProfileCode*>(NULL));
2855
2856 // Insert between.
2857 ProfileCode* code4 = new (Z)
2858 ProfileCode(ProfileCode::kNativeCode, 65, 75, timestamp, null_code);
2859 EXPECT_EQ(table->InsertCode(code4), 2);
2860 EXPECT_EQ(table->FindCodeForPC(0), static_cast<ProfileCode*>(NULL));
2861 EXPECT_EQ(table->FindCodeForPC(100), static_cast<ProfileCode*>(NULL));
2862 EXPECT_EQ(table->FindCodeForPC(50), code1);
2863 EXPECT_EQ(table->FindCodeForPC(10), code2);
2864 EXPECT_EQ(table->FindCodeForPC(80), code3);
2865 EXPECT_EQ(table->FindCodeForPC(65), code4);
2866 EXPECT_EQ(table->FindCodeForPC(74), code4);
2867 EXPECT_EQ(table->FindCodeForPC(75), static_cast<ProfileCode*>(NULL));
2868
2869 // Insert overlapping left.
2870 ProfileCode* code5 = new (Z)
2871 ProfileCode(ProfileCode::kNativeCode, 15, 25, timestamp, null_code);
2872 EXPECT_EQ(table->InsertCode(code5), 0);
2873 EXPECT_EQ(table->FindCodeForPC(0), static_cast<ProfileCode*>(NULL));
2874 EXPECT_EQ(table->FindCodeForPC(100), static_cast<ProfileCode*>(NULL));
2875 EXPECT_EQ(table->FindCodeForPC(50), code1);
2876 EXPECT_EQ(table->FindCodeForPC(10), code2);
2877 EXPECT_EQ(table->FindCodeForPC(80), code3);
2878 EXPECT_EQ(table->FindCodeForPC(65), code4);
2879 EXPECT_EQ(table->FindCodeForPC(15), code2); // Merged left.
2880 EXPECT_EQ(table->FindCodeForPC(24), code2); // Merged left.
2881 EXPECT_EQ(table->FindCodeForPC(25), static_cast<ProfileCode*>(NULL));
2882
2883 // Insert overlapping right.
2884 ProfileCode* code6 = new (Z)
2885 ProfileCode(ProfileCode::kNativeCode, 45, 55, timestamp, null_code);
2886 EXPECT_EQ(table->InsertCode(code6), 1);
2887 EXPECT_EQ(table->FindCodeForPC(0), static_cast<ProfileCode*>(NULL));
2888 EXPECT_EQ(table->FindCodeForPC(100), static_cast<ProfileCode*>(NULL));
2889 EXPECT_EQ(table->FindCodeForPC(50), code1);
2890 EXPECT_EQ(table->FindCodeForPC(10), code2);
2891 EXPECT_EQ(table->FindCodeForPC(80), code3);
2892 EXPECT_EQ(table->FindCodeForPC(65), code4);
2893 EXPECT_EQ(table->FindCodeForPC(15), code2); // Merged left.
2894 EXPECT_EQ(table->FindCodeForPC(24), code2); // Merged left.
2895 EXPECT_EQ(table->FindCodeForPC(45), code1); // Merged right.
2896 EXPECT_EQ(table->FindCodeForPC(54), code1); // Merged right.
2897 EXPECT_EQ(table->FindCodeForPC(55), code1);
2898
2899 // Insert overlapping both.
2900 ProfileCode* code7 = new (Z)
2901 ProfileCode(ProfileCode::kNativeCode, 20, 50, timestamp, null_code);
2902 EXPECT_EQ(table->InsertCode(code7), 0);
2903 EXPECT_EQ(table->FindCodeForPC(0), static_cast<ProfileCode*>(NULL));
2904 EXPECT_EQ(table->FindCodeForPC(100), static_cast<ProfileCode*>(NULL));
2905 EXPECT_EQ(table->FindCodeForPC(50), code1);
2906 EXPECT_EQ(table->FindCodeForPC(10), code2);
2907 EXPECT_EQ(table->FindCodeForPC(80), code3);
2908 EXPECT_EQ(table->FindCodeForPC(65), code4);
2909 EXPECT_EQ(table->FindCodeForPC(15), code2); // Merged left.
2910 EXPECT_EQ(table->FindCodeForPC(24), code2); // Merged left.
2911 EXPECT_EQ(table->FindCodeForPC(45), code1); // Merged right.
2912 EXPECT_EQ(table->FindCodeForPC(54), code1); // Merged right.
2913 EXPECT_EQ(table->FindCodeForPC(20), code2); // Merged left.
2914 EXPECT_EQ(table->FindCodeForPC(49), code1); // Truncated.
2915 EXPECT_EQ(table->FindCodeForPC(50), code1);
2916 }
2917
2812 #endif // !PRODUCT 2918 #endif // !PRODUCT
2813 2919
2814 } // namespace dart 2920 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/profiler_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698