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

Side by Side Diff: test/cctest/test-debug.cc

Issue 2909893002: [debug] Untangle DebugInfo from break point support (Closed)
Patch Set: Address comments 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 | « src/objects/shared-function-info-inl.h ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } else { 151 } else {
152 i::Handle<i::Object> i_data = i_isolate->factory()->undefined_value(); 152 i::Handle<i::Object> i_data = i_isolate->factory()->undefined_value();
153 if (!data.IsEmpty()) i_data = v8::Utils::OpenHandle(*data); 153 if (!data.IsEmpty()) i_data = v8::Utils::OpenHandle(*data);
154 i::NativeDebugDelegate* delegate = 154 i::NativeDebugDelegate* delegate =
155 new i::NativeDebugDelegate(i_isolate, that, i_data); 155 new i::NativeDebugDelegate(i_isolate, that, i_data);
156 i_isolate->debug()->SetDebugDelegate(delegate, true); 156 i_isolate->debug()->SetDebugDelegate(delegate, true);
157 } 157 }
158 } 158 }
159 159
160 // Is there any debug info for the function? 160 // Is there any debug info for the function?
161 static bool HasDebugInfo(v8::Local<v8::Function> fun) { 161 static bool HasBreakInfo(v8::Local<v8::Function> fun) {
162 Handle<v8::internal::JSFunction> f = 162 Handle<v8::internal::JSFunction> f =
163 Handle<v8::internal::JSFunction>::cast(v8::Utils::OpenHandle(*fun)); 163 Handle<v8::internal::JSFunction>::cast(v8::Utils::OpenHandle(*fun));
164 Handle<v8::internal::SharedFunctionInfo> shared(f->shared()); 164 Handle<v8::internal::SharedFunctionInfo> shared(f->shared());
165 return shared->HasDebugInfo(); 165 return shared->HasBreakInfo();
166 } 166 }
167 167
168 // Set a break point in a function with a position relative to function start, 168 // Set a break point in a function with a position relative to function start,
169 // and return the associated break point number. 169 // and return the associated break point number.
170 static int SetBreakPoint(v8::Local<v8::Function> fun, int position) { 170 static int SetBreakPoint(v8::Local<v8::Function> fun, int position) {
171 i::Handle<i::JSFunction> function = 171 i::Handle<i::JSFunction> function =
172 i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*fun)); 172 i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*fun));
173 position += function->shared()->start_position(); 173 position += function->shared()->start_position();
174 static int break_point = 0; 174 static int break_point = 0;
175 v8::internal::Isolate* isolate = function->GetIsolate(); 175 v8::internal::Isolate* isolate = function->GetIsolate();
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 TEST(DebugInfo) { 899 TEST(DebugInfo) {
900 DebugLocalContext env; 900 DebugLocalContext env;
901 v8::HandleScope scope(env->GetIsolate()); 901 v8::HandleScope scope(env->GetIsolate());
902 // Create a couple of functions for the test. 902 // Create a couple of functions for the test.
903 v8::Local<v8::Function> foo = 903 v8::Local<v8::Function> foo =
904 CompileFunction(&env, "function foo(){}", "foo"); 904 CompileFunction(&env, "function foo(){}", "foo");
905 v8::Local<v8::Function> bar = 905 v8::Local<v8::Function> bar =
906 CompileFunction(&env, "function bar(){}", "bar"); 906 CompileFunction(&env, "function bar(){}", "bar");
907 // Initially no functions are debugged. 907 // Initially no functions are debugged.
908 CHECK_EQ(0, v8::internal::GetDebuggedFunctions()->length()); 908 CHECK_EQ(0, v8::internal::GetDebuggedFunctions()->length());
909 CHECK(!HasDebugInfo(foo)); 909 CHECK(!HasBreakInfo(foo));
910 CHECK(!HasDebugInfo(bar)); 910 CHECK(!HasBreakInfo(bar));
911 EnableDebugger(env->GetIsolate()); 911 EnableDebugger(env->GetIsolate());
912 // One function (foo) is debugged. 912 // One function (foo) is debugged.
913 int bp1 = SetBreakPoint(foo, 0); 913 int bp1 = SetBreakPoint(foo, 0);
914 CHECK_EQ(1, v8::internal::GetDebuggedFunctions()->length()); 914 CHECK_EQ(1, v8::internal::GetDebuggedFunctions()->length());
915 CHECK(HasDebugInfo(foo)); 915 CHECK(HasBreakInfo(foo));
916 CHECK(!HasDebugInfo(bar)); 916 CHECK(!HasBreakInfo(bar));
917 // Two functions are debugged. 917 // Two functions are debugged.
918 int bp2 = SetBreakPoint(bar, 0); 918 int bp2 = SetBreakPoint(bar, 0);
919 CHECK_EQ(2, v8::internal::GetDebuggedFunctions()->length()); 919 CHECK_EQ(2, v8::internal::GetDebuggedFunctions()->length());
920 CHECK(HasDebugInfo(foo)); 920 CHECK(HasBreakInfo(foo));
921 CHECK(HasDebugInfo(bar)); 921 CHECK(HasBreakInfo(bar));
922 // One function (bar) is debugged. 922 // One function (bar) is debugged.
923 ClearBreakPoint(bp1); 923 ClearBreakPoint(bp1);
924 CHECK_EQ(1, v8::internal::GetDebuggedFunctions()->length()); 924 CHECK_EQ(1, v8::internal::GetDebuggedFunctions()->length());
925 CHECK(!HasDebugInfo(foo)); 925 CHECK(!HasBreakInfo(foo));
926 CHECK(HasDebugInfo(bar)); 926 CHECK(HasBreakInfo(bar));
927 // No functions are debugged. 927 // No functions are debugged.
928 ClearBreakPoint(bp2); 928 ClearBreakPoint(bp2);
929 DisableDebugger(env->GetIsolate()); 929 DisableDebugger(env->GetIsolate());
930 CHECK_EQ(0, v8::internal::GetDebuggedFunctions()->length()); 930 CHECK_EQ(0, v8::internal::GetDebuggedFunctions()->length());
931 CHECK(!HasDebugInfo(foo)); 931 CHECK(!HasBreakInfo(foo));
932 CHECK(!HasDebugInfo(bar)); 932 CHECK(!HasBreakInfo(bar));
933 } 933 }
934 934
935 935
936 // Test that a break point can be set at an IC store location. 936 // Test that a break point can be set at an IC store location.
937 TEST(BreakPointICStore) { 937 TEST(BreakPointICStore) {
938 break_point_hit_count = 0; 938 break_point_hit_count = 0;
939 DebugLocalContext env; 939 DebugLocalContext env;
940 v8::HandleScope scope(env->GetIsolate()); 940 v8::HandleScope scope(env->GetIsolate());
941 941
942 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount); 942 SetDebugEventListener(env->GetIsolate(), DebugEventBreakPointHitCount);
(...skipping 5451 matching lines...) Expand 10 before | Expand all | Expand 10 after
6394 " debugger; \n" 6394 " debugger; \n"
6395 " f(); \n" 6395 " f(); \n"
6396 " debugger; \n" 6396 " debugger; \n"
6397 "} \n" 6397 "} \n"
6398 "f"); 6398 "f");
6399 Handle<i::Object> function_obj = v8::Utils::OpenHandle(*result); 6399 Handle<i::Object> function_obj = v8::Utils::OpenHandle(*result);
6400 Handle<i::JSFunction> function = Handle<i::JSFunction>::cast(function_obj); 6400 Handle<i::JSFunction> function = Handle<i::JSFunction>::cast(function_obj);
6401 Handle<i::SharedFunctionInfo> shared(function->shared()); 6401 Handle<i::SharedFunctionInfo> shared(function->shared());
6402 6402
6403 EnableDebugger(isolate); 6403 EnableDebugger(isolate);
6404 CHECK(i_isolate->debug()->EnsureDebugInfo(shared)); 6404 CHECK(i_isolate->debug()->EnsureBreakInfo(shared));
6405 6405
6406 Handle<i::DebugInfo> debug_info(shared->GetDebugInfo()); 6406 Handle<i::DebugInfo> debug_info(shared->GetDebugInfo());
6407 Handle<i::AbstractCode> abstract_code(shared->abstract_code()); 6407 Handle<i::AbstractCode> abstract_code(shared->abstract_code());
6408 6408
6409 { 6409 {
6410 auto iterator = i::BreakIterator::GetIterator(debug_info, abstract_code); 6410 auto iterator = i::BreakIterator::GetIterator(debug_info, abstract_code);
6411 CHECK(iterator->GetBreakLocation().IsDebuggerStatement()); 6411 CHECK(iterator->GetBreakLocation().IsDebuggerStatement());
6412 CHECK_EQ(17, iterator->GetBreakLocation().position()); 6412 CHECK_EQ(17, iterator->GetBreakLocation().position());
6413 iterator->Next(); 6413 iterator->Next();
6414 CHECK(iterator->GetBreakLocation().IsDebugBreakSlot()); 6414 CHECK(iterator->GetBreakLocation().IsDebugBreakSlot());
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
6728 // itself contains additional sanity checks. 6728 // itself contains additional sanity checks.
6729 for (i::Handle<i::JSFunction> fun : list) { 6729 for (i::Handle<i::JSFunction> fun : list) {
6730 bool failed = false; 6730 bool failed = false;
6731 { 6731 {
6732 i::NoSideEffectScope scope(isolate, true); 6732 i::NoSideEffectScope scope(isolate, true);
6733 failed = !isolate->debug()->PerformSideEffectCheck(fun); 6733 failed = !isolate->debug()->PerformSideEffectCheck(fun);
6734 } 6734 }
6735 if (failed) isolate->clear_pending_exception(); 6735 if (failed) isolate->clear_pending_exception();
6736 } 6736 }
6737 } 6737 }
OLDNEW
« no previous file with comments | « src/objects/shared-function-info-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698