diff options
| author | blasty <blasty@local> | 2026-07-26 15:22:11 +0200 |
|---|---|---|
| committer | blasty <blasty@local> | 2026-07-26 15:22:11 +0200 |
| commit | cc7ef9bb2c3fdb23cde0162158184d15709af43c (patch) | |
| tree | 8fb6575588b3ade7418a8f1c843ff8155228d2ef /tests | |
| parent | arm: offer 32-bit ARM at load, and fix `p` on carved code (diff) | |
| download | ida-tui-cc7ef9bb2c3fdb23cde0162158184d15709af43c.tar.gz ida-tui-cc7ef9bb2c3fdb23cde0162158184d15709af43c.tar.xz ida-tui-cc7ef9bb2c3fdb23cde0162158184d15709af43c.zip | |
app: rebuild the function index after an edit changes it
"even when I define functions with `p` I still get 'no functions: wrong
processor/base?'". Two bugs, and the second is the worse one.
The hint was LATCHED at load and only cleared on a reload, so it went on telling
you the image was described wrongly long after you'd proved otherwise. It is now
derived: the moment the index has a function, it stops being true.
But the index never had one. Nothing rebuilt _func_index after an edit, so `p`
gave you a function the rest of the app could not see — the names pane didn't
list it and Ctrl+N couldn't find it. The hint was just the visible symptom of
that.
_edit_done now reindexes when the edit changed which functions exist (`p` and
`u`; carving code doesn't, and a full walk after every `c` would be waste). It
uses its own worker rather than _load_functions(), which is the BOOT path — that
one clears the table, streams progress and auto-lands, which would yank the view
off the function you just made.
Verified on a blob with no functions: carve, `p`, and the status reads "created
function 0x4040–0x404c", the index reports 1, and the hint is gone.
Also: the reload confirmation said "1 functions". It counts now.
tests: +4 blob UI (30) — no functions and the hint says so, `p` creates one the
index can see, the stale hint is gone, the status names it. The Ctrl+L check
became wrong in the good way and now asserts the confirmation counts what would
be lost, since by then there IS something to lose. 209/0 scenarios, 13/0 thumb,
30/0 project UI.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_blob_ui.py | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/tests/test_blob_ui.py b/tests/test_blob_ui.py index f930401..b30bba5 100644 --- a/tests/test_blob_ui.py +++ b/tests/test_blob_ui.py @@ -214,14 +214,43 @@ async def run() -> int: lst._cursor_ea() == cur_before, f"{cur_before:#x} -> {lst._cursor_ea():#x}") + # -- `p` after carving: the rest of the app must notice ------ # + # The "no functions" hint was latched at load and only cleared on a + # reload, so it kept telling you the processor/base were wrong long + # after you'd defined a function. The function index was never + # rebuilt either, which meant Ctrl+N couldn't find what `p` made. + check("no functions yet, and the hint says so", + len(app._func_index) == 0 + and "no functions" in str(app.query_one("#status", Static).render()), + f"n={len(app._func_index)}") + lst.cursor = lst.model.index_of_ea(target) + lst._scroll_cursor_into_view() + await pilot.pause(0.3) + mp = lst.model + await pilot.press("p") + await wait(lambda: lst.model is not mp and lst.model is not None, + pilot, 40) + await wait(lambda: app._func_index is not None + and len(app._func_index) > 0, pilot, 60) + check("`p` creates a function the index can see", + len(app._func_index) == 1, f"n={len(app._func_index)}") + status = str(app.query_one("#status", Static).render()) + check("and the stale 'no functions' hint is gone", + "no functions" not in status, status[:90]) + check("the status names the function it made", + "created function" in status, status[:90]) + await pilot.press("ctrl+l") opened = await wait(lambda: isinstance(app.screen, ConfirmScreen), pilot, 20) check("Ctrl+L offers to reload with different options", opened, f"screen={type(app.screen).__name__}") if opened: note = str(app.screen.query_one("#confirm-note", Static).render()) - check("and says nothing is lost when there's nothing to lose", - "nothing is lost" in note, note[:70]) + # We just made a function, so it must NOT claim nothing is lost — + # reloading throws the database away and that is now a real cost. + check("the confirmation counts what would be lost", + "1 function," in note and "nothing is lost" not in note, + note[:80]) await pilot.press("escape") await pilot.pause(0.3) check("declining leaves the binary open", |
