mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-30 02:25:19 +00:00
[FaultMaps] Move FaultMapParser to Object/
Summary: That way llvm-objdump can rely on it without adding an extra dependency on CodeGen. This change duplicates the FaultKind enum and the code that serializes it to a string. I could not figure out a way to get around this without adding a new dependency to Object Reviewers: rafael, ab Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10619 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240364 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -8,6 +8,7 @@ add_llvm_library(LLVMObject
|
||||
ELFObjectFile.cpp
|
||||
ELFYAML.cpp
|
||||
Error.cpp
|
||||
FaultMapParser.cpp
|
||||
IRObjectFile.cpp
|
||||
MachOObjectFile.cpp
|
||||
MachOUniversal.cpp
|
||||
|
61
lib/Object/FaultMapParser.cpp
Normal file
61
lib/Object/FaultMapParser.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
//===----------------------- FaultMapParser.cpp ---------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Object/FaultMapParser.h"
|
||||
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/Format.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
const char *faultKindToString(FaultMapParser::FaultKind FT) {
|
||||
switch (FT) {
|
||||
default:
|
||||
llvm_unreachable("unhandled fault type!");
|
||||
|
||||
case FaultMapParser::FaultingLoad:
|
||||
return "FaultingLoad";
|
||||
}
|
||||
}
|
||||
|
||||
raw_ostream &llvm::
|
||||
operator<<(raw_ostream &OS,
|
||||
const FaultMapParser::FunctionFaultInfoAccessor &FFI) {
|
||||
OS << "Fault kind: "
|
||||
<< faultKindToString((FaultMapParser::FaultKind)FFI.getFaultKind())
|
||||
<< ", 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;
|
||||
}
|
Reference in New Issue
Block a user