diff options
| author | blasty <blasty@local> | 2026-08-06 23:07:43 +0200 |
|---|---|---|
| committer | blasty <blasty@local> | 2026-08-06 23:07:43 +0200 |
| commit | f898350818062ccde209657632537d0d11bbdafa (patch) | |
| tree | b7603ec189e16f22d62253c9fa984b8f56c70e37 /tests | |
| parent | app: lift database edits out of IdaTui, and one prompt abstraction (diff) | |
| download | ida-tui-f898350818062ccde209657632537d0d11bbdafa.tar.gz ida-tui-f898350818062ccde209657632537d0d11bbdafa.tar.xz ida-tui-f898350818062ccde209657632537d0d11bbdafa.zip | |
split: stop the resync loop that spun the worker forever
_split_range is the min/max of the decomp_map's addresses, which does not cover
every address in the function -- Hex-Rays doesn't attribute them all. An anchor
inside the loaded function but outside that span therefore asked _sync_split for
a resync, _apply_resync found the function already decompiled, called
_sync_split again, and it asked again. One thread worker and one lookup_funcs
round trip per iteration, for as long as the cursor sat there.
Measured in the pilot: 23,888 function_of calls in one scenario across FOUR
distinct addresses, 21,156 of them for 0x2060 alone. In the live app that is an
idle split view pegging the worker.
_sync_split grows a resync flag; the one caller that is itself the resync passes
resync=False, so the branch can be entered at most once per chain.
While measuring, three scenarios waited on "fail" appearing in the status --
the app says "cannot decompile". decomp_fallback burned its full 25s timeout and
then passed a check on _active == "listing", which was already true before Tab
was pressed: it asserted nothing, slowly. Now waits for the real text and checks
that the fallback actually said something.
scenarios 115.8s -> 74.9s, suite 195.7s -> 153.3s, 732 checks green.
Not included: a range cache for function_of. It broke graph_minimap (the graph
stopped loading at all -- the 65s was that scenario's own 60s wait timing out)
and with the loop gone it buys little. Left out rather than shipped
half-understood.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_scenarios.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/tests/test_scenarios.py b/tests/test_scenarios.py index a6e7753..68ebfa3 100644 --- a/tests/test_scenarios.py +++ b/tests/test_scenarios.py @@ -61,6 +61,12 @@ def scenario(name): # --------------------------------------------------------------------------- # # Shared context + helpers # --------------------------------------------------------------------------- # +#: What the app says when Hex-Rays can't decompile (idatui/app.py, +#: _apply_decomp). Waiting on the wrong text here doesn't fail a test -- it +#: times out and then lets a weaker check pass, which is far more expensive. +_CANNOT_DECOMP = "cannot decompile" + + class Ctx: def __init__(self, app, pilot): self.app = app @@ -785,10 +791,16 @@ async def s_fallback(c: Ctx): await c.open(failing.addr, "listing") c.dis.focus() await c.press("tab") - await c.wait(lambda: app._active == "listing" - and "fail" in c.status().lower(), 25) - c.check("F5/Tab on an undecompilable function falls back to the listing", - app._active == "listing" and c.dis.display, + # "cannot decompile" is what _apply_decomp actually says. This waited on + # "fail", which never appears, so it burned the full 25s timeout and the + # check below then passed on _active == "listing" -- already true before Tab + # was pressed, since the function was opened in the listing. It asserted + # nothing, slowly. + landed = await c.wait(lambda: _CANNOT_DECOMP in c.status().lower(), 25) + c.check("F5/Tab on an undecompilable function says so", landed, + f"active={app._active} status={c.status()!r}") + c.check("F5/Tab on an undecompilable function falls back to a code view", + app._active in ("listing", "disasm") and c.dis.display, f"active={app._active} status={c.status()!r}") # a decompilable function F5s into pseudocode await c.open("main", "decomp") @@ -1306,7 +1318,8 @@ async def s_follow_xrefs(c: Ctx): await c.press("tab") landed = await c.wait( lambda: (app._active == "decomp" and dec.loaded_ea == xref.fn_addr) - or (app._active == "listing" and "fail" in c.status().lower()), 25) + or (app._active in ("listing", "disasm") + and _CANNOT_DECOMP in c.status().lower()), 25) if app._active == "decomp": c.check("F5 at the xref site decompiles the referencing function", dec.loaded_ea == xref.fn_addr, f"loaded={dec.loaded_ea}") @@ -2281,7 +2294,8 @@ async def s_continuous_view(c: Ctx): c.lst.focus() await c.press("tab") await c.wait(lambda: (app._active == "decomp" and c.dec.loaded_ea == fn_ea) - or (app._active == "listing" and "fail" in c.status().lower()), 25) + or (app._active in ("listing", "disasm") + and _CANNOT_DECOMP in c.status().lower()), 25) if app._active == "decomp": c.check("F5/Tab decompiles the function under the cursor", c.dec.loaded_ea == fn_ea, f"loaded={c.dec.loaded_ea}") |
