static void printGroup(llvm::raw_ostream &out, const GroupRecord &Group,
                       bool FlagsOnly, unsigned Indent = 0) {
    out.indent(Indent * 2);

    bool ShowColors = showColors(out);
    setColor(ShowColors, out, llvm::raw_ostream::YELLOW);
    out << "-W" << Group.getName() << "\n";
    resetColor(ShowColors, out);

    ++Indent;
    for (GroupRecord::subgroup_iterator I = Group.subgroup_begin(),
            E = Group.subgroup_end();
            I != E; ++I) {
        printGroup(out, *I, FlagsOnly, Indent);
    }

    if (!FlagsOnly) {
        for (GroupRecord::diagnostics_iterator I = Group.diagnostics_begin(),
                E = Group.diagnostics_end();
                I != E; ++I) {
            if (ShowColors) {
                if (getLevel(I->DiagID) != DiagnosticsEngine::Ignored) {
                    setColor(ShowColors, out, llvm::raw_ostream::GREEN);
                }
            }
            out.indent(Indent * 2);
            out << I->getName();
            resetColor(ShowColors, out);
            out << "\n";
        }
    }
}
Пример #2
0
void CGBitFieldInfo::print(llvm::raw_ostream &OS) const {
  OS << "<CGBitFieldInfo";
  OS << " Size:" << Size;
  OS << " IsSigned:" << IsSigned << "\n";

  OS.indent(4 + strlen("<CGBitFieldInfo"));
  OS << " NumComponents:" << getNumComponents();
  OS << " Components: [";
  if (getNumComponents()) {
    OS << "\n";
    for (unsigned i = 0, e = getNumComponents(); i != e; ++i) {
      const AccessInfo &AI = getComponent(i);
      OS.indent(8);
      OS << "<AccessInfo"
         << " FieldIndex:" << AI.FieldIndex
         << " FieldByteOffset:" << AI.FieldByteOffset
         << " FieldBitStart:" << AI.FieldBitStart
         << " AccessWidth:" << AI.AccessWidth << "\n";
      OS.indent(8 + strlen("<AccessInfo"));
      OS << " AccessAlignment:" << AI.AccessAlignment
         << " TargetBitOffset:" << AI.TargetBitOffset
         << " TargetBitWidth:" << AI.TargetBitWidth
         << ">\n";
    }
    OS.indent(4);
  }
  OS << "]>";
}
Пример #3
0
static void PrintHelpOptionList(llvm::raw_ostream &OS, llvm::StringRef Title,
                                std::vector<std::pair<std::string,
                                const char*> > &OptionHelp) {
  OS << Title << ":\n";

  // Find the maximum option length.
  unsigned OptionFieldWidth = 0;
  for (unsigned i = 0, e = OptionHelp.size(); i != e; ++i) {
    // Skip titles.
    if (!OptionHelp[i].second)
      continue;

    // Limit the amount of padding we are willing to give up for alignment.
    unsigned Length = OptionHelp[i].first.size();
    if (Length <= 23)
      OptionFieldWidth = std::max(OptionFieldWidth, Length);
  }

  const unsigned InitialPad = 2;
  for (unsigned i = 0, e = OptionHelp.size(); i != e; ++i) {
    const std::string &Option = OptionHelp[i].first;
    int Pad = OptionFieldWidth - int(Option.size());
    OS.indent(InitialPad) << Option;

    // Break on long option names.
    if (Pad < 0) {
      OS << "\n";
      Pad = OptionFieldWidth + InitialPad;
    }
    OS.indent(Pad + 1) << OptionHelp[i].second << '\n';
  }
}
Пример #4
0
 /// Print the current state of all MemoryAccesses to @p OS.
 void printAccesses(llvm::raw_ostream &OS, int Indent = 0) const {
   OS.indent(Indent) << "After accesses {\n";
   for (auto &Stmt : *S) {
     OS.indent(Indent + 4) << Stmt.getBaseName() << "\n";
     for (auto *MA : Stmt)
       MA->print(OS);
   }
   OS.indent(Indent) << "}\n";
 }
Пример #5
0
void TempScop::printDetail(llvm::raw_ostream &OS, ScalarEvolution *SE,
                           LoopInfo *LI, const Region *CurR,
                           unsigned ind) const {
  // Print the loop bounds,  if the current region is a loop.
  LoopBoundMapType::const_iterator at = LoopBounds.find(castToLoop(*CurR, *LI));
  if (at != LoopBounds.end()) {
    OS.indent(ind) << "Bounds of Loop: " << at->first->getHeader()->getName()
      << ":\t{ ";
    at->second.print(OS, false);
    OS << " }\n";
    ind += 2;
  }

  // Iterate over the region nodes of this Scop to print the access functions
  // and loop bounds.
  for (Region::const_element_iterator I = CurR->element_begin(),
       E = CurR->element_end(); I != E; ++I) {
    if (I->isSubRegion()) {
      Region *subR = I->getNodeAs<Region>();
      printDetail(OS, SE, LI, subR, ind + 2);
    } else {
      BasicBlock *BB = I->getNodeAs<BasicBlock>();

      if (const AccFuncSetType *AccFunc = getAccessFunctions(BB)) {
        OS.indent(ind) << "BB: " << BB->getName() << "{\n";

        for (AccFuncSetType::const_iterator FI = AccFunc->begin(),
             FE = AccFunc->end(); FI != FE; ++FI) {
          const SCEVAffFunc &AF = FI->first;
          const Value *Ptr = AF.getBaseAddr();

          OS.indent(ind + 2) << AF << "  Refs: ";
          for (MayAliasSetInfo::const_alias_iterator
               MI = MayASInfo->alias_begin(Ptr), ME = MayASInfo->alias_end(Ptr);
               MI != ME; ++MI) {
            MI->second->print(OS);
            OS << ", ";
          }
          
          OS << '\n';
        }

        if (Reductions.count(BB))
          OS.indent(ind + 2) << "Reduction\n";

        OS.indent(ind) << "}\n";
      }
    }
  }
}
Пример #6
0
void SymbolicValue::print(llvm::raw_ostream &os, unsigned indent) const {
  os.indent(indent);
  switch (representationKind) {
  case RK_Unknown: {
    os << "unknown(" << (int)getUnknownReason() << "): ";
    getUnknownNode()->dump();
    return;
  }
  case RK_Metatype:
    os << "metatype: ";
    getMetatypeValue()->print(os);
    os << "\n";
    return;
  case RK_Function: {
    auto fn = getFunctionValue();
    os << "fn: " << fn->getName() << ": ";
    os << Demangle::demangleSymbolAsString(fn->getName());
    os << "\n";
    return;
  }
  case RK_Integer:
  case RK_IntegerInline:
    os << "int: " << getIntegerValue() << "\n";
    return;
  case RK_Aggregate: {
    ArrayRef<SymbolicValue> elements = getAggregateValue();
    switch (elements.size()) {
    case 0:
      os << "agg: 0 elements []\n";
      return;
    case 1:
      os << "agg: 1 elt: ";
      elements[0].print(os, indent + 2);
      return;
    default:
      os << "agg: " << elements.size() << " elements [\n";
      for (auto elt : elements)
        elt.print(os, indent + 2);
      os.indent(indent) << "]\n";
      return;
    }
  }
  }
}
Пример #7
0
void SubstitutionMap::dump(llvm::raw_ostream &out) const {
  out << "Substitutions:\n";
  for (const auto &sub : subMap) {
    out.indent(2);
    sub.first->print(out);
    out << " -> ";
    sub.second->print(out);
    out << "\n";
  }

  out << "\nConformance map:\n";
  for (const auto &conformances : conformanceMap) {
    out.indent(2);
    conformances.first->print(out);
    out << " -> [";
    interleave(conformances.second.begin(), conformances.second.end(),
               [&](ProtocolConformanceRef conf) {
                 conf.dump(out);
               },
               [&] {
                 out << ", ";
               });
    out << "]\n";
  }

  out << "\nParent map:\n";
  for (const auto &parent : parentMap) {
    out.indent(2);
    parent.first->print(out);
    out << " -> [";
    interleave(parent.second.begin(), parent.second.end(),
               [&](SubstitutionMap::ParentType parentType) {
                 parentType.first->print(out);
                 out << " @ ";
                 out << parentType.second->getProtocol()->getName().str()
                     << "." << parentType.second->getName().str();
               },
               [&] {
                 out << ", ";
               });
    out << "]\n";
  }
}
Пример #8
0
 /// Print simplification statistics to @p OS.
 void printStatistics(llvm::raw_ostream &OS, int Indent = 0) const {
   OS.indent(Indent) << "Statistics {\n";
   OS.indent(Indent + 4) << "Overwrites removed: " << OverwritesRemoved
                         << '\n';
   OS.indent(Indent + 4) << "Partial writes coalesced: " << WritesCoalesced
                         << "\n";
   OS.indent(Indent + 4) << "Redundant writes removed: "
                         << RedundantWritesRemoved << "\n";
   OS.indent(Indent + 4) << "Accesses with empty domains removed: "
                         << EmptyPartialAccessesRemoved << "\n";
   OS.indent(Indent + 4) << "Dead accesses removed: " << DeadAccessesRemoved
                         << '\n';
   OS.indent(Indent + 4) << "Dead instructions removed: "
                         << DeadInstructionsRemoved << '\n';
   OS.indent(Indent + 4) << "Stmts removed: " << StmtsRemoved << "\n";
   OS.indent(Indent) << "}\n";
 }
Пример #9
0
void CheckerRegistry::printHelp(llvm::raw_ostream &out,
                                size_t maxNameChars) const {
  // FIXME: Alphabetical sort puts 'experimental' in the middle.
  // Would it be better to name it '~experimental' or something else
  // that's ASCIIbetically last?
  std::sort(Checkers.begin(), Checkers.end(), checkerNameLT);

  // FIXME: Print available packages.

  out << "CHECKERS:\n";

  // Find the maximum option length.
  size_t optionFieldWidth = 0;
  for (CheckerInfoList::const_iterator i = Checkers.begin(), e = Checkers.end();
       i != e; ++i) {
    // Limit the amount of padding we are willing to give up for alignment.
    //   Package.Name     Description  [Hidden]
    size_t nameLength = i->FullName.size();
    if (nameLength <= maxNameChars)
      optionFieldWidth = std::max(optionFieldWidth, nameLength);
  }

  const size_t initialPad = 2;
  for (CheckerInfoList::const_iterator i = Checkers.begin(), e = Checkers.end();
       i != e; ++i) {
    out.indent(initialPad) << i->FullName;

    int pad = optionFieldWidth - i->FullName.size();

    // Break on long option names.
    if (pad < 0) {
      out << '\n';
      pad = optionFieldWidth + initialPad;
    }
    out.indent(pad + 2) << i->Desc;

    out << '\n';
  }
}
Пример #10
0
void CGRecordLayout::print(llvm::raw_ostream &OS) const {
  OS << "<CGRecordLayout\n";
  OS << "  LLVMType:" << *LLVMType << "\n";
  OS << "  ContainsPointerToDataMember:" << ContainsPointerToDataMember << "\n";
  OS << "  BitFields:[\n";
  for (llvm::DenseMap<const FieldDecl*, CGBitFieldInfo>::const_iterator
         it = BitFields.begin(), ie = BitFields.end();
       it != ie; ++it) {
    OS.indent(4);
    it->second.print(OS);
    OS << "\n";
  }
  OS << "]>\n";
}
Пример #11
0
void Table::Dump(llvm::raw_ostream &OS, llvm::StringRef Prefix) const {
  for(unsigned I = 0, E = RowsCount(); I < E; ++I) {
    if(!Prefix.empty()) {
      OS.changeColor(llvm::raw_ostream::GREEN) << Prefix << ": ";
      OS.resetColor();
    }

    for(unsigned J = 0, K = ColsCount(); J < K; ++J) {
      llvm::StringRef Cell = Columns[J][I];
      OS.indent(Columns[J].GetWidth() - Cell.size()) << Cell;
      if(J != K - 1)
        OS << " ";
    }
    OS << "\n";
  }
}
Пример #12
0
void ConstraintGraph::printConnectedComponents(llvm::raw_ostream &out) {
  SmallVector<TypeVariableType *, 16> typeVars;
  SmallVector<unsigned, 16> components;
  unsigned numComponents = computeConnectedComponents(typeVars, components);
  for (unsigned component = 0; component != numComponents; ++component) {
    out.indent(2);
    out << component << ":";
    for (unsigned i = 0, n = typeVars.size(); i != n; ++i) {
      if (components[i] == component) {
        out << ' ';
        typeVars[i]->print(out);
      }
    }
    out << '\n';
  }
}
Пример #13
0
void PabloPrinter::print(const Statement * stmt, llvm::raw_ostream & out, const bool expandNested, const unsigned indent) {
    out.indent(indent);
    if (stmt == nullptr) {
        out << "<null-stmt>";
    } else if (const Assign * an = dyn_cast<const Assign>(stmt)) {
        out << an->getName() << " = ";
        print(an->getExpression(), out);
    } else if (const Next * next = dyn_cast<const Next>(stmt)) {
        out << "Next(" << next->getName() << ") = ";
        print(next->getExpr(), out);
    } else if (const If * ifNode = dyn_cast<const If>(stmt)) {
        out << "If ";
        print(ifNode->getCondition(), out);
        if (expandNested) {
            out << ":\n";
            print(ifNode->getBody(), out, true, indent + BlockIndenting);
            if (ifNode->getDefined().size() > 0) {
                out.indent(indent);
                out << "Else:\n";
                print_vars(ifNode->getDefined(), out, indent + BlockIndenting);
            }
        }
    } else if (const While * whileNode = dyn_cast<const While>(stmt)) {
        out << "While ";
        print(whileNode->getCondition(), out);
        if (expandNested) {
            out << ":\n";
            print(whileNode->getBody(), out, true, indent + BlockIndenting);
        }
    } else if (const Call * call = dyn_cast<const Call>(stmt)) {
        if (call->getPrototype()->getNumOfResults() > 0) {
            out << " = ";
        }
        out << call->getCallee() << "(";
        for (unsigned i = 0; i != call->getNumOperands(); ++i) {
            print(call->getOperand(i), out);
        }
        out << ")";
    } else if (const And * andNode = dyn_cast<const And>(stmt)) {
        out << andNode->getName() << " = (";
        for (unsigned i = 0; i != andNode->getNumOperands(); ++i) {
            if (i) out << " & ";
            print(andNode->getOperand(i), out);
        }
        out << ")";
    } else if (const Or * orNode = dyn_cast<const Or>(stmt)) {
        out << orNode->getName() << " = (";
        for (unsigned i = 0; i != orNode->getNumOperands(); ++i) {
            if (i) out << " | ";
            print(orNode->getOperand(i), out);
        }
        out << ")";
    } else if (const Xor * xorNode = dyn_cast<const Xor>(stmt)) {
        out << xorNode->getName() << " = (";
        for (unsigned i = 0; i != xorNode->getNumOperands(); ++i) {
            if (i) out << " ^ ";
            print(xorNode->getOperand(i), out);
        }
        out << ")";
    } else if (const Sel * selNode = dyn_cast<const Sel>(stmt)) {
        out << selNode->getName() << " = (";
        print(selNode->getCondition(), out);
        out << " ? ";
        print(selNode->getTrueExpr(), out);
        out << " : ";
        print(selNode->getFalseExpr(), out);
        out << ")";
    } else if (const Not * notNode = dyn_cast<const Not>(stmt)) {
        out << notNode->getName() << " = (~";
        print(notNode->getExpr(), out);
        out << ")";
    } else if (const Advance * adv = dyn_cast<const Advance>(stmt)) {
        out << adv->getName() << " = pablo.Advance(";
        print(adv->getExpr(), out);
        out << ", " << std::to_string(adv->getAmount()) << ")";
    } else if (const Lookahead * adv = dyn_cast<const Lookahead>(stmt)) {
        out << adv->getName() << " = pablo.Lookahead(";
        print(adv->getExpr(), out);
        out << ", " << std::to_string(adv->getAmount()) << ")";
    } else if (const MatchStar * mstar = dyn_cast<const MatchStar>(stmt)) {
        out << mstar->getName() << " = pablo.MatchStar(";
        print(mstar->getMarker(), out);
        out << ", ";
        print(mstar->getCharClass(), out);
        out << ")";
    } else if (const ScanThru * sthru = dyn_cast<const ScanThru>(stmt)) {
        out << sthru->getName() << " = pablo.ScanThru(";
        print(sthru->getScanFrom(), out);
        out << ", ";
        print(sthru->getScanThru(), out);
        out << ")";
    } else if (const Count * count = dyn_cast<const Count>(stmt)) {
        out << count->getName() << " = pablo.Count(";
        print(count->getExpr(), out);
        out << ")";
    } else {
        out << "???";
    }
}
Пример #14
0
inline void print_vars(const pablo::If::DefinedVars & vars, llvm::raw_ostream & out, const unsigned indent) {
    for (const Assign * def : vars) {
        out.indent(indent);
        out << def->getName() << " = 0\n";
    }
}
Пример #15
0
void ConstraintGraphNode::print(llvm::raw_ostream &out, unsigned indent) {
  out.indent(indent);
  TypeVar->print(out);
  out << ":\n";

  // Print constraints.
  if (!Constraints.empty()) {
    out.indent(indent + 2);
    out << "Constraints:\n";
    SmallVector<Constraint *, 4> sortedConstraints(Constraints.begin(),
                                                   Constraints.end());
    std::sort(sortedConstraints.begin(), sortedConstraints.end());
    for (auto constraint : sortedConstraints) {
      out.indent(indent + 4);
      constraint->print(out, &TypeVar->getASTContext().SourceMgr);
      out << "\n";
    }
  }

  // Print adjacencies.
  if (!Adjacencies.empty()) {
    out.indent(indent + 2);
    out << "Adjacencies:";
    SmallVector<TypeVariableType *, 4> sortedAdjacencies(Adjacencies.begin(),
                                                         Adjacencies.end());
    std::sort(sortedAdjacencies.begin(), sortedAdjacencies.end(),
              [&](TypeVariableType *typeVar1, TypeVariableType *typeVar2) {
                return typeVar1->getID() < typeVar2->getID();
              });

    for (auto adj : sortedAdjacencies) {
      out << ' ';
      adj->print(out);

      auto &info = AdjacencyInfo[adj];
      auto degree = info.NumConstraints;
      if (degree > 1 || info.FixedBinding) {
        out << " (";
        if (degree > 1) {
          out << degree;
          if (info.FixedBinding)
            out << ", fixed";
        } else {
          out << "fixed";
        }
        out << ")";
      }
    }
    out << "\n";
  }

  // Print equivalence class.
  if (TypeVar->getImpl().getRepresentative(nullptr) == TypeVar &&
      EquivalenceClass.size() > 1) {
    out.indent(indent + 2);
    out << "Equivalence class:";
    for (unsigned i = 1, n = EquivalenceClass.size(); i != n; ++i) {
      out << ' ';
      EquivalenceClass[i]->print(out);
    }
    out << "\n";
  }

  // Print member types.
  if (!MemberTypes.empty()) {
    out.indent(indent + 2);
    out << "Member types:\n";
    for (auto memberType : MemberTypes) {
      out.indent(indent + 4);
      out << memberType.first.str() << " -> ";
      memberType.second->print(out);
      out << "\n";
    }
    out << "\n";
  }
}
Пример #16
0
void Module::print(llvm::raw_ostream &OS, unsigned Indent) const {
  OS.indent(Indent);
  if (IsFramework)
    OS << "framework ";
  if (IsExplicit)
    OS << "explicit ";
  OS << "module " << Name << " {\n";

  if (!Requires.empty()) {
    OS.indent(Indent + 2);
    OS << "requires ";
    for (unsigned I = 0, N = Requires.size(); I != N; ++I) {
      if (I)
        OS << ", ";
      OS << Requires[I];
    }
    OS << "\n";
  }
  
  if (const FileEntry *UmbrellaHeader = getUmbrellaHeader()) {
    OS.indent(Indent + 2);
    OS << "umbrella header \"";
    OS.write_escaped(UmbrellaHeader->getName());
    OS << "\"\n";
  } else if (const DirectoryEntry *UmbrellaDir = getUmbrellaDir()) {
    OS.indent(Indent + 2);
    OS << "umbrella \"";
    OS.write_escaped(UmbrellaDir->getName());
    OS << "\"\n";    
  }
  
  for (unsigned I = 0, N = Headers.size(); I != N; ++I) {
    OS.indent(Indent + 2);
    OS << "header \"";
    OS.write_escaped(Headers[I]->getName());
    OS << "\"\n";
  }
  
  for (submodule_const_iterator MI = submodule_begin(), MIEnd = submodule_end();
       MI != MIEnd; ++MI)
    (*MI)->print(OS, Indent + 2);
  
  for (unsigned I = 0, N = Exports.size(); I != N; ++I) {
    OS.indent(Indent + 2);
    OS << "export ";
    if (Module *Restriction = Exports[I].getPointer()) {
      OS << Restriction->getFullModuleName();
      if (Exports[I].getInt())
        OS << ".*";
    } else {
      OS << "*";
    }
    OS << "\n";
  }

  for (unsigned I = 0, N = UnresolvedExports.size(); I != N; ++I) {
    OS.indent(Indent + 2);
    OS << "export ";
    printModuleId(OS, UnresolvedExports[I].Id);
    if (UnresolvedExports[I].Wildcard) {
      if (UnresolvedExports[I].Id.empty())
        OS << "*";
      else
        OS << ".*";
    }
    OS << "\n";
  }

  if (InferSubmodules) {
    OS.indent(Indent + 2);
    if (InferExplicitSubmodules)
      OS << "explicit ";
    OS << "module * {\n";
    if (InferExportWildcard) {
      OS.indent(Indent + 4);
      OS << "export *\n";
    }
    OS.indent(Indent + 2);
    OS << "}\n";
  }
  
  OS.indent(Indent);
  OS << "}\n";
}
DisassembleResult Disassemble(llvm::raw_ostream &pOutput, const char *pTriple,
                              const char *pFuncName, const uint8_t *pFunc,
                              size_t pFuncSize) {
  DisassembleResult result = kDisassembleSuccess;
  uint64_t i = 0;

  const llvm::MCSubtargetInfo *subtarget_info = NULL;
  const llvm::MCDisassembler *disassembler = NULL;
  const llvm::MCInstrInfo *mc_inst_info = NULL;
  const llvm::MCRegisterInfo *mc_reg_info = NULL;
  const llvm::MCAsmInfo *asm_info = NULL;
  llvm::MCInstPrinter *inst_printer = NULL;

  BufferMemoryObject *input_function = NULL;

  std::string error;
  const llvm::Target* target =
      llvm::TargetRegistry::lookupTarget(pTriple, error);

  if (target == NULL) {
    ALOGE("Invalid target triple for disassembler: %s (%s)!",
          pTriple, error.c_str());
    return kDisassembleUnknownTarget;
  }

  subtarget_info =
      target->createMCSubtargetInfo(pTriple, /* CPU */"", /* Features */"");;

  if (subtarget_info == NULL) {
    result = kDisassembleFailedSetup;
    goto bail;
  }

  disassembler = target->createMCDisassembler(*subtarget_info);

  mc_inst_info = target->createMCInstrInfo();

  mc_reg_info = target->createMCRegInfo(pTriple);

  asm_info = target->createMCAsmInfo(pTriple);

  if ((disassembler == NULL) || (mc_inst_info == NULL) ||
      (mc_reg_info == NULL) || (asm_info == NULL)) {
    result = kDisassembleFailedSetup;
    goto bail;
  }

  inst_printer = target->createMCInstPrinter(asm_info->getAssemblerDialect(),
                                             *asm_info, *mc_inst_info,
                                             *mc_reg_info, *subtarget_info);

  if (inst_printer == NULL) {
    result = kDisassembleFailedSetup;
    goto bail;
  }

  input_function = new (std::nothrow) BufferMemoryObject(pFunc, pFuncSize);

  if (input_function == NULL) {
    result = kDisassembleOutOfMemory;
    goto bail;
  }

  // Disassemble the given function
  pOutput << "Disassembled code: " << pFuncName << "\n";

  while (i < pFuncSize) {
    llvm::MCInst inst;
    uint64_t inst_size;

    llvm::MCDisassembler::DecodeStatus decode_result =
        disassembler->getInstruction(inst, inst_size, *input_function, i,
                                     llvm::nulls(), llvm::nulls());

    switch (decode_result) {
      case llvm::MCDisassembler::Fail: {
        ALOGW("Invalid instruction encoding encountered at %llu of function %s "
              "under %s.", i, pFuncName, pTriple);
        i++;
        break;
      }
      case llvm::MCDisassembler::SoftFail: {
        ALOGW("Potentially undefined instruction encoding encountered at %llu "
              "of function %s under %s.", i, pFuncName, pTriple);
        // fall-through
      }
      case llvm::MCDisassembler::Success : {
        const uint8_t *inst_addr = pFunc + i;

        pOutput.indent(4);
        pOutput << "0x";
        pOutput.write_hex(reinterpret_cast<uintptr_t>(inst_addr));
        pOutput << ": 0x";
        pOutput.write_hex(*reinterpret_cast<const uint32_t *>(inst_addr));
        inst_printer->printInst(&inst, pOutput, /* Annot */"");
        pOutput << "\n";

        i += inst_size;
        break;
      }
    }
  }

  pOutput << "\n";

bail:
  // Clean up
  delete input_function;
  delete inst_printer;
  delete asm_info;
  delete mc_reg_info;
  delete mc_inst_info;
  delete disassembler;
  delete subtarget_info;

  return result;
}