static void _interpreterTrace(JSDContext* jsdc, JSContext *cx, JSStackFrame *fp, JSBool before) { JSDScript* jsdscript = NULL; JSScript * script; static indent = 0; char* buf; const char* funName = NULL; script = JS_GetFrameScript(cx, fp); if(script) { JSD_LOCK_SCRIPTS(jsdc); jsdscript = jsd_FindJSDScript(jsdc, script); JSD_UNLOCK_SCRIPTS(jsdc); if(jsdscript) funName = JSD_GetScriptFunctionName(jsdc, jsdscript); } if(!funName) funName = "TOP_LEVEL"; if(before) { buf = JS_smprintf("%sentering %s %s this: %0x\n", _indentSpaces(indent++), funName, JS_IsConstructorFrame(cx, fp) ? "constructing":"", (int)JS_GetFrameThis(cx, fp)); } else { buf = JS_smprintf("%sleaving %s\n", _indentSpaces(--indent), funName); } JS_ASSERT(indent >= 0); if(!buf) return; printf(buf); free(buf); }
static void _interpreterTrace(JSDContext* jsdc, JSContext *cx, JSAbstractFramePtr frame, bool isConstructing, JSBool before) { JSDScript* jsdscript = NULL; JSScript * script; static indent = 0; JSString* funName = NULL; script = frame.script(); if(script) { JSD_LOCK_SCRIPTS(jsdc); jsdscript = jsd_FindOrCreateJSDScript(jsdc, cx, script, frame); JSD_UNLOCK_SCRIPTS(jsdc); if(jsdscript) funName = JSD_GetScriptFunctionId(jsdc, jsdscript); } if(before) printf("%sentering ", _indentSpaces(indent++)); else printf("%sleaving ", _indentSpaces(--indent)); if (!funName) printf("TOP_LEVEL"); else JS_FileEscapedString(stdout, funName, 0); if(before) { jsval thisVal; printf("%s this: ", isConstructing ? "constructing":""); if (JS_GetFrameThis(cx, frame, &thisVal)) printf("0x%0llx", (uintptr_t) thisVal); else puts("<unavailable>"); } printf("\n"); JS_ASSERT(indent >= 0); }