From 4fdb7188a2ce135f0e90544843433535ba4e95a9 Mon Sep 17 00:00:00 2001 From: Mikura Kyouka <13207280@qq.com> Date: Mon, 20 Jul 2026 22:18:46 +0800 Subject: [PATCH] [DYNAREC] Added BOX64_DYNAREC_DISASM for Zydis disassembly in dynarec dump --- docs/USAGE.md | 7 +++++++ docs/USAGE_CN.md | 7 +++++++ docs/box64.pod | 8 ++++++++ docs/gen/usage.json | 19 +++++++++++++++++++ docs/gen/usage_cn.json | 7 +++++++ src/core.c | 2 +- src/emu/x64run.c | 2 +- src/include/env.h | 1 + src/test.c | 2 +- 9 files changed, 52 insertions(+), 3 deletions(-) diff --git a/docs/USAGE.md b/docs/USAGE.md index 569a091d14..aa3281f2f2 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -590,6 +590,13 @@ Dump DynaRec blocks in the specified range. Available in WowBox64. * 0xXXXXXXXX-0xYYYYYYYY: Define the range where DynaBlock gets dumped (inclusive-exclusive). +### BOX64_DYNAREC_DISASM + +Try to initialize libZydis for more readable x86 disassembly in dump, trace, crash report, etc. + + * 0: Do not load Zydis for Dynarec. [Default] + * 1: Try to load Zydis for Dynarec. + ### BOX64_DYNAREC_GDBJIT The GDBJIT debugging support, only available on build with `-DGDBJIT=ON`, enable it with gdb command: jit-reader-load /usr/local/lib/libbox64gdbjitreader.so. diff --git a/docs/USAGE_CN.md b/docs/USAGE_CN.md index 6d1f2746a9..1e4689eff4 100644 --- a/docs/USAGE_CN.md +++ b/docs/USAGE_CN.md @@ -727,6 +727,13 @@ x87 80 位 long double 的行为。 在 WowBox64 中可用。 * 0xXXXXXXXX-0xYYYYYYYY: 定义代码块 被转储的范围(左闭右开)。 +### BOX64_DYNAREC_DISASM + +尝试初始化 libZydis,以在转储、追踪、崩溃报告等场景中获得更具可读性的 x86 反汇编结果。 + + * 0: 不为 Dynarec 加载 Zydis。 [默认值] + * 1: 尝试为 Dynarec 加载 Zydis。 + ### BOX64_DYNAREC_GDBJIT GDBJIT 调试支持,仅在使用 `-DGDBJIT=ON` 构建时可用,通过 gdb 命令启用:jit-reader-load /usr/local/lib/libbox64gdbjitreader.so。 diff --git a/docs/box64.pod b/docs/box64.pod index 58a70b85c1..1c115edd60 100644 --- a/docs/box64.pod +++ b/docs/box64.pod @@ -244,6 +244,14 @@ Dump DynaRec blocks in the specified range. Available in WowBox64. * 0xXXXXXXXX-0xYYYYYYYY : Define the range where DynaBlock gets dumped (inclusive-exclusive). +=item B =I<0|1> + +Try to initialize libZydis for more readable x86 disassembly in dump, trace, crash report, etc. + + * 0 : Do not load Zydis for Dynarec. [Default] + * 1 : Try to load Zydis for Dynarec. + + =item B =I<0|1> Enable or disable fast NaN handling. Available in WowBox64. diff --git a/docs/gen/usage.json b/docs/gen/usage.json index 04f69ce8db..9930aa60e9 100644 --- a/docs/gen/usage.json +++ b/docs/gen/usage.json @@ -476,6 +476,25 @@ } ] }, + { + "name": "BOX64_DYNAREC_DISASM", + "description": "Try to initialize libZydis for more readable x86 disassembly in dump, trace, crash report, etc.", + "category": "Debugging", + "wine": false, + "configurator": false, + "options": [ + { + "key": "0", + "description": "Do not load Zydis for Dynarec.", + "default": true + }, + { + "key": "1", + "description": "Try to load Zydis for Dynarec.", + "default": false + } + ] + }, { "name": "BOX64_DYNAREC_FASTNAN", "description": "Enable or disable fast NaN handling.", diff --git a/docs/gen/usage_cn.json b/docs/gen/usage_cn.json index 92dbc2ac04..269bd8f1c7 100644 --- a/docs/gen/usage_cn.json +++ b/docs/gen/usage_cn.json @@ -168,6 +168,13 @@ "0xXXXXXXXX-0xYYYYYYYY": "定义代码块 被转储的范围(左闭右开)。" } }, + "BOX64_DYNAREC_DISASM": { + "description": "尝试初始化 libZydis,以在转储、追踪、崩溃报告等场景中获得更具可读性的 x86 反汇编结果。", + "options": { + "0": "不为 Dynarec 加载 Zydis。", + "1": "尝试为 Dynarec 加载 Zydis。" + } + }, "BOX64_DYNAREC_FASTNAN": { "description": "启用或禁用快速 NaN 处理。", "options": { diff --git a/src/core.c b/src/core.c index 9b8011a011..9fd9f5bee6 100644 --- a/src/core.c +++ b/src/core.c @@ -471,7 +471,7 @@ static void setupZydis(box64context_t* context) if ((BOX64ENV(trace_init) && strcmp(BOX64ENV(trace_init), "0")) || (BOX64ENV(trace) && strcmp(BOX64ENV(trace), "0"))) { context->x64trace = 1; } - if (context->x64trace) { + if (context->x64trace || BOX64ENV(dynarec_disasm)) { printf_log(LOG_INFO, "Initializing Zydis lib\n"); if (InitX64Trace(context)) { printf_log(LOG_INFO, "Zydis init failed. No x86 trace activated\n"); diff --git a/src/emu/x64run.c b/src/emu/x64run.c index 05f77aa48c..60ae874b12 100644 --- a/src/emu/x64run.c +++ b/src/emu/x64run.c @@ -78,7 +78,7 @@ int Run(x64emu_t *emu, int step) #if defined(HAVE_TRACE) __builtin_prefetch((void*)addr, 0, 0); emu->prev2_ip = emu->old_ip; - if(my_context->dec && IsTraceAddr(addr)) + if(my_context->x64trace && IsTraceAddr(addr)) PrintTrace(emu, addr, 0); #endif emu->old_ip = addr; diff --git a/src/include/env.h b/src/include/env.h index 100c8ff81f..f2991d7b3d 100644 --- a/src/include/env.h +++ b/src/include/env.h @@ -56,6 +56,7 @@ extern char* ftrace_name; BOOLEAN(BOX64_DYNAREC_NOHOTPAGE, dynarec_nohotpage, 0, 0, 1) \ BOOLEAN(BOX64_DYNAREC_DIV0, dynarec_div0, 0, 1, 1) \ INTEGER(BOX64_DYNAREC_DUMP, dynarec_dump, 0, 0, 3, 1, 0) \ + BOOLEAN(BOX64_DYNAREC_DISASM, dynarec_disasm, 0, 0, 0) \ STRING(BOX64_DYNAREC_DUMP_RANGE, dynarec_dump_range, 1, 0) \ BOOLEAN(BOX64_DYNAREC_FASTNAN, dynarec_fastnan, 1, 1, 1) \ INTEGER(BOX64_DYNAREC_FASTROUND, dynarec_fastround, 1, 0, 2, 1, 2) \ diff --git a/src/test.c b/src/test.c index 20ac2b6aed..2d33f2636c 100644 --- a/src/test.c +++ b/src/test.c @@ -507,7 +507,7 @@ static void setupZydis(box64context_t* context) if ((BOX64ENV(trace_init) && strcmp(BOX64ENV(trace_init), "0")) || (BOX64ENV(trace) && strcmp(BOX64ENV(trace), "0"))) { context->x64trace = 1; } - if (context->x64trace) { + if (context->x64trace || BOX64ENV(dynarec_disasm)) { printf_log(LOG_INFO, "Initializing Zydis lib\n"); if (InitX64Trace(context)) { printf_log(LOG_INFO, "Zydis init failed. No x86 trace activated\n");