Exemple #1
0
bool Architecture::FormatFunction(
    Document      const& rDoc,
    Address       const& rAddr,
    Function      const& rFunc,
    PrintData          & rPrintData) const
{
    auto FuncLabel = rDoc.GetLabelFromAddress(rAddr);

    if (rFunc.GetSize() != 0 && rFunc.GetInstructionCounter() != 0)
    {
        std::ostringstream oss;
        oss
                << std::hex << std::showbase << std::left
                << "; size=" << rFunc.GetSize()
                << ", insn_cnt=" << rFunc.GetInstructionCounter();

        rPrintData.AppendComment(oss.str());
    }
    else
        rPrintData.AppendComment("; imported");

    Id CurId;
    if (!rDoc.RetrieveDetailId(rAddr, 0, CurId))
        return true;

    FunctionDetail FuncDtl;
    if (!rDoc.GetFunctionDetail(CurId, FuncDtl))
        return true;

    rPrintData.AppendNewLine().AppendSpace(2).AppendComment(";").AppendSpace();

    auto const& RetType = FuncDtl.GetReturnType();

    std::string FuncName;
    Label CurLbl = rDoc.GetLabelFromAddress(rAddr);
    if (CurLbl.GetType() == Label::Unknown)
        FuncName = FuncDtl.GetName();
    else
        FuncName = CurLbl.GetName();

    FormatTypeDetail(RetType, rPrintData);
    rPrintData.AppendSpace().AppendLabel(FuncName).AppendOperator("(");

    bool FirstParam = true;
    auto const& Params = FuncDtl.GetParameters();
    for (auto const& Param : Params)
    {
        if (FirstParam)
            FirstParam = false;
        else
            rPrintData.AppendOperator(",").AppendSpace();

        FormatTypeDetail(Param.GetType(), rPrintData);
        rPrintData.AppendSpace().AppendLabel(Param.GetValue().GetName());
    }

    rPrintData.AppendOperator(");");

    return true;
}
Exemple #2
0
bool Architecture::FormatFunction(
  Document      const& rDoc,
  BinaryStream  const& rBinStrm,
  Address       const& rAddr,
  Function      const& rFunc,
  std::string        & rStrMultiCell,
  Cell::Mark::List   & rMarks) const
{
  std::ostringstream oss;
  oss << std::hex << std::showbase << std::left;
  auto FuncLabel = rDoc.GetLabelFromAddress(rAddr);

  oss
    << "; " << FuncLabel.GetLabel()
    << ": size=" << rFunc.GetSize()
    << ", insn_cnt=" << rFunc.GetInstructionCounter();

  rStrMultiCell = oss.str();
  return true;
}