summaryrefslogtreecommitdiffstats
path: root/idatui/domain.py
diff options
context:
space:
mode:
authorblasty <peter@haxx.in>2026-07-25 12:15:45 +0200
committerblasty <peter@haxx.in>2026-07-25 12:15:45 +0200
commitf79fbbdd6c089b58f29b6b5dcfd58ebc71e3bf78 (patch)
tree0f35f2206684e209475378ed62664f5ab11ef91a /idatui/domain.py
parentui: horizontally centre the splash logo in the loading dialog (diff)
downloadida-tui-f79fbbdd6c089b58f29b6b5dcfd58ebc71e3bf78.tar.gz
ida-tui-f79fbbdd6c089b58f29b6b5dcfd58ebc71e3bf78.tar.xz
ida-tui-f79fbbdd6c089b58f29b6b5dcfd58ebc71e3bf78.zip
retype: 'y' now retypes globals too, not just prototypes and locals
In the decompiler, 'y' on a local variable already worked (func_types -> lvars -> set_lvar_type), but a GLOBAL fell through every case and silently retyped the ENCLOSING FUNCTION'S PROTOTYPE — worse than not working, since the prompt said "prototype" while you thought you were typing a variable. * server/patch_server.py: new data_type tool — {addr,name,type,size,is_func} for a data item, so the prompt can prefill the current type and the caller can tell a global from a function. * domain: Program.data_type() + set_data_type() (set_type with kind="global"). * app: _prepare_retype gains the data case between "function" and the current-function fallback, with a size-based prefill when the global is still untyped; _do_retype routes kind="data" to set_data_type. Classification verified on echo/main: 'v3' -> lvar (prefill 'char *'), 'stdout' -> data (prefill 'FILE *'), 'main' -> func prototype, an unresolvable token -> the enclosing prototype (unchanged fallback). Also fixes a latent crash found while probing this: on_listing/decomp_view_ cursor_moved called self.query_one(ListingView), but App.query_one searches the TOP screen — a cursor-moved message landing while any modal is up (loading overlay, project switch) raised NoMatches out of a message handler and killed the app. Both handlers now go through _try_view(). Pilot `retype` extended to 9 checks covering all three flavours, each asserting the other targets are left alone. Two of the new checks needed settles: applying a retype recompiles asynchronously, so scanning/indexing the pseudocode without waiting reads text that's about to be replaced (this also cut the scenario from 30s to 2.6s of previously-wasted timeout). Full suite 174/2-flake.
Diffstat (limited to 'idatui/domain.py')
-rw-r--r--idatui/domain.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/idatui/domain.py b/idatui/domain.py
index 33c44b6..ef37ab9 100644
--- a/idatui/domain.py
+++ b/idatui/domain.py
@@ -1068,6 +1068,27 @@ class Program:
return None
return row.get("error") or "failed to set the prototype"
+ def data_type(self, ea: int) -> dict | None:
+ """Current type info for a data item/global: {addr,name,type,size,is_func}.
+ None if the tool is unavailable or the address isn't mapped."""
+ try:
+ r = self.client.call("data_type", addr=hex(ea))
+ except IDAToolError:
+ return None
+ if not isinstance(r, dict) or r.get("error"):
+ return None
+ return r
+
+ def set_data_type(self, ea: int, decl: str) -> str | None:
+ """Set a global/data item's type. None on success, else an error string."""
+ r = self.client.call(
+ "set_type", edits=[{"kind": "global", "addr": hex(ea), "type": decl}])
+ res = r.get("result", []) if isinstance(r, dict) else []
+ row = res[0] if res and isinstance(res[0], dict) else {}
+ if row.get("ok"):
+ return None
+ return row.get("error") or "failed to set the type"
+
def set_lvar_type(self, fn_ea: int, var: str, ty: str) -> str | None:
"""Set a decompiler local variable's type (via the injected server tool).
None on success, else an error string."""