From b5a859dd2188e51abdbbbcb68af1a299605f92dd Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 16 Apr 2021 16:59:01 -0700 Subject: debugging: disassemble vm code out of debugger. * lib.c (dis): New function that we can call from gdb to disassemble a VM function, if we know its address. I've done this manually way too many times. * lib.h (dis): Declared. --- lib.c | 13 +++++++++++++ lib.h | 1 + 2 files changed, 14 insertions(+) diff --git a/lib.c b/lib.c index dcf9e870..58b05f0a 100644 --- a/lib.c +++ b/lib.c @@ -13098,3 +13098,16 @@ void d(val obj) void breakpt(void) { } + +/* + * Function for dissembling VM functions + * when debugging in gdb. + */ + +void dis(val obj) +{ + val sym = intern(lit("disassemble"), user_package); + val fun = cdr(if2(sym, lookup_fun(nil, sym))); + if (fun) + funcall1(fun, obj); +} diff --git a/lib.h b/lib.h index cd357004..e4040bc5 100644 --- a/lib.h +++ b/lib.h @@ -1217,6 +1217,7 @@ int compat_fixup(int compat_ver); void dump(val obj, val stream); void d(val obj); void breakpt(void); +void dis(val obj); #define nil convert(obj_t *, 0) -- cgit v1.2.3