Local variables

Local variables (lvar) are implemented in Bip by the class HxLvar. They represent a local variable (including arguments) such as view by the decompiler.

The main way to access the HxLvar is through a HxCFunc object using, for example the lvars() property.

As of now there is no way to get the equivalent storage for a lvar.

HxLvar API

class bip.hexrays.HxLvar(lvar, hxcfunc, persistent=True)

Python object for representing a local variable of hexrays.

Todo

flags (not accessible publicly)

__init__(lvar, hxcfunc, persistent=True)

Constructor for the HxLvar representing a local variable from hexrays.

Parameters:
  • lvar – A lvar_t object from hexrays (those are swig proxy) which is the ida variable corresponding to this object.
  • hxcfunc – The HxCFunc object to which this local variable is attached.
  • persistent (bool) – Indicate if change to this object using the setter should be made persistent in the idb. True by default. See save() for more information.
name

Property which return the name of this local variable.

Return str:The name of the variable
size

Property which return the size of the current local variable.

Returns:The number of bytes (int) corresponding to the size of this lvar.
hxcfunc

Property which return the hexrays C function (HxCFunc) object to which this local variable is attached.

Returns:A HxCFunc object.
comment

Property which return the comment of the lvar.

Returns:The value of the comment or an empty string if there is no comment.
Return type:str
type

Property which return the object, which inherit from BipType, corresponding to the type of this local variable.

Because of the handling of the type in IDA the object returned is a copy of the type of this local variable. For changing the type of this variable it is necessary to use the setter of this property. For more information about this problem see BipType .

Returns:An object which inherit from BipType and represent the type of this local variable.
save()

Function which allow to save the change made to the local variable inside the idb. This is necessary because by default the change made to a lvar using the IDA interface only change the object in memory and not its content.

This function is called by default by the setters of this object if the _persistent property is at True (the default). It should not be necessary to call this directly.

Todo

this should probably set the flags to ? flags are not directly accessible through the the lvar object from IDAPython rigth now…

is_arg

Property which return true if this local variable is an argument of this function, false otherwise.

Returns:bool
is_reg

Property for checking if this local variable is located in a register.

Returns:bool
is_stk

Property for checking if this local variable is located on the stack.

Returns:bool
has_user_name

Property which return True if this variable has a user name.

Returns:bool
has_user_type

Property which return True if this variable has a user type.

Returns:bool