more debug functions
This commit is contained in:
@@ -9,6 +9,11 @@ JSC_CCALL(debug_build_backtrace, return js_debugger_build_backtrace(js,NULL))
|
|||||||
// Return the closure variables for a given function.
|
// Return the closure variables for a given function.
|
||||||
JSC_CCALL(debug_closure_vars, return js_debugger_closure_variables(js,argv[0]))
|
JSC_CCALL(debug_closure_vars, return js_debugger_closure_variables(js,argv[0]))
|
||||||
|
|
||||||
|
JSC_CCALL(debug_set_closure_var,
|
||||||
|
js_debugger_set_closure_variable(js,argv[0],argv[1],argv[2]);
|
||||||
|
return JS_NULL;
|
||||||
|
)
|
||||||
|
|
||||||
// Return the local variables for a specific stack frame.
|
// Return the local variables for a specific stack frame.
|
||||||
JSC_CCALL(debug_local_vars, return js_debugger_local_variables(js, js2number(js,argv[0])))
|
JSC_CCALL(debug_local_vars, return js_debugger_local_variables(js, js2number(js,argv[0])))
|
||||||
|
|
||||||
@@ -22,6 +27,7 @@ static const JSCFunctionListEntry js_debug_funcs[] = {
|
|||||||
MIST_FUNC_DEF(debug, stack_depth, 0),
|
MIST_FUNC_DEF(debug, stack_depth, 0),
|
||||||
MIST_FUNC_DEF(debug, build_backtrace, 0),
|
MIST_FUNC_DEF(debug, build_backtrace, 0),
|
||||||
MIST_FUNC_DEF(debug, closure_vars, 1),
|
MIST_FUNC_DEF(debug, closure_vars, 1),
|
||||||
|
MIST_FUNC_DEF(debug, set_closure_var, 3),
|
||||||
MIST_FUNC_DEF(debug, local_vars, 1),
|
MIST_FUNC_DEF(debug, local_vars, 1),
|
||||||
MIST_FUNC_DEF(debug, fn_info, 1),
|
MIST_FUNC_DEF(debug, fn_info, 1),
|
||||||
MIST_FUNC_DEF(debug, backtrace_fns,0),
|
MIST_FUNC_DEF(debug, backtrace_fns,0),
|
||||||
|
|||||||
@@ -880,8 +880,6 @@ function get_module_cache_key(path, package_context) {
|
|||||||
|
|
||||||
Shop.is_loaded = function(path, package_context) {
|
Shop.is_loaded = function(path, package_context) {
|
||||||
var cache_key = get_module_cache_key(path, package_context)
|
var cache_key = get_module_cache_key(path, package_context)
|
||||||
log.console(cache_key)
|
|
||||||
if (!cache_key) return false
|
|
||||||
return use_cache[cache_key] != null
|
return use_cache[cache_key] != null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1319,21 +1317,24 @@ Shop.compile_module = function(alias) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var debug = use('debug')
|
||||||
|
|
||||||
Shop.module_reload = function(path, package) {
|
Shop.module_reload = function(path, package) {
|
||||||
if (!Shop.is_loaded(path,package)) return
|
if (!Shop.is_loaded(path,package)) return
|
||||||
var info = resolve_module_info(path, package)
|
var info = resolve_module_info(path, package)
|
||||||
if (!info) return
|
if (!info) return
|
||||||
|
|
||||||
var cache_key = info.cache_key
|
var cache_key = info.cache_key
|
||||||
log.console(`reloading ${cache_key}`)
|
|
||||||
var old = use_cache[cache_key]
|
var old = use_cache[cache_key]
|
||||||
var newmod = get_module(path, package)
|
var newmod = get_module(path, package)
|
||||||
|
|
||||||
log.console(typeof old)
|
|
||||||
log.console(typeof newmod)
|
|
||||||
|
|
||||||
for (var i in newmod)
|
for (var i in newmod)
|
||||||
old[i] = newmod[i]
|
old[i] = newmod[i]
|
||||||
|
|
||||||
|
for (var i in old) {
|
||||||
|
if (!(i in newmod))
|
||||||
|
old[i] = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Shop.build_package = function(package)
|
Shop.build_package = function(package)
|
||||||
|
|||||||
@@ -37457,6 +37457,40 @@ done:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void js_debugger_set_closure_variable(JSContext *ctx, JSValue fn, JSValue var_name, JSValue val)
|
||||||
|
{
|
||||||
|
JSObject *f = JS_VALUE_GET_OBJ(fn);
|
||||||
|
if (!f || !js_class_has_bytecode(f->class_id))
|
||||||
|
return;
|
||||||
|
|
||||||
|
JSFunctionBytecode *b = f->u.func.function_bytecode;
|
||||||
|
const char *name_str = JS_ToCString(ctx, var_name);
|
||||||
|
if (!name_str)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < b->closure_var_count; i++) {
|
||||||
|
JSClosureVar *cvar = b->closure_var + i;
|
||||||
|
const char *cvar_name = JS_AtomToCString(ctx, cvar->var_name);
|
||||||
|
if (!cvar_name)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (strcmp(name_str, cvar_name) == 0) {
|
||||||
|
JS_FreeCString(ctx, cvar_name);
|
||||||
|
JSVarRef *var_ref = NULL;
|
||||||
|
if (f->u.func.var_refs)
|
||||||
|
var_ref = f->u.func.var_refs[i];
|
||||||
|
if (var_ref && var_ref->pvalue) {
|
||||||
|
JS_FreeValue(ctx, *var_ref->pvalue);
|
||||||
|
*var_ref->pvalue = JS_DupValue(ctx, val);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
JS_FreeCString(ctx, cvar_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
JS_FreeCString(ctx, name_str);
|
||||||
|
}
|
||||||
|
|
||||||
JSValue js_debugger_closure_variables(JSContext *ctx, JSValue fn) {
|
JSValue js_debugger_closure_variables(JSContext *ctx, JSValue fn) {
|
||||||
JSValue ret = JS_NewObject(ctx);
|
JSValue ret = JS_NewObject(ctx);
|
||||||
JSObject *f = JS_VALUE_GET_OBJ(fn);
|
JSObject *f = JS_VALUE_GET_OBJ(fn);
|
||||||
|
|||||||
@@ -988,6 +988,7 @@ uint32_t js_debugger_stack_depth(JSContext *ctx);
|
|||||||
JSValue js_debugger_backtrace_fns(JSContext *ctx, const uint8_t *cur_pc);
|
JSValue js_debugger_backtrace_fns(JSContext *ctx, const uint8_t *cur_pc);
|
||||||
JSValue js_debugger_closure_variables(JSContext *ctx, JSValue fn);
|
JSValue js_debugger_closure_variables(JSContext *ctx, JSValue fn);
|
||||||
JSValue js_debugger_local_variables(JSContext *ctx, int stack_index);
|
JSValue js_debugger_local_variables(JSContext *ctx, int stack_index);
|
||||||
|
void js_debugger_set_closure_variable(JSContext *js, JSValue fn, JSValue var_name, JSValue val);
|
||||||
JSValue js_debugger_build_backtrace(JSContext *ctx, const uint8_t *cur_pc);
|
JSValue js_debugger_build_backtrace(JSContext *ctx, const uint8_t *cur_pc);
|
||||||
JSValue js_debugger_fn_info(JSContext *ctx, JSValue fn);
|
JSValue js_debugger_fn_info(JSContext *ctx, JSValue fn);
|
||||||
JSValue js_debugger_fn_bytecode(JSContext *js, JSValue fn);
|
JSValue js_debugger_fn_bytecode(JSContext *js, JSValue fn);
|
||||||
|
|||||||
Reference in New Issue
Block a user