Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: src/api.cc

Issue 1694011: Adds C++ API for retrieving a stack trace without running JavaScript (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/api.h ('k') | src/messages.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 i::Object** argv[1] = { data.location() }; 1431 i::Object** argv[1] = { data.location() };
1432 return CallV8HeapFunction(name, 1432 return CallV8HeapFunction(name,
1433 i::Top::builtins(), 1433 i::Top::builtins(),
1434 1, 1434 1,
1435 argv, 1435 argv,
1436 has_pending_exception); 1436 has_pending_exception);
1437 } 1437 }
1438 1438
1439 1439
1440 int Message::GetLineNumber() const { 1440 int Message::GetLineNumber() const {
1441 ON_BAILOUT("v8::Message::GetLineNumber()", return -1); 1441 ON_BAILOUT("v8::Message::GetLineNumber()", return kNoLineNumberInfo);
1442 ENTER_V8; 1442 ENTER_V8;
1443 HandleScope scope; 1443 HandleScope scope;
1444 EXCEPTION_PREAMBLE(); 1444 EXCEPTION_PREAMBLE();
1445 i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber", 1445 i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber",
1446 Utils::OpenHandle(this), 1446 Utils::OpenHandle(this),
1447 &has_pending_exception); 1447 &has_pending_exception);
1448 EXCEPTION_BAILOUT_CHECK(0); 1448 EXCEPTION_BAILOUT_CHECK(0);
1449 return static_cast<int>(result->Number()); 1449 return static_cast<int>(result->Number());
1450 } 1450 }
1451 1451
(...skipping 11 matching lines...) Expand all
1463 int Message::GetEndPosition() const { 1463 int Message::GetEndPosition() const {
1464 if (IsDeadCheck("v8::Message::GetEndPosition()")) return 0; 1464 if (IsDeadCheck("v8::Message::GetEndPosition()")) return 0;
1465 ENTER_V8; 1465 ENTER_V8;
1466 HandleScope scope; 1466 HandleScope scope;
1467 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); 1467 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
1468 return static_cast<int>(GetProperty(data_obj, "endPos")->Number()); 1468 return static_cast<int>(GetProperty(data_obj, "endPos")->Number());
1469 } 1469 }
1470 1470
1471 1471
1472 int Message::GetStartColumn() const { 1472 int Message::GetStartColumn() const {
1473 if (IsDeadCheck("v8::Message::GetStartColumn()")) return 0; 1473 if (IsDeadCheck("v8::Message::GetStartColumn()")) return kNoColumnInfo;
1474 ENTER_V8; 1474 ENTER_V8;
1475 HandleScope scope; 1475 HandleScope scope;
1476 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); 1476 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
1477 EXCEPTION_PREAMBLE(); 1477 EXCEPTION_PREAMBLE();
1478 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( 1478 i::Handle<i::Object> start_col_obj = CallV8HeapFunction(
1479 "GetPositionInLine", 1479 "GetPositionInLine",
1480 data_obj, 1480 data_obj,
1481 &has_pending_exception); 1481 &has_pending_exception);
1482 EXCEPTION_BAILOUT_CHECK(0); 1482 EXCEPTION_BAILOUT_CHECK(0);
1483 return static_cast<int>(start_col_obj->Number()); 1483 return static_cast<int>(start_col_obj->Number());
1484 } 1484 }
1485 1485
1486 1486
1487 int Message::GetEndColumn() const { 1487 int Message::GetEndColumn() const {
1488 if (IsDeadCheck("v8::Message::GetEndColumn()")) return 0; 1488 if (IsDeadCheck("v8::Message::GetEndColumn()")) return kNoColumnInfo;
1489 ENTER_V8; 1489 ENTER_V8;
1490 HandleScope scope; 1490 HandleScope scope;
1491 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); 1491 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
1492 EXCEPTION_PREAMBLE(); 1492 EXCEPTION_PREAMBLE();
1493 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( 1493 i::Handle<i::Object> start_col_obj = CallV8HeapFunction(
1494 "GetPositionInLine", 1494 "GetPositionInLine",
1495 data_obj, 1495 data_obj,
1496 &has_pending_exception); 1496 &has_pending_exception);
1497 EXCEPTION_BAILOUT_CHECK(0); 1497 EXCEPTION_BAILOUT_CHECK(0);
1498 int start = static_cast<int>(GetProperty(data_obj, "startPos")->Number()); 1498 int start = static_cast<int>(GetProperty(data_obj, "startPos")->Number());
(...skipping 19 matching lines...) Expand all
1518 } 1518 }
1519 1519
1520 1520
1521 void Message::PrintCurrentStackTrace(FILE* out) { 1521 void Message::PrintCurrentStackTrace(FILE* out) {
1522 if (IsDeadCheck("v8::Message::PrintCurrentStackTrace()")) return; 1522 if (IsDeadCheck("v8::Message::PrintCurrentStackTrace()")) return;
1523 ENTER_V8; 1523 ENTER_V8;
1524 i::Top::PrintCurrentStackTrace(out); 1524 i::Top::PrintCurrentStackTrace(out);
1525 } 1525 }
1526 1526
1527 1527
1528 // --- S t a c k T r a c e ---
1529
1530 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const {
1531 if (IsDeadCheck("v8::StackTrace::GetFrame()")) return Local<StackFrame>();
1532 ENTER_V8;
1533 HandleScope scope;
1534 i::Handle<i::JSArray> self = Utils::OpenHandle(this);
1535 i::Handle<i::JSObject> obj(i::JSObject::cast(self->GetElement(index)));
1536 return scope.Close(Utils::StackFrameToLocal(obj));
1537 }
1538
1539
1540 int StackTrace::GetFrameCount() const {
1541 if (IsDeadCheck("v8::StackTrace::GetFrameCount()")) return -1;
1542 ENTER_V8;
1543 return i::Smi::cast(Utils::OpenHandle(this)->length())->value();
1544 }
1545
1546
1547 Local<Array> StackTrace::AsArray() {
1548 if (IsDeadCheck("v8::StackTrace::AsArray()")) Local<Array>();
1549 ENTER_V8;
1550 return Utils::ToLocal(Utils::OpenHandle(this));
1551 }
1552
1553
1554 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit,
1555 StackTraceOptions options) {
1556 if (IsDeadCheck("v8::StackTrace::CurrentStackTrace()")) Local<StackTrace>();
1557 ENTER_V8;
1558 return i::Top::CaptureCurrentStackTrace(frame_limit, options);
1559 }
1560
1561
1562 // --- S t a c k F r a m e ---
1563
1564 int StackFrame::GetLineNumber() const {
1565 if (IsDeadCheck("v8::StackFrame::GetLineNumber()")) {
1566 return Message::kNoLineNumberInfo;
1567 }
1568 ENTER_V8;
1569 i::HandleScope scope;
1570 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1571 i::Handle<i::Object> line = GetProperty(self, "lineNumber");
1572 if (!line->IsSmi()) {
1573 return Message::kNoLineNumberInfo;
1574 }
1575 return i::Smi::cast(*line)->value();
1576 }
1577
1578
1579 int StackFrame::GetColumn() const {
1580 if (IsDeadCheck("v8::StackFrame::GetColumn()")) {
1581 return Message::kNoColumnInfo;
1582 }
1583 ENTER_V8;
1584 i::HandleScope scope;
1585 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1586 i::Handle<i::Object> column = GetProperty(self, "column");
1587 if (!column->IsSmi()) {
1588 return Message::kNoColumnInfo;
1589 }
1590 return i::Smi::cast(*column)->value();
1591 }
1592
1593
1594 Local<String> StackFrame::GetScriptName() const {
1595 if (IsDeadCheck("v8::StackFrame::GetScriptName()")) return Local<String>();
1596 ENTER_V8;
1597 HandleScope scope;
1598 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1599 i::Handle<i::Object> name = GetProperty(self, "scriptName");
1600 if (!name->IsString()) {
1601 return Local<String>();
1602 }
1603 return scope.Close(Local<String>::Cast(Utils::ToLocal(name)));
1604 }
1605
1606
1607 Local<String> StackFrame::GetFunctionName() const {
1608 if (IsDeadCheck("v8::StackFrame::GetFunctionName()")) return Local<String>();
1609 ENTER_V8;
1610 HandleScope scope;
1611 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1612 i::Handle<i::Object> name = GetProperty(self, "functionName");
1613 if (!name->IsString()) {
1614 return Local<String>();
1615 }
1616 return scope.Close(Local<String>::Cast(Utils::ToLocal(name)));
1617 }
1618
1619
1620 bool StackFrame::IsEval() const {
1621 if (IsDeadCheck("v8::StackFrame::IsEval()")) return false;
1622 ENTER_V8;
1623 i::HandleScope scope;
1624 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1625 i::Handle<i::Object> is_eval = GetProperty(self, "isEval");
1626 return is_eval->IsTrue();
1627 }
1628
1629
1630 bool StackFrame::IsConstructor() const {
1631 if (IsDeadCheck("v8::StackFrame::IsConstructor()")) return false;
1632 ENTER_V8;
1633 i::HandleScope scope;
1634 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
1635 i::Handle<i::Object> is_constructor = GetProperty(self, "isConstructor");
1636 return is_constructor->IsTrue();
1637 }
1638
1639
1528 // --- D a t a --- 1640 // --- D a t a ---
1529 1641
1530 bool Value::IsUndefined() const { 1642 bool Value::IsUndefined() const {
1531 if (IsDeadCheck("v8::Value::IsUndefined()")) return false; 1643 if (IsDeadCheck("v8::Value::IsUndefined()")) return false;
1532 return Utils::OpenHandle(this)->IsUndefined(); 1644 return Utils::OpenHandle(this)->IsUndefined();
1533 } 1645 }
1534 1646
1535 1647
1536 bool Value::IsNull() const { 1648 bool Value::IsNull() const {
1537 if (IsDeadCheck("v8::Value::IsNull()")) return false; 1649 if (IsDeadCheck("v8::Value::IsNull()")) return false;
(...skipping 2701 matching lines...) Expand 10 before | Expand all | Expand 10 after
4239 4351
4240 4352
4241 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 4353 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
4242 HandleScopeImplementer* thread_local = 4354 HandleScopeImplementer* thread_local =
4243 reinterpret_cast<HandleScopeImplementer*>(storage); 4355 reinterpret_cast<HandleScopeImplementer*>(storage);
4244 thread_local->IterateThis(v); 4356 thread_local->IterateThis(v);
4245 return storage + ArchiveSpacePerThread(); 4357 return storage + ArchiveSpacePerThread();
4246 } 4358 }
4247 4359
4248 } } // namespace v8::internal 4360 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698