1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/lib/Object/FaultMapParser.cpp
Craig Topper 96c406a887 [FaultsMaps][llvm-objdump] Move FaultMapParser to Object/. Remove CodeGen dependency from llvm-objdump
FaultsMapParser lived in CodeGen and was forcing llvm-objdump to
link CodeGen and everything CodeGen depends on.

This was previously attempted in r240364 to fix a link failure.
The CodeGen dependency was independently added to fix the same
link failure, and that ended up being kept.

Removing the dependency seems like the correct layering for
llvm-objdump.

Reviewed By: MaskRay, jhenderson

Differential Revision: https://reviews.llvm.org/D95414
2021-01-27 10:39:59 -08:00

67 lines
2.1 KiB
C++

//===----------------------- FaultMapParser.cpp ---------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "llvm/Object/FaultMapParser.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
void printFaultType(FaultMapParser::FaultKind FT, raw_ostream &OS) {
switch (FT) {
default:
llvm_unreachable("unhandled fault type!");
case FaultMapParser::FaultingLoad:
OS << "FaultingLoad";
break;
case FaultMapParser::FaultingLoadStore:
OS << "FaultingLoadStore";
break;
case FaultMapParser::FaultingStore:
OS << "FaultingStore";
break;
}
}
raw_ostream &
llvm::operator<<(raw_ostream &OS,
const FaultMapParser::FunctionFaultInfoAccessor &FFI) {
OS << "Fault kind: ";
printFaultType((FaultMapParser::FaultKind)FFI.getFaultKind(), OS);
OS << ", faulting PC offset: " << FFI.getFaultingPCOffset()
<< ", handling PC offset: " << FFI.getHandlerPCOffset();
return OS;
}
raw_ostream &llvm::operator<<(raw_ostream &OS,
const FaultMapParser::FunctionInfoAccessor &FI) {
OS << "FunctionAddress: " << format_hex(FI.getFunctionAddr(), 8)
<< ", NumFaultingPCs: " << FI.getNumFaultingPCs() << "\n";
for (unsigned I = 0, E = FI.getNumFaultingPCs(); I != E; ++I)
OS << FI.getFunctionFaultInfoAt(I) << "\n";
return OS;
}
raw_ostream &llvm::operator<<(raw_ostream &OS, const FaultMapParser &FMP) {
OS << "Version: " << format_hex(FMP.getFaultMapVersion(), 2) << "\n";
OS << "NumFunctions: " << FMP.getNumFunctions() << "\n";
if (FMP.getNumFunctions() == 0)
return OS;
FaultMapParser::FunctionInfoAccessor FI;
for (unsigned I = 0, E = FMP.getNumFunctions(); I != E; ++I) {
FI = (I == 0) ? FMP.getFirstFunctionInfo() : FI.getNextFunctionInfo();
OS << FI;
}
return OS;
}