diff options
| author | blasty <blasty@local> | 2026-07-23 02:12:24 +0200 |
|---|---|---|
| committer | blasty <blasty@local> | 2026-07-23 02:12:24 +0200 |
| commit | 938235f7484b791a3828da3905c7c4949b8dba30 (patch) | |
| tree | c13920c817bc77a147e4272e49281cec16ab9ec3 /tests | |
| parent | TODO: M4 progress — string auto-detect + streaming done; struct-expand/unif... (diff) | |
| download | ida-tui-938235f7484b791a3828da3905c7c4949b8dba30.tar.gz ida-tui-938235f7484b791a3828da3905c7c4949b8dba30.tar.xz ida-tui-938235f7484b791a3828da3905c7c4949b8dba30.zip | |
listing: expand struct-typed globals into member rows (M4 item 3)
A struct-typed data item rendered as one dense 'MyS <...>' line. Now the heads
walker emits indented member rows after the summary (from get_udt_details):
+off name type, each a head of kind member at ea+offset. ListingView renders
them indented/dimmed; _line_plain matches for cursor/search.
Verified: a struct global expands to +0 a int / +4 b char[4] / +8 c __int16,
member rows carry field addresses. New listing_struct_expand scenario; listing
suite 22/0 (in-process).
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_scenarios.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/test_scenarios.py b/tests/test_scenarios.py index 62d86dd..d3576c0 100644 --- a/tests/test_scenarios.py +++ b/tests/test_scenarios.py @@ -1556,6 +1556,54 @@ async def s_listing_make_string(c: Ctx): c.prog.bump_items() +@scenario("listing_struct_expand") +async def s_listing_struct_expand(c: Ctx): + """A struct-typed global expands into indented member rows in the listing.""" + app = c.app + # a writable data address: reuse a data segment's first data head + A = None + for start, end, name in c.prog.sections(): + if start >= end: + continue + lm = c.prog.listing(start) + if lm is None: + continue + lm.ensure(60) + h = next((h for h in lm.window(0, 60) if h.kind == "data"), None) + if h is not None: + A = h.ea + break + if A is None: + c.check("found a data address for the struct test", False) + return + try: + c.prog.client.call( + "declare_type", + decls=["struct TuiExpandS { int a; char b[4]; short c; };"]) + c.prog.make_data(A, "TuiExpandS") + c.prog.bump_items() + await c.goto_ui(hex(A)) + await c.wait(lambda: app._active == "listing" and app._cur is not None + and app._cur.ea == A and c.lst.total > 0, 25) + # the summary head, then member rows for a/b/c + si = c.lst.model.index_of_ea(A) + members = [c.lst.model.get(si + 1 + k) for k in range(3)] + names = [m.text for m in members if m is not None] + c.check("struct global expands into member rows", + all(m is not None and m.kind == "member" for m in members) + and any("a" in t for t in names) and any("b" in t for t in names), + f"members={names}") + c.check("member rows carry field addresses", + members[1] is not None and members[1].ea == A + 4, + f"ea={members[1].ea if members[1] else None:#x} want={A+4:#x}") + finally: + try: + c.prog.undefine(A, size=16) + except Exception: # noqa: BLE001 + pass + c.prog.bump_items() + + # --------------------------------------------------------------------------- # # Runner # --------------------------------------------------------------------------- # |
