mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Add disfile() helper to debug shell, to make it easier to see disassembly of top-level scripts.
This commit is contained in:
parent
c1491b01c2
commit
ae64a20e56
@ -1408,6 +1408,37 @@ Disassemble(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
DisassFile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
JSString *str;
|
||||
const char *filename;
|
||||
JSScript *script;
|
||||
JSBool ok;
|
||||
|
||||
if (!argc)
|
||||
return JS_TRUE;
|
||||
|
||||
str = JS_ValueToString(cx, argv[0]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
|
||||
filename = JS_GetStringBytes(str);
|
||||
script = JS_CompileFile(cx, obj, filename);
|
||||
if (!script)
|
||||
return JS_FALSE;
|
||||
|
||||
obj = JS_NewScriptObject(cx, script);
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
|
||||
*rval = OBJECT_TO_JSVAL(obj); /* I like to root it, root it. */
|
||||
ok = Disassemble(cx, obj, 1, rval, rval); /* gross, but works! */
|
||||
*rval = JSVAL_VOID;
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
DisassWithSrc(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
jsval *rval)
|
||||
@ -2802,6 +2833,7 @@ static JSFunctionSpec shell_functions[] = {
|
||||
JS_FS("throwError", ThrowError, 0,0,0),
|
||||
#ifdef DEBUG
|
||||
JS_FS("dis", Disassemble, 1,0,0),
|
||||
JS_FS("disfile", DisassFile, 1,0,0),
|
||||
JS_FS("dissrc", DisassWithSrc, 1,0,0),
|
||||
JS_FN("dumpHeap", DumpHeap, 0,0,0),
|
||||
JS_FS("notes", Notes, 1,0,0),
|
||||
@ -2873,6 +2905,7 @@ static const char *const shell_help_messages[] = {
|
||||
"throwError() Throw an error from JS_ReportError",
|
||||
#ifdef DEBUG
|
||||
"dis([fun]) Disassemble functions into bytecodes",
|
||||
"disfile('foo.js') Disassemble script file into bytecodes",
|
||||
"dissrc([fun]) Disassemble functions with source lines",
|
||||
"dumpHeap([fileName[, start[, toFind[, maxDepth[, toIgnore]]]]])\n"
|
||||
" Interface to JS_DumpHeap with output sent to file",
|
||||
|
Loading…
Reference in New Issue
Block a user