diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-06-23 01:05:26 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-06-23 01:05:26 +0000 |
commit | 9d95716c159ca4a07b435ec65943fa475cacc997 (patch) | |
tree | 8b489bd3b70ebc7aecc0b821fb247e3b19cb330a /llvm/lib/Object/FaultMapParser.cpp | |
parent | 3eb434acf408b590f6631f87719895154cf2ff13 (diff) | |
download | llvm-9d95716c159ca4a07b435ec65943fa475cacc997.zip llvm-9d95716c159ca4a07b435ec65943fa475cacc997.tar.gz llvm-9d95716c159ca4a07b435ec65943fa475cacc997.tar.bz2 |
[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
llvm-svn: 240364
Diffstat (limited to 'llvm/lib/Object/FaultMapParser.cpp')
-rw-r--r-- | llvm/lib/Object/FaultMapParser.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/llvm/lib/Object/FaultMapParser.cpp b/llvm/lib/Object/FaultMapParser.cpp new file mode 100644 index 0000000..dd663f3 --- /dev/null +++ b/llvm/lib/Object/FaultMapParser.cpp @@ -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; +} |