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 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 MaybeHandle<Object> Debug::MakeCompileEvent(Handle<Script> script, | 1700 MaybeHandle<Object> Debug::MakeCompileEvent(Handle<Script> script, |
1701 v8::DebugEvent type) { | 1701 v8::DebugEvent type) { |
1702 // Create the compile event object. | 1702 // Create the compile event object. |
1703 Handle<Object> script_wrapper = Script::GetWrapper(script); | 1703 Handle<Object> script_wrapper = Script::GetWrapper(script); |
1704 Handle<Object> argv[] = { script_wrapper, | 1704 Handle<Object> argv[] = { script_wrapper, |
1705 isolate_->factory()->NewNumberFromInt(type) }; | 1705 isolate_->factory()->NewNumberFromInt(type) }; |
1706 return CallFunction("MakeCompileEvent", arraysize(argv), argv); | 1706 return CallFunction("MakeCompileEvent", arraysize(argv), argv); |
1707 } | 1707 } |
1708 | 1708 |
1709 | 1709 |
1710 MaybeHandle<Object> Debug::MakePromiseEvent(Handle<JSObject> event_data) { | |
1711 // Create the promise event object. | |
1712 Handle<Object> argv[] = { event_data }; | |
1713 return CallFunction("MakePromiseEvent", arraysize(argv), argv); | |
1714 } | |
1715 | |
1716 | |
1717 MaybeHandle<Object> Debug::MakeAsyncTaskEvent(Handle<JSObject> task_event) { | 1710 MaybeHandle<Object> Debug::MakeAsyncTaskEvent(Handle<JSObject> task_event) { |
1718 // Create the async task event object. | 1711 // Create the async task event object. |
1719 Handle<Object> argv[] = { task_event }; | 1712 Handle<Object> argv[] = { task_event }; |
1720 return CallFunction("MakeAsyncTaskEvent", arraysize(argv), argv); | 1713 return CallFunction("MakeAsyncTaskEvent", arraysize(argv), argv); |
1721 } | 1714 } |
1722 | 1715 |
1723 | 1716 |
1724 void Debug::OnThrow(Handle<Object> exception) { | 1717 void Debug::OnThrow(Handle<Object> exception) { |
1725 if (in_debug_scope() || ignore_events()) return; | 1718 if (in_debug_scope() || ignore_events()) return; |
1726 PrepareStepOnThrow(); | 1719 PrepareStepOnThrow(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1837 ProcessCompileEvent(v8::BeforeCompile, script); | 1830 ProcessCompileEvent(v8::BeforeCompile, script); |
1838 } | 1831 } |
1839 | 1832 |
1840 | 1833 |
1841 // Handle debugger actions when a new script is compiled. | 1834 // Handle debugger actions when a new script is compiled. |
1842 void Debug::OnAfterCompile(Handle<Script> script) { | 1835 void Debug::OnAfterCompile(Handle<Script> script) { |
1843 ProcessCompileEvent(v8::AfterCompile, script); | 1836 ProcessCompileEvent(v8::AfterCompile, script); |
1844 } | 1837 } |
1845 | 1838 |
1846 | 1839 |
1847 void Debug::OnPromiseEvent(Handle<JSObject> data) { | |
1848 if (in_debug_scope() || ignore_events()) return; | |
1849 | |
1850 HandleScope scope(isolate_); | |
1851 DebugScope debug_scope(this); | |
1852 if (debug_scope.failed()) return; | |
1853 | |
1854 // Create the script collected state object. | |
1855 Handle<Object> event_data; | |
1856 // Bail out and don't call debugger if exception. | |
1857 if (!MakePromiseEvent(data).ToHandle(&event_data)) return; | |
1858 | |
1859 // Process debug event. | |
1860 ProcessDebugEvent(v8::PromiseEvent, | |
1861 Handle<JSObject>::cast(event_data), | |
1862 true); | |
1863 } | |
1864 | |
1865 | |
1866 void Debug::OnAsyncTaskEvent(Handle<JSObject> data) { | 1840 void Debug::OnAsyncTaskEvent(Handle<JSObject> data) { |
1867 if (in_debug_scope() || ignore_events()) return; | 1841 if (in_debug_scope() || ignore_events()) return; |
1868 | 1842 |
1869 HandleScope scope(isolate_); | 1843 HandleScope scope(isolate_); |
1870 DebugScope debug_scope(this); | 1844 DebugScope debug_scope(this); |
1871 if (debug_scope.failed()) return; | 1845 if (debug_scope.failed()) return; |
1872 | 1846 |
1873 // Create the script collected state object. | 1847 // Create the script collected state object. |
1874 Handle<Object> event_data; | 1848 Handle<Object> event_data; |
1875 // Bail out and don't call debugger if exception. | 1849 // Bail out and don't call debugger if exception. |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2005 HandleScope scope(isolate_); | 1979 HandleScope scope(isolate_); |
2006 // Process the individual events. | 1980 // Process the individual events. |
2007 bool sendEventMessage = false; | 1981 bool sendEventMessage = false; |
2008 switch (event) { | 1982 switch (event) { |
2009 case v8::Break: | 1983 case v8::Break: |
2010 sendEventMessage = !auto_continue; | 1984 sendEventMessage = !auto_continue; |
2011 break; | 1985 break; |
2012 case v8::NewFunction: | 1986 case v8::NewFunction: |
2013 case v8::BeforeCompile: | 1987 case v8::BeforeCompile: |
2014 case v8::CompileError: | 1988 case v8::CompileError: |
2015 case v8::PromiseEvent: | |
2016 case v8::AsyncTaskEvent: | 1989 case v8::AsyncTaskEvent: |
2017 break; | 1990 break; |
2018 case v8::Exception: | 1991 case v8::Exception: |
2019 case v8::AfterCompile: | 1992 case v8::AfterCompile: |
2020 sendEventMessage = true; | 1993 sendEventMessage = true; |
2021 break; | 1994 break; |
2022 } | 1995 } |
2023 | 1996 |
2024 // The debug command interrupt flag might have been set when the command was | 1997 // The debug command interrupt flag might have been set when the command was |
2025 // added. It should be enough to clear the flag only once while we are in the | 1998 // added. It should be enough to clear the flag only once while we are in the |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2621 } | 2594 } |
2622 | 2595 |
2623 | 2596 |
2624 void LockingCommandMessageQueue::Clear() { | 2597 void LockingCommandMessageQueue::Clear() { |
2625 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2598 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
2626 queue_.Clear(); | 2599 queue_.Clear(); |
2627 } | 2600 } |
2628 | 2601 |
2629 } // namespace internal | 2602 } // namespace internal |
2630 } // namespace v8 | 2603 } // namespace v8 |
OLD | NEW |