+2004-10-07 Richard Williamson <rjw@apple.com>
+
+ Added simple JavaScript call tracing. Very useful for
+ debugging complex pages.
+
+ Tracing is only available in development builds and is
+ enabled by:
+
+ (gdb) set traceJavaScript = 1
+
+ or programatically
+
+ setTraceJavaScript(true)
+
+ Function, args, and return values are printed to console. Very
+ verbose.
+
+ Reviewed by Ken.
+
+ * kjs/function_object.cpp:
+ (FunctionProtoFuncImp::call):
+ * kjs/object.cpp:
+ (KJS::Object::call):
+
=== Safari-166 ===
2004-10-05 Richard Williamson <rjw@apple.com>
#include "error_object.h"
#include "nodes.h"
+#ifndef NDEBUG
+#define JAVASCRIPT_CALL_TRACING Yes
+#endif
+
+#ifdef JAVASCRIPT_CALL_TRACING
+static bool traceJavaScript = false;
+
+extern "C" {
+ void setTraceJavaScript(bool f)
+ {
+ traceJavaScript = f;
+ }
+
+ static bool traceJavaScript()
+ {
+ return traceJavaScript;
+ }
+}
+#endif
+
namespace KJS {
// ------------------------------ Object ---------------------------------------
{
#if KJS_MAX_STACK > 0
static int depth = 0; // sum of all concurrent interpreters
+
+#ifdef JAVASCRIPT_CALL_TRACING
+ static bool tracing = false;
+ if (javaScriptTrace() && !tracing) {
+ tracing = true;
+ for (int i = 0; i < depth; i++)
+ putchar (' ');
+ printf ("*** calling: %s\n", toString(exec).ascii());
+ for (int j = 0; j < args.size(); j++) {
+ for (int i = 0; i < depth; i++)
+ putchar (' ');
+ printf ("*** arg[%d] = %s\n", j, args[j].toString(exec).ascii());
+ }
+ tracing = false;
+ }
+#endif
+
if (++depth > KJS_MAX_STACK) {
--depth;
Object err = Error::create(exec, RangeError,
--depth;
#endif
+#ifdef JAVASCRIPT_CALL_TRACING
+ if (javaScriptTrace() && !tracing) {
+ tracing = true;
+ for (int i = 0; i < depth; i++)
+ putchar (' ');
+ printf ("*** returning: %s\n", ret.toString(exec).ascii());
+ tracing = false;
+ }
+#endif
+
return ret;
}