| OLD | NEW |
| 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/debug/debug.h" | 5 #include "src/debug/debug.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 1857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1868 } | 1868 } |
| 1869 | 1869 |
| 1870 // Process debug event. | 1870 // Process debug event. |
| 1871 ProcessDebugEvent(v8::Exception, Handle<JSObject>::cast(event_data), false); | 1871 ProcessDebugEvent(v8::Exception, Handle<JSObject>::cast(event_data), false); |
| 1872 // Return to continue execution from where the exception was thrown. | 1872 // Return to continue execution from where the exception was thrown. |
| 1873 } | 1873 } |
| 1874 | 1874 |
| 1875 | 1875 |
| 1876 void Debug::OnCompileError(Handle<Script> script) { | 1876 void Debug::OnCompileError(Handle<Script> script) { |
| 1877 if (ignore_events()) return; | 1877 if (ignore_events()) return; |
| 1878 SuppressDebug while_processing(this); |
| 1878 | 1879 |
| 1879 if (in_debug_scope()) { | 1880 if (in_debug_scope()) { |
| 1880 ProcessCompileEventInDebugScope(v8::CompileError, script); | 1881 ProcessCompileEventInDebugScope(v8::CompileError, script); |
| 1881 return; | 1882 return; |
| 1882 } | 1883 } |
| 1883 | 1884 |
| 1884 HandleScope scope(isolate_); | 1885 HandleScope scope(isolate_); |
| 1885 DebugScope debug_scope(this); | 1886 DebugScope debug_scope(this); |
| 1886 if (debug_scope.failed()) return; | 1887 if (debug_scope.failed()) return; |
| 1887 | 1888 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1910 | 1911 |
| 1911 // Process debug event. | 1912 // Process debug event. |
| 1912 ProcessDebugEvent(v8::Break, | 1913 ProcessDebugEvent(v8::Break, |
| 1913 Handle<JSObject>::cast(event_data), | 1914 Handle<JSObject>::cast(event_data), |
| 1914 auto_continue); | 1915 auto_continue); |
| 1915 } | 1916 } |
| 1916 | 1917 |
| 1917 | 1918 |
| 1918 void Debug::OnBeforeCompile(Handle<Script> script) { | 1919 void Debug::OnBeforeCompile(Handle<Script> script) { |
| 1919 if (in_debug_scope() || ignore_events()) return; | 1920 if (in_debug_scope() || ignore_events()) return; |
| 1921 SuppressDebug while_processing(this); |
| 1920 | 1922 |
| 1921 HandleScope scope(isolate_); | 1923 HandleScope scope(isolate_); |
| 1922 DebugScope debug_scope(this); | 1924 DebugScope debug_scope(this); |
| 1923 if (debug_scope.failed()) return; | 1925 if (debug_scope.failed()) return; |
| 1924 | 1926 |
| 1925 // Create the event data object. | 1927 // Create the event data object. |
| 1926 Handle<Object> event_data; | 1928 Handle<Object> event_data; |
| 1927 // Bail out and don't call debugger if exception. | 1929 // Bail out and don't call debugger if exception. |
| 1928 if (!MakeCompileEvent(script, v8::BeforeCompile).ToHandle(&event_data)) | 1930 if (!MakeCompileEvent(script, v8::BeforeCompile).ToHandle(&event_data)) |
| 1929 return; | 1931 return; |
| 1930 | 1932 |
| 1931 // Process debug event. | 1933 // Process debug event. |
| 1932 ProcessDebugEvent(v8::BeforeCompile, | 1934 ProcessDebugEvent(v8::BeforeCompile, |
| 1933 Handle<JSObject>::cast(event_data), | 1935 Handle<JSObject>::cast(event_data), |
| 1934 true); | 1936 true); |
| 1935 } | 1937 } |
| 1936 | 1938 |
| 1937 | 1939 |
| 1938 // Handle debugger actions when a new script is compiled. | 1940 // Handle debugger actions when a new script is compiled. |
| 1939 void Debug::OnAfterCompile(Handle<Script> script) { | 1941 void Debug::OnAfterCompile(Handle<Script> script) { |
| 1940 // Add the newly compiled script to the script cache. | 1942 // Add the newly compiled script to the script cache. |
| 1941 if (script_cache_ != NULL) script_cache_->Add(script); | 1943 if (script_cache_ != NULL) script_cache_->Add(script); |
| 1942 | 1944 |
| 1943 if (ignore_events()) return; | 1945 if (ignore_events()) return; |
| 1946 SuppressDebug while_processing(this); |
| 1944 | 1947 |
| 1945 if (in_debug_scope()) { | 1948 if (in_debug_scope()) { |
| 1946 ProcessCompileEventInDebugScope(v8::AfterCompile, script); | 1949 ProcessCompileEventInDebugScope(v8::AfterCompile, script); |
| 1947 return; | 1950 return; |
| 1948 } | 1951 } |
| 1949 | 1952 |
| 1950 HandleScope scope(isolate_); | 1953 HandleScope scope(isolate_); |
| 1951 DebugScope debug_scope(this); | 1954 DebugScope debug_scope(this); |
| 1952 if (debug_scope.failed()) return; | 1955 if (debug_scope.failed()) return; |
| 1953 | 1956 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2030 if ((event != v8::Break || !auto_continue) && !event_listener_.is_null()) { | 2033 if ((event != v8::Break || !auto_continue) && !event_listener_.is_null()) { |
| 2031 CallEventCallback(event, exec_state, event_data, NULL); | 2034 CallEventCallback(event, exec_state, event_data, NULL); |
| 2032 } | 2035 } |
| 2033 } | 2036 } |
| 2034 | 2037 |
| 2035 | 2038 |
| 2036 void Debug::CallEventCallback(v8::DebugEvent event, | 2039 void Debug::CallEventCallback(v8::DebugEvent event, |
| 2037 Handle<Object> exec_state, | 2040 Handle<Object> exec_state, |
| 2038 Handle<Object> event_data, | 2041 Handle<Object> event_data, |
| 2039 v8::Debug::ClientData* client_data) { | 2042 v8::Debug::ClientData* client_data) { |
| 2043 // Prevent other interrupts from triggering, for example API callbacks, |
| 2044 // while dispatching event listners. |
| 2045 PostponeInterruptsScope postpone(isolate_); |
| 2040 bool previous = in_debug_event_listener_; | 2046 bool previous = in_debug_event_listener_; |
| 2041 in_debug_event_listener_ = true; | 2047 in_debug_event_listener_ = true; |
| 2042 if (event_listener_->IsForeign()) { | 2048 if (event_listener_->IsForeign()) { |
| 2043 // Invoke the C debug event listener. | 2049 // Invoke the C debug event listener. |
| 2044 v8::Debug::EventCallback callback = | 2050 v8::Debug::EventCallback callback = |
| 2045 FUNCTION_CAST<v8::Debug::EventCallback>( | 2051 FUNCTION_CAST<v8::Debug::EventCallback>( |
| 2046 Handle<Foreign>::cast(event_listener_)->foreign_address()); | 2052 Handle<Foreign>::cast(event_listener_)->foreign_address()); |
| 2047 EventDetailsImpl event_details(event, | 2053 EventDetailsImpl event_details(event, |
| 2048 Handle<JSObject>::cast(exec_state), | 2054 Handle<JSObject>::cast(exec_state), |
| 2049 Handle<JSObject>::cast(event_data), | 2055 Handle<JSObject>::cast(event_data), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2063 global, arraysize(argv), argv); | 2069 global, arraysize(argv), argv); |
| 2064 } | 2070 } |
| 2065 in_debug_event_listener_ = previous; | 2071 in_debug_event_listener_ = previous; |
| 2066 } | 2072 } |
| 2067 | 2073 |
| 2068 | 2074 |
| 2069 void Debug::ProcessCompileEventInDebugScope(v8::DebugEvent event, | 2075 void Debug::ProcessCompileEventInDebugScope(v8::DebugEvent event, |
| 2070 Handle<Script> script) { | 2076 Handle<Script> script) { |
| 2071 if (event_listener_.is_null()) return; | 2077 if (event_listener_.is_null()) return; |
| 2072 | 2078 |
| 2073 SuppressDebug while_processing(this); | |
| 2074 DebugScope debug_scope(this); | 2079 DebugScope debug_scope(this); |
| 2075 if (debug_scope.failed()) return; | 2080 if (debug_scope.failed()) return; |
| 2076 | 2081 |
| 2077 Handle<Object> event_data; | 2082 Handle<Object> event_data; |
| 2078 // Bail out and don't call debugger if exception. | 2083 // Bail out and don't call debugger if exception. |
| 2079 if (!MakeCompileEvent(script, event).ToHandle(&event_data)) return; | 2084 if (!MakeCompileEvent(script, event).ToHandle(&event_data)) return; |
| 2080 | 2085 |
| 2081 // Create the execution state. | 2086 // Create the execution state. |
| 2082 Handle<Object> exec_state; | 2087 Handle<Object> exec_state; |
| 2083 // Bail out and don't call debugger if exception. | 2088 // Bail out and don't call debugger if exception. |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2676 } | 2681 } |
| 2677 | 2682 |
| 2678 | 2683 |
| 2679 void LockingCommandMessageQueue::Clear() { | 2684 void LockingCommandMessageQueue::Clear() { |
| 2680 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2685 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
| 2681 queue_.Clear(); | 2686 queue_.Clear(); |
| 2682 } | 2687 } |
| 2683 | 2688 |
| 2684 } // namespace internal | 2689 } // namespace internal |
| 2685 } // namespace v8 | 2690 } // namespace v8 |
| OLD | NEW |