I'm working on a function in the Ghidra decompiler with a bunch of variables that are re-used across different scopes. I don't see any way to rename this variable on a per-line basis. Is it possible?
Yaldi already mentioned the important first step of
Commit Locals for finer variable scoping.
If your Ghidra version has at least the commit https://github.com/NationalSecurityAgency/ghidra/commit/885402bbc3618b895c4b9b8f09300d3120a9abe8 which will probably be in the
9.2 release you can explicitly split a variable after
Commit Locals, by right clicking the variable in the decompiler view and selecting
Split out as New Variable.
This workaround is suggested by GitHub user ubitux, here: https://github.com/NationalSecurityAgency/ghidra/issues/1510, and I can confirm it works around the problem to some degrees.
When you "Commit Locals" for the function, some variable types and the names will be fixed, and the variable scopes will become smaller, so that one variable will be automatically split across multiple scopes. You can then iteratively annotate variable types, rename variables, commit, and the scopes will shrink further.