From d5ce6b3b2c62badebc7534550f09f1b5592a7aa3 Mon Sep 17 00:00:00 2001 From: Martin Nowack Date: Tue, 7 Aug 2018 17:03:22 +0100 Subject: Refactor InstructionInfoTable Better debug information --- .../klee/Internal/Module/InstructionInfoTable.h | 63 ++++++++++++---------- 1 file changed, 34 insertions(+), 29 deletions(-) (limited to 'include') 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 +#include #include -#include +#include +#include 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 infos; - std::set 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> + infos; + std::unordered_map> + functionInfos; + std::vector> 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; }; } -- cgit 1.4.1