参考所有分组,完成尽量多的内容。禁止顺手扩功能 smoke:锁定tooldata未激活DB语义

结论:按 LinuxCNC src/emc/tooldata/tooldata_db.cc 锁定 tooldata_db_getall() 未激活返回 -1、tooldata_db_notify() 未激活返回 0 的 WASM shim 探针与 source-map 守卫;不启用外部 DB 服务,不扩展 smoke 解析。
This commit is contained in:
cnc
2026-06-04 19:48:47 +08:00
parent b89d6311ff
commit aaa6dce99a
6 changed files with 35 additions and 1 deletions

View File

@@ -28,6 +28,14 @@ grep -F 'int tool_nml_register(CANON_TOOL_TABLE *tblptr)' \
"$linuxcnc_root/src/emc/tooldata/tooldata_nml.cc" >/dev/null
grep -F 'int tooldata_db_init(char progname_plus_args[]' \
"$linuxcnc_root/src/emc/tooldata/tooldata_db.cc" >/dev/null
grep -F 'int tooldata_db_getall() {' \
"$linuxcnc_root/src/emc/tooldata/tooldata_db.cc" >/dev/null
grep -F 'if (!db_live) {return -1;}' \
"$linuxcnc_root/src/emc/tooldata/tooldata_db.cc" >/dev/null
grep -F 'int tooldata_db_notify(tool_notify_t ntype,' \
"$linuxcnc_root/src/emc/tooldata/tooldata_db.cc" >/dev/null
grep -F 'if (!db_live) return 0;' \
"$linuxcnc_root/src/emc/tooldata/tooldata_db.cc" >/dev/null
grep -F 'int tooldata_read_entry(const char *input_line)' \
"$linuxcnc_root/src/emc/tooldata/tooldata_common.cc" >/dev/null
@@ -64,10 +72,13 @@ grep -F 'LinuxCNC source basis: src/emc/tooldata/tooldata_mmap.cc provides these
core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null
grep -F 'LinuxCNC source basis: src/emc/tooldata/tooldata_nml.cc and tooldata_db.cc' \
core/wasm_shims/tooldata/tooldata_runtime_stubs.cc >/dev/null
grep -F 'returns 0 when' core/wasm_shims/tooldata/tooldata_runtime_stubs.cc >/dev/null
grep -F 'LinuxCNC source basis: src/emc/tooldata/tooldata_common.cc provides' \
core/wasm_shims/tooldata/tooldata_common_probe_main.cc >/dev/null
grep -F 'LinuxCNC source basis: src/emc/tooldata/tooldata_mmap.cc, tooldata_nml.cc,' \
core/wasm_shims/tooldata/tooldata_probe_main.cc >/dev/null
grep -F 'tooldata_db_notify() returns 0 without side effects while db_live is' \
core/wasm_shims/tooldata/tooldata_probe_main.cc >/dev/null
grep -F 'core/wasm_shims/tooldata/tooldata_mmap_backend.cc' docs/linuxcnc-wasm-shims-source-map.md >/dev/null
grep -F 'core/wasm_shims/tooldata/tooldata_runtime_stubs.cc' docs/linuxcnc-wasm-shims-source-map.md >/dev/null
@@ -129,6 +140,7 @@ for phrase in [
"source coverage only",
"must not become browser API fields",
"WASM-safe tooldata shims must preserve the LinuxCNC export surface",
"inactive-DB return values",
"./check-linuxcnc-tooldata-source-map.sh",
]:
if phrase not in doc:

View File

@@ -36,6 +36,8 @@ grep -F 'PythonPlugin::instantiate' "$linuxcnc_root/src/emc/pythonplugin/python_
grep -F '#define TOOL_MMAP_FILENAME ".tool.mmap"' "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null
grep -F 'int tool_nml_register(CANON_TOOL_TABLE *tblptr)' "$linuxcnc_root/src/emc/tooldata/tooldata_nml.cc" >/dev/null
grep -F 'int tooldata_db_init(char progname_plus_args[]' "$linuxcnc_root/src/emc/tooldata/tooldata_db.cc" >/dev/null
grep -F 'if (!db_live) {return -1;}' "$linuxcnc_root/src/emc/tooldata/tooldata_db.cc" >/dev/null
grep -F 'if (!db_live) return 0;' "$linuxcnc_root/src/emc/tooldata/tooldata_db.cc" >/dev/null
python3 - "$manifest" <<'PY'
from pathlib import Path
@@ -115,6 +117,7 @@ for phrase in [
"CMake `linuxcnc_wasm_safe_probe_shims` set",
"RS274/WASM manifest",
"browser-safe LinuxCNC adaptations",
"inactive-DB return values",
]:
if phrase not in source_map:
raise SystemExit(f"docs/linuxcnc-wasm-shims-source-map.md missing boundary phrase: {phrase}")

