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

Side by Side Diff: src/debug.cc

Issue 1227213003: Debugger: ensure that functions with debug info have code with break slots. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | src/objects.h » ('j') | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 } 919 }
920 // Remove all debug info. 920 // Remove all debug info.
921 while (debug_info_list_ != NULL) { 921 while (debug_info_list_ != NULL) {
922 RemoveDebugInfoAndClearFromShared(debug_info_list_->debug_info()); 922 RemoveDebugInfoAndClearFromShared(debug_info_list_->debug_info());
923 } 923 }
924 } 924 }
925 925
926 926
927 void Debug::FloodWithOneShot(Handle<JSFunction> function, 927 void Debug::FloodWithOneShot(Handle<JSFunction> function,
928 BreakLocatorType type) { 928 BreakLocatorType type) {
929 // Do not ever break in native and extension functions.
930 if (!function->IsSubjectToDebugging()) return;
931
932 PrepareForBreakPoints(); 929 PrepareForBreakPoints();
933 930
934 // Make sure the function is compiled and has set up the debug info. 931 // Make sure the function is compiled and has set up the debug info.
935 Handle<SharedFunctionInfo> shared(function->shared()); 932 Handle<SharedFunctionInfo> shared(function->shared());
936 if (!EnsureDebugInfo(shared, function)) { 933 if (!EnsureDebugInfo(shared, function)) {
937 // Return if we failed to retrieve the debug info. 934 // Return if we failed to retrieve the debug info.
938 return; 935 return;
939 } 936 }
940 937
941 // Flood the function with break points. 938 // Flood the function with break points.
942 for (BreakLocation::Iterator it(GetDebugInfo(shared), type); !it.Done(); 939 for (BreakLocation::Iterator it(GetDebugInfo(shared), type); !it.Done();
943 it.Next()) { 940 it.Next()) {
944 it.GetBreakLocation().SetOneShot(); 941 it.GetBreakLocation().SetOneShot();
945 } 942 }
946 } 943 }
947 944
948 945
949 void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) { 946 void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) {
950 Handle<FixedArray> new_bindings(function->function_bindings()); 947 Handle<FixedArray> new_bindings(function->function_bindings());
951 Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex), 948 Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex),
952 isolate_); 949 isolate_);
953 950
954 if (!bindee.is_null() && bindee->IsJSFunction() && 951 if (!bindee.is_null() && bindee->IsJSFunction()) {
955 JSFunction::cast(*bindee)->IsSubjectToDebugging()) {
956 Handle<JSFunction> bindee_function(JSFunction::cast(*bindee)); 952 Handle<JSFunction> bindee_function(JSFunction::cast(*bindee));
957 FloodWithOneShotGeneric(bindee_function); 953 FloodWithOneShotGeneric(bindee_function);
958 } 954 }
959 } 955 }
960 956
961 957
962 void Debug::FloodDefaultConstructorWithOneShot(Handle<JSFunction> function) { 958 void Debug::FloodDefaultConstructorWithOneShot(Handle<JSFunction> function) {
963 DCHECK(function->shared()->is_default_constructor()); 959 DCHECK(function->shared()->is_default_constructor());
964 // Instead of stepping into the function we directly step into the super class 960 // Instead of stepping into the function we directly step into the super class
965 // constructor. 961 // constructor.
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
1874 break; 1870 break;
1875 } 1871 }
1876 } 1872 }
1877 return isolate_->factory()->undefined_value(); 1873 return isolate_->factory()->undefined_value();
1878 } 1874 }
1879 1875
1880 1876
1881 // Ensures the debug information is present for shared. 1877 // Ensures the debug information is present for shared.
1882 bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, 1878 bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared,
1883 Handle<JSFunction> function) { 1879 Handle<JSFunction> function) {
1884 Isolate* isolate = shared->GetIsolate(); 1880 if (!shared->IsSubjectToDebugging()) return false;
1885 1881
1886 // Return if we already have the debug info for shared. 1882 // Return if we already have the debug info for shared.
1887 if (HasDebugInfo(shared)) { 1883 if (HasDebugInfo(shared)) {
1888 DCHECK(shared->is_compiled()); 1884 DCHECK(shared->is_compiled());
1885 DCHECK(shared->code()->has_debug_break_slots());
1889 return true; 1886 return true;
1890 } 1887 }
1891 1888
1892 // There will be at least one break point when we are done. 1889 // There will be at least one break point when we are done.
1893 has_break_points_ = true; 1890 has_break_points_ = true;
1894 1891
1895 // Ensure function is compiled. Return false if this failed. 1892 if (function.is_null()) {
1896 if (!function.is_null() && 1893 DCHECK(shared->is_compiled());
1897 !Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) { 1894 DCHECK(shared->code()->has_debug_break_slots());
1895 } else if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) {
1898 return false; 1896 return false;
1899 } 1897 }
1900 1898
1901 // Make sure IC state is clean. This is so that we correctly flood 1899 // Make sure IC state is clean. This is so that we correctly flood
1902 // accessor pairs when stepping in. 1900 // accessor pairs when stepping in.
1903 shared->code()->ClearInlineCaches(); 1901 shared->code()->ClearInlineCaches();
1904 shared->feedback_vector()->ClearICSlots(*shared); 1902 shared->feedback_vector()->ClearICSlots(*shared);
1905 1903
1906 // Create the debug info object. 1904 // Create the debug info object.
1907 Handle<DebugInfo> debug_info = isolate->factory()->NewDebugInfo(shared); 1905 DCHECK(shared->is_compiled());
1906 DCHECK(shared->code()->has_debug_break_slots());
1907 Handle<DebugInfo> debug_info = isolate_->factory()->NewDebugInfo(shared);
1908 1908
1909 // Add debug info to the list. 1909 // Add debug info to the list.
1910 DebugInfoListNode* node = new DebugInfoListNode(*debug_info); 1910 DebugInfoListNode* node = new DebugInfoListNode(*debug_info);
1911 node->set_next(debug_info_list_); 1911 node->set_next(debug_info_list_);
1912 debug_info_list_ = node; 1912 debug_info_list_ = node;
1913 1913
1914 return true; 1914 return true;
1915 } 1915 }
1916 1916
1917 1917
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
3071 } 3071 }
3072 3072
3073 3073
3074 void LockingCommandMessageQueue::Clear() { 3074 void LockingCommandMessageQueue::Clear() {
3075 base::LockGuard<base::Mutex> lock_guard(&mutex_); 3075 base::LockGuard<base::Mutex> lock_guard(&mutex_);
3076 queue_.Clear(); 3076 queue_.Clear();
3077 } 3077 }
3078 3078
3079 } // namespace internal 3079 } // namespace internal
3080 } // namespace v8 3080 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698