LLVM API Documentation

RuntimeDyldCheckerImpl.h
Go to the documentation of this file.
00001 //===-- RuntimeDyldCheckerImpl.h -- RuntimeDyld test framework --*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDCHECKERIMPL_H
00011 #define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDCHECKERIMPL_H
00012 
00013 #include "RuntimeDyldImpl.h"
00014 #include <set>
00015 
00016 namespace llvm {
00017 
00018 class RuntimeDyldCheckerImpl {
00019   friend class RuntimeDyldChecker;
00020   friend class RuntimeDyldImpl;
00021   friend class RuntimeDyldCheckerExprEval;
00022 
00023 public:
00024   RuntimeDyldCheckerImpl(RuntimeDyld &RTDyld, MCDisassembler *Disassembler,
00025                          MCInstPrinter *InstPrinter,
00026                          llvm::raw_ostream &ErrStream);
00027 
00028   bool check(StringRef CheckExpr) const;
00029   bool checkAllRulesInBuffer(StringRef RulePrefix, MemoryBuffer *MemBuf) const;
00030 
00031 private:
00032 
00033   // StubMap typedefs.
00034   typedef std::map<std::string, uint64_t> StubOffsetsMap;
00035   struct SectionAddressInfo {
00036     uint64_t SectionID;
00037     StubOffsetsMap StubOffsets;
00038   };
00039   typedef std::map<std::string, SectionAddressInfo> SectionMap;
00040   typedef std::map<std::string, SectionMap> StubMap;
00041 
00042   RuntimeDyldImpl &getRTDyld() const { return *RTDyld.Dyld; }
00043 
00044   bool isSymbolValid(StringRef Symbol) const;
00045   uint64_t getSymbolLinkerAddr(StringRef Symbol) const;
00046   uint64_t getSymbolRemoteAddr(StringRef Symbol) const;
00047   uint64_t readMemoryAtAddr(uint64_t Addr, unsigned Size) const;
00048 
00049   std::pair<const SectionAddressInfo*, std::string> findSectionAddrInfo(
00050                                                    StringRef FileName,
00051                                                    StringRef SectionName) const;
00052 
00053   std::pair<uint64_t, std::string> getSectionAddr(StringRef FileName,
00054                                                   StringRef SectionName,
00055                                                   bool IsInsideLoad) const;
00056 
00057   std::pair<uint64_t, std::string> getStubAddrFor(StringRef FileName,
00058                                                   StringRef SectionName,
00059                                                   StringRef Symbol,
00060                                                   bool IsInsideLoad) const;
00061   StringRef getSubsectionStartingAt(StringRef Name) const;
00062 
00063   void registerSection(StringRef FilePath, unsigned SectionID);
00064   void registerStubMap(StringRef FilePath, unsigned SectionID,
00065                        const RuntimeDyldImpl::StubMap &RTDyldStubs);
00066 
00067   RuntimeDyld &RTDyld;
00068   MCDisassembler *Disassembler;
00069   MCInstPrinter *InstPrinter;
00070   llvm::raw_ostream &ErrStream;
00071 
00072   StubMap Stubs;
00073 };
00074 }
00075 
00076 #endif