| 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 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 } | 1233 } |
| 1234 | 1234 |
| 1235 | 1235 |
| 1236 const kFrameDetailsFrameIdIndex = 0; | 1236 const kFrameDetailsFrameIdIndex = 0; |
| 1237 const kFrameDetailsReceiverIndex = 1; | 1237 const kFrameDetailsReceiverIndex = 1; |
| 1238 const kFrameDetailsFunctionIndex = 2; | 1238 const kFrameDetailsFunctionIndex = 2; |
| 1239 const kFrameDetailsArgumentCountIndex = 3; | 1239 const kFrameDetailsArgumentCountIndex = 3; |
| 1240 const kFrameDetailsLocalCountIndex = 4; | 1240 const kFrameDetailsLocalCountIndex = 4; |
| 1241 const kFrameDetailsSourcePositionIndex = 5; | 1241 const kFrameDetailsSourcePositionIndex = 5; |
| 1242 const kFrameDetailsConstructCallIndex = 6; | 1242 const kFrameDetailsConstructCallIndex = 6; |
| 1243 const kFrameDetailsDebuggerFrameIndex = 7; | 1243 const kFrameDetailsAtReturnIndex = 7; |
| 1244 const kFrameDetailsFirstDynamicIndex = 8; | 1244 const kFrameDetailsDebuggerFrameIndex = 8; |
| 1245 const kFrameDetailsFirstDynamicIndex = 9; |
| 1245 | 1246 |
| 1246 const kFrameDetailsNameIndex = 0; | 1247 const kFrameDetailsNameIndex = 0; |
| 1247 const kFrameDetailsValueIndex = 1; | 1248 const kFrameDetailsValueIndex = 1; |
| 1248 const kFrameDetailsNameValueSize = 2; | 1249 const kFrameDetailsNameValueSize = 2; |
| 1249 | 1250 |
| 1250 /** | 1251 /** |
| 1251 * Wrapper for the frame details information retreived from the VM. The frame | 1252 * Wrapper for the frame details information retreived from the VM. The frame |
| 1252 * details from the VM is an array with the following content. See runtime.cc | 1253 * details from the VM is an array with the following content. See runtime.cc |
| 1253 * Runtime_GetFrameDetails. | 1254 * Runtime_GetFrameDetails. |
| 1254 * 0: Id | 1255 * 0: Id |
| 1255 * 1: Receiver | 1256 * 1: Receiver |
| 1256 * 2: Function | 1257 * 2: Function |
| 1257 * 3: Argument count | 1258 * 3: Argument count |
| 1258 * 4: Local count | 1259 * 4: Local count |
| 1259 * 5: Source position | 1260 * 5: Source position |
| 1260 * 6: Construct call | 1261 * 6: Construct call |
| 1262 * 7: Is at return |
| 1263 * 8: Debugger frame |
| 1261 * Arguments name, value | 1264 * Arguments name, value |
| 1262 * Locals name, value | 1265 * Locals name, value |
| 1266 * Return value if any |
| 1263 * @param {number} break_id Current break id | 1267 * @param {number} break_id Current break id |
| 1264 * @param {number} index Frame number | 1268 * @param {number} index Frame number |
| 1265 * @constructor | 1269 * @constructor |
| 1266 */ | 1270 */ |
| 1267 function FrameDetails(break_id, index) { | 1271 function FrameDetails(break_id, index) { |
| 1268 this.break_id_ = break_id; | 1272 this.break_id_ = break_id; |
| 1269 this.details_ = %GetFrameDetails(break_id, index); | 1273 this.details_ = %GetFrameDetails(break_id, index); |
| 1270 } | 1274 } |
| 1271 | 1275 |
| 1272 | 1276 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1287 return this.details_[kFrameDetailsFunctionIndex]; | 1291 return this.details_[kFrameDetailsFunctionIndex]; |
| 1288 } | 1292 } |
| 1289 | 1293 |
| 1290 | 1294 |
| 1291 FrameDetails.prototype.isConstructCall = function() { | 1295 FrameDetails.prototype.isConstructCall = function() { |
| 1292 %CheckExecutionState(this.break_id_); | 1296 %CheckExecutionState(this.break_id_); |
| 1293 return this.details_[kFrameDetailsConstructCallIndex]; | 1297 return this.details_[kFrameDetailsConstructCallIndex]; |
| 1294 } | 1298 } |
| 1295 | 1299 |
| 1296 | 1300 |
| 1301 FrameDetails.prototype.isAtReturn = function() { |
| 1302 %CheckExecutionState(this.break_id_); |
| 1303 return this.details_[kFrameDetailsAtReturnIndex]; |
| 1304 } |
| 1305 |
| 1306 |
| 1297 FrameDetails.prototype.isDebuggerFrame = function() { | 1307 FrameDetails.prototype.isDebuggerFrame = function() { |
| 1298 %CheckExecutionState(this.break_id_); | 1308 %CheckExecutionState(this.break_id_); |
| 1299 return this.details_[kFrameDetailsDebuggerFrameIndex]; | 1309 return this.details_[kFrameDetailsDebuggerFrameIndex]; |
| 1300 } | 1310 } |
| 1301 | 1311 |
| 1302 | 1312 |
| 1303 FrameDetails.prototype.argumentCount = function() { | 1313 FrameDetails.prototype.argumentCount = function() { |
| 1304 %CheckExecutionState(this.break_id_); | 1314 %CheckExecutionState(this.break_id_); |
| 1305 return this.details_[kFrameDetailsArgumentCountIndex]; | 1315 return this.details_[kFrameDetailsArgumentCountIndex]; |
| 1306 } | 1316 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1334 | 1344 |
| 1335 FrameDetails.prototype.sourcePosition = function() { | 1345 FrameDetails.prototype.sourcePosition = function() { |
| 1336 %CheckExecutionState(this.break_id_); | 1346 %CheckExecutionState(this.break_id_); |
| 1337 return this.details_[kFrameDetailsSourcePositionIndex]; | 1347 return this.details_[kFrameDetailsSourcePositionIndex]; |
| 1338 } | 1348 } |
| 1339 | 1349 |
| 1340 | 1350 |
| 1341 FrameDetails.prototype.localName = function(index) { | 1351 FrameDetails.prototype.localName = function(index) { |
| 1342 %CheckExecutionState(this.break_id_); | 1352 %CheckExecutionState(this.break_id_); |
| 1343 if (index >= 0 && index < this.localCount()) { | 1353 if (index >= 0 && index < this.localCount()) { |
| 1344 var locals_offset = kFrameDetailsFirstDynamicIndex + this.argumentCount() *
kFrameDetailsNameValueSize | 1354 var locals_offset = kFrameDetailsFirstDynamicIndex + |
| 1355 this.argumentCount() * kFrameDetailsNameValueSize |
| 1345 return this.details_[locals_offset + | 1356 return this.details_[locals_offset + |
| 1346 index * kFrameDetailsNameValueSize + | 1357 index * kFrameDetailsNameValueSize + |
| 1347 kFrameDetailsNameIndex] | 1358 kFrameDetailsNameIndex] |
| 1348 } | 1359 } |
| 1349 } | 1360 } |
| 1350 | 1361 |
| 1351 | 1362 |
| 1352 FrameDetails.prototype.localValue = function(index) { | 1363 FrameDetails.prototype.localValue = function(index) { |
| 1353 %CheckExecutionState(this.break_id_); | 1364 %CheckExecutionState(this.break_id_); |
| 1354 if (index >= 0 && index < this.localCount()) { | 1365 if (index >= 0 && index < this.localCount()) { |
| 1355 var locals_offset = kFrameDetailsFirstDynamicIndex + this.argumentCount() *
kFrameDetailsNameValueSize | 1366 var locals_offset = kFrameDetailsFirstDynamicIndex + |
| 1367 this.argumentCount() * kFrameDetailsNameValueSize |
| 1356 return this.details_[locals_offset + | 1368 return this.details_[locals_offset + |
| 1357 index * kFrameDetailsNameValueSize + | 1369 index * kFrameDetailsNameValueSize + |
| 1358 kFrameDetailsValueIndex] | 1370 kFrameDetailsValueIndex] |
| 1359 } | 1371 } |
| 1360 } | 1372 } |
| 1361 | 1373 |
| 1362 | 1374 |
| 1375 FrameDetails.prototype.returnValue = function() { |
| 1376 %CheckExecutionState(this.break_id_); |
| 1377 var return_value_offset = |
| 1378 kFrameDetailsFirstDynamicIndex + |
| 1379 (this.argumentCount() + this.localCount()) * kFrameDetailsNameValueSize; |
| 1380 if (this.details_[kFrameDetailsAtReturnIndex]) { |
| 1381 return this.details_[return_value_offset]; |
| 1382 } |
| 1383 } |
| 1384 |
| 1385 |
| 1363 FrameDetails.prototype.scopeCount = function() { | 1386 FrameDetails.prototype.scopeCount = function() { |
| 1364 return %GetScopeCount(this.break_id_, this.frameId()); | 1387 return %GetScopeCount(this.break_id_, this.frameId()); |
| 1365 } | 1388 } |
| 1366 | 1389 |
| 1367 | 1390 |
| 1368 /** | 1391 /** |
| 1369 * Mirror object for stack frames. | 1392 * Mirror object for stack frames. |
| 1370 * @param {number} break_id The break id in the VM for which this frame is | 1393 * @param {number} break_id The break id in the VM for which this frame is |
| 1371 valid | 1394 valid |
| 1372 * @param {number} index The frame index (top frame is index 0) | 1395 * @param {number} index The frame index (top frame is index 0) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 FrameMirror.prototype.receiver = function() { | 1428 FrameMirror.prototype.receiver = function() { |
| 1406 return MakeMirror(this.details_.receiver()); | 1429 return MakeMirror(this.details_.receiver()); |
| 1407 }; | 1430 }; |
| 1408 | 1431 |
| 1409 | 1432 |
| 1410 FrameMirror.prototype.isConstructCall = function() { | 1433 FrameMirror.prototype.isConstructCall = function() { |
| 1411 return this.details_.isConstructCall(); | 1434 return this.details_.isConstructCall(); |
| 1412 }; | 1435 }; |
| 1413 | 1436 |
| 1414 | 1437 |
| 1438 FrameMirror.prototype.isAtReturn = function() { |
| 1439 return this.details_.isAtReturn(); |
| 1440 }; |
| 1441 |
| 1442 |
| 1415 FrameMirror.prototype.isDebuggerFrame = function() { | 1443 FrameMirror.prototype.isDebuggerFrame = function() { |
| 1416 return this.details_.isDebuggerFrame(); | 1444 return this.details_.isDebuggerFrame(); |
| 1417 }; | 1445 }; |
| 1418 | 1446 |
| 1419 | 1447 |
| 1420 FrameMirror.prototype.argumentCount = function() { | 1448 FrameMirror.prototype.argumentCount = function() { |
| 1421 return this.details_.argumentCount(); | 1449 return this.details_.argumentCount(); |
| 1422 }; | 1450 }; |
| 1423 | 1451 |
| 1424 | 1452 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1440 FrameMirror.prototype.localName = function(index) { | 1468 FrameMirror.prototype.localName = function(index) { |
| 1441 return this.details_.localName(index); | 1469 return this.details_.localName(index); |
| 1442 }; | 1470 }; |
| 1443 | 1471 |
| 1444 | 1472 |
| 1445 FrameMirror.prototype.localValue = function(index) { | 1473 FrameMirror.prototype.localValue = function(index) { |
| 1446 return MakeMirror(this.details_.localValue(index)); | 1474 return MakeMirror(this.details_.localValue(index)); |
| 1447 }; | 1475 }; |
| 1448 | 1476 |
| 1449 | 1477 |
| 1478 FrameMirror.prototype.returnValue = function() { |
| 1479 return MakeMirror(this.details_.returnValue()); |
| 1480 }; |
| 1481 |
| 1482 |
| 1450 FrameMirror.prototype.sourcePosition = function() { | 1483 FrameMirror.prototype.sourcePosition = function() { |
| 1451 return this.details_.sourcePosition(); | 1484 return this.details_.sourcePosition(); |
| 1452 }; | 1485 }; |
| 1453 | 1486 |
| 1454 | 1487 |
| 1455 FrameMirror.prototype.sourceLocation = function() { | 1488 FrameMirror.prototype.sourceLocation = function() { |
| 1456 if (this.func().resolved() && this.func().script()) { | 1489 if (this.func().resolved() && this.func().script()) { |
| 1457 return this.func().script().locationFromPosition(this.sourcePosition(), | 1490 return this.func().script().locationFromPosition(this.sourcePosition(), |
| 1458 true); | 1491 true); |
| 1459 } | 1492 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1567 if (i != 0) result += ', '; | 1600 if (i != 0) result += ', '; |
| 1568 if (this.argumentName(i)) { | 1601 if (this.argumentName(i)) { |
| 1569 result += this.argumentName(i); | 1602 result += this.argumentName(i); |
| 1570 result += '='; | 1603 result += '='; |
| 1571 } | 1604 } |
| 1572 result += this.argumentValue(i).toText(); | 1605 result += this.argumentValue(i).toText(); |
| 1573 } | 1606 } |
| 1574 result += ')'; | 1607 result += ')'; |
| 1575 } | 1608 } |
| 1576 | 1609 |
| 1610 if (this.isAtReturn()) { |
| 1611 result += ' returning '; |
| 1612 result += this.returnValue().toText(); |
| 1613 } |
| 1614 |
| 1577 return result; | 1615 return result; |
| 1578 } | 1616 } |
| 1579 | 1617 |
| 1580 | 1618 |
| 1581 FrameMirror.prototype.sourceAndPositionText = function() { | 1619 FrameMirror.prototype.sourceAndPositionText = function() { |
| 1582 // Format source and position. | 1620 // Format source and position. |
| 1583 var result = ''; | 1621 var result = ''; |
| 1584 var func = this.func(); | 1622 var func = this.func(); |
| 1585 if (func.resolved()) { | 1623 if (func.resolved()) { |
| 1586 if (func.script()) { | 1624 if (func.script()) { |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2260 | 2298 |
| 2261 JSONProtocolSerializer.prototype.serializeFrame_ = function(mirror, content) { | 2299 JSONProtocolSerializer.prototype.serializeFrame_ = function(mirror, content) { |
| 2262 content.index = mirror.index(); | 2300 content.index = mirror.index(); |
| 2263 content.receiver = this.serializeReference(mirror.receiver()); | 2301 content.receiver = this.serializeReference(mirror.receiver()); |
| 2264 var func = mirror.func(); | 2302 var func = mirror.func(); |
| 2265 content.func = this.serializeReference(func); | 2303 content.func = this.serializeReference(func); |
| 2266 if (func.script()) { | 2304 if (func.script()) { |
| 2267 content.script = this.serializeReference(func.script()); | 2305 content.script = this.serializeReference(func.script()); |
| 2268 } | 2306 } |
| 2269 content.constructCall = mirror.isConstructCall(); | 2307 content.constructCall = mirror.isConstructCall(); |
| 2308 content.atReturn = mirror.isAtReturn(); |
| 2309 if (mirror.isAtReturn()) { |
| 2310 content.returnValue = this.serializeReference(mirror.returnValue()); |
| 2311 } |
| 2270 content.debuggerFrame = mirror.isDebuggerFrame(); | 2312 content.debuggerFrame = mirror.isDebuggerFrame(); |
| 2271 var x = new Array(mirror.argumentCount()); | 2313 var x = new Array(mirror.argumentCount()); |
| 2272 for (var i = 0; i < mirror.argumentCount(); i++) { | 2314 for (var i = 0; i < mirror.argumentCount(); i++) { |
| 2273 var arg = {}; | 2315 var arg = {}; |
| 2274 var argument_name = mirror.argumentName(i) | 2316 var argument_name = mirror.argumentName(i) |
| 2275 if (argument_name) { | 2317 if (argument_name) { |
| 2276 arg.name = argument_name; | 2318 arg.name = argument_name; |
| 2277 } | 2319 } |
| 2278 arg.value = this.serializeReference(mirror.argumentValue(i)); | 2320 arg.value = this.serializeReference(mirror.argumentValue(i)); |
| 2279 x[i] = arg; | 2321 x[i] = arg; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2329 } | 2371 } |
| 2330 if (!isFinite(value)) { | 2372 if (!isFinite(value)) { |
| 2331 if (value > 0) { | 2373 if (value > 0) { |
| 2332 return 'Infinity'; | 2374 return 'Infinity'; |
| 2333 } else { | 2375 } else { |
| 2334 return '-Infinity'; | 2376 return '-Infinity'; |
| 2335 } | 2377 } |
| 2336 } | 2378 } |
| 2337 return value; | 2379 return value; |
| 2338 } | 2380 } |
| OLD | NEW |