| 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 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 const kFrameDetailsSourcePositionIndex = 5; | 1243 const kFrameDetailsSourcePositionIndex = 5; |
| 1244 const kFrameDetailsConstructCallIndex = 6; | 1244 const kFrameDetailsConstructCallIndex = 6; |
| 1245 const kFrameDetailsAtReturnIndex = 7; | 1245 const kFrameDetailsAtReturnIndex = 7; |
| 1246 const kFrameDetailsFlagsIndex = 8; | 1246 const kFrameDetailsFlagsIndex = 8; |
| 1247 const kFrameDetailsFirstDynamicIndex = 9; | 1247 const kFrameDetailsFirstDynamicIndex = 9; |
| 1248 | 1248 |
| 1249 const kFrameDetailsNameIndex = 0; | 1249 const kFrameDetailsNameIndex = 0; |
| 1250 const kFrameDetailsValueIndex = 1; | 1250 const kFrameDetailsValueIndex = 1; |
| 1251 const kFrameDetailsNameValueSize = 2; | 1251 const kFrameDetailsNameValueSize = 2; |
| 1252 | 1252 |
| 1253 const kFrameDetailsFlagDebuggerFrame = 1; | 1253 const kFrameDetailsFlagDebuggerFrameMask = 1 << 0; |
| 1254 const kFrameDetailsFlagOptimizedFrame = 2; | 1254 const kFrameDetailsFlagOptimizedFrameMask = 1 << 1; |
| 1255 const kFrameDetailsFlagInlinedFrame = 4; | 1255 const kFrameDetailsFlagInlinedFrameIndexMask = 7 << 2; |
| 1256 | 1256 |
| 1257 /** | 1257 /** |
| 1258 * Wrapper for the frame details information retreived from the VM. The frame | 1258 * Wrapper for the frame details information retreived from the VM. The frame |
| 1259 * details from the VM is an array with the following content. See runtime.cc | 1259 * details from the VM is an array with the following content. See runtime.cc |
| 1260 * Runtime_GetFrameDetails. | 1260 * Runtime_GetFrameDetails. |
| 1261 * 0: Id | 1261 * 0: Id |
| 1262 * 1: Receiver | 1262 * 1: Receiver |
| 1263 * 2: Function | 1263 * 2: Function |
| 1264 * 3: Argument count | 1264 * 3: Argument count |
| 1265 * 4: Local count | 1265 * 4: Local count |
| 1266 * 5: Source position | 1266 * 5: Source position |
| 1267 * 6: Construct call | 1267 * 6: Construct call |
| 1268 * 7: Is at return | 1268 * 7: Is at return |
| 1269 * 8: Flags (debugger frame, optimized frame, inlined frame) | 1269 * 8: Flags (debugger frame, optimized frame, inlined frame index) |
| 1270 * Arguments name, value | 1270 * Arguments name, value |
| 1271 * Locals name, value | 1271 * Locals name, value |
| 1272 * Return value if any | 1272 * Return value if any |
| 1273 * @param {number} break_id Current break id | 1273 * @param {number} break_id Current break id |
| 1274 * @param {number} index Frame number | 1274 * @param {number} index Frame number |
| 1275 * @constructor | 1275 * @constructor |
| 1276 */ | 1276 */ |
| 1277 function FrameDetails(break_id, index) { | 1277 function FrameDetails(break_id, index) { |
| 1278 this.break_id_ = break_id; | 1278 this.break_id_ = break_id; |
| 1279 this.details_ = %GetFrameDetails(break_id, index); | 1279 this.details_ = %GetFrameDetails(break_id, index); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1305 | 1305 |
| 1306 | 1306 |
| 1307 FrameDetails.prototype.isAtReturn = function() { | 1307 FrameDetails.prototype.isAtReturn = function() { |
| 1308 %CheckExecutionState(this.break_id_); | 1308 %CheckExecutionState(this.break_id_); |
| 1309 return this.details_[kFrameDetailsAtReturnIndex]; | 1309 return this.details_[kFrameDetailsAtReturnIndex]; |
| 1310 } | 1310 } |
| 1311 | 1311 |
| 1312 | 1312 |
| 1313 FrameDetails.prototype.isDebuggerFrame = function() { | 1313 FrameDetails.prototype.isDebuggerFrame = function() { |
| 1314 %CheckExecutionState(this.break_id_); | 1314 %CheckExecutionState(this.break_id_); |
| 1315 var f = kFrameDetailsFlagDebuggerFrame; | 1315 var f = kFrameDetailsFlagDebuggerFrameMask; |
| 1316 return (this.details_[kFrameDetailsFlagsIndex] & f) == f; | 1316 return (this.details_[kFrameDetailsFlagsIndex] & f) == f; |
| 1317 } | 1317 } |
| 1318 | 1318 |
| 1319 | 1319 |
| 1320 FrameDetails.prototype.isOptimizedFrame = function() { | 1320 FrameDetails.prototype.isOptimizedFrame = function() { |
| 1321 %CheckExecutionState(this.break_id_); | 1321 %CheckExecutionState(this.break_id_); |
| 1322 var f = kFrameDetailsFlagOptimizedFrame; | 1322 var f = kFrameDetailsFlagOptimizedFrameMask; |
| 1323 return (this.details_[kFrameDetailsFlagsIndex] & f) == f; | 1323 return (this.details_[kFrameDetailsFlagsIndex] & f) == f; |
| 1324 } | 1324 } |
| 1325 | 1325 |
| 1326 | 1326 |
| 1327 FrameDetails.prototype.isInlinedFrame = function() { | 1327 FrameDetails.prototype.isInlinedFrame = function() { |
| 1328 %CheckExecutionState(this.break_id_); | 1328 return this.inlinedFrameIndex() > 0; |
| 1329 var f = kFrameDetailsFlagInlinedFrame; | |
| 1330 return (this.details_[kFrameDetailsFlagsIndex] & f) == f; | |
| 1331 } | 1329 } |
| 1332 | 1330 |
| 1333 | 1331 |
| 1332 FrameDetails.prototype.inlinedFrameIndex = function() { |
| 1333 %CheckExecutionState(this.break_id_); |
| 1334 var f = kFrameDetailsFlagInlinedFrameIndexMask; |
| 1335 return (this.details_[kFrameDetailsFlagsIndex] & f) >> 2 |
| 1336 } |
| 1337 |
| 1338 |
| 1334 FrameDetails.prototype.argumentCount = function() { | 1339 FrameDetails.prototype.argumentCount = function() { |
| 1335 %CheckExecutionState(this.break_id_); | 1340 %CheckExecutionState(this.break_id_); |
| 1336 return this.details_[kFrameDetailsArgumentCountIndex]; | 1341 return this.details_[kFrameDetailsArgumentCountIndex]; |
| 1337 } | 1342 } |
| 1338 | 1343 |
| 1339 | 1344 |
| 1340 FrameDetails.prototype.argumentName = function(index) { | 1345 FrameDetails.prototype.argumentName = function(index) { |
| 1341 %CheckExecutionState(this.break_id_); | 1346 %CheckExecutionState(this.break_id_); |
| 1342 if (index >= 0 && index < this.argumentCount()) { | 1347 if (index >= 0 && index < this.argumentCount()) { |
| 1343 return this.details_[kFrameDetailsFirstDynamicIndex + | 1348 return this.details_[kFrameDetailsFirstDynamicIndex + |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1469 FrameMirror.prototype.isOptimizedFrame = function() { | 1474 FrameMirror.prototype.isOptimizedFrame = function() { |
| 1470 return this.details_.isOptimizedFrame(); | 1475 return this.details_.isOptimizedFrame(); |
| 1471 }; | 1476 }; |
| 1472 | 1477 |
| 1473 | 1478 |
| 1474 FrameMirror.prototype.isInlinedFrame = function() { | 1479 FrameMirror.prototype.isInlinedFrame = function() { |
| 1475 return this.details_.isInlinedFrame(); | 1480 return this.details_.isInlinedFrame(); |
| 1476 }; | 1481 }; |
| 1477 | 1482 |
| 1478 | 1483 |
| 1484 FrameMirror.prototype.inlinedFrameIndex = function() { |
| 1485 return this.details_.inlinedFrameIndex(); |
| 1486 }; |
| 1487 |
| 1488 |
| 1479 FrameMirror.prototype.argumentCount = function() { | 1489 FrameMirror.prototype.argumentCount = function() { |
| 1480 return this.details_.argumentCount(); | 1490 return this.details_.argumentCount(); |
| 1481 }; | 1491 }; |
| 1482 | 1492 |
| 1483 | 1493 |
| 1484 FrameMirror.prototype.argumentName = function(index) { | 1494 FrameMirror.prototype.argumentName = function(index) { |
| 1485 return this.details_.argumentName(index); | 1495 return this.details_.argumentName(index); |
| 1486 }; | 1496 }; |
| 1487 | 1497 |
| 1488 | 1498 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 return this.details_.scopeCount(); | 1568 return this.details_.scopeCount(); |
| 1559 }; | 1569 }; |
| 1560 | 1570 |
| 1561 | 1571 |
| 1562 FrameMirror.prototype.scope = function(index) { | 1572 FrameMirror.prototype.scope = function(index) { |
| 1563 return new ScopeMirror(this, index); | 1573 return new ScopeMirror(this, index); |
| 1564 }; | 1574 }; |
| 1565 | 1575 |
| 1566 | 1576 |
| 1567 FrameMirror.prototype.evaluate = function(source, disable_break, opt_context_obj
ect) { | 1577 FrameMirror.prototype.evaluate = function(source, disable_break, opt_context_obj
ect) { |
| 1568 var result = %DebugEvaluate(this.break_id_, this.details_.frameId(), | 1578 var result = %DebugEvaluate(this.break_id_, |
| 1569 source, Boolean(disable_break), opt_context_object
); | 1579 this.details_.frameId(), |
| 1580 this.details_.inlinedFrameIndex(), |
| 1581 source, |
| 1582 Boolean(disable_break), |
| 1583 opt_context_object); |
| 1570 return MakeMirror(result); | 1584 return MakeMirror(result); |
| 1571 }; | 1585 }; |
| 1572 | 1586 |
| 1573 | 1587 |
| 1574 FrameMirror.prototype.invocationText = function() { | 1588 FrameMirror.prototype.invocationText = function() { |
| 1575 // Format frame invoaction (receiver, function and arguments). | 1589 // Format frame invoaction (receiver, function and arguments). |
| 1576 var result = ''; | 1590 var result = ''; |
| 1577 var func = this.func(); | 1591 var func = this.func(); |
| 1578 var receiver = this.receiver(); | 1592 var receiver = this.receiver(); |
| 1579 if (this.isConstructCall()) { | 1593 if (this.isConstructCall()) { |
| 1580 // For constructor frames display new followed by the function name. | 1594 // For constructor frames display new followed by the function name. |
| 1581 result += 'new '; | 1595 result += 'new '; |
| 1582 result += func.name() ? func.name() : '[anonymous]'; | 1596 result += func.name() ? func.name() : '[anonymous]'; |
| 1583 } else if (this.isDebuggerFrame()) { | 1597 } else if (this.isDebuggerFrame()) { |
| 1584 result += '[debugger]'; | 1598 result += '[debugger]'; |
| 1585 } else { | 1599 } else { |
| 1586 // If the receiver has a className which is 'global' don't display it. | 1600 // If the receiver has a className which is 'global' don't display it. |
| 1587 var display_receiver = !receiver.className || receiver.className() != 'globa
l'; | 1601 var display_receiver = !receiver.className || receiver.className() != 'globa
l'; |
| 1588 if (display_receiver) { | 1602 if (display_receiver) { |
| 1589 result += receiver.toText(); | 1603 result += receiver.toText(); |
| 1590 } | 1604 } |
| 1591 // Try to find the function as a property in the receiver. Include the | 1605 // Try to find the function as a property in the receiver. Include the |
| 1592 // prototype chain in the lookup. | 1606 // prototype chain in the lookup. |
| 1593 var property = GetUndefinedMirror(); | 1607 var property = GetUndefinedMirror(); |
| 1594 if (!receiver.isUndefined()) { | 1608 if (receiver.isObject()) { |
| 1595 for (var r = receiver; !r.isNull() && property.isUndefined(); r = r.protoO
bject()) { | 1609 for (var r = receiver; |
| 1610 !r.isNull() && property.isUndefined(); |
| 1611 r = r.protoObject()) { |
| 1596 property = r.lookupProperty(func); | 1612 property = r.lookupProperty(func); |
| 1597 } | 1613 } |
| 1598 } | 1614 } |
| 1599 if (!property.isUndefined()) { | 1615 if (!property.isUndefined()) { |
| 1600 // The function invoked was found on the receiver. Use the property name | 1616 // The function invoked was found on the receiver. Use the property name |
| 1601 // for the backtrace. | 1617 // for the backtrace. |
| 1602 if (!property.isIndexed()) { | 1618 if (!property.isIndexed()) { |
| 1603 if (display_receiver) { | 1619 if (display_receiver) { |
| 1604 result += '.'; | 1620 result += '.'; |
| 1605 } | 1621 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 } | 1728 } |
| 1713 | 1729 |
| 1714 | 1730 |
| 1715 const kScopeDetailsTypeIndex = 0; | 1731 const kScopeDetailsTypeIndex = 0; |
| 1716 const kScopeDetailsObjectIndex = 1; | 1732 const kScopeDetailsObjectIndex = 1; |
| 1717 | 1733 |
| 1718 function ScopeDetails(frame, index) { | 1734 function ScopeDetails(frame, index) { |
| 1719 this.break_id_ = frame.break_id_; | 1735 this.break_id_ = frame.break_id_; |
| 1720 this.details_ = %GetScopeDetails(frame.break_id_, | 1736 this.details_ = %GetScopeDetails(frame.break_id_, |
| 1721 frame.details_.frameId(), | 1737 frame.details_.frameId(), |
| 1738 frame.details_.inlinedFrameIndex(), |
| 1722 index); | 1739 index); |
| 1723 } | 1740 } |
| 1724 | 1741 |
| 1725 | 1742 |
| 1726 ScopeDetails.prototype.type = function() { | 1743 ScopeDetails.prototype.type = function() { |
| 1727 %CheckExecutionState(this.break_id_); | 1744 %CheckExecutionState(this.break_id_); |
| 1728 return this.details_[kScopeDetailsTypeIndex]; | 1745 return this.details_[kScopeDetailsTypeIndex]; |
| 1729 } | 1746 } |
| 1730 | 1747 |
| 1731 | 1748 |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2402 } | 2419 } |
| 2403 if (!NUMBER_IS_FINITE(value)) { | 2420 if (!NUMBER_IS_FINITE(value)) { |
| 2404 if (value > 0) { | 2421 if (value > 0) { |
| 2405 return 'Infinity'; | 2422 return 'Infinity'; |
| 2406 } else { | 2423 } else { |
| 2407 return '-Infinity'; | 2424 return '-Infinity'; |
| 2408 } | 2425 } |
| 2409 } | 2426 } |
| 2410 return value; | 2427 return value; |
| 2411 } | 2428 } |
| OLD | NEW |