View File

@@ -113,6 +113,18 @@ int main() {
if (tooldata_db_getall() != -1) {
return 28;
}
// LinuxCNC source basis: src/emc/tooldata/tooldata_db.cc
// tooldata_db_notify() returns 0 without side effects while db_live is
// false, which is the browser-safe shim state for external DB services.
if (tooldata_db_notify(SPINDLE_LOAD, 7, 12, uncreated_tool) != 0) {
return 57;
}
if (tooldata_db_notify(SPINDLE_UNLOAD, 7, 12, uncreated_tool) != 0) {
return 58;
}
if (tooldata_db_notify(TOOL_OFFSET, 7, 12, uncreated_tool) != 0) {
return 59;
}
std::string missing_db_program_with_arg_string =
make_temp_path("cnc_tooldata_probe_missing_db_program arg");
std::vector<char> missing_db_program_with_arg(

View File

@@ -48,6 +48,8 @@ int tooldata_db_init(char progname_plus_args[], int) {
}
int tooldata_db_notify(tool_notify_t, int, int, CANON_TOOL_TABLE) {
// LinuxCNC source basis: src/emc/tooldata/tooldata_db.cc returns 0 when
// db_live is false, before formatting or sending any DB notification.
return 0;
}

View File

@@ -15,6 +15,9 @@ source-link/shim guard only; it must not add CNC behavior and must not expand th
- `src/emc/tooldata/tooldata_nml.cc` provides the NML tool table registration
backend selected by `TOOL_NML_FLAG`.
- `src/emc/tooldata/tooldata_db.cc` provides external database entry points.
- `src/emc/tooldata/tooldata_db.cc` returns `-1` from
`tooldata_db_getall()` when the external DB is not live, and returns `0`
from `tooldata_db_notify()` without side effects in that same state.
- `src/emc/tooldata/tool_mmap_read.cc` and `src/emc/tooldata/tool_watch.cc` are
utility sources from the same LinuxCNC tooldata build metadata.
- `src/emc/tooldata/tooldata.hh` declares the tooldata API used by RS274 and
@@ -40,6 +43,8 @@ source-link/shim guard only; it must not add CNC behavior and must not expand th
they must not become browser API fields or generated switchkins aliases.
- WASM-safe tooldata shims must preserve the LinuxCNC export surface checked by
symbol probes.
- WASM-safe tooldata runtime stubs must keep external database services
unavailable while preserving LinuxCNC inactive-DB return values.
- Native and source-link paths must keep the full LinuxCNC `src/emc/tooldata`
source directory tracked in the native RS274 manifest.
- `build-wasm.sh` must run tooldata link and symbol probes before copying

View File

@@ -23,7 +23,7 @@ only; it must not add CNC behavior and must not expand the temporary smoke parse
| `core/wasm_shims/rcs_print_shim.cc` | `src/libnml/rcs/rcs_print.cc` | Provides LinuxCNC RCS print diagnostics used by NML validation. |
| `core/wasm_shims/rtapi_compat.cc` | `src/rtapi/uspace_common.h`, `src/rtapi/rtapi.h` | Provides userspace RTAPI formatting declarations used by RS274/NML code. |
| `core/wasm_shims/tooldata/tooldata_mmap_backend.cc` | `src/emc/tooldata/tooldata_mmap.cc` | Replaces native mmap storage with an in-memory WASM-safe backend for probes. |
| `core/wasm_shims/tooldata/tooldata_runtime_stubs.cc` | `src/emc/tooldata/tooldata_nml.cc`, `src/emc/tooldata/tooldata_db.cc` | Satisfies NML and external tool database entry points without native services. |
| `core/wasm_shims/tooldata/tooldata_runtime_stubs.cc` | `src/emc/tooldata/tooldata_nml.cc`, `src/emc/tooldata/tooldata_db.cc` | Satisfies NML and external tool database entry points without native services, preserving inactive-DB return values. |
| `core/wasm_shims/pythonplugin/python_plugin.cc` | `src/emc/pythonplugin/python_plugin.cc`, `src/emc/pythonplugin/python_plugin.hh` | Keeps LinuxCNC PythonPlugin API available while Python execution is disabled for browser-safe probes. |
## Boundaries