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

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, 4 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 frame->asObject()->getNumber("timestamp", &timestamp);
1042 return timestamp;
vsm 2014/08/13 14:26:45 Assert this is > 0 to ensure it's actually set?
Jacob 2014/08/13 21:36:16 Done. Assert that timestamp exists. Even though th
1043 }
1044
1045 static inline bool compareCallFrameTimestamps(PassRefPtr<CallFrame> frame1, Pass RefPtr<CallFrame> frame2)
1046 {
1047 return lookupTimestamp(frame1) > lookupTimestamp(frame2);
1048 }
1049
1050 void addFramesToVector(PassRefPtr<Array<CallFrame> > trace, Vector<RefPtr<CallFr ame> > & v)
1051 {
1052 RefPtr<JSONArray> traceArray = trace->asArray();
1053 for (JSONArray::iterator it = traceArray->begin(); it != traceArray->end(); ++it) {
1054 v.append(CallFrame::runtimeCast(*it));
1055 }
1056 }
1057
1058 PassRefPtr<Array<CallFrame> > mergeStackTraces(PassRefPtr<Array<CallFrame> > tra ce1, PassRefPtr<Array<CallFrame> > trace2)
1059 {
1060 Vector<RefPtr<CallFrame> > mergedFrames;
1061 addFramesToVector(trace1, mergedFrames);
1062 addFramesToVector(trace2, mergedFrames);
1063 std::stable_sort(mergedFrames.begin(), mergedFrames.end(), compareCallFrameT imestamps);
1064
1065 RefPtr<Array<CallFrame> > ret = Array<CallFrame>::create();
1066 for (size_t i = 0; i < mergedFrames.size(); ++i)
1067 ret->addItem(mergedFrames[i]);
1068 return ret;
1069 }
1070
1037 PassRefPtr<Array<CallFrame> > InspectorDebuggerAgent::currentCallFrames() 1071 PassRefPtr<Array<CallFrame> > InspectorDebuggerAgent::currentCallFrames()
1038 { 1072 {
1039 if (!m_pausedScriptState || m_currentCallStack.isNull()) 1073 if (!m_pausedScriptState || m_currentCallStack.isNull())
1040 return Array<TypeBuilder::Debugger::CallFrame>::create(); 1074 return Array<TypeBuilder::Debugger::CallFrame>::create();
1075 if (m_currentCallStack.isMixedLanguageStackTrace()) {
1076 return mergeStackTraces(
1077 m_injectedScriptManager->injectedScriptFor(m_currentCallStack.dartSc riptState()).wrapCallFrames(m_currentCallStack, 0),
1078 // FIXMEDART: passing in -1 as hack to force AsyncStack mode
1079 // evaluation as V8 cannot handle regular evaluation of a call
1080 // frame if not stopped at a v8 breakpoint due to an assert
1081 // in the V8 code base that should probably be removed.
1082 // Async call frame evaluation works almost as well as regular
1083 // call frame evaluation with the only difference being that
1084 // local variable modifications have no impact.
1085 m_injectedScriptManager->injectedScriptFor(m_currentCallStack.v8Scri ptState()).wrapCallFrames(m_currentCallStack, m_pausedScriptState->isJavaScript( ) ? 0 : -1));
1086 }
1087
1041 InjectedScript& injectedScript = m_injectedScriptManager->injectedScriptFor( m_pausedScriptState.get()); 1088 InjectedScript& injectedScript = m_injectedScriptManager->injectedScriptFor( m_pausedScriptState.get());
1042 if (injectedScript.isEmpty()) { 1089 if (injectedScript.isEmpty()) {
1043 ASSERT_NOT_REACHED(); 1090 ASSERT_NOT_REACHED();
1044 return Array<CallFrame>::create(); 1091 return Array<CallFrame>::create();
1045 } 1092 }
1046 return injectedScript.wrapCallFrames(m_currentCallStack, 0); 1093 return injectedScript.wrapCallFrames(m_currentCallStack, 0);
1047 } 1094 }
1048 1095
1049 PassRefPtr<WebCore::TypeBuilder::Debugger::StackTrace> InspectorDebuggerAgent::c urrentAsyncStackTrace() 1096 PassRefPtr<WebCore::TypeBuilder::Debugger::StackTrace> InspectorDebuggerAgent::c urrentAsyncStackTrace()
1050 { 1097 {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 { 1326 {
1280 m_scripts.clear(); 1327 m_scripts.clear();
1281 m_breakpointIdToDebugServerBreakpointIds.clear(); 1328 m_breakpointIdToDebugServerBreakpointIds.clear();
1282 m_asyncCallStackTracker.clear(); 1329 m_asyncCallStackTracker.clear();
1283 if (m_frontend) 1330 if (m_frontend)
1284 m_frontend->globalObjectCleared(); 1331 m_frontend->globalObjectCleared();
1285 } 1332 }
1286 1333
1287 } // namespace WebCore 1334 } // namespace WebCore
1288 1335
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698