Changeset 7786 in webkit for trunk/JavaScriptCore/kjs/object.cpp


Ignore:
Timestamp:
Oct 7, 2004, 2:30:47 PM (21 years ago)
Author:
rjw
Message:

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):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/object.cpp

    r7105 r7786  
    4040#include "nodes.h"
    4141
     42#ifndef NDEBUG
     43#define JAVASCRIPT_CALL_TRACING Yes
     44#endif
     45
     46#ifdef JAVASCRIPT_CALL_TRACING
     47static bool traceJavaScript = false;
     48
     49extern "C" {
     50    void setTraceJavaScript(bool f)
     51    {
     52        traceJavaScript = f;
     53    }
     54
     55    static bool traceJavaScript()
     56    {
     57        return traceJavaScript;
     58    }
     59}
     60#endif
     61
    4262namespace KJS {
    4363
     
    5777#if KJS_MAX_STACK > 0
    5878  static int depth = 0; // sum of all concurrent interpreters
     79
     80#ifdef JAVASCRIPT_CALL_TRACING
     81    static bool tracing = false;
     82    if (javaScriptTrace() && !tracing) {
     83        tracing = true;
     84        for (int i = 0; i < depth; i++)
     85            putchar (' ');
     86        printf ("*** calling:  %s\n", toString(exec).ascii());
     87        for (int j = 0; j < args.size(); j++) {
     88            for (int i = 0; i < depth; i++)
     89                putchar (' ');
     90            printf ("*** arg[%d] = %s\n", j, args[j].toString(exec).ascii());
     91        }
     92        tracing = false;
     93    }
     94#endif
     95
    5996  if (++depth > KJS_MAX_STACK) {
    6097    --depth;
     
    70107#if KJS_MAX_STACK > 0
    71108  --depth;
     109#endif
     110
     111#ifdef JAVASCRIPT_CALL_TRACING
     112    if (javaScriptTrace() && !tracing) {
     113        tracing = true;
     114        for (int i = 0; i < depth; i++)
     115            putchar (' ');
     116        printf ("*** returning:  %s\n", ret.toString(exec).ascii());
     117        tracing = false;
     118    }
    72119#endif
    73120
Note: See TracChangeset for help on using the changeset viewer.