0

Is there a way to get all the PcodeOps within a given function for a given local variable? So far I can find the HighSymbol given the function and the name, but I want to then grab all the uses of that variable?

DecompileResults res = decomplib.decompileFunction(f, 200, monitor);
if (res.decompileCompleted())
{
    HighFunction highFunc = res.getHighFunction();
    LocalSymbolMap localMap = highFunc.getLocalSymbolMap();
    Iterator<HighSymbol> localSymbols = localMap.getSymbols();
                        
    HighSymbol localSymbol = null;
    while (localSymbols.hasNext())
    {
      HighSymbol current = localSymbols.next();
      if (current.getName().equals(theName)) { 
       localSymbol = current;
        break;
      }
  }
}
kew
  • 1
  • 1

1 Answers1

0

If you are starting from a HighSymbol, you first get the HighVariable by accessing highSymbol.highVariable.

You can then get get all PCodeOPs using the variable by accessing the instances of a HighVariable which are of type VarnodeAST , and then getting their def (definition) and descendants

hvar = currentLocation.token.highVariable # get the high variable that is currently selected highlighted in the decompiler window
for varnode in hvar.instances:
    print(varnode.def) # the PCodeOp that defines this instance of the variable
    for dsc in varnode.descendants:
        print(dsc) # every PCodeOp that uses this variable
Florian Magin
  • 576
  • 3
  • 6