rename
Assign new names to functions, global variables, function arguments, or local variables in Ghidra, with support for namespace-qualified names and split-out variable occurrences.
Instructions
Rename a function, global label/variable, function argument, or local variable.
The target can be selected either with a compact typed selector or with the
`kind` and `function` arguments:
- `function:main` or `kind="function", target="main"`
- `global:g_counter` or `kind="global", target="0x404020"`
- `arg:#0@main`, `arg:argc@main`, or `kind="argument", function="main"`
- `local:uVar4@main` or `kind="local", function="main"`
- `var:name@main` or `kind="variable", function="main"` to match either
an argument or local variable
For the decompiler's "Split Out As New Variable" behavior, pass
`split_at` with the instruction address of the variable occurrence to
isolate, for example `target="local:res@handler", new_name="did_index",
split_at="0x90003482"`. The split variable is type-locked the same way
Ghidra's UI action does, so the split survives the next decompile.
If `kind` is `auto` and no `function` is supplied, the target is first
treated as a function at/containing the resolved address, then as a global
label/variable. Function, global, argument, and local renames are marked as
`USER_DEFINED` in Ghidra.
For C++, `new_name` may be namespace-qualified, e.g.
`new_name="MyClass::method"` or `new_name="ns::sub::g_table"`. The namespace
hierarchy is created if missing (missing levels become plain namespaces;
existing namespaces/classes are reused), and the function or global symbol
is placed in that namespace. To create a real C++ class first (so methods
land in a `Class` rather than a plain namespace), use `namespaces(...,
action="create", kind="class")`. Namespace-qualified names are only valid
for function and global renames, not argument/local variables.
Args:
target: Rename target selector. Local/argument selectors can use
`<kind>:<variable-or-#index>@<function>`.
new_name: Replacement name.
program: Required Ghidra project path or name to target.
kind: One of `auto`, `function`, `global`, `argument`, `local`, or
`variable`.
function: Function address/name for argument, local, or variable
renames when not using the `@function` selector syntax.
split_at: Optional instruction address of the local/argument
occurrence to split out as a new variable before renaming.
timeout: Decompiler timeout in seconds for local/argument renames.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | No | auto | |
| target | Yes | ||
| program | Yes | ||
| timeout | No | ||
| function | No | ||
| new_name | Yes | ||
| split_at | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |