diff options
author | Martin Nowack <m.nowack@imperial.ac.uk> | 2018-08-07 17:03:22 +0100 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2019-03-19 15:37:46 +0000 |
commit | d5ce6b3b2c62badebc7534550f09f1b5592a7aa3 (patch) | |
tree | b8733065d645291db4ee0728b834c8dfc48fd42e /include | |
parent | 488e65f76e49e28e3db1a845276bf3dac49a2dc1 (diff) | |
download | klee-d5ce6b3b2c62badebc7534550f09f1b5592a7aa3.tar.gz |
Refactor InstructionInfoTable
Better debug information
Diffstat (limited to 'include')
-rw-r--r-- | include/klee/Internal/Module/InstructionInfoTable.h | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/include/klee/Internal/Module/InstructionInfoTable.h b/include/klee/Internal/Module/InstructionInfoTable.h index 98af6ac9..4c9c19b1 100644 --- a/include/klee/Internal/Module/InstructionInfoTable.h +++ b/include/klee/Internal/Module/InstructionInfoTable.h @@ -10,9 +10,10 @@ #ifndef KLEE_LIB_INSTRUCTIONINFOTABLE_H #define KLEE_LIB_INSTRUCTIONINFOTABLE_H -#include <map> +#include <memory> #include <string> -#include <set> +#include <unordered_map> +#include <vector> namespace llvm { class Function; @@ -27,44 +28,48 @@ namespace klee { unsigned id; const std::string &file; unsigned line; + unsigned column; unsigned assemblyLine; public: - InstructionInfo(unsigned _id, - const std::string &_file, - unsigned _line, - unsigned _assemblyLine) - : id(_id), - file(_file), - line(_line), - assemblyLine(_assemblyLine) { - } + InstructionInfo(unsigned _id, const std::string &_file, unsigned _line, + unsigned _column, unsigned _assemblyLine) + : id(_id), file(_file), line(_line), column(_column), + assemblyLine(_assemblyLine) {} }; - class InstructionInfoTable { - struct ltstr { - bool operator()(const std::string *a, const std::string *b) const { - return *a<*b; - } - }; + /* Stores debug information for a KInstruction */ + struct FunctionInfo { + unsigned id; + const std::string &file; + unsigned line; + uint64_t assemblyLine; - std::string dummyString; - InstructionInfo dummyInfo; - std::map<const llvm::Instruction*, InstructionInfo> infos; - std::set<const std::string *, ltstr> internedStrings; + public: + FunctionInfo(unsigned _id, const std::string &_file, unsigned _line, + uint64_t _assemblyLine) + : id(_id), file(_file), line(_line), assemblyLine(_assemblyLine) {} + + FunctionInfo(const FunctionInfo &) = delete; + FunctionInfo &operator=(FunctionInfo const &) = delete; - private: - const std::string *internString(std::string s); - bool getInstructionDebugInfo(const llvm::Instruction *I, - const std::string *&File, unsigned &Line); + FunctionInfo(FunctionInfo &&) = default; + }; + + class InstructionInfoTable { + std::unordered_map<const llvm::Instruction *, + std::unique_ptr<InstructionInfo>> + infos; + std::unordered_map<const llvm::Function *, std::unique_ptr<FunctionInfo>> + functionInfos; + std::vector<std::unique_ptr<std::string>> internedStrings; public: - InstructionInfoTable(llvm::Module *m); - ~InstructionInfoTable(); + InstructionInfoTable(const llvm::Module &m); unsigned getMaxID() const; - const InstructionInfo &getInfo(const llvm::Instruction*) const; - const InstructionInfo &getFunctionInfo(const llvm::Function*) const; + const InstructionInfo &getInfo(const llvm::Instruction &) const; + const FunctionInfo &getFunctionInfo(const llvm::Function &) const; }; } |