等待目标进入指定状态(通用等待)
wait_stateWait for a target state (stopped, running, expr) with timeout and polling, returning observed state and timeout kind to avoid manual polling loops.
Instructions
轮询等待目标进入某个状态,把「等待 + 超时 + 现场」三件事一次做完,省掉 AI 自己 sleep + get_status 的轮询循环(那种循环既慢又容易在超时后不知道现场是什么)。state 取值:stopped(已停下,含 halt 后)、running(执行中)、not_debugging(未进入调试)、expr(表达式成立,需配 expr 参数,如 expr="uwTick > 1000" 或 expr="state == 3",非 0 即视为成立)。timeout_s 默认 10;poll_ms 默认 200。返回 matched(是否等到)、elapsed_s、polls、observed(最终观测到的状态)、以及超时时的 timeout_kind(timeout=等到了时间还没到目标状态 / unreachable=调试通道本身连不上 / never_debugging=目标停在 not_debugging 但你等的是调试态)。不要用它替代 wait_breakpoint:断点命中要用 wait_breakpoint(它认断点 id 与命中计数,比轮询 PC 更可靠);本工具适合「等标志位/等变量变化/等目标自己停下来」这类含糊等待。
【参数】必填: 无;可选: state, timeout_s, poll_ms, expr
【调用示例】{}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expr | No | ||
| state | No | stopped | |
| poll_ms | No | ||
| timeout_s | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |