1 //===----------------------- FaultMapParser.cpp ---------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Object/FaultMapParser.h"
12 #include "llvm/Support/ErrorHandling.h"
13 #include "llvm/Support/Format.h"
17 const char *faultKindToString(FaultMapParser::FaultKind FT) {
20 llvm_unreachable("unhandled fault type!");
22 case FaultMapParser::FaultingLoad:
23 return "FaultingLoad";
28 operator<<(raw_ostream &OS,
29 const FaultMapParser::FunctionFaultInfoAccessor &FFI) {
31 << faultKindToString((FaultMapParser::FaultKind)FFI.getFaultKind())
32 << ", faulting PC offset: " << FFI.getFaultingPCOffset()
33 << ", handling PC offset: " << FFI.getHandlerPCOffset();
38 operator<<(raw_ostream &OS, const FaultMapParser::FunctionInfoAccessor &FI) {
39 OS << "FunctionAddress: " << format_hex(FI.getFunctionAddr(), 8)
40 << ", NumFaultingPCs: " << FI.getNumFaultingPCs() << "\n";
41 for (unsigned i = 0, e = FI.getNumFaultingPCs(); i != e; ++i)
42 OS << FI.getFunctionFaultInfoAt(i) << "\n";
46 raw_ostream &llvm::operator<<(raw_ostream &OS, const FaultMapParser &FMP) {
47 OS << "Version: " << format_hex(FMP.getFaultMapVersion(), 2) << "\n";
48 OS << "NumFunctions: " << FMP.getNumFunctions() << "\n";
50 if (FMP.getNumFunctions() == 0)
53 FaultMapParser::FunctionInfoAccessor FI;
55 for (unsigned i = 0, e = FMP.getNumFunctions(); i != e; ++i) {
56 FI = (i == 0) ? FMP.getFirstFunctionInfo() : FI.getNextFunctionInfo();