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

Side by Side Diff: Source/bindings/dart/DartInjectedScript.cpp

Issue 466243002: Support merged Dart-JS callstacks (Closed) Base URL: svn://svn.chromium.org/blink/branches/dart/dartium
Patch Set: ptal Created 6 years, 3 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 | « Source/bindings/common/common.gypi ('k') | Source/bindings/dart/DartScriptDebugServer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 using WebCore::TypeBuilder::Debugger::Location; 50 using WebCore::TypeBuilder::Debugger::Location;
51 using WebCore::TypeBuilder::Debugger::Scope; 51 using WebCore::TypeBuilder::Debugger::Scope;
52 using WebCore::TypeBuilder::Runtime::PropertyDescriptor; 52 using WebCore::TypeBuilder::Runtime::PropertyDescriptor;
53 using WebCore::TypeBuilder::Runtime::InternalPropertyDescriptor; 53 using WebCore::TypeBuilder::Runtime::InternalPropertyDescriptor;
54 using WebCore::TypeBuilder::Debugger::FunctionDetails; 54 using WebCore::TypeBuilder::Debugger::FunctionDetails;
55 using WebCore::TypeBuilder::Runtime::RemoteObject; 55 using WebCore::TypeBuilder::Runtime::RemoteObject;
56 using WebCore::TypeBuilder::Runtime::PropertyPreview; 56 using WebCore::TypeBuilder::Runtime::PropertyPreview;
57 57
58 namespace WebCore { 58 namespace WebCore {
59 59
60 static const uint64_t kMaxSafeIntegerForDouble = 0x1fffffffffffffUL;
61
60 Dart_Handle getLibraryUrl(Dart_Handle handle) 62 Dart_Handle getLibraryUrl(Dart_Handle handle)
61 { 63 {
62 intptr_t libraryId = 0; 64 intptr_t libraryId = 0;
63 Dart_Handle ALLOW_UNUSED result = Dart_LibraryId(handle, &libraryId); 65 Dart_Handle ALLOW_UNUSED result = Dart_LibraryId(handle, &libraryId);
64 ASSERT(!Dart_IsError(result)); 66 ASSERT(!Dart_IsError(result));
65 Dart_Handle libraryUrl = Dart_GetLibraryURL(libraryId); 67 Dart_Handle libraryUrl = Dart_GetLibraryURL(libraryId);
66 ASSERT(Dart_IsString(libraryUrl)); 68 ASSERT(Dart_IsString(libraryUrl));
67 return libraryUrl; 69 return libraryUrl;
68 } 70 }
69 71
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 739
738 void DartInjectedScript::restartFrame(ErrorString* errorString, const StackTrace & callFrames, const String& callFrameId, RefPtr<JSONObject>* result) 740 void DartInjectedScript::restartFrame(ErrorString* errorString, const StackTrace & callFrames, const String& callFrameId, RefPtr<JSONObject>* result)
739 { 741 {
740 ASSERT(!callFrames.isJavaScript()); 742 ASSERT(!callFrames.isJavaScript());
741 *errorString = "Dart does not yet support restarting call frames"; 743 *errorString = "Dart does not yet support restarting call frames";
742 return; 744 return;
743 } 745 }
744 746
745 void DartInjectedScript::getStepInPositions(ErrorString* errorString, const Stac kTrace& callFrames, const String& callFrameId, RefPtr<Array<TypeBuilder::Debugge r::Location> >& positions) 747 void DartInjectedScript::getStepInPositions(ErrorString* errorString, const Stac kTrace& callFrames, const String& callFrameId, RefPtr<Array<TypeBuilder::Debugge r::Location> >& positions)
746 { 748 {
747 ASSERT(!callFrames.isJavaScript()); 749 ASSERT(callFrames.isJavaScript());
748 if (!m_scriptState) { 750 if (!m_scriptState) {
749 *errorString = "Invalid DartInjectedScript"; 751 *errorString = "Invalid DartInjectedScript";
750 return; 752 return;
751 } 753 }
752 DartIsolateScope scope(m_scriptState->isolate()); 754 DartIsolateScope scope(m_scriptState->isolate());
753 DartApiScope apiScope; 755 DartApiScope apiScope;
754 *errorString = "FIXME: support dart."; 756 *errorString = "FIXME: support dart.";
755 return; 757 return;
756 } 758 }
757 759
758 void DartInjectedScript::setVariableValue(ErrorString* errorString, const StackT race& callFrames, const String* callFrameIdOpt, const String* functionObjectIdOp t, int scopeNumber, const String& variableName, const String& newValueStr) 760 void DartInjectedScript::setVariableValue(ErrorString* errorString, const StackT race& callFrames, const String* callFrameIdOpt, const String* functionObjectIdOp t, int scopeNumber, const String& variableName, const String& newValueStr)
759 { 761 {
762 ASSERT(callFrames.isJavaScript());
760 if (!m_scriptState) { 763 if (!m_scriptState) {
761 *errorString = "Invalid DartInjectedScript"; 764 *errorString = "Invalid DartInjectedScript";
762 return; 765 return;
763 } 766 }
764 DartIsolateScope scope(m_scriptState->isolate()); 767 DartIsolateScope scope(m_scriptState->isolate());
765 DartApiScope apiScope; 768 DartApiScope apiScope;
766 ASSERT(!callFrames.isJavaScript());
767 *errorString = "Not supported by Dart."; 769 *errorString = "Not supported by Dart.";
768 return; 770 return;
769 } 771 }
770 772
771 void DartInjectedScript::getFunctionDetails(ErrorString* errorString, const Stri ng& functionId, RefPtr<FunctionDetails>* result) 773 void DartInjectedScript::getFunctionDetails(ErrorString* errorString, const Stri ng& functionId, RefPtr<FunctionDetails>* result)
772 { 774 {
773 if (!m_scriptState) { 775 if (!m_scriptState) {
774 *errorString = "Invalid DartInjectedScript"; 776 *errorString = "Invalid DartInjectedScript";
775 return; 777 return;
776 } 778 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 { 838 {
837 ASSERT(Dart_IsList(completions)); 839 ASSERT(Dart_IsList(completions));
838 intptr_t length = 0; 840 intptr_t length = 0;
839 Dart_ListLength(completions, &length); 841 Dart_ListLength(completions, &length);
840 for (intptr_t i = 0; i < length; ++i) 842 for (intptr_t i = 0; i < length; ++i)
841 (*result)->addItem(DartUtilities::toString(Dart_ListGetAt(completions, i ))); 843 (*result)->addItem(DartUtilities::toString(Dart_ListGetAt(completions, i )));
842 } 844 }
843 845
844 void DartInjectedScript::getCompletionsOnCallFrame(ErrorString* errorString, con st StackTrace& callFrames, const Vector<StackTrace>& asyncCallStacks, const Stri ng& callFrameId, const String& expression, RefPtr<TypeBuilder::Array<String> >* result) 846 void DartInjectedScript::getCompletionsOnCallFrame(ErrorString* errorString, con st StackTrace& callFrames, const Vector<StackTrace>& asyncCallStacks, const Stri ng& callFrameId, const String& expression, RefPtr<TypeBuilder::Array<String> >* result)
845 { 847 {
846 ASSERT(!callFrames.isJavaScript()); 848 ASSERT(callFrames.isJavaScript());
847 *result = TypeBuilder::Array<String>::create(); 849 *result = TypeBuilder::Array<String>::create();
848 if (!m_scriptState) { 850 if (!m_scriptState) {
849 *errorString = "Invalid DartInjectedScript"; 851 *errorString = "Invalid DartInjectedScript";
850 return; 852 return;
851 } 853 }
852 DartIsolateScope scope(m_scriptState->isolate()); 854 DartIsolateScope scope(m_scriptState->isolate());
853 DartApiScope apiScope; 855 DartApiScope apiScope;
854 V8Scope v8scope(DartDOMData::current()); 856 V8Scope v8scope(DartDOMData::current());
855 857
856 Dart_ActivationFrame frame = callFrameForId(callFrames, asyncCallStacks, cal lFrameId); 858 Dart_ActivationFrame frame = callFrameForId(callFrames, asyncCallStacks, cal lFrameId);
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 success = json->asObject()->getNumber("asyncOrdinal", &asyncOrdinal); 1210 success = json->asObject()->getNumber("asyncOrdinal", &asyncOrdinal);
1209 ASSERT(success); 1211 ASSERT(success);
1210 } else { 1212 } else {
1211 ASSERT(json && json->type() == JSONValue::TypeObject); 1213 ASSERT(json && json->type() == JSONValue::TypeObject);
1212 return 0; 1214 return 0;
1213 } 1215 }
1214 Dart_Handle ALLOW_UNUSED result; 1216 Dart_Handle ALLOW_UNUSED result;
1215 if (asyncOrdinal > 0) { // 1-based index 1217 if (asyncOrdinal > 0) { // 1-based index
1216 ASSERT(asyncOrdinal <= (int)asyncCallStacks.size()); 1218 ASSERT(asyncOrdinal <= (int)asyncCallStacks.size());
1217 if (asyncOrdinal <= (int)asyncCallStacks.size()) { 1219 if (asyncOrdinal <= (int)asyncCallStacks.size()) {
1218 ASSERT(!asyncCallStacks[asyncOrdinal-1].isJavaScript()); 1220 StackTrace asyncCallStack = asyncCallStacks[asyncOrdinal-1];
1219 result = Dart_GetActivationFrame(asyncCallStacks[asyncOrdinal-1].asD art(), ordinal, &frame); 1221 ASSERT(!asyncCallStack.isJavaScript());
1222 result = Dart_GetActivationFrame(asyncCallStack.asDart(), ordinal, & frame);
1220 } else { 1223 } else {
1221 return 0; 1224 return 0;
1222 } 1225 }
1223 } else { 1226 } else {
1224 result = Dart_GetActivationFrame(trace, ordinal, &frame); 1227 result = Dart_GetActivationFrame(trace, ordinal, &frame);
1225 } 1228 }
1226 ASSERT(result); 1229 ASSERT(result);
1227 return frame; 1230 return frame;
1228 } 1231 }
1229 1232
1230 PassRefPtr<Array<CallFrame> > DartInjectedScript::wrapCallFrames(const StackTrac e& callFrames, int asyncOrdinal) 1233 PassRefPtr<Array<CallFrame> > DartInjectedScript::wrapCallFrames(const StackTrac e& callFrames, int asyncOrdinal)
1231 { 1234 {
1232 ASSERT(!callFrames.isJavaScript()); 1235 ASSERT(!callFrames.isJavaScript());
1233 if (callFrames.isJavaScript()) 1236 if (callFrames.isJavaScript())
1234 return nullptr; 1237 return nullptr;
1238 DartIsolateScope scope(m_scriptState->isolate());
1239 DartApiScope apiScope;
1235 Dart_StackTrace trace = callFrames.asDart(); 1240 Dart_StackTrace trace = callFrames.asDart();
1236 intptr_t length = 0; 1241 intptr_t length = 0;
1237 Dart_Handle ALLOW_UNUSED result; 1242 Dart_Handle ALLOW_UNUSED result;
1238 RefPtr<Array<CallFrame> > ret = Array<CallFrame>::create(); 1243 RefPtr<Array<CallFrame> > ret = Array<CallFrame>::create();
1239 result = Dart_StackTraceLength(trace, &length); 1244 result = Dart_StackTraceLength(trace, &length);
1240 ASSERT(!Dart_IsError(result)); 1245 ASSERT(!Dart_IsError(result));
1241 DartScriptDebugServer& debugServer = DartScriptDebugServer::shared(); 1246 DartScriptDebugServer& debugServer = DartScriptDebugServer::shared();
1242 Dart_Handle libraries = Dart_GetLibraryIds(); 1247 Dart_Handle libraries = Dart_GetLibraryIds();
1248
1243 for (intptr_t i = 0; i < length; i++) { 1249 for (intptr_t i = 0; i < length; i++) {
1244 Dart_ActivationFrame frame = 0; 1250 Dart_ActivationFrame frame = 0;
1245 result = Dart_GetActivationFrame(trace, i, &frame); 1251 result = Dart_GetActivationFrame(trace, i, &frame);
1246 ASSERT(!Dart_IsError(result)); 1252 ASSERT(!Dart_IsError(result));
1247 Dart_Handle functionName = 0; 1253 Dart_Handle functionName = 0;
1248 Dart_Handle function = 0; 1254 Dart_Handle function = 0;
1249 Dart_CodeLocation location; 1255 Dart_CodeLocation location;
1250 Dart_ActivationFrameGetLocation(frame, &functionName, &function, &locati on); 1256 result = Dart_ActivationFrameGetLocation(frame, &functionName, &function , &location);
1257 ASSERT(!Dart_IsError(result));
1258
1251 const String& url = DartUtilities::toString(location.script_url); 1259 const String& url = DartUtilities::toString(location.script_url);
1252 intptr_t line = 0; 1260 intptr_t line = 0;
1253 intptr_t column = 0; 1261 intptr_t column = 0;
1254 Dart_ActivationFrameInfo(frame, 0, 0, &line, &column); 1262 Dart_ActivationFrameInfo(frame, 0, 0, &line, &column);
1255 RefPtr<Location> locationJson = Location::create() 1263 RefPtr<Location> locationJson = Location::create()
1256 .setScriptId(debugServer.getScriptId(url, Dart_CurrentIsolate())) 1264 .setScriptId(debugServer.getScriptId(url, Dart_CurrentIsolate()))
1257 .setLineNumber(line - 1); 1265 .setLineNumber(line - 1);
1258 locationJson->setColumnNumber(column); 1266 locationJson->setColumnNumber(column);
1259 Dart_Handle localVariables = Dart_GetLocalVariables(frame); 1267 Dart_Handle localVariables = Dart_GetLocalVariables(frame);
1260 Dart_Handle thisHandle = findReceiver(localVariables); 1268 Dart_Handle thisHandle = findReceiver(localVariables);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 .setType(Scope::Type::Library) 1303 .setType(Scope::Type::Library)
1296 .setObject(wrapDartHandle(library, DartDebuggerObject::CurrentLi brary, "backtrace", false)) 1304 .setObject(wrapDartHandle(library, DartDebuggerObject::CurrentLi brary, "backtrace", false))
1297 .release()); 1305 .release());
1298 } 1306 }
1299 1307
1300 scopeChain->addItem(Scope::create() 1308 scopeChain->addItem(Scope::create()
1301 .setType(Scope::Type::Isolate) 1309 .setType(Scope::Type::Isolate)
1302 .setObject(wrapDartHandle(libraries, DartDebuggerObject::Isolate, "b acktrace", false)) 1310 .setObject(wrapDartHandle(libraries, DartDebuggerObject::Isolate, "b acktrace", false))
1303 .release()); 1311 .release());
1304 1312
1305 ret->addItem(CallFrame::create() 1313 RefPtr<CallFrame> callFrame = CallFrame::create()
1306 .setCallFrameId(getCallFrameId(i, asyncOrdinal)) 1314 .setCallFrameId(getCallFrameId(i, asyncOrdinal))
1307 .setFunctionName(DartUtilities::toString(functionName)) 1315 .setFunctionName(DartUtilities::toString(functionName))
1308 .setLocation(locationJson) 1316 .setLocation(locationJson)
1309 .setScopeChain(scopeChain) 1317 .setScopeChain(scopeChain)
1310 .setThis(thisObject) 1318 .setThis(thisObject)
1311 .release()); 1319 .release();
1320
1321 uintptr_t framePointer = 0;
1322 result = Dart_ActivationFrameGetFramePointer(frame, &framePointer);
rmacnak 2014/09/08 22:51:44 Why not represent the frame pointer as a string or
Jacob 2014/09/10 17:58:56 I've switched to high and low halves instead of tr
1323 // No frame pointers will actually be larger than 2^48 on a current x64
1324 // machine but we truncate to 52 bits of precision to future proof the
1325 // method. As we don't care about the exact frame pointer only the
1326 // order of frame pointers, truncating to 52 bits will still generate th e
1327 // correct ordering with high probability.
1328 framePointer = framePointer & kMaxSafeIntegerForDouble;
1329 callFrame->setFramePointer(static_cast<double>(framePointer));
1330 ret->addItem(callFrame);
1312 } 1331 }
1313 return ret; 1332 return ret;
1314 } 1333 }
1315 1334
1316 DartDebuggerObject::Kind DartInjectedScript::inferKind(Dart_Handle handle) 1335 DartDebuggerObject::Kind DartInjectedScript::inferKind(Dart_Handle handle)
1317 { 1336 {
1318 DartDOMData* domData = DartDOMData::current(); 1337 DartDOMData* domData = DartDOMData::current();
1319 ASSERT(domData); 1338 ASSERT(domData);
1320 if (Dart_IsType(handle)) 1339 if (Dart_IsType(handle))
1321 return DartDebuggerObject::Class; 1340 return DartDebuggerObject::Class;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 } 1431 }
1413 1432
1414 DartDebuggerObject* DartInjectedScript::lookupObject(const String& objectId) 1433 DartDebuggerObject* DartInjectedScript::lookupObject(const String& objectId)
1415 { 1434 {
1416 ASSERT(validateObjectId(objectId)); 1435 ASSERT(validateObjectId(objectId));
1417 DebuggerObjectMap::iterator it = m_objects.find(objectId); 1436 DebuggerObjectMap::iterator it = m_objects.find(objectId);
1418 return it != m_objects.end() ? it->value : 0; 1437 return it != m_objects.end() ? it->value : 0;
1419 } 1438 }
1420 1439
1421 } // namespace WebCore 1440 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/common/common.gypi ('k') | Source/bindings/dart/DartScriptDebugServer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698