Title: [170421] trunk/Source/_javascript_Core
- Revision
- 170421
- Author
- msab...@apple.com
- Date
- 2014-06-24 23:45:50 -0700 (Tue, 24 Jun 2014)
Log Message
Add support routines to provide descriptive _javascript_ backtraces
https://bugs.webkit.org/show_bug.cgi?id=134278
Reviewed by Mark Lam.
* interpreter/CallFrame.cpp:
(JSC::CallFrame::dump):
(JSC::CallFrame::describeFrame):
* interpreter/CallFrame.h:
* runtime/JSCJSValue.cpp:
(JSC::JSValue::dumpForBacktrace):
* runtime/JSCJSValue.h:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (170420 => 170421)
--- trunk/Source/_javascript_Core/ChangeLog 2014-06-25 06:44:36 UTC (rev 170420)
+++ trunk/Source/_javascript_Core/ChangeLog 2014-06-25 06:45:50 UTC (rev 170421)
@@ -1,3 +1,18 @@
+2014-06-24 Michael Saboff <msab...@apple.com>
+
+ Add support routines to provide descriptive _javascript_ backtraces
+ https://bugs.webkit.org/show_bug.cgi?id=134278
+
+ Reviewed by Mark Lam.
+
+ * interpreter/CallFrame.cpp:
+ (JSC::CallFrame::dump):
+ (JSC::CallFrame::describeFrame):
+ * interpreter/CallFrame.h:
+ * runtime/JSCJSValue.cpp:
+ (JSC::JSValue::dumpForBacktrace):
+ * runtime/JSCJSValue.h:
+
2014-06-24 Brady Eidson <beid...@apple.com>
Enable GAMEPAD in the Mac build, but disabled at runtime.
Modified: trunk/Source/_javascript_Core/interpreter/CallFrame.cpp (170420 => 170421)
--- trunk/Source/_javascript_Core/interpreter/CallFrame.cpp 2014-06-25 06:44:36 UTC (rev 170420)
+++ trunk/Source/_javascript_Core/interpreter/CallFrame.cpp 2014-06-25 06:45:50 UTC (rev 170421)
@@ -32,6 +32,7 @@
#include "JSActivation.h"
#include "JSCInlines.h"
#include "VMEntryScope.h"
+#include <wtf/StringPrintStream.h>
namespace JSC {
@@ -151,4 +152,41 @@
registers()[activationRegister.offset()] = activation;
}
+void CallFrame::dump(PrintStream& out)
+{
+ if (CodeBlock* codeBlock = this->codeBlock()) {
+ out.print(codeBlock->inferredName(), "#", codeBlock->hashAsStringIfPossible(), " [", codeBlock->jitType(), "]");
+
+ out.print("(");
+ thisValue().dumpForBacktrace(out);
+
+ for (size_t i = 0; i < argumentCount(); ++i) {
+ out.print(", ");
+ JSValue value = argument(i);
+ value.dumpForBacktrace(out);
+ }
+
+ out.print(")");
+
+ return;
+ }
+
+ out.print(returnPC());
+}
+
+const char* CallFrame::describeFrame()
+{
+ const size_t bufferSize = 200;
+ static char buffer[bufferSize + 1];
+
+ WTF::StringPrintStream stringStream;
+
+ dump(stringStream);
+
+ strncpy(buffer, stringStream.toCString().data(), bufferSize);
+ buffer[bufferSize] = '\0';
+
+ return buffer;
+}
+
} // namespace JSC
Modified: trunk/Source/_javascript_Core/interpreter/CallFrame.h (170420 => 170421)
--- trunk/Source/_javascript_Core/interpreter/CallFrame.h 2014-06-25 06:44:36 UTC (rev 170420)
+++ trunk/Source/_javascript_Core/interpreter/CallFrame.h 2014-06-25 06:45:50 UTC (rev 170421)
@@ -308,6 +308,9 @@
StackVisitor::visit<Functor>(this, functor);
}
+ void dump(PrintStream&);
+ JS_EXPORT_PRIVATE const char* describeFrame();
+
private:
static const intptr_t s_VMEntrySentinel = 1;
Modified: trunk/Source/_javascript_Core/runtime/JSCJSValue.cpp (170420 => 170421)
--- trunk/Source/_javascript_Core/runtime/JSCJSValue.cpp 2014-06-25 06:44:36 UTC (rev 170420)
+++ trunk/Source/_javascript_Core/runtime/JSCJSValue.cpp 2014-06-25 06:45:50 UTC (rev 170421)
@@ -251,6 +251,47 @@
out.print("INVALID");
}
+void JSValue::dumpForBacktrace(PrintStream& out) const
+{
+ if (!*this)
+ out.print("<JSValue()>");
+ else if (isInt32())
+ out.printf("%d", asInt32());
+ else if (isDouble())
+ out.printf("%lf", asDouble());
+ else if (isCell()) {
+ if (asCell()->inherits(JSString::info())) {
+ JSString* string = jsCast<JSString*>(asCell());
+ const StringImpl* impl = string->tryGetValueImpl();
+ if (impl)
+ out.print("\"", impl, "\"");
+ else
+ out.print("(unresolved string)");
+ } else if (asCell()->inherits(Structure::info())) {
+ out.print("Structure[ ", asCell()->structure()->classInfo()->className);
+#if USE(JSVALUE64)
+ out.print(" ID: ", asCell()->structureID());
+#endif
+ out.print("]: ", RawPointer(asCell()));
+ } else {
+ out.print("Cell[", asCell()->structure()->classInfo()->className);
+#if USE(JSVALUE64)
+ out.print(" ID: ", asCell()->structureID());
+#endif
+ out.print("]: ", RawPointer(asCell()));
+ }
+ } else if (isTrue())
+ out.print("True");
+ else if (isFalse())
+ out.print("False");
+ else if (isNull())
+ out.print("Null");
+ else if (isUndefined())
+ out.print("Undefined");
+ else
+ out.print("INVALID");
+}
+
// This in the ToInt32 operation is defined in section 9.5 of the ECMA-262 spec.
// Note that this operation is identical to ToUInt32 other than to interpretation
// of the resulting bit-pattern (as such this metod is also called to implement
Modified: trunk/Source/_javascript_Core/runtime/JSCJSValue.h (170420 => 170421)
--- trunk/Source/_javascript_Core/runtime/JSCJSValue.h 2014-06-25 06:44:36 UTC (rev 170420)
+++ trunk/Source/_javascript_Core/runtime/JSCJSValue.h 2014-06-25 06:45:50 UTC (rev 170421)
@@ -280,6 +280,7 @@
JS_EXPORT_PRIVATE void dump(PrintStream&) const;
void dumpInContext(PrintStream&, DumpContext*) const;
+ void dumpForBacktrace(PrintStream&) const;
JS_EXPORT_PRIVATE JSObject* synthesizePrototype(ExecState*) const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes