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 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 | 1163 |
1164 | 1164 |
1165 // Return the debug info for this function. EnsureDebugInfo must be called | 1165 // Return the debug info for this function. EnsureDebugInfo must be called |
1166 // prior to ensure the debug info has been generated for shared. | 1166 // prior to ensure the debug info has been generated for shared. |
1167 Handle<DebugInfo> Debug::GetDebugInfo(Handle<SharedFunctionInfo> shared) { | 1167 Handle<DebugInfo> Debug::GetDebugInfo(Handle<SharedFunctionInfo> shared) { |
1168 ASSERT(HasDebugInfo(shared)); | 1168 ASSERT(HasDebugInfo(shared)); |
1169 return Handle<DebugInfo>(DebugInfo::cast(shared->debug_info())); | 1169 return Handle<DebugInfo>(DebugInfo::cast(shared->debug_info())); |
1170 } | 1170 } |
1171 | 1171 |
1172 | 1172 |
1173 void Debug::SetBreakPoint(Handle<JSFunction> function, | 1173 void Debug::SetBreakPoint(Handle<SharedFunctionInfo> shared, |
1174 Handle<Object> break_point_object, | 1174 Handle<Object> break_point_object, |
1175 int* source_position) { | 1175 int* source_position) { |
1176 HandleScope scope(isolate_); | 1176 HandleScope scope(isolate_); |
1177 | 1177 |
1178 PrepareForBreakPoints(); | 1178 PrepareForBreakPoints(); |
1179 | 1179 |
1180 // Make sure the function is compiled and has set up the debug info. | 1180 if (!EnsureDebugInfo(shared)) { |
1181 Handle<SharedFunctionInfo> shared(function->shared()); | |
1182 if (!EnsureDebugInfo(shared, function)) { | |
1183 // Return if retrieving debug info failed. | 1181 // Return if retrieving debug info failed. |
1184 return; | 1182 return; |
1185 } | 1183 } |
1186 | 1184 |
1187 Handle<DebugInfo> debug_info = GetDebugInfo(shared); | 1185 Handle<DebugInfo> debug_info = GetDebugInfo(shared); |
1188 // Source positions starts with zero. | 1186 // Source positions starts with zero. |
1189 ASSERT(*source_position >= 0); | 1187 ASSERT(*source_position >= 0); |
1190 | 1188 |
1191 // Find the break point and change it. | 1189 // Find the break point and change it. |
1192 BreakLocationIterator it(debug_info, SOURCE_BREAK_LOCATIONS); | 1190 BreakLocationIterator it(debug_info, SOURCE_BREAK_LOCATIONS); |
1193 it.FindBreakLocationFromPosition(*source_position); | 1191 it.FindBreakLocationFromPosition(*source_position); |
1194 it.SetBreakPoint(break_point_object); | 1192 it.SetBreakPoint(break_point_object); |
1195 | 1193 |
1196 *source_position = it.position(); | 1194 *source_position = it.position(); |
1197 | 1195 |
1198 // At least one active break point now. | 1196 // At least one active break point now. |
1199 ASSERT(debug_info->GetBreakPointCount() > 0); | 1197 ASSERT(debug_info->GetBreakPointCount() > 0); |
1200 } | 1198 } |
1201 | 1199 |
1202 | 1200 |
1203 bool Debug::SetBreakPointForScript(Handle<Script> script, | |
1204 Handle<Object> break_point_object, | |
1205 int* source_position) { | |
1206 HandleScope scope(isolate_); | |
1207 | |
1208 // No need to call PrepareForBreakPoints because it will be called | |
1209 // implicitly by Runtime::FindSharedFunctionInfoInScript. | |
1210 Object* result = Runtime::FindSharedFunctionInfoInScript(isolate_, | |
1211 script, | |
1212 *source_position); | |
1213 if (result->IsUndefined()) return false; | |
1214 | |
1215 // Make sure the function has set up the debug info. | |
1216 Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(result)); | |
1217 if (!EnsureDebugInfo(shared, Handle<JSFunction>::null())) { | |
1218 // Return if retrieving debug info failed. | |
1219 return false; | |
1220 } | |
1221 | |
1222 // Find position within function. The script position might be before the | |
1223 // source position of the first function. | |
1224 int position; | |
1225 if (shared->start_position() > *source_position) { | |
1226 position = 0; | |
1227 } else { | |
1228 position = *source_position - shared->start_position(); | |
1229 } | |
1230 | |
1231 Handle<DebugInfo> debug_info = GetDebugInfo(shared); | |
1232 // Source positions starts with zero. | |
1233 ASSERT(position >= 0); | |
1234 | |
1235 // Find the break point and change it. | |
1236 BreakLocationIterator it(debug_info, SOURCE_BREAK_LOCATIONS); | |
1237 it.FindBreakLocationFromPosition(position); | |
1238 it.SetBreakPoint(break_point_object); | |
1239 | |
1240 *source_position = it.position() + shared->start_position(); | |
1241 | |
1242 // At least one active break point now. | |
1243 ASSERT(debug_info->GetBreakPointCount() > 0); | |
1244 return true; | |
1245 } | |
1246 | |
1247 | |
1248 void Debug::ClearBreakPoint(Handle<Object> break_point_object) { | 1201 void Debug::ClearBreakPoint(Handle<Object> break_point_object) { |
1249 HandleScope scope(isolate_); | 1202 HandleScope scope(isolate_); |
1250 | 1203 |
1251 DebugInfoListNode* node = debug_info_list_; | 1204 DebugInfoListNode* node = debug_info_list_; |
1252 while (node != NULL) { | 1205 while (node != NULL) { |
1253 Object* result = DebugInfo::FindBreakPointInfo(node->debug_info(), | 1206 Object* result = DebugInfo::FindBreakPointInfo(node->debug_info(), |
1254 break_point_object); | 1207 break_point_object); |
1255 if (!result->IsUndefined()) { | 1208 if (!result->IsUndefined()) { |
1256 // Get information in the break point. | 1209 // Get information in the break point. |
1257 BreakPointInfo* break_point_info = BreakPointInfo::cast(result); | 1210 BreakPointInfo* break_point_info = BreakPointInfo::cast(result); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 node = node->next(); | 1242 node = node->next(); |
1290 } | 1243 } |
1291 | 1244 |
1292 // Remove all debug info. | 1245 // Remove all debug info. |
1293 while (debug_info_list_ != NULL) { | 1246 while (debug_info_list_ != NULL) { |
1294 RemoveDebugInfo(debug_info_list_->debug_info()); | 1247 RemoveDebugInfo(debug_info_list_->debug_info()); |
1295 } | 1248 } |
1296 } | 1249 } |
1297 | 1250 |
1298 | 1251 |
1299 void Debug::FloodWithOneShot(Handle<JSFunction> function) { | 1252 void Debug::FloodWithOneShot(Handle<SharedFunctionInfo> shared) { |
1300 PrepareForBreakPoints(); | 1253 PrepareForBreakPoints(); |
1301 | 1254 // Make sure the function has set up the debug info. |
1302 // Make sure the function is compiled and has set up the debug info. | 1255 if (!EnsureDebugInfo(shared)) { |
1303 Handle<SharedFunctionInfo> shared(function->shared()); | |
1304 if (!EnsureDebugInfo(shared, function)) { | |
1305 // Return if we failed to retrieve the debug info. | 1256 // Return if we failed to retrieve the debug info. |
1306 return; | 1257 return; |
1307 } | 1258 } |
1308 | 1259 |
1309 // Flood the function with break points. | 1260 // Flood the function with break points. |
1310 BreakLocationIterator it(GetDebugInfo(shared), ALL_BREAK_LOCATIONS); | 1261 BreakLocationIterator it(GetDebugInfo(shared), ALL_BREAK_LOCATIONS); |
1311 while (!it.Done()) { | 1262 while (!it.Done()) { |
1312 it.SetOneShot(); | 1263 it.SetOneShot(); |
1313 it.Next(); | 1264 it.Next(); |
1314 } | 1265 } |
1315 } | 1266 } |
1316 | 1267 |
1317 | 1268 |
1318 void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) { | 1269 void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) { |
1319 Handle<FixedArray> new_bindings(function->function_bindings()); | 1270 Handle<FixedArray> new_bindings(function->function_bindings()); |
1320 Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex)); | 1271 Handle<Object> bindee(new_bindings->get(JSFunction::kBoundFunctionIndex)); |
1321 | 1272 |
1322 if (!bindee.is_null() && bindee->IsJSFunction() && | 1273 if (!bindee.is_null() && bindee->IsJSFunction() && |
1323 !JSFunction::cast(*bindee)->IsBuiltin()) { | 1274 !JSFunction::cast(*bindee)->IsBuiltin()) { |
1324 Handle<JSFunction> bindee_function(JSFunction::cast(*bindee)); | 1275 Handle<SharedFunctionInfo> shared_info(JSFunction::cast(*bindee)->shared()); |
1325 Debug::FloodWithOneShot(bindee_function); | 1276 Debug::FloodWithOneShot(shared_info); |
1326 } | 1277 } |
1327 } | 1278 } |
1328 | 1279 |
1329 | 1280 |
1330 void Debug::FloodHandlerWithOneShot() { | 1281 void Debug::FloodHandlerWithOneShot() { |
1331 // Iterate through the JavaScript stack looking for handlers. | 1282 // Iterate through the JavaScript stack looking for handlers. |
1332 StackFrame::Id id = break_frame_id(); | 1283 StackFrame::Id id = break_frame_id(); |
1333 if (id == StackFrame::NO_ID) { | 1284 if (id == StackFrame::NO_ID) { |
1334 // If there is no JavaScript stack don't do anything. | 1285 // If there is no JavaScript stack don't do anything. |
1335 return; | 1286 return; |
1336 } | 1287 } |
1337 for (JavaScriptFrameIterator it(isolate_, id); !it.done(); it.Advance()) { | 1288 for (JavaScriptFrameIterator it(isolate_, id); !it.done(); it.Advance()) { |
1338 JavaScriptFrame* frame = it.frame(); | 1289 JavaScriptFrame* frame = it.frame(); |
1339 if (frame->HasHandler()) { | 1290 if (frame->HasHandler()) { |
| 1291 Handle<SharedFunctionInfo> shared = |
| 1292 Handle<SharedFunctionInfo>( |
| 1293 JSFunction::cast(frame->function())->shared()); |
1340 // Flood the function with the catch block with break points | 1294 // Flood the function with the catch block with break points |
1341 JSFunction* function = JSFunction::cast(frame->function()); | 1295 FloodWithOneShot(shared); |
1342 FloodWithOneShot(Handle<JSFunction>(function)); | |
1343 return; | 1296 return; |
1344 } | 1297 } |
1345 } | 1298 } |
1346 } | 1299 } |
1347 | 1300 |
1348 | 1301 |
1349 void Debug::ChangeBreakOnException(ExceptionBreakType type, bool enable) { | 1302 void Debug::ChangeBreakOnException(ExceptionBreakType type, bool enable) { |
1350 if (type == BreakUncaughtException) { | 1303 if (type == BreakUncaughtException) { |
1351 break_on_uncaught_exception_ = enable; | 1304 break_on_uncaught_exception_ = enable; |
1352 } else { | 1305 } else { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 | 1352 |
1400 // If the function on the top frame is unresolved perform step out. This will | 1353 // If the function on the top frame is unresolved perform step out. This will |
1401 // be the case when calling unknown functions and having the debugger stopped | 1354 // be the case when calling unknown functions and having the debugger stopped |
1402 // in an unhandled exception. | 1355 // in an unhandled exception. |
1403 if (!frame->function()->IsJSFunction()) { | 1356 if (!frame->function()->IsJSFunction()) { |
1404 // Step out: Find the calling JavaScript frame and flood it with | 1357 // Step out: Find the calling JavaScript frame and flood it with |
1405 // breakpoints. | 1358 // breakpoints. |
1406 frames_it.Advance(); | 1359 frames_it.Advance(); |
1407 // Fill the function to return to with one-shot break points. | 1360 // Fill the function to return to with one-shot break points. |
1408 JSFunction* function = JSFunction::cast(frames_it.frame()->function()); | 1361 JSFunction* function = JSFunction::cast(frames_it.frame()->function()); |
1409 FloodWithOneShot(Handle<JSFunction>(function)); | 1362 FloodWithOneShot(Handle<SharedFunctionInfo>(function->shared())); |
1410 return; | 1363 return; |
1411 } | 1364 } |
1412 | 1365 |
1413 // Get the debug info (create it if it does not exist). | 1366 // Get the debug info (create it if it does not exist). |
1414 Handle<JSFunction> function(JSFunction::cast(frame->function())); | 1367 Handle<SharedFunctionInfo> shared = |
1415 Handle<SharedFunctionInfo> shared(function->shared()); | 1368 Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared()); |
1416 if (!EnsureDebugInfo(shared, function)) { | 1369 if (!EnsureDebugInfo(shared)) { |
1417 // Return if ensuring debug info failed. | 1370 // Return if ensuring debug info failed. |
1418 return; | 1371 return; |
1419 } | 1372 } |
1420 Handle<DebugInfo> debug_info = GetDebugInfo(shared); | 1373 Handle<DebugInfo> debug_info = GetDebugInfo(shared); |
1421 | 1374 |
1422 // Find the break location where execution has stopped. | 1375 // Find the break location where execution has stopped. |
1423 BreakLocationIterator it(debug_info, ALL_BREAK_LOCATIONS); | 1376 BreakLocationIterator it(debug_info, ALL_BREAK_LOCATIONS); |
1424 it.FindBreakLocationFromAddress(frame->pc()); | 1377 it.FindBreakLocationFromAddress(frame->pc()); |
1425 | 1378 |
1426 // Compute whether or not the target is a call target. | 1379 // Compute whether or not the target is a call target. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 // Skip builtin functions on the stack. | 1429 // Skip builtin functions on the stack. |
1477 while (!frames_it.done() && | 1430 while (!frames_it.done() && |
1478 JSFunction::cast(frames_it.frame()->function())->IsBuiltin()) { | 1431 JSFunction::cast(frames_it.frame()->function())->IsBuiltin()) { |
1479 frames_it.Advance(); | 1432 frames_it.Advance(); |
1480 } | 1433 } |
1481 // Step out: If there is a JavaScript caller frame, we need to | 1434 // Step out: If there is a JavaScript caller frame, we need to |
1482 // flood it with breakpoints. | 1435 // flood it with breakpoints. |
1483 if (!frames_it.done()) { | 1436 if (!frames_it.done()) { |
1484 // Fill the function to return to with one-shot break points. | 1437 // Fill the function to return to with one-shot break points. |
1485 JSFunction* function = JSFunction::cast(frames_it.frame()->function()); | 1438 JSFunction* function = JSFunction::cast(frames_it.frame()->function()); |
1486 FloodWithOneShot(Handle<JSFunction>(function)); | 1439 FloodWithOneShot(Handle<SharedFunctionInfo>(function->shared())); |
1487 // Set target frame pointer. | 1440 // Set target frame pointer. |
1488 ActivateStepOut(frames_it.frame()); | 1441 ActivateStepOut(frames_it.frame()); |
1489 } | 1442 } |
1490 } else if (!(is_inline_cache_stub || RelocInfo::IsConstructCall(it.rmode()) || | 1443 } else if (!(is_inline_cache_stub || RelocInfo::IsConstructCall(it.rmode()) || |
1491 !call_function_stub.is_null() || is_at_restarted_function) | 1444 !call_function_stub.is_null() || is_at_restarted_function) |
1492 || step_action == StepNext || step_action == StepMin) { | 1445 || step_action == StepNext || step_action == StepMin) { |
1493 // Step next or step min. | 1446 // Step next or step min. |
1494 | 1447 |
1495 // Fill the current function with one-shot break points. | 1448 // Fill the current function with one-shot break points. |
1496 FloodWithOneShot(function); | 1449 FloodWithOneShot(shared); |
1497 | 1450 |
1498 // Remember source position and frame to handle step next. | 1451 // Remember source position and frame to handle step next. |
1499 thread_local_.last_statement_position_ = | 1452 thread_local_.last_statement_position_ = |
1500 debug_info->code()->SourceStatementPosition(frame->pc()); | 1453 debug_info->code()->SourceStatementPosition(frame->pc()); |
1501 thread_local_.last_fp_ = frame->UnpaddedFP(); | 1454 thread_local_.last_fp_ = frame->UnpaddedFP(); |
1502 } else { | 1455 } else { |
1503 // If there's restarter frame on top of the stack, just get the pointer | 1456 // If there's restarter frame on top of the stack, just get the pointer |
1504 // to function which is going to be restarted. | 1457 // to function which is going to be restarted. |
1505 if (is_at_restarted_function) { | 1458 if (is_at_restarted_function) { |
1506 Handle<JSFunction> restarted_function( | 1459 Handle<JSFunction> restarted_function( |
1507 JSFunction::cast(*thread_local_.restarter_frame_function_pointer_)); | 1460 JSFunction::cast(*thread_local_.restarter_frame_function_pointer_)); |
1508 FloodWithOneShot(restarted_function); | 1461 Handle<SharedFunctionInfo> restarted_shared( |
| 1462 restarted_function->shared()); |
| 1463 FloodWithOneShot(restarted_shared); |
1509 } else if (!call_function_stub.is_null()) { | 1464 } else if (!call_function_stub.is_null()) { |
1510 // If it's CallFunction stub ensure target function is compiled and flood | 1465 // If it's CallFunction stub ensure target function is compiled and flood |
1511 // it with one shot breakpoints. | 1466 // it with one shot breakpoints. |
1512 | 1467 |
1513 // Find out number of arguments from the stub minor key. | 1468 // Find out number of arguments from the stub minor key. |
1514 // Reverse lookup required as the minor key cannot be retrieved | 1469 // Reverse lookup required as the minor key cannot be retrieved |
1515 // from the code object. | 1470 // from the code object. |
1516 Handle<Object> obj( | 1471 Handle<Object> obj( |
1517 isolate_->heap()->code_stubs()->SlowReverseLookup( | 1472 isolate_->heap()->code_stubs()->SlowReverseLookup( |
1518 *call_function_stub)); | 1473 *call_function_stub)); |
(...skipping 21 matching lines...) Expand all Loading... |
1540 ASSERT(expressions_count - 2 - call_function_arg_count >= 0); | 1495 ASSERT(expressions_count - 2 - call_function_arg_count >= 0); |
1541 Object* fun = frame->GetExpression( | 1496 Object* fun = frame->GetExpression( |
1542 expressions_count - 2 - call_function_arg_count); | 1497 expressions_count - 2 - call_function_arg_count); |
1543 if (fun->IsJSFunction()) { | 1498 if (fun->IsJSFunction()) { |
1544 Handle<JSFunction> js_function(JSFunction::cast(fun)); | 1499 Handle<JSFunction> js_function(JSFunction::cast(fun)); |
1545 if (js_function->shared()->bound()) { | 1500 if (js_function->shared()->bound()) { |
1546 Debug::FloodBoundFunctionWithOneShot(js_function); | 1501 Debug::FloodBoundFunctionWithOneShot(js_function); |
1547 } else if (!js_function->IsBuiltin()) { | 1502 } else if (!js_function->IsBuiltin()) { |
1548 // Don't step into builtins. | 1503 // Don't step into builtins. |
1549 // It will also compile target function if it's not compiled yet. | 1504 // It will also compile target function if it's not compiled yet. |
1550 FloodWithOneShot(js_function); | 1505 FloodWithOneShot(Handle<SharedFunctionInfo>(js_function->shared())); |
1551 } | 1506 } |
1552 } | 1507 } |
1553 } | 1508 } |
1554 | 1509 |
1555 // Fill the current function with one-shot break points even for step in on | 1510 // Fill the current function with one-shot break points even for step in on |
1556 // a call target as the function called might be a native function for | 1511 // a call target as the function called might be a native function for |
1557 // which step in will not stop. It also prepares for stepping in | 1512 // which step in will not stop. It also prepares for stepping in |
1558 // getters/setters. | 1513 // getters/setters. |
1559 FloodWithOneShot(function); | 1514 FloodWithOneShot(shared); |
1560 | 1515 |
1561 if (is_load_or_store) { | 1516 if (is_load_or_store) { |
1562 // Remember source position and frame to handle step in getter/setter. If | 1517 // Remember source position and frame to handle step in getter/setter. If |
1563 // there is a custom getter/setter it will be handled in | 1518 // there is a custom getter/setter it will be handled in |
1564 // Object::Get/SetPropertyWithCallback, otherwise the step action will be | 1519 // Object::Get/SetPropertyWithCallback, otherwise the step action will be |
1565 // propagated on the next Debug::Break. | 1520 // propagated on the next Debug::Break. |
1566 thread_local_.last_statement_position_ = | 1521 thread_local_.last_statement_position_ = |
1567 debug_info->code()->SourceStatementPosition(frame->pc()); | 1522 debug_info->code()->SourceStatementPosition(frame->pc()); |
1568 thread_local_.last_fp_ = frame->UnpaddedFP(); | 1523 thread_local_.last_fp_ = frame->UnpaddedFP(); |
1569 } | 1524 } |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1749 if (function->shared()->code() == | 1704 if (function->shared()->code() == |
1750 Isolate::Current()->builtins()->builtin(Builtins::kFunctionApply) || | 1705 Isolate::Current()->builtins()->builtin(Builtins::kFunctionApply) || |
1751 function->shared()->code() == | 1706 function->shared()->code() == |
1752 Isolate::Current()->builtins()->builtin(Builtins::kFunctionCall)) { | 1707 Isolate::Current()->builtins()->builtin(Builtins::kFunctionCall)) { |
1753 // Handle function.apply and function.call separately to flood the | 1708 // Handle function.apply and function.call separately to flood the |
1754 // function to be called and not the code for Builtins::FunctionApply or | 1709 // function to be called and not the code for Builtins::FunctionApply or |
1755 // Builtins::FunctionCall. The receiver of call/apply is the target | 1710 // Builtins::FunctionCall. The receiver of call/apply is the target |
1756 // function. | 1711 // function. |
1757 if (!holder.is_null() && holder->IsJSFunction() && | 1712 if (!holder.is_null() && holder->IsJSFunction() && |
1758 !JSFunction::cast(*holder)->IsBuiltin()) { | 1713 !JSFunction::cast(*holder)->IsBuiltin()) { |
1759 Handle<JSFunction> js_function = Handle<JSFunction>::cast(holder); | 1714 Handle<SharedFunctionInfo> shared_info( |
1760 Debug::FloodWithOneShot(js_function); | 1715 JSFunction::cast(*holder)->shared()); |
| 1716 Debug::FloodWithOneShot(shared_info); |
1761 } | 1717 } |
1762 } else { | 1718 } else { |
1763 Debug::FloodWithOneShot(function); | 1719 Debug::FloodWithOneShot(Handle<SharedFunctionInfo>(function->shared())); |
1764 } | 1720 } |
1765 } | 1721 } |
1766 } | 1722 } |
1767 } | 1723 } |
1768 | 1724 |
1769 | 1725 |
1770 void Debug::ClearStepping() { | 1726 void Debug::ClearStepping() { |
1771 // Clear the various stepping setup. | 1727 // Clear the various stepping setup. |
1772 ClearOneShot(); | 1728 ClearOneShot(); |
1773 ClearStepIn(); | 1729 ClearStepIn(); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1993 | 1949 |
1994 void Debug::PrepareForBreakPoints() { | 1950 void Debug::PrepareForBreakPoints() { |
1995 // If preparing for the first break point make sure to deoptimize all | 1951 // If preparing for the first break point make sure to deoptimize all |
1996 // functions as debugging does not work with optimized code. | 1952 // functions as debugging does not work with optimized code. |
1997 if (!has_break_points_) { | 1953 if (!has_break_points_) { |
1998 Deoptimizer::DeoptimizeAll(); | 1954 Deoptimizer::DeoptimizeAll(); |
1999 | 1955 |
2000 Handle<Code> lazy_compile = | 1956 Handle<Code> lazy_compile = |
2001 Handle<Code>(isolate_->builtins()->builtin(Builtins::kLazyCompile)); | 1957 Handle<Code>(isolate_->builtins()->builtin(Builtins::kLazyCompile)); |
2002 | 1958 |
2003 // There will be at least one break point when we are done. | |
2004 has_break_points_ = true; | |
2005 | |
2006 // Keep the list of activated functions in a handlified list as it | 1959 // Keep the list of activated functions in a handlified list as it |
2007 // is used both in GC and non-GC code. | 1960 // is used both in GC and non-GC code. |
2008 List<Handle<JSFunction> > active_functions(100); | 1961 List<Handle<JSFunction> > active_functions(100); |
2009 | 1962 |
2010 { | 1963 { |
2011 // We are going to iterate heap to find all functions without | 1964 // We are going to iterate heap to find all functions without |
2012 // debug break slots. | 1965 // debug break slots. |
2013 isolate_->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask, | 1966 isolate_->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
2014 "preparing for breakpoints"); | 1967 "preparing for breakpoints"); |
2015 | 1968 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2103 isolate_->thread_local_top()); | 2056 isolate_->thread_local_top()); |
2104 | 2057 |
2105 ActiveFunctionsRedirector active_functions_redirector; | 2058 ActiveFunctionsRedirector active_functions_redirector; |
2106 isolate_->thread_manager()->IterateArchivedThreads( | 2059 isolate_->thread_manager()->IterateArchivedThreads( |
2107 &active_functions_redirector); | 2060 &active_functions_redirector); |
2108 } | 2061 } |
2109 } | 2062 } |
2110 | 2063 |
2111 | 2064 |
2112 // Ensures the debug information is present for shared. | 2065 // Ensures the debug information is present for shared. |
2113 bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, | 2066 bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared) { |
2114 Handle<JSFunction> function) { | |
2115 // Return if we already have the debug info for shared. | 2067 // Return if we already have the debug info for shared. |
2116 if (HasDebugInfo(shared)) { | 2068 if (HasDebugInfo(shared)) { |
2117 ASSERT(shared->is_compiled()); | 2069 ASSERT(shared->is_compiled()); |
2118 return true; | 2070 return true; |
2119 } | 2071 } |
2120 | 2072 |
2121 // There will be at least one break point when we are done. | 2073 // Ensure shared in compiled. Return false if this failed. |
2122 has_break_points_ = true; | 2074 if (!SharedFunctionInfo::EnsureCompiled(shared, CLEAR_EXCEPTION)) { |
2123 | |
2124 // Ensure function is compiled. Return false if this failed. | |
2125 if (!function.is_null() && | |
2126 !JSFunction::EnsureCompiled(function, CLEAR_EXCEPTION)) { | |
2127 return false; | 2075 return false; |
2128 } | 2076 } |
2129 | 2077 |
2130 // Create the debug info object. | 2078 // Create the debug info object. |
2131 Handle<DebugInfo> debug_info = FACTORY->NewDebugInfo(shared); | 2079 Handle<DebugInfo> debug_info = FACTORY->NewDebugInfo(shared); |
2132 | 2080 |
2133 // Add debug info to the list. | 2081 // Add debug info to the list. |
2134 DebugInfoListNode* node = new DebugInfoListNode(*debug_info); | 2082 DebugInfoListNode* node = new DebugInfoListNode(*debug_info); |
2135 node->set_next(debug_info_list_); | 2083 node->set_next(debug_info_list_); |
2136 debug_info_list_ = node; | 2084 debug_info_list_ = node; |
2137 | 2085 |
| 2086 // Now there is at least one break point. |
| 2087 has_break_points_ = true; |
| 2088 |
2138 return true; | 2089 return true; |
2139 } | 2090 } |
2140 | 2091 |
2141 | 2092 |
2142 void Debug::RemoveDebugInfo(Handle<DebugInfo> debug_info) { | 2093 void Debug::RemoveDebugInfo(Handle<DebugInfo> debug_info) { |
2143 ASSERT(debug_info_list_ != NULL); | 2094 ASSERT(debug_info_list_ != NULL); |
2144 // Run through the debug info objects to find this one and remove it. | 2095 // Run through the debug info objects to find this one and remove it. |
2145 DebugInfoListNode* prev = NULL; | 2096 DebugInfoListNode* prev = NULL; |
2146 DebugInfoListNode* current = debug_info_list_; | 2097 DebugInfoListNode* current = debug_info_list_; |
2147 while (current != NULL) { | 2098 while (current != NULL) { |
(...skipping 21 matching lines...) Expand all Loading... |
2169 UNREACHABLE(); | 2120 UNREACHABLE(); |
2170 } | 2121 } |
2171 | 2122 |
2172 | 2123 |
2173 void Debug::SetAfterBreakTarget(JavaScriptFrame* frame) { | 2124 void Debug::SetAfterBreakTarget(JavaScriptFrame* frame) { |
2174 HandleScope scope(isolate_); | 2125 HandleScope scope(isolate_); |
2175 | 2126 |
2176 PrepareForBreakPoints(); | 2127 PrepareForBreakPoints(); |
2177 | 2128 |
2178 // Get the executing function in which the debug break occurred. | 2129 // Get the executing function in which the debug break occurred. |
2179 Handle<JSFunction> function(JSFunction::cast(frame->function())); | 2130 Handle<SharedFunctionInfo> shared = |
2180 Handle<SharedFunctionInfo> shared(function->shared()); | 2131 Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared()); |
2181 if (!EnsureDebugInfo(shared, function)) { | 2132 if (!EnsureDebugInfo(shared)) { |
2182 // Return if we failed to retrieve the debug info. | 2133 // Return if we failed to retrieve the debug info. |
2183 return; | 2134 return; |
2184 } | 2135 } |
2185 Handle<DebugInfo> debug_info = GetDebugInfo(shared); | 2136 Handle<DebugInfo> debug_info = GetDebugInfo(shared); |
2186 Handle<Code> code(debug_info->code()); | 2137 Handle<Code> code(debug_info->code()); |
2187 Handle<Code> original_code(debug_info->original_code()); | 2138 Handle<Code> original_code(debug_info->original_code()); |
2188 #ifdef DEBUG | 2139 #ifdef DEBUG |
2189 // Get the code which is actually executing. | 2140 // Get the code which is actually executing. |
2190 Handle<Code> frame_code(frame->LookupCode()); | 2141 Handle<Code> frame_code(frame->LookupCode()); |
2191 ASSERT(frame_code.is_identical_to(code)); | 2142 ASSERT(frame_code.is_identical_to(code)); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2261 // If there are no break points this cannot be break at return, as | 2212 // If there are no break points this cannot be break at return, as |
2262 // the debugger statement and stack guard bebug break cannot be at | 2213 // the debugger statement and stack guard bebug break cannot be at |
2263 // return. | 2214 // return. |
2264 if (!has_break_points_) { | 2215 if (!has_break_points_) { |
2265 return false; | 2216 return false; |
2266 } | 2217 } |
2267 | 2218 |
2268 PrepareForBreakPoints(); | 2219 PrepareForBreakPoints(); |
2269 | 2220 |
2270 // Get the executing function in which the debug break occurred. | 2221 // Get the executing function in which the debug break occurred. |
2271 Handle<JSFunction> function(JSFunction::cast(frame->function())); | 2222 Handle<SharedFunctionInfo> shared = |
2272 Handle<SharedFunctionInfo> shared(function->shared()); | 2223 Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared()); |
2273 if (!EnsureDebugInfo(shared, function)) { | 2224 if (!EnsureDebugInfo(shared)) { |
2274 // Return if we failed to retrieve the debug info. | 2225 // Return if we failed to retrieve the debug info. |
2275 return false; | 2226 return false; |
2276 } | 2227 } |
2277 Handle<DebugInfo> debug_info = GetDebugInfo(shared); | 2228 Handle<DebugInfo> debug_info = GetDebugInfo(shared); |
2278 Handle<Code> code(debug_info->code()); | 2229 Handle<Code> code(debug_info->code()); |
2279 #ifdef DEBUG | 2230 #ifdef DEBUG |
2280 // Get the code which is actually executing. | 2231 // Get the code which is actually executing. |
2281 Handle<Code> frame_code(frame->LookupCode()); | 2232 Handle<Code> frame_code(frame->LookupCode()); |
2282 ASSERT(frame_code.is_identical_to(code)); | 2233 ASSERT(frame_code.is_identical_to(code)); |
2283 #endif | 2234 #endif |
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3670 { | 3621 { |
3671 Locker locker; | 3622 Locker locker; |
3672 Isolate::Current()->debugger()->CallMessageDispatchHandler(); | 3623 Isolate::Current()->debugger()->CallMessageDispatchHandler(); |
3673 } | 3624 } |
3674 } | 3625 } |
3675 } | 3626 } |
3676 | 3627 |
3677 #endif // ENABLE_DEBUGGER_SUPPORT | 3628 #endif // ENABLE_DEBUGGER_SUPPORT |
3678 | 3629 |
3679 } } // namespace v8::internal | 3630 } } // namespace v8::internal |
OLD | NEW |