Callable.extended_instructions()

Returns the set of all instructions from the current function entry in the control flow graph.

extended_instructions() -> APISet[Instruction]

The function is the extended/inter-procedural variant of the instructions(), meaning that it works recursively. It returns a set of Instructions object representing all the instructions which are reachable from the target function, the differences between extended_instructions() and instructions() the latter will only return instructions directly accessible from the function. At the same time, the extended version will find all the instructions recursively, which are eventually called when executing the function.

Also, note that the return types of extended_instructions() -> APISet[Instruction] and instructions() -> Instructions are different, the extended version returns an APISet of Instruction objects, while the original one returns Instructions (queryable) object.

Example

from glider import *

def query():
    # lets find a function with name transferFrom
    functions = Functions().with_name('transferOwnership').exec(1)

    #print the code of the function
    print(functions[0].source_code())

    #return the list of (extended) instructions, as it return a set, we need to cast it to list
    return list(functions[0].extended_instructions())

For the function:

function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

The output is:

Example Output

Last updated