diff options
Diffstat (limited to 'include/lldb/Expression/IRExecutionUnit.h')
-rw-r--r-- | include/lldb/Expression/IRExecutionUnit.h | 170 |
1 files changed, 125 insertions, 45 deletions
diff --git a/include/lldb/Expression/IRExecutionUnit.h b/include/lldb/Expression/IRExecutionUnit.h index 86744b7b9726..d557a35d0b06 100644 --- a/include/lldb/Expression/IRExecutionUnit.h +++ b/include/lldb/Expression/IRExecutionUnit.h @@ -26,8 +26,8 @@ #include "lldb/lldb-private.h" #include "lldb/Core/DataBufferHeap.h" #include "lldb/Expression/IRMemoryMap.h" -#include "lldb/Host/Mutex.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Symbol/SymbolContext.h" namespace llvm { @@ -71,13 +71,19 @@ public: std::unique_ptr<llvm::Module> &module_ap, ConstString &name, const lldb::TargetSP &target_sp, + const SymbolContext &sym_ctx, std::vector<std::string> &cpu_features); //------------------------------------------------------------------ /// Destructor //------------------------------------------------------------------ ~IRExecutionUnit() override; - + + ConstString GetFunctionName() + { + return m_name; + } + llvm::Module * GetModule() { @@ -131,7 +137,83 @@ public: lldb::ModuleSP GetJITModule (); + + lldb::addr_t + FindSymbol(const ConstString &name); + void + GetStaticInitializers(std::vector <lldb::addr_t> &static_initializers); + + //---------------------------------------------------------------------- + /// @class JittedFunction IRExecutionUnit.h "lldb/Expression/IRExecutionUnit.h" + /// @brief Encapsulates a single function that has been generated by the JIT. + /// + /// Functions that have been generated by the JIT are first resident in the + /// local process, and then placed in the target process. JittedFunction + /// represents a function possibly resident in both. + //---------------------------------------------------------------------- + struct JittedEntity { + ConstString m_name; ///< The function's name + lldb::addr_t m_local_addr; ///< The address of the function in LLDB's memory + lldb::addr_t m_remote_addr; ///< The address of the function in the target's memory + + //------------------------------------------------------------------ + /// Constructor + /// + /// Initializes class variabes. + /// + /// @param[in] name + /// The name of the function. + /// + /// @param[in] local_addr + /// The address of the function in LLDB, or LLDB_INVALID_ADDRESS if + /// it is not present in LLDB's memory. + /// + /// @param[in] remote_addr + /// The address of the function in the target, or LLDB_INVALID_ADDRESS + /// if it is not present in the target's memory. + //------------------------------------------------------------------ + JittedEntity (const char *name, + lldb::addr_t local_addr = LLDB_INVALID_ADDRESS, + lldb::addr_t remote_addr = LLDB_INVALID_ADDRESS) : + m_name (name), + m_local_addr (local_addr), + m_remote_addr (remote_addr) + { + } + }; + + struct JittedFunction : JittedEntity + { + bool m_external; + JittedFunction (const char *name, + bool external, + lldb::addr_t local_addr = LLDB_INVALID_ADDRESS, + lldb::addr_t remote_addr = LLDB_INVALID_ADDRESS) : + JittedEntity (name, local_addr, remote_addr), + m_external(external) + {} + }; + + struct JittedGlobalVariable : JittedEntity + { + JittedGlobalVariable (const char *name, + lldb::addr_t local_addr = LLDB_INVALID_ADDRESS, + lldb::addr_t remote_addr = LLDB_INVALID_ADDRESS) : + JittedEntity (name, local_addr, remote_addr) + {} + }; + + const std::vector<JittedFunction> &GetJittedFunctions() + { + return m_jitted_functions; + } + + const std::vector<JittedGlobalVariable> &GetJittedGlobalVariables() + { + return m_jitted_global_variables; + } + private: //------------------------------------------------------------------ /// Look up the object in m_address_map that contains a given address, @@ -201,6 +283,33 @@ private: DisassembleFunction (Stream &stream, lldb::ProcessSP &process_sp); + struct SearchSpec; + + void + CollectCandidateCNames(std::vector<SearchSpec> &C_specs, + const ConstString &name); + + void + CollectCandidateCPlusPlusNames(std::vector<SearchSpec> &CPP_specs, + const std::vector<SearchSpec> &C_specs, + const SymbolContext &sc); + + void + CollectFallbackNames(std::vector<SearchSpec> &fallback_specs, + const std::vector<SearchSpec> &C_specs); + + lldb::addr_t + FindInSymbols(const std::vector<SearchSpec> &specs, + const lldb_private::SymbolContext &sc); + + lldb::addr_t + FindInRuntimes(const std::vector<SearchSpec> &specs, + const lldb_private::SymbolContext &sc); + + lldb::addr_t + FindInUserDefinedSymbols(const std::vector<SearchSpec> &specs, + const lldb_private::SymbolContext &sc); + void ReportSymbolLookupError(const ConstString &name); @@ -275,9 +384,6 @@ private: void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) override { } - //------------------------------------------------------------------ - /// Passthrough interface stub - //------------------------------------------------------------------ uint64_t getSymbolAddress(const std::string &Name) override; void *getPointerToNamedFunction(const std::string &Name, @@ -288,45 +394,6 @@ private: IRExecutionUnit &m_parent; ///< The execution unit this is a proxy for. }; - //---------------------------------------------------------------------- - /// @class JittedFunction IRExecutionUnit.h "lldb/Expression/IRExecutionUnit.h" - /// @brief Encapsulates a single function that has been generated by the JIT. - /// - /// Functions that have been generated by the JIT are first resident in the - /// local process, and then placed in the target process. JittedFunction - /// represents a function possibly resident in both. - //---------------------------------------------------------------------- - struct JittedFunction { - std::string m_name; ///< The function's name - lldb::addr_t m_local_addr; ///< The address of the function in LLDB's memory - lldb::addr_t m_remote_addr; ///< The address of the function in the target's memory - - //------------------------------------------------------------------ - /// Constructor - /// - /// Initializes class variables. - /// - /// @param[in] name - /// The name of the function. - /// - /// @param[in] local_addr - /// The address of the function in LLDB, or LLDB_INVALID_ADDRESS if - /// it is not present in LLDB's memory. - /// - /// @param[in] remote_addr - /// The address of the function in the target, or LLDB_INVALID_ADDRESS - /// if it is not present in the target's memory. - //------------------------------------------------------------------ - JittedFunction (const char *name, - lldb::addr_t local_addr = LLDB_INVALID_ADDRESS, - lldb::addr_t remote_addr = LLDB_INVALID_ADDRESS) : - m_name (name), - m_local_addr (local_addr), - m_remote_addr (remote_addr) - { - } - }; - static const unsigned eSectionIDInvalid = (unsigned)-1; //---------------------------------------------------------------------- @@ -377,6 +444,9 @@ private: void dump (Log *log); }; + bool + CommitOneAllocation (lldb::ProcessSP &process_sp, Error &error, AllocationRecord &record); + typedef std::vector<AllocationRecord> RecordVector; RecordVector m_records; @@ -385,14 +455,24 @@ private: std::unique_ptr<llvm::Module> m_module_ap; ///< Holder for the module until it's been handed off llvm::Module *m_module; ///< Owned by the execution engine std::vector<std::string> m_cpu_features; - llvm::SmallVector<JittedFunction, 1> m_jitted_functions; ///< A vector of all functions that have been JITted into machine code + std::vector<JittedFunction> m_jitted_functions; ///< A vector of all functions that have been JITted into machine code + std::vector<JittedGlobalVariable> m_jitted_global_variables; ///< A vector of all functions that have been JITted into machine code const ConstString m_name; + SymbolContext m_sym_ctx; ///< Used for symbol lookups std::vector<ConstString> m_failed_lookups; std::atomic<bool> m_did_jit; lldb::addr_t m_function_load_addr; lldb::addr_t m_function_end_load_addr; + + bool m_strip_underscore; ///< True for platforms where global symbols have a _ prefix + bool m_reported_allocations; ///< True after allocations have been reported. It is possible that + ///< sections will be allocated when this is true, in which case they weren't + ///< depended on by any function. (Top-level code defining a variable, but + ///< defining no functions using that variable, would do this.) If this + ///< is true, any allocations need to be committed immediately -- no + ///< opportunity for relocation. }; } // namespace lldb_private |