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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/inspector/InspectorDebuggerAgent.cpp
diff --git a/Source/core/inspector/InspectorDebuggerAgent.cpp b/Source/core/inspector/InspectorDebuggerAgent.cpp
index b95de81a82054a004a522b05426118e6e4caac5d..dbc8457a483ce104a3354ba9facf7439e42a24e8 100644
--- a/Source/core/inspector/InspectorDebuggerAgent.cpp
+++ b/Source/core/inspector/InspectorDebuggerAgent.cpp
@@ -47,6 +47,7 @@
#include "core/inspector/ScriptCallFrame.h"
#include "core/inspector/ScriptCallStack.h"
#include "platform/JSONValues.h"
+#include "wtf/Vector.h"
#include "wtf/text/WTFString.h"
using WebCore::TypeBuilder::Array;
@@ -1034,10 +1035,56 @@ void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directive
}
}
+double lookupTimestamp(PassRefPtr<CallFrame> frame)
+{
+ double timestamp = 0;
+ frame->asObject()->getNumber("timestamp", &timestamp);
+ 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
+}
+
+static inline bool compareCallFrameTimestamps(PassRefPtr<CallFrame> frame1, PassRefPtr<CallFrame> frame2)
+{
+ return lookupTimestamp(frame1) > lookupTimestamp(frame2);
+}
+
+void addFramesToVector(PassRefPtr<Array<CallFrame> > trace, Vector<RefPtr<CallFrame> > & v)
+{
+ RefPtr<JSONArray> traceArray = trace->asArray();
+ for (JSONArray::iterator it = traceArray->begin(); it != traceArray->end(); ++it) {
+ v.append(CallFrame::runtimeCast(*it));
+ }
+}
+
+PassRefPtr<Array<CallFrame> > mergeStackTraces(PassRefPtr<Array<CallFrame> > trace1, PassRefPtr<Array<CallFrame> > trace2)
+{
+ Vector<RefPtr<CallFrame> > mergedFrames;
+ addFramesToVector(trace1, mergedFrames);
+ addFramesToVector(trace2, mergedFrames);
+ std::stable_sort(mergedFrames.begin(), mergedFrames.end(), compareCallFrameTimestamps);
+
+ RefPtr<Array<CallFrame> > ret = Array<CallFrame>::create();
+ for (size_t i = 0; i < mergedFrames.size(); ++i)
+ ret->addItem(mergedFrames[i]);
+ return ret;
+}
+
PassRefPtr<Array<CallFrame> > InspectorDebuggerAgent::currentCallFrames()
{
if (!m_pausedScriptState || m_currentCallStack.isNull())
return Array<TypeBuilder::Debugger::CallFrame>::create();
+ if (m_currentCallStack.isMixedLanguageStackTrace()) {
+ return mergeStackTraces(
+ m_injectedScriptManager->injectedScriptFor(m_currentCallStack.dartScriptState()).wrapCallFrames(m_currentCallStack, 0),
+ // FIXMEDART: passing in -1 as hack to force AsyncStack mode
+ // evaluation as V8 cannot handle regular evaluation of a call
+ // frame if not stopped at a v8 breakpoint due to an assert
+ // in the V8 code base that should probably be removed.
+ // Async call frame evaluation works almost as well as regular
+ // call frame evaluation with the only difference being that
+ // local variable modifications have no impact.
+ m_injectedScriptManager->injectedScriptFor(m_currentCallStack.v8ScriptState()).wrapCallFrames(m_currentCallStack, m_pausedScriptState->isJavaScript() ? 0 : -1));
+ }
+
InjectedScript& injectedScript = m_injectedScriptManager->injectedScriptFor(m_pausedScriptState.get());
if (injectedScript.isEmpty()) {
ASSERT_NOT_REACHED();

Powered by Google App Engine
This is Rietveld 408576698