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

Side by Side Diff: Source/core/inspector/InspectorDebuggerAgent.cpp

Issue 466243002: Support merged Dart-JS callstacks (Closed) Base URL: svn://svn.chromium.org/blink/branches/dart/dartium
Patch Set: 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 29 matching lines...) Expand all
40 #include "core/fetch/Resource.h" 40 #include "core/fetch/Resource.h"
41 #include "core/inspector/ContentSearchUtils.h" 41 #include "core/inspector/ContentSearchUtils.h"
42 #include "core/inspector/InjectedScriptManager.h" 42 #include "core/inspector/InjectedScriptManager.h"
43 #include "core/inspector/InspectorPageAgent.h" 43 #include "core/inspector/InspectorPageAgent.h"
44 #include "core/inspector/InspectorState.h" 44 #include "core/inspector/InspectorState.h"
45 #include "core/inspector/InstrumentingAgents.h" 45 #include "core/inspector/InstrumentingAgents.h"
46 #include "core/inspector/ScriptArguments.h" 46 #include "core/inspector/ScriptArguments.h"
47 #include "core/inspector/ScriptCallFrame.h" 47 #include "core/inspector/ScriptCallFrame.h"
48 #include "core/inspector/ScriptCallStack.h" 48 #include "core/inspector/ScriptCallStack.h"
49 #include "platform/JSONValues.h" 49 #include "platform/JSONValues.h"
50 #include "wtf/Vector.h"
50 #include "wtf/text/WTFString.h" 51 #include "wtf/text/WTFString.h"
51 52
52 using WebCore::TypeBuilder::Array; 53 using WebCore::TypeBuilder::Array;
53 using WebCore::TypeBuilder::Debugger::BreakpointId; 54 using WebCore::TypeBuilder::Debugger::BreakpointId;
54 using WebCore::TypeBuilder::Debugger::CallFrame; 55 using WebCore::TypeBuilder::Debugger::CallFrame;
55 using WebCore::TypeBuilder::Debugger::ExceptionDetails; 56 using WebCore::TypeBuilder::Debugger::ExceptionDetails;
56 using WebCore::TypeBuilder::Debugger::FunctionDetails; 57 using WebCore::TypeBuilder::Debugger::FunctionDetails;
57 using WebCore::TypeBuilder::Debugger::ScriptId; 58 using WebCore::TypeBuilder::Debugger::ScriptId;
58 using WebCore::TypeBuilder::Debugger::StackTrace; 59 using WebCore::TypeBuilder::Debugger::StackTrace;
59 using WebCore::TypeBuilder::Runtime::RemoteObject; 60 using WebCore::TypeBuilder::Runtime::RemoteObject;
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 1028
1028 void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directive Text) 1029 void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directive Text)
1029 { 1030 {
1030 if (scriptDebugServer().pauseOnExceptionsState() != ScriptDebugServer::DontP auseOnExceptions) { 1031 if (scriptDebugServer().pauseOnExceptionsState() != ScriptDebugServer::DontP auseOnExceptions) {
1031 RefPtr<JSONObject> directive = JSONObject::create(); 1032 RefPtr<JSONObject> directive = JSONObject::create();
1032 directive->setString("directiveText", directiveText); 1033 directive->setString("directiveText", directiveText);
1033 breakProgram(InspectorFrontend::Debugger::Reason::CSPViolation, directiv e.release()); 1034 breakProgram(InspectorFrontend::Debugger::Reason::CSPViolation, directiv e.release());
1034 } 1035 }
1035 } 1036 }
1036 1037
1038 double lookupTimestamp(PassRefPtr<CallFrame> frame)
1039 {
1040 double timestamp = 0;
1041 bool ALLOW_UNUSED hasTimestamp = frame->asObject()->getNumber("timestamp", & timestamp);
1042 ASSERT(hasTimestamp);
1043 return timestamp;
1044 }
1045
1046 static inline bool compareCallFrameTimestamps(PassRefPtr<CallFrame> frame1, Pass RefPtr<CallFrame> frame2)
1047 {
1048 return lookupTimestamp(frame1) > lookupTimestamp(frame2);
1049 }
1050
1051 void addFramesToVector(PassRefPtr<Array<CallFrame> > trace, Vector<RefPtr<CallFr ame> > & v)
1052 {
1053 RefPtr<JSONArray> traceArray = trace->asArray();
1054 for (JSONArray::iterator it = traceArray->begin(); it != traceArray->end(); ++it) {
1055 v.append(CallFrame::runtimeCast(*it));
1056 }
1057 }
1058
1059 PassRefPtr<Array<CallFrame> > mergeStackTraces(PassRefPtr<Array<CallFrame> > tra ce1, PassRefPtr<Array<CallFrame> > trace2)
1060 {
1061 Vector<RefPtr<CallFrame> > mergedFrames;
1062 addFramesToVector(trace1, mergedFrames);
1063 addFramesToVector(trace2, mergedFrames);
1064 std::stable_sort(mergedFrames.begin(), mergedFrames.end(), compareCallFrameT imestamps);
1065
1066 RefPtr<Array<CallFrame> > ret = Array<CallFrame>::create();
1067 for (size_t i = 0; i < mergedFrames.size(); ++i)
1068 ret->addItem(mergedFrames[i]);
1069 return ret;
1070 }
1071
1037 PassRefPtr<Array<CallFrame> > InspectorDebuggerAgent::currentCallFrames() 1072 PassRefPtr<Array<CallFrame> > InspectorDebuggerAgent::currentCallFrames()
1038 { 1073 {
1039 if (!m_pausedScriptState || m_currentCallStack.isNull()) 1074 if (!m_pausedScriptState || m_currentCallStack.isNull())
1040 return Array<TypeBuilder::Debugger::CallFrame>::create(); 1075 return Array<TypeBuilder::Debugger::CallFrame>::create();
1076 if (m_currentCallStack.isMixedLanguageStackTrace()) {
1077 return mergeStackTraces(
1078 m_injectedScriptManager->injectedScriptFor(m_currentCallStack.dartSc riptState()).wrapCallFrames(m_currentCallStack, 0),
1079 // FIXMEDART: passing in -1 as hack to force AsyncStack mode
1080 // evaluation as V8 cannot handle regular evaluation of a call
1081 // frame if not stopped at a v8 breakpoint due to an assert
1082 // in the V8 code base that should probably be removed.
1083 // Async call frame evaluation works almost as well as regular
1084 // call frame evaluation with the only difference being that
1085 // local variable modifications have no impact.
1086 m_injectedScriptManager->injectedScriptFor(m_currentCallStack.v8Scri ptState()).wrapCallFrames(m_currentCallStack, m_pausedScriptState->isJavaScript( ) ? 0 : -1));
1087 }
1088
1041 InjectedScript& injectedScript = m_injectedScriptManager->injectedScriptFor( m_pausedScriptState.get()); 1089 InjectedScript& injectedScript = m_injectedScriptManager->injectedScriptFor( m_pausedScriptState.get());
1042 if (injectedScript.isEmpty()) { 1090 if (injectedScript.isEmpty()) {
1043 ASSERT_NOT_REACHED(); 1091 ASSERT_NOT_REACHED();
1044 return Array<CallFrame>::create(); 1092 return Array<CallFrame>::create();
1045 } 1093 }
1046 return injectedScript.wrapCallFrames(m_currentCallStack, 0); 1094 return injectedScript.wrapCallFrames(m_currentCallStack, 0);
1047 } 1095 }
1048 1096
1049 PassRefPtr<WebCore::TypeBuilder::Debugger::StackTrace> InspectorDebuggerAgent::c urrentAsyncStackTrace() 1097 PassRefPtr<WebCore::TypeBuilder::Debugger::StackTrace> InspectorDebuggerAgent::c urrentAsyncStackTrace()
1050 { 1098 {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 if (location) 1188 if (location)
1141 m_frontend->breakpointResolved(it->key, location); 1189 m_frontend->breakpointResolved(it->key, location);
1142 } 1190 }
1143 } 1191 }
1144 1192
1145 void InspectorDebuggerAgent::failedToParseSource(const String& url, const String & data, int firstLine, int errorLine, const String& errorMessage) 1193 void InspectorDebuggerAgent::failedToParseSource(const String& url, const String & data, int firstLine, int errorLine, const String& errorMessage)
1146 { 1194 {
1147 m_frontend->scriptFailedToParse(url, data, firstLine, errorLine, errorMessag e); 1195 m_frontend->scriptFailedToParse(url, data, firstLine, errorLine, errorMessag e);
1148 } 1196 }
1149 1197
1150 ScriptDebugListener::SkipPauseRequest InspectorDebuggerAgent::didPause(ScriptSta te* scriptState, const StackTrace& callFrames, const ScriptValue& exception, con st Vector<String>& hitBreakpoints) 1198 ScriptDebugListener::SkipPauseRequest InspectorDebuggerAgent::didPause(ScriptSta te* scriptState, const ScriptValue& exception, const Vector<String>& hitBreakpoi nts)
1151 { 1199 {
1200 const StackTrace& callFrames = scriptDebugServer().currentCallFrames();
1152 ScriptDebugListener::SkipPauseRequest result; 1201 ScriptDebugListener::SkipPauseRequest result;
1153 if (m_javaScriptPauseScheduled) 1202 if (m_javaScriptPauseScheduled)
1154 result = ScriptDebugListener::NoSkip; // Don't skip explicit pause reque sts from front-end. 1203 result = ScriptDebugListener::NoSkip; // Don't skip explicit pause reque sts from front-end.
1155 else if (m_skipAllPauses) 1204 else if (m_skipAllPauses)
1156 result = ScriptDebugListener::Continue; 1205 result = ScriptDebugListener::Continue;
1157 else if (!hitBreakpoints.isEmpty()) 1206 else if (!hitBreakpoints.isEmpty())
1158 result = ScriptDebugListener::NoSkip; // Don't skip explicit breakpoints even if set in frameworks. 1207 result = ScriptDebugListener::NoSkip; // Don't skip explicit breakpoints even if set in frameworks.
1159 else if (!exception.isEmpty()) 1208 else if (!exception.isEmpty())
1160 result = shouldSkipExceptionPause(); 1209 result = shouldSkipExceptionPause();
1161 else if (m_debuggerStepScheduled || m_pausingOnNativeEvent) 1210 else if (m_debuggerStepScheduled || m_pausingOnNativeEvent)
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 { 1328 {
1280 m_scripts.clear(); 1329 m_scripts.clear();
1281 m_breakpointIdToDebugServerBreakpointIds.clear(); 1330 m_breakpointIdToDebugServerBreakpointIds.clear();
1282 m_asyncCallStackTracker.clear(); 1331 m_asyncCallStackTracker.clear();
1283 if (m_frontend) 1332 if (m_frontend)
1284 m_frontend->globalObjectCleared(); 1333 m_frontend->globalObjectCleared();
1285 } 1334 }
1286 1335
1287 } // namespace WebCore 1336 } // namespace WebCore
1288 1337
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698