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

Side by Side Diff: src/debug.cc

Issue 14886: Bring toiger up to date with bleeding edge 984. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: Created 12 years 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 | Annotate | Revision Log
« no previous file with comments | « src/debug.h ('k') | src/debug-delay.js » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 // Flood the function with break points. 842 // Flood the function with break points.
843 BreakLocationIterator it(GetDebugInfo(shared), ALL_BREAK_LOCATIONS); 843 BreakLocationIterator it(GetDebugInfo(shared), ALL_BREAK_LOCATIONS);
844 while (!it.Done()) { 844 while (!it.Done()) {
845 it.SetOneShot(); 845 it.SetOneShot();
846 it.Next(); 846 it.Next();
847 } 847 }
848 } 848 }
849 849
850 850
851 void Debug::FloodHandlerWithOneShot() { 851 void Debug::FloodHandlerWithOneShot() {
852 // Iterate through the JavaScript stack looking for handlers.
852 StackFrame::Id id = Top::break_frame_id(); 853 StackFrame::Id id = Top::break_frame_id();
854 if (id == StackFrame::NO_ID) {
855 // If there is no JavaScript stack don't do anything.
856 return;
857 }
853 for (JavaScriptFrameIterator it(id); !it.done(); it.Advance()) { 858 for (JavaScriptFrameIterator it(id); !it.done(); it.Advance()) {
854 JavaScriptFrame* frame = it.frame(); 859 JavaScriptFrame* frame = it.frame();
855 if (frame->HasHandler()) { 860 if (frame->HasHandler()) {
856 Handle<SharedFunctionInfo> shared = 861 Handle<SharedFunctionInfo> shared =
857 Handle<SharedFunctionInfo>( 862 Handle<SharedFunctionInfo>(
858 JSFunction::cast(frame->function())->shared()); 863 JSFunction::cast(frame->function())->shared());
859 // Flood the function with the catch block with break points 864 // Flood the function with the catch block with break points
860 FloodWithOneShot(shared); 865 FloodWithOneShot(shared);
861 return; 866 return;
862 } 867 }
(...skipping 16 matching lines...) Expand all
879 884
880 // Remember this step action and count. 885 // Remember this step action and count.
881 thread_local_.last_step_action_ = step_action; 886 thread_local_.last_step_action_ = step_action;
882 thread_local_.step_count_ = step_count; 887 thread_local_.step_count_ = step_count;
883 888
884 // Get the frame where the execution has stopped and skip the debug frame if 889 // Get the frame where the execution has stopped and skip the debug frame if
885 // any. The debug frame will only be present if execution was stopped due to 890 // any. The debug frame will only be present if execution was stopped due to
886 // hitting a break point. In other situations (e.g. unhandled exception) the 891 // hitting a break point. In other situations (e.g. unhandled exception) the
887 // debug frame is not present. 892 // debug frame is not present.
888 StackFrame::Id id = Top::break_frame_id(); 893 StackFrame::Id id = Top::break_frame_id();
894 if (id == StackFrame::NO_ID) {
895 // If there is no JavaScript stack don't do anything.
896 return;
897 }
889 JavaScriptFrameIterator frames_it(id); 898 JavaScriptFrameIterator frames_it(id);
890 JavaScriptFrame* frame = frames_it.frame(); 899 JavaScriptFrame* frame = frames_it.frame();
891 900
892 // First of all ensure there is one-shot break points in the top handler 901 // First of all ensure there is one-shot break points in the top handler
893 // if any. 902 // if any.
894 FloodHandlerWithOneShot(); 903 FloodHandlerWithOneShot();
895 904
896 // If the function on the top frame is unresolved perform step out. This will 905 // If the function on the top frame is unresolved perform step out. This will
897 // be the case when calling unknown functions and having the debugger stopped 906 // be the case when calling unknown functions and having the debugger stopped
898 // in an unhandled exception. 907 // in an unhandled exception.
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 // Called by the V8 thread. 1702 // Called by the V8 thread.
1694 // The new copy of the event string is destroyed in Run(). 1703 // The new copy of the event string is destroyed in Run().
1695 void DebugMessageThread::SendMessage(Vector<uint16_t> message) { 1704 void DebugMessageThread::SendMessage(Vector<uint16_t> message) {
1696 Vector<uint16_t> message_copy = message.Clone(); 1705 Vector<uint16_t> message_copy = message.Clone();
1697 Logger::DebugTag("Put message on event message_queue."); 1706 Logger::DebugTag("Put message on event message_queue.");
1698 message_queue_.Put(message_copy); 1707 message_queue_.Put(message_copy);
1699 message_received_->Signal(); 1708 message_received_->Signal();
1700 } 1709 }
1701 1710
1702 1711
1703 void DebugMessageThread::SetEventJSONFromEvent(Handle<Object> event_data) { 1712 bool DebugMessageThread::SetEventJSONFromEvent(Handle<Object> event_data) {
1704 v8::HandleScope scope; 1713 v8::HandleScope scope;
1705 // Call toJSONProtocol on the debug event object. 1714 // Call toJSONProtocol on the debug event object.
1706 v8::Local<v8::Object> api_event_data = 1715 v8::Local<v8::Object> api_event_data =
1707 v8::Utils::ToLocal(Handle<JSObject>::cast(event_data)); 1716 v8::Utils::ToLocal(Handle<JSObject>::cast(event_data));
1708 v8::Local<v8::String> fun_name = v8::String::New("toJSONProtocol"); 1717 v8::Local<v8::String> fun_name = v8::String::New("toJSONProtocol");
1709 v8::Local<v8::Function> fun = 1718 v8::Local<v8::Function> fun =
1710 v8::Function::Cast(*api_event_data->Get(fun_name)); 1719 v8::Function::Cast(*api_event_data->Get(fun_name));
1711 v8::TryCatch try_catch; 1720 v8::TryCatch try_catch;
1712 v8::Local<v8::Value> json_event = *fun->Call(api_event_data, 0, NULL); 1721 v8::Local<v8::Value> json_event = *fun->Call(api_event_data, 0, NULL);
1713 v8::Local<v8::String> json_event_string; 1722 v8::Local<v8::String> json_event_string;
1714 if (!try_catch.HasCaught()) { 1723 if (!try_catch.HasCaught()) {
1715 if (!json_event->IsUndefined()) { 1724 if (!json_event->IsUndefined()) {
1716 json_event_string = json_event->ToString(); 1725 json_event_string = json_event->ToString();
1717 if (FLAG_trace_debug_json) { 1726 if (FLAG_trace_debug_json) {
1718 PrintLn(json_event_string); 1727 PrintLn(json_event_string);
1719 } 1728 }
1720 v8::String::Value val(json_event_string); 1729 v8::String::Value val(json_event_string);
1721 Vector<uint16_t> str(reinterpret_cast<uint16_t*>(*val), 1730 Vector<uint16_t> str(reinterpret_cast<uint16_t*>(*val),
1722 json_event_string->Length()); 1731 json_event_string->Length());
1723 SendMessage(str); 1732 SendMessage(str);
1724 } else { 1733 } else {
1725 SendMessage(Vector<uint16_t>::empty()); 1734 SendMessage(Vector<uint16_t>::empty());
1726 } 1735 }
1727 } else { 1736 } else {
1728 PrintLn(try_catch.Exception()); 1737 PrintLn(try_catch.Exception());
1729 SendMessage(Vector<uint16_t>::empty()); 1738 return false;
1730 } 1739 }
1740 return true;
1731 } 1741 }
1732 1742
1733 1743
1734 void DebugMessageThread::Run() { 1744 void DebugMessageThread::Run() {
1735 // Sends debug events to an installed debugger message callback. 1745 // Sends debug events to an installed debugger message callback.
1736 while (true) { 1746 while (true) {
1737 // Wait and Get are paired so that semaphore count equals queue length. 1747 // Wait and Get are paired so that semaphore count equals queue length.
1738 message_received_->Wait(); 1748 message_received_->Wait();
1739 Logger::DebugTag("Get message from event message_queue."); 1749 Logger::DebugTag("Get message from event message_queue.");
1740 Vector<uint16_t> message = message_queue_.Get(); 1750 Vector<uint16_t> message = message_queue_.Get();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 v8::Function::Cast(*api_exec_state->Get(fun_name)); 1793 v8::Function::Cast(*api_exec_state->Get(fun_name));
1784 v8::TryCatch try_catch; 1794 v8::TryCatch try_catch;
1785 v8::Local<v8::Object> cmd_processor = 1795 v8::Local<v8::Object> cmd_processor =
1786 v8::Object::Cast(*fun->Call(api_exec_state, 0, NULL)); 1796 v8::Object::Cast(*fun->Call(api_exec_state, 0, NULL));
1787 if (try_catch.HasCaught()) { 1797 if (try_catch.HasCaught()) {
1788 PrintLn(try_catch.Exception()); 1798 PrintLn(try_catch.Exception());
1789 return; 1799 return;
1790 } 1800 }
1791 1801
1792 // Notify the debugger that a debug event has occurred. 1802 // Notify the debugger that a debug event has occurred.
1793 host_running_ = false; 1803 bool success = SetEventJSONFromEvent(event_data);
1794 SetEventJSONFromEvent(event_data); 1804 if (!success) {
1805 // If failed to notify debugger just continue running.
1806 return;
1807 }
1795 1808
1796 // Wait for requests from the debugger. 1809 // Wait for requests from the debugger.
1810 host_running_ = false;
1797 while (true) { 1811 while (true) {
1798 command_received_->Wait(); 1812 command_received_->Wait();
1799 Logger::DebugTag("Got request from command queue, in interactive loop."); 1813 Logger::DebugTag("Got request from command queue, in interactive loop.");
1800 Vector<uint16_t> command = command_queue_.Get(); 1814 Vector<uint16_t> command = command_queue_.Get();
1801 ASSERT(!host_running_); 1815 ASSERT(!host_running_);
1802 if (!Debugger::debugger_active()) { 1816 if (!Debugger::debugger_active()) {
1803 host_running_ = true; 1817 host_running_ = true;
1804 return; 1818 return;
1805 } 1819 }
1806 1820
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 } 1974 }
1961 1975
1962 1976
1963 void LockingMessageQueue::Clear() { 1977 void LockingMessageQueue::Clear() {
1964 ScopedLock sl(lock_); 1978 ScopedLock sl(lock_);
1965 queue_.Clear(); 1979 queue_.Clear();
1966 } 1980 }
1967 1981
1968 1982
1969 } } // namespace v8::internal 1983 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/debug.h ('k') | src/debug-delay.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698