def stackStartAddressInSelectedFrame(frame):
  # Determine if the %ebp register has already had the stack register pushed into it (always the first instruction)
  frameSymbol = frame.GetSymbolContext(0).GetSymbol()
  frameStartAddress = frameSymbol.GetStartAddress().GetLoadAddress(lldb.debugger.GetSelectedTarget())

  currentPC = frame.GetPC()

  offset = currentPC - frameStartAddress

  if offset == 0:
    return int(frame.EvaluateExpression('($esp + 4)').GetValue())
  elif offset == 1:
    return int(frame.EvaluateExpression('($esp + 8)').GetValue())
  else:
    return int(frame.EvaluateExpression('($ebp + 8)').GetValue())
dataset/ETHPy150Open facebook/chisel/commands/FBInvocationCommands.py/stackStartAddressInSelectedFrame/original