Benjamin Kramer | 0b8b771 | 2011-09-19 17:56:04 +0000 | [diff] [blame] | 1 | //===-- llvm-objdump.h ----------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef LLVM_OBJDUMP_H |
| 11 | #define LLVM_OBJDUMP_H |
| 12 | |
| 13 | #include "llvm/ADT/StringRef.h" |
| 14 | #include "llvm/Support/CommandLine.h" |
| 15 | #include "llvm/Support/DataTypes.h" |
| 16 | #include "llvm/Support/MemoryObject.h" |
| 17 | |
| 18 | namespace llvm { |
| 19 | |
| 20 | extern cl::opt<std::string> TripleName; |
| 21 | extern cl::opt<std::string> ArchName; |
| 22 | |
| 23 | // Various helper functions. |
| 24 | void DumpBytes(StringRef bytes); |
Benjamin Kramer | 0b8b771 | 2011-09-19 17:56:04 +0000 | [diff] [blame] | 25 | void DisassembleInputMachO(StringRef Filename); |
| 26 | |
| 27 | class StringRefMemoryObject : public MemoryObject { |
David Blaikie | 2d24e2a | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 28 | virtual void anchor(); |
Benjamin Kramer | 0b8b771 | 2011-09-19 17:56:04 +0000 | [diff] [blame] | 29 | StringRef Bytes; |
| 30 | public: |
| 31 | StringRefMemoryObject(StringRef bytes) : Bytes(bytes) {} |
| 32 | |
| 33 | uint64_t getBase() const { return 0; } |
Derek Schuff | adef06a | 2012-02-29 01:09:06 +0000 | [diff] [blame] | 34 | uint64_t getExtent() const { return Bytes.size(); } |
Benjamin Kramer | 0b8b771 | 2011-09-19 17:56:04 +0000 | [diff] [blame] | 35 | |
Derek Schuff | adef06a | 2012-02-29 01:09:06 +0000 | [diff] [blame] | 36 | int readByte(uint64_t Addr, uint8_t *Byte) const { |
Benjamin Kramer | 0b8b771 | 2011-09-19 17:56:04 +0000 | [diff] [blame] | 37 | if (Addr >= getExtent()) |
| 38 | return -1; |
| 39 | *Byte = Bytes[Addr]; |
| 40 | return 0; |
| 41 | } |
| 42 | }; |
| 43 | |
| 44 | } |
| 45 | |
| 46 | #endif |