| OLD | NEW |
| 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 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 | 918 |
| 919 | 919 |
| 920 Object* Debug::Break(Arguments args) { | 920 Object* Debug::Break(Arguments args) { |
| 921 Heap* heap = isolate_->heap(); | 921 Heap* heap = isolate_->heap(); |
| 922 HandleScope scope(isolate_); | 922 HandleScope scope(isolate_); |
| 923 ASSERT(args.length() == 0); | 923 ASSERT(args.length() == 0); |
| 924 | 924 |
| 925 thread_local_.frame_drop_mode_ = FRAMES_UNTOUCHED; | 925 thread_local_.frame_drop_mode_ = FRAMES_UNTOUCHED; |
| 926 | 926 |
| 927 // Get the top-most JavaScript frame. | 927 // Get the top-most JavaScript frame. |
| 928 JavaScriptFrameIterator it; | 928 JavaScriptFrameIterator it(isolate_); |
| 929 JavaScriptFrame* frame = it.frame(); | 929 JavaScriptFrame* frame = it.frame(); |
| 930 | 930 |
| 931 // Just continue if breaks are disabled or debugger cannot be loaded. | 931 // Just continue if breaks are disabled or debugger cannot be loaded. |
| 932 if (disable_break() || !Load()) { | 932 if (disable_break() || !Load()) { |
| 933 SetAfterBreakTarget(frame); | 933 SetAfterBreakTarget(frame); |
| 934 return heap->undefined_value(); | 934 return heap->undefined_value(); |
| 935 } | 935 } |
| 936 | 936 |
| 937 // Enter the debugger. | 937 // Enter the debugger. |
| 938 EnterDebugger debugger; | 938 EnterDebugger debugger; |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 } | 1217 } |
| 1218 | 1218 |
| 1219 | 1219 |
| 1220 void Debug::FloodHandlerWithOneShot() { | 1220 void Debug::FloodHandlerWithOneShot() { |
| 1221 // Iterate through the JavaScript stack looking for handlers. | 1221 // Iterate through the JavaScript stack looking for handlers. |
| 1222 StackFrame::Id id = break_frame_id(); | 1222 StackFrame::Id id = break_frame_id(); |
| 1223 if (id == StackFrame::NO_ID) { | 1223 if (id == StackFrame::NO_ID) { |
| 1224 // If there is no JavaScript stack don't do anything. | 1224 // If there is no JavaScript stack don't do anything. |
| 1225 return; | 1225 return; |
| 1226 } | 1226 } |
| 1227 for (JavaScriptFrameIterator it(id); !it.done(); it.Advance()) { | 1227 for (JavaScriptFrameIterator it(isolate_, id); !it.done(); it.Advance()) { |
| 1228 JavaScriptFrame* frame = it.frame(); | 1228 JavaScriptFrame* frame = it.frame(); |
| 1229 if (frame->HasHandler()) { | 1229 if (frame->HasHandler()) { |
| 1230 Handle<SharedFunctionInfo> shared = | 1230 Handle<SharedFunctionInfo> shared = |
| 1231 Handle<SharedFunctionInfo>( | 1231 Handle<SharedFunctionInfo>( |
| 1232 JSFunction::cast(frame->function())->shared()); | 1232 JSFunction::cast(frame->function())->shared()); |
| 1233 // Flood the function with the catch block with break points | 1233 // Flood the function with the catch block with break points |
| 1234 FloodWithOneShot(shared); | 1234 FloodWithOneShot(shared); |
| 1235 return; | 1235 return; |
| 1236 } | 1236 } |
| 1237 } | 1237 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 | 1273 |
| 1274 // Get the frame where the execution has stopped and skip the debug frame if | 1274 // Get the frame where the execution has stopped and skip the debug frame if |
| 1275 // any. The debug frame will only be present if execution was stopped due to | 1275 // any. The debug frame will only be present if execution was stopped due to |
| 1276 // hitting a break point. In other situations (e.g. unhandled exception) the | 1276 // hitting a break point. In other situations (e.g. unhandled exception) the |
| 1277 // debug frame is not present. | 1277 // debug frame is not present. |
| 1278 StackFrame::Id id = break_frame_id(); | 1278 StackFrame::Id id = break_frame_id(); |
| 1279 if (id == StackFrame::NO_ID) { | 1279 if (id == StackFrame::NO_ID) { |
| 1280 // If there is no JavaScript stack don't do anything. | 1280 // If there is no JavaScript stack don't do anything. |
| 1281 return; | 1281 return; |
| 1282 } | 1282 } |
| 1283 JavaScriptFrameIterator frames_it(id); | 1283 JavaScriptFrameIterator frames_it(isolate_, id); |
| 1284 JavaScriptFrame* frame = frames_it.frame(); | 1284 JavaScriptFrame* frame = frames_it.frame(); |
| 1285 | 1285 |
| 1286 // First of all ensure there is one-shot break points in the top handler | 1286 // First of all ensure there is one-shot break points in the top handler |
| 1287 // if any. | 1287 // if any. |
| 1288 FloodHandlerWithOneShot(); | 1288 FloodHandlerWithOneShot(); |
| 1289 | 1289 |
| 1290 // If the function on the top frame is unresolved perform step out. This will | 1290 // If the function on the top frame is unresolved perform step out. This will |
| 1291 // be the case when calling unknown functions and having the debugger stopped | 1291 // be the case when calling unknown functions and having the debugger stopped |
| 1292 // in an unhandled exception. | 1292 // in an unhandled exception. |
| 1293 if (!frame->function()->IsJSFunction()) { | 1293 if (!frame->function()->IsJSFunction()) { |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1770 Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared()); | 1770 Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared()); |
| 1771 if (!EnsureDebugInfo(shared)) { | 1771 if (!EnsureDebugInfo(shared)) { |
| 1772 // Return if we failed to retrieve the debug info. | 1772 // Return if we failed to retrieve the debug info. |
| 1773 return; | 1773 return; |
| 1774 } | 1774 } |
| 1775 Handle<DebugInfo> debug_info = GetDebugInfo(shared); | 1775 Handle<DebugInfo> debug_info = GetDebugInfo(shared); |
| 1776 Handle<Code> code(debug_info->code()); | 1776 Handle<Code> code(debug_info->code()); |
| 1777 Handle<Code> original_code(debug_info->original_code()); | 1777 Handle<Code> original_code(debug_info->original_code()); |
| 1778 #ifdef DEBUG | 1778 #ifdef DEBUG |
| 1779 // Get the code which is actually executing. | 1779 // Get the code which is actually executing. |
| 1780 Handle<Code> frame_code(frame->LookupCode(isolate_)); | 1780 Handle<Code> frame_code(frame->LookupCode()); |
| 1781 ASSERT(frame_code.is_identical_to(code)); | 1781 ASSERT(frame_code.is_identical_to(code)); |
| 1782 #endif | 1782 #endif |
| 1783 | 1783 |
| 1784 // Find the call address in the running code. This address holds the call to | 1784 // Find the call address in the running code. This address holds the call to |
| 1785 // either a DebugBreakXXX or to the debug break return entry code if the | 1785 // either a DebugBreakXXX or to the debug break return entry code if the |
| 1786 // break point is still active after processing the break point. | 1786 // break point is still active after processing the break point. |
| 1787 Address addr = frame->pc() - Assembler::kCallTargetAddressOffset; | 1787 Address addr = frame->pc() - Assembler::kCallTargetAddressOffset; |
| 1788 | 1788 |
| 1789 // Check if the location is at JS exit or debug break slot. | 1789 // Check if the location is at JS exit or debug break slot. |
| 1790 bool at_js_return = false; | 1790 bool at_js_return = false; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1852 Handle<SharedFunctionInfo> shared = | 1852 Handle<SharedFunctionInfo> shared = |
| 1853 Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared()); | 1853 Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared()); |
| 1854 if (!EnsureDebugInfo(shared)) { | 1854 if (!EnsureDebugInfo(shared)) { |
| 1855 // Return if we failed to retrieve the debug info. | 1855 // Return if we failed to retrieve the debug info. |
| 1856 return false; | 1856 return false; |
| 1857 } | 1857 } |
| 1858 Handle<DebugInfo> debug_info = GetDebugInfo(shared); | 1858 Handle<DebugInfo> debug_info = GetDebugInfo(shared); |
| 1859 Handle<Code> code(debug_info->code()); | 1859 Handle<Code> code(debug_info->code()); |
| 1860 #ifdef DEBUG | 1860 #ifdef DEBUG |
| 1861 // Get the code which is actually executing. | 1861 // Get the code which is actually executing. |
| 1862 Handle<Code> frame_code(frame->LookupCode(Isolate::Current())); | 1862 Handle<Code> frame_code(frame->LookupCode()); |
| 1863 ASSERT(frame_code.is_identical_to(code)); | 1863 ASSERT(frame_code.is_identical_to(code)); |
| 1864 #endif | 1864 #endif |
| 1865 | 1865 |
| 1866 // Find the call address in the running code. | 1866 // Find the call address in the running code. |
| 1867 Address addr = frame->pc() - Assembler::kCallTargetAddressOffset; | 1867 Address addr = frame->pc() - Assembler::kCallTargetAddressOffset; |
| 1868 | 1868 |
| 1869 // Check if the location is at JS return. | 1869 // Check if the location is at JS return. |
| 1870 RelocIterator it(debug_info->code()); | 1870 RelocIterator it(debug_info->code()); |
| 1871 while (!it.done()) { | 1871 while (!it.done()) { |
| 1872 if (RelocInfo::IsJSReturn(it.rinfo()->rmode())) { | 1872 if (RelocInfo::IsJSReturn(it.rinfo()->rmode())) { |
| (...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3179 { | 3179 { |
| 3180 Locker locker; | 3180 Locker locker; |
| 3181 Isolate::Current()->debugger()->CallMessageDispatchHandler(); | 3181 Isolate::Current()->debugger()->CallMessageDispatchHandler(); |
| 3182 } | 3182 } |
| 3183 } | 3183 } |
| 3184 } | 3184 } |
| 3185 | 3185 |
| 3186 #endif // ENABLE_DEBUGGER_SUPPORT | 3186 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3187 | 3187 |
| 3188 } } // namespace v8::internal | 3188 } } // namespace v8::internal |
| OLD | NEW |