From d5c6b7555a1251adf128d7c9b697732963e3bdae Mon Sep 17 00:00:00 2001 From: cnc Date: Fri, 5 Jun 2026 15:03:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=88=9A=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9A=84=20AGENTS.md=20=E5=92=8C=20align-linuxcnc=20=E5=8A=A0?= =?UTF-8?q?=E9=80=9F=E8=A7=84=E5=88=99=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 结论:按 align-linuxcnc 先确认干净基线,避免 source-map-only 和 smoke 扩展;新增 WASM tooldata 运行探针对 LinuxCNC src/emc/tooldata/tooldata_mmap.cc 随机换刀 T0 查找分支的覆盖,确认随机换刀扫描会越过 pocket 0 并返回非零 T0 pocket。\n\n测试结论:./test-linuxcnc-wasm-tooldata-link.sh、./test-linuxcnc-wasm-tooldata-runtime-symbols.sh、./test-native.sh、./test-linuxcnc-source-link.sh 均通过。 --- .../tooldata/tooldata_probe_main.cc | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/core/wasm_shims/tooldata/tooldata_probe_main.cc b/core/wasm_shims/tooldata/tooldata_probe_main.cc index 3e36a66..33b630c 100644 --- a/core/wasm_shims/tooldata/tooldata_probe_main.cc +++ b/core/wasm_shims/tooldata/tooldata_probe_main.cc @@ -113,6 +113,42 @@ int main() { return 69; } + const pid_t random_t0_child = fork(); + if (random_t0_child < 0) { + return 70; + } + if (random_t0_child == 0) { + if (tool_mmap_creator(nullptr, 1) != 0) { + _exit(71); + } + tooldata_reset(); + CANON_TOOL_TABLE spindle_t0 = tooldata_entry_init(); + spindle_t0.toolno = 0; + spindle_t0.pocketno = 0; + if (tooldata_put(spindle_t0, 0) == IDX_FAIL) { + _exit(72); + } + CANON_TOOL_TABLE random_t0 = tooldata_entry_init(); + random_t0.toolno = 0; + random_t0.pocketno = 15; + if (tooldata_put(random_t0, 15) == IDX_FAIL) { + _exit(73); + } + // LinuxCNC src/emc/tooldata/tooldata_mmap.cc continues past pocket 0 + // while scanning random toolchanger entries, so a nonzero T0 pocket wins. + if (tooldata_find_index_for_tool(0) != 15) { + _exit(74); + } + _exit(0); + } + int random_t0_status = 0; + if (waitpid(random_t0_child, &random_t0_status, 0) != random_t0_child) { + return 75; + } + if (!WIFEXITED(random_t0_status) || WEXITSTATUS(random_t0_status) != 0) { + return 76; + } + if (tool_mmap_user() != -1) { return 25; }