OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 EnterDebugger debugger; | 958 EnterDebugger debugger; |
959 if (debugger.FailedToEnter()) { | 959 if (debugger.FailedToEnter()) { |
960 return heap->undefined_value(); | 960 return heap->undefined_value(); |
961 } | 961 } |
962 | 962 |
963 // Postpone interrupt during breakpoint processing. | 963 // Postpone interrupt during breakpoint processing. |
964 PostponeInterruptsScope postpone(isolate_); | 964 PostponeInterruptsScope postpone(isolate_); |
965 | 965 |
966 // Get the debug info (create it if it does not exist). | 966 // Get the debug info (create it if it does not exist). |
967 Handle<SharedFunctionInfo> shared = | 967 Handle<SharedFunctionInfo> shared = |
968 Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared()); | 968 Handle<SharedFunctionInfo>(frame->function()->shared()); |
969 Handle<DebugInfo> debug_info = GetDebugInfo(shared); | 969 Handle<DebugInfo> debug_info = GetDebugInfo(shared); |
970 | 970 |
971 // Find the break point where execution has stopped. | 971 // Find the break point where execution has stopped. |
972 BreakLocationIterator break_location_iterator(debug_info, | 972 BreakLocationIterator break_location_iterator(debug_info, |
973 ALL_BREAK_LOCATIONS); | 973 ALL_BREAK_LOCATIONS); |
974 // pc points to the instruction after the current one, possibly a break | 974 // pc points to the instruction after the current one, possibly a break |
975 // location as well. So the "- 1" to exclude it from the search. | 975 // location as well. So the "- 1" to exclude it from the search. |
976 break_location_iterator.FindBreakLocationFromAddress(frame->pc() - 1); | 976 break_location_iterator.FindBreakLocationFromAddress(frame->pc() - 1); |
977 | 977 |
978 // Check whether step next reached a new statement. | 978 // Check whether step next reached a new statement. |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1341 // Iterate through the JavaScript stack looking for handlers. | 1341 // Iterate through the JavaScript stack looking for handlers. |
1342 StackFrame::Id id = break_frame_id(); | 1342 StackFrame::Id id = break_frame_id(); |
1343 if (id == StackFrame::NO_ID) { | 1343 if (id == StackFrame::NO_ID) { |
1344 // If there is no JavaScript stack don't do anything. | 1344 // If there is no JavaScript stack don't do anything. |
1345 return; | 1345 return; |
1346 } | 1346 } |
1347 for (JavaScriptFrameIterator it(isolate_, id); !it.done(); it.Advance()) { | 1347 for (JavaScriptFrameIterator it(isolate_, id); !it.done(); it.Advance()) { |
1348 JavaScriptFrame* frame = it.frame(); | 1348 JavaScriptFrame* frame = it.frame(); |
1349 if (frame->HasHandler()) { | 1349 if (frame->HasHandler()) { |
1350 // Flood the function with the catch block with break points | 1350 // Flood the function with the catch block with break points |
1351 JSFunction* function = JSFunction::cast(frame->function()); | 1351 FloodWithOneShot(Handle<JSFunction>(frame->function())); |
1352 FloodWithOneShot(Handle<JSFunction>(function)); | |
1353 return; | 1352 return; |
1354 } | 1353 } |
1355 } | 1354 } |
1356 } | 1355 } |
1357 | 1356 |
1358 | 1357 |
1359 void Debug::ChangeBreakOnException(ExceptionBreakType type, bool enable) { | 1358 void Debug::ChangeBreakOnException(ExceptionBreakType type, bool enable) { |
1360 if (type == BreakUncaughtException) { | 1359 if (type == BreakUncaughtException) { |
1361 break_on_uncaught_exception_ = enable; | 1360 break_on_uncaught_exception_ = enable; |
1362 } else { | 1361 } else { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 FloodHandlerWithOneShot(); | 1407 FloodHandlerWithOneShot(); |
1409 | 1408 |
1410 // If the function on the top frame is unresolved perform step out. This will | 1409 // If the function on the top frame is unresolved perform step out. This will |
1411 // be the case when calling unknown functions and having the debugger stopped | 1410 // be the case when calling unknown functions and having the debugger stopped |
1412 // in an unhandled exception. | 1411 // in an unhandled exception. |
1413 if (!frame->function()->IsJSFunction()) { | 1412 if (!frame->function()->IsJSFunction()) { |
1414 // Step out: Find the calling JavaScript frame and flood it with | 1413 // Step out: Find the calling JavaScript frame and flood it with |
1415 // breakpoints. | 1414 // breakpoints. |
1416 frames_it.Advance(); | 1415 frames_it.Advance(); |
1417 // Fill the function to return to with one-shot break points. | 1416 // Fill the function to return to with one-shot break points. |
1418 JSFunction* function = JSFunction::cast(frames_it.frame()->function()); | 1417 JSFunction* function = frames_it.frame()->function(); |
1419 FloodWithOneShot(Handle<JSFunction>(function)); | 1418 FloodWithOneShot(Handle<JSFunction>(function)); |
1420 return; | 1419 return; |
1421 } | 1420 } |
1422 | 1421 |
1423 // Get the debug info (create it if it does not exist). | 1422 // Get the debug info (create it if it does not exist). |
1424 Handle<JSFunction> function(JSFunction::cast(frame->function())); | 1423 Handle<JSFunction> function(frame->function()); |
1425 Handle<SharedFunctionInfo> shared(function->shared()); | 1424 Handle<SharedFunctionInfo> shared(function->shared()); |
1426 if (!EnsureDebugInfo(shared, function)) { | 1425 if (!EnsureDebugInfo(shared, function)) { |
1427 // Return if ensuring debug info failed. | 1426 // Return if ensuring debug info failed. |
1428 return; | 1427 return; |
1429 } | 1428 } |
1430 Handle<DebugInfo> debug_info = GetDebugInfo(shared); | 1429 Handle<DebugInfo> debug_info = GetDebugInfo(shared); |
1431 | 1430 |
1432 // Find the break location where execution has stopped. | 1431 // Find the break location where execution has stopped. |
1433 BreakLocationIterator it(debug_info, ALL_BREAK_LOCATIONS); | 1432 BreakLocationIterator it(debug_info, ALL_BREAK_LOCATIONS); |
1434 // pc points to the instruction after the current one, possibly a break | 1433 // pc points to the instruction after the current one, possibly a break |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1479 if (step_action == StepOut) { | 1478 if (step_action == StepOut) { |
1480 // Skip step_count frames starting with the current one. | 1479 // Skip step_count frames starting with the current one. |
1481 while (step_count-- > 0 && !frames_it.done()) { | 1480 while (step_count-- > 0 && !frames_it.done()) { |
1482 frames_it.Advance(); | 1481 frames_it.Advance(); |
1483 } | 1482 } |
1484 } else { | 1483 } else { |
1485 ASSERT(it.IsExit()); | 1484 ASSERT(it.IsExit()); |
1486 frames_it.Advance(); | 1485 frames_it.Advance(); |
1487 } | 1486 } |
1488 // Skip builtin functions on the stack. | 1487 // Skip builtin functions on the stack. |
1489 while (!frames_it.done() && | 1488 while (!frames_it.done() && frames_it.frame()->function()->IsBuiltin()) { |
1490 JSFunction::cast(frames_it.frame()->function())->IsBuiltin()) { | |
1491 frames_it.Advance(); | 1489 frames_it.Advance(); |
1492 } | 1490 } |
1493 // Step out: If there is a JavaScript caller frame, we need to | 1491 // Step out: If there is a JavaScript caller frame, we need to |
1494 // flood it with breakpoints. | 1492 // flood it with breakpoints. |
1495 if (!frames_it.done()) { | 1493 if (!frames_it.done()) { |
1496 // Fill the function to return to with one-shot break points. | 1494 // Fill the function to return to with one-shot break points. |
1497 JSFunction* function = JSFunction::cast(frames_it.frame()->function()); | 1495 JSFunction* function = frames_it.frame()->function(); |
1498 FloodWithOneShot(Handle<JSFunction>(function)); | 1496 FloodWithOneShot(Handle<JSFunction>(function)); |
1499 // Set target frame pointer. | 1497 // Set target frame pointer. |
1500 ActivateStepOut(frames_it.frame()); | 1498 ActivateStepOut(frames_it.frame()); |
1501 } | 1499 } |
1502 } else if (!(is_inline_cache_stub || RelocInfo::IsConstructCall(it.rmode()) || | 1500 } else if (!(is_inline_cache_stub || RelocInfo::IsConstructCall(it.rmode()) || |
1503 !call_function_stub.is_null() || is_at_restarted_function) | 1501 !call_function_stub.is_null() || is_at_restarted_function) |
1504 || step_action == StepNext || step_action == StepMin) { | 1502 || step_action == StepNext || step_action == StepMin) { |
1505 // Step next or step min. | 1503 // Step next or step min. |
1506 | 1504 |
1507 // Fill the current function with one-shot break points. | 1505 // Fill the current function with one-shot break points. |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1909 JavaScriptFrame* frame = it.frame(); | 1907 JavaScriptFrame* frame = it.frame(); |
1910 if (frame->is_optimized()) { | 1908 if (frame->is_optimized()) { |
1911 List<JSFunction*> functions(Compiler::kMaxInliningLevels + 1); | 1909 List<JSFunction*> functions(Compiler::kMaxInliningLevels + 1); |
1912 frame->GetFunctions(&functions); | 1910 frame->GetFunctions(&functions); |
1913 for (int i = 0; i < functions.length(); i++) { | 1911 for (int i = 0; i < functions.length(); i++) { |
1914 JSFunction* function = functions[i]; | 1912 JSFunction* function = functions[i]; |
1915 active_functions->Add(Handle<JSFunction>(function)); | 1913 active_functions->Add(Handle<JSFunction>(function)); |
1916 function->shared()->code()->set_gc_metadata(active_code_marker); | 1914 function->shared()->code()->set_gc_metadata(active_code_marker); |
1917 } | 1915 } |
1918 } else if (frame->function()->IsJSFunction()) { | 1916 } else if (frame->function()->IsJSFunction()) { |
1919 JSFunction* function = JSFunction::cast(frame->function()); | 1917 JSFunction* function = frame->function(); |
1920 ASSERT(frame->LookupCode()->kind() == Code::FUNCTION); | 1918 ASSERT(frame->LookupCode()->kind() == Code::FUNCTION); |
1921 active_functions->Add(Handle<JSFunction>(function)); | 1919 active_functions->Add(Handle<JSFunction>(function)); |
1922 function->shared()->code()->set_gc_metadata(active_code_marker); | 1920 function->shared()->code()->set_gc_metadata(active_code_marker); |
1923 } | 1921 } |
1924 } | 1922 } |
1925 } | 1923 } |
1926 | 1924 |
1927 | 1925 |
1928 static void RedirectActivationsToRecompiledCodeOnThread( | 1926 static void RedirectActivationsToRecompiledCodeOnThread( |
1929 Isolate* isolate, | 1927 Isolate* isolate, |
1930 ThreadLocalTop* top) { | 1928 ThreadLocalTop* top) { |
1931 for (JavaScriptFrameIterator it(isolate, top); !it.done(); it.Advance()) { | 1929 for (JavaScriptFrameIterator it(isolate, top); !it.done(); it.Advance()) { |
1932 JavaScriptFrame* frame = it.frame(); | 1930 JavaScriptFrame* frame = it.frame(); |
1933 | 1931 |
1934 if (frame->is_optimized() || !frame->function()->IsJSFunction()) continue; | 1932 if (frame->is_optimized() || !frame->function()->IsJSFunction()) continue; |
1935 | 1933 |
1936 JSFunction* function = JSFunction::cast(frame->function()); | 1934 JSFunction* function = frame->function(); |
1937 | 1935 |
1938 ASSERT(frame->LookupCode()->kind() == Code::FUNCTION); | 1936 ASSERT(frame->LookupCode()->kind() == Code::FUNCTION); |
1939 | 1937 |
1940 Handle<Code> frame_code(frame->LookupCode()); | 1938 Handle<Code> frame_code(frame->LookupCode()); |
1941 if (frame_code->has_debug_break_slots()) continue; | 1939 if (frame_code->has_debug_break_slots()) continue; |
1942 | 1940 |
1943 Handle<Code> new_code(function->shared()->code()); | 1941 Handle<Code> new_code(function->shared()->code()); |
1944 if (new_code->kind() != Code::FUNCTION || | 1942 if (new_code->kind() != Code::FUNCTION || |
1945 !new_code->has_debug_break_slots()) { | 1943 !new_code->has_debug_break_slots()) { |
1946 continue; | 1944 continue; |
(...skipping 1913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3860 { | 3858 { |
3861 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); | 3859 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); |
3862 isolate_->debugger()->CallMessageDispatchHandler(); | 3860 isolate_->debugger()->CallMessageDispatchHandler(); |
3863 } | 3861 } |
3864 } | 3862 } |
3865 } | 3863 } |
3866 | 3864 |
3867 #endif // ENABLE_DEBUGGER_SUPPORT | 3865 #endif // ENABLE_DEBUGGER_SUPPORT |
3868 | 3866 |
3869 } } // namespace v8::internal | 3867 } } // namespace v8::internal |
OLD | NEW |