summaryrefslogtreecommitdiffstats
path: root/lldb/include
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/include')
-rw-r--r--lldb/include/lldb/Core/Module.h8
-rw-r--r--lldb/include/lldb/Expression/ClangExpressionParser.h13
-rw-r--r--lldb/include/lldb/Expression/ClangFunction.h3
-rw-r--r--lldb/include/lldb/Expression/ClangUserExpression.h13
-rw-r--r--lldb/include/lldb/Expression/ClangUtilityFunction.h8
-rw-r--r--lldb/include/lldb/Expression/IRExecutionUnit.h83
-rw-r--r--lldb/include/lldb/Expression/IRForTarget.h8
-rw-r--r--lldb/include/lldb/Expression/IRMemoryMap.h2
-rw-r--r--lldb/include/lldb/Host/Host.h3
-rw-r--r--lldb/include/lldb/Symbol/ObjectFile.h40
-rw-r--r--lldb/include/lldb/Target/Target.h16
-rw-r--r--lldb/include/lldb/lldb-forward.h3
-rw-r--r--lldb/include/lldb/lldb-private-enumerations.h2
13 files changed, 161 insertions, 41 deletions
diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 42904dd9eac..f6491db72bf 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -92,6 +92,10 @@ public:
const TimeValue *object_mod_time_ptr = NULL);
Module (const ModuleSpec &module_spec);
+
+ static lldb::ModuleSP
+ CreateJITModule (const lldb::ObjectFileJITDelegateSP &delegate_sp);
+
//------------------------------------------------------------------
/// Destructor.
//------------------------------------------------------------------
@@ -1170,7 +1174,9 @@ protected:
friend class SymbolFile;
private:
-
+
+ Module (); // Only used internally by CreateJITModule ()
+
size_t
FindTypes_Impl (const SymbolContext& sc,
const ConstString &name,
diff --git a/lldb/include/lldb/Expression/ClangExpressionParser.h b/lldb/include/lldb/Expression/ClangExpressionParser.h
index 3247f2094ba..cb7a2c06993 100644
--- a/lldb/include/lldb/Expression/ClangExpressionParser.h
+++ b/lldb/include/lldb/Expression/ClangExpressionParser.h
@@ -51,7 +51,8 @@ public:
/// The expression to be parsed.
//------------------------------------------------------------------
ClangExpressionParser (ExecutionContextScope *exe_scope,
- ClangExpression &expr);
+ ClangExpression &expr,
+ bool generate_debug_info);
//------------------------------------------------------------------
/// Destructor
@@ -84,9 +85,9 @@ public:
/// and func_end do not delimit an allocated region; the allocated
/// region may begin before func_addr.)
///
- /// @param[in] execution_unit_ap
+ /// @param[in] execution_unit_sp
/// After parsing, ownership of the execution unit for
- /// for the expression is handed to this unique pointer.
+ /// for the expression is handed to this shared pointer.
///
/// @param[in] exe_ctx
/// The execution context to write the function into.
@@ -112,7 +113,7 @@ public:
Error
PrepareForExecution (lldb::addr_t &func_addr,
lldb::addr_t &func_end,
- std::unique_ptr<IRExecutionUnit> &execution_unit_ap,
+ std::shared_ptr<IRExecutionUnit> &execution_unit_sp,
ExecutionContext &exe_ctx,
bool &can_interpret,
lldb_private::ExecutionPolicy execution_policy);
@@ -134,6 +135,9 @@ public:
DisassembleFunction (Stream &stream,
ExecutionContext &exe_ctx);
+ bool
+ GetGenerateDebugInfo () const;
+
private:
ClangExpression & m_expr; ///< The expression to be parsed
std::unique_ptr<llvm::LLVMContext> m_llvm_context; ///< The LLVM context to generate IR into
@@ -143,7 +147,6 @@ private:
std::unique_ptr<clang::SelectorTable> m_selector_table; ///< Selector table for Objective-C methods
std::unique_ptr<clang::ASTContext> m_ast_context; ///< The AST context used to hold types and names for the parser
std::unique_ptr<clang::CodeGenerator> m_code_generator; ///< The Clang object that generates IR
- std::unique_ptr<IRExecutionUnit> m_execution_unit; ///< The container for the finished Module
};
}
diff --git a/lldb/include/lldb/Expression/ClangFunction.h b/lldb/include/lldb/Expression/ClangFunction.h
index e150d389b41..23540dd901b 100644
--- a/lldb/include/lldb/Expression/ClangFunction.h
+++ b/lldb/include/lldb/Expression/ClangFunction.h
@@ -410,7 +410,8 @@ private:
//------------------------------------------------------------------
std::unique_ptr<ClangExpressionParser> m_parser; ///< The parser responsible for compiling the function.
- std::unique_ptr<IRExecutionUnit> m_execution_unit_ap;
+ std::shared_ptr<IRExecutionUnit> m_execution_unit_sp;
+ lldb::ModuleWP m_jit_module_wp;
Function *m_function_ptr; ///< The function we're going to call. May be NULL if we don't have debug info for the function.
Address m_function_addr; ///< If we don't have the FunctionSP, we at least need the address & return type.
diff --git a/lldb/include/lldb/Expression/ClangUserExpression.h b/lldb/include/lldb/Expression/ClangUserExpression.h
index 83fdf1c2195..9121d147de4 100644
--- a/lldb/include/lldb/Expression/ClangUserExpression.h
+++ b/lldb/include/lldb/Expression/ClangUserExpression.h
@@ -105,7 +105,8 @@ public:
Parse (Stream &error_stream,
ExecutionContext &exe_ctx,
lldb_private::ExecutionPolicy execution_policy,
- bool keep_result_in_memory);
+ bool keep_result_in_memory,
+ bool generate_debug_info);
bool
CanInterpret ()
@@ -344,11 +345,11 @@ private:
std::string m_transformed_text; ///< The text of the expression, as send to the parser
ResultType m_desired_type; ///< The type to coerce the expression's result to. If eResultTypeAny, inferred from the expression.
- std::unique_ptr<ClangExpressionDeclMap> m_expr_decl_map; ///< The map to use when parsing the expression.
- std::unique_ptr<IRExecutionUnit> m_execution_unit_ap; ///< The execution unit the expression is stored in.
- std::unique_ptr<Materializer> m_materializer_ap; ///< The materializer to use when running the expression.
- std::unique_ptr<ASTResultSynthesizer> m_result_synthesizer; ///< The result synthesizer, if one is needed.
-
+ std::unique_ptr<ClangExpressionDeclMap> m_expr_decl_map; ///< The map to use when parsing the expression.
+ std::shared_ptr<IRExecutionUnit> m_execution_unit_sp; ///< The execution unit the expression is stored in.
+ std::unique_ptr<Materializer> m_materializer_ap; ///< The materializer to use when running the expression.
+ std::unique_ptr<ASTResultSynthesizer> m_result_synthesizer; ///< The result synthesizer, if one is needed.
+ lldb::ModuleWP m_jit_module_wp;
bool m_enforce_valid_object; ///< True if the expression parser should enforce the presence of a valid class pointer in order to generate the expression as a method.
bool m_cplusplus; ///< True if the expression is compiled as a C++ member function (true if it was parsed when exe_ctx was in a C++ method).
bool m_objectivec; ///< True if the expression is compiled as an Objective-C method (true if it was parsed when exe_ctx was in an Objective-C method).
diff --git a/lldb/include/lldb/Expression/ClangUtilityFunction.h b/lldb/include/lldb/Expression/ClangUtilityFunction.h
index 6da8e5ec3a8..bb5601fa291 100644
--- a/lldb/include/lldb/Expression/ClangUtilityFunction.h
+++ b/lldb/include/lldb/Expression/ClangUtilityFunction.h
@@ -168,10 +168,10 @@ public:
private:
std::unique_ptr<ClangExpressionDeclMap> m_expr_decl_map; ///< The map to use when parsing and materializing the expression.
- std::unique_ptr<IRExecutionUnit> m_execution_unit_ap;
-
- std::string m_function_text; ///< The text of the function. Must be a well-formed translation unit.
- std::string m_function_name; ///< The name of the function.
+ std::shared_ptr<IRExecutionUnit> m_execution_unit_sp;
+ lldb::ModuleWP m_jit_module_wp;
+ std::string m_function_text; ///< The text of the function. Must be a well-formed translation unit.
+ std::string m_function_name; ///< The name of the function.
};
} // namespace lldb_private
diff --git a/lldb/include/lldb/Expression/IRExecutionUnit.h b/lldb/include/lldb/Expression/IRExecutionUnit.h
index 2820317e108..32ccfe7ca4a 100644
--- a/lldb/include/lldb/Expression/IRExecutionUnit.h
+++ b/lldb/include/lldb/Expression/IRExecutionUnit.h
@@ -30,6 +30,7 @@
#include "lldb/Expression/ClangExpressionParser.h"
#include "lldb/Expression/IRMemoryMap.h"
#include "lldb/Host/Mutex.h"
+#include "lldb/Symbol/ObjectFile.h"
namespace llvm {
@@ -60,7 +61,10 @@ class Error;
/// into the target process, the IRExecutionUnit knows how to copy the
/// emitted code into the target process.
//----------------------------------------------------------------------
-class IRExecutionUnit : public IRMemoryMap
+class IRExecutionUnit :
+ public std::enable_shared_from_this<IRExecutionUnit>,
+ public IRMemoryMap,
+ public ObjectFileJITDelegate
{
public:
//------------------------------------------------------------------
@@ -77,12 +81,14 @@ public:
//------------------------------------------------------------------
~IRExecutionUnit();
- llvm::Module *GetModule()
+ llvm::Module *
+ GetModule()
{
return m_module;
}
- llvm::Function *GetFunction()
+ llvm::Function *
+ GetFunction()
{
if (m_module)
return m_module->getFunction (m_name.AsCString());
@@ -90,9 +96,10 @@ public:
return NULL;
}
- void GetRunnableInfo(Error &error,
- lldb::addr_t &func_addr,
- lldb::addr_t &func_end);
+ void
+ GetRunnableInfo (Error &error,
+ lldb::addr_t &func_addr,
+ lldb::addr_t &func_end);
//------------------------------------------------------------------
/// Accessors for IRForTarget and other clients that may want binary
@@ -100,11 +107,36 @@ public:
/// IRExecutionUnit unless the client explicitly chooses to free it.
//------------------------------------------------------------------
- lldb::addr_t WriteNow(const uint8_t *bytes,
- size_t size,
- Error &error);
+ lldb::addr_t
+ WriteNow (const uint8_t *bytes,
+ size_t size,
+ Error &error);
+
+ void
+ FreeNow (lldb::addr_t allocation);
+
+ //------------------------------------------------------------------
+ /// ObjectFileJITDelegate overrides
+ //------------------------------------------------------------------
+ virtual lldb::ByteOrder
+ GetByteOrder () const;
- void FreeNow(lldb::addr_t allocation);
+ virtual uint32_t
+ GetAddressByteSize () const;
+
+ virtual void
+ PopulateSymtab (lldb_private::ObjectFile *obj_file,
+ lldb_private::Symtab &symtab);
+
+ virtual void
+ PopulateSectionList (lldb_private::ObjectFile *obj_file,
+ lldb_private::SectionList &section_list);
+
+ virtual bool
+ GetArchitecture (lldb_private::ArchSpec &arch);
+
+ lldb::ModuleSP
+ GetJITModule ();
private:
//------------------------------------------------------------------
@@ -180,6 +212,7 @@ private:
public:
MemoryManager (IRExecutionUnit &parent);
+ virtual ~MemoryManager();
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
@@ -455,26 +488,42 @@ private:
/// Allocations made by the JIT are first queued up and then applied in
/// bulk to the underlying process.
//----------------------------------------------------------------------
+ enum class AllocationKind {
+ Stub, Code, Data, Global, Bytes
+ };
+
+ static lldb::SectionType
+ GetSectionTypeFromSectionName (const llvm::StringRef &name,
+ AllocationKind alloc_kind);
+
struct AllocationRecord {
- lldb::addr_t m_process_address;
- uintptr_t m_host_address;
- uint32_t m_permissions;
- size_t m_size;
- unsigned m_alignment;
- unsigned m_section_id;
+ std::string m_name;
+ lldb::addr_t m_process_address;
+ uintptr_t m_host_address;
+ uint32_t m_permissions;
+ lldb::SectionType m_sect_type;
+ size_t m_size;
+ unsigned m_alignment;
+ unsigned m_section_id;
AllocationRecord (uintptr_t host_address,
uint32_t permissions,
+ lldb::SectionType sect_type,
size_t size,
unsigned alignment,
- unsigned section_id = eSectionIDInvalid) :
+ unsigned section_id,
+ const char *name) :
+ m_name (),
m_process_address(LLDB_INVALID_ADDRESS),
m_host_address(host_address),
m_permissions(permissions),
+ m_sect_type (sect_type),
m_size(size),
m_alignment(alignment),
m_section_id(section_id)
{
+ if (name && name[0])
+ m_name = name;
}
void dump (Log *log);
diff --git a/lldb/include/lldb/Expression/IRForTarget.h b/lldb/include/lldb/Expression/IRForTarget.h
index 502f796d15a..7eac13dda86 100644
--- a/lldb/include/lldb/Expression/IRForTarget.h
+++ b/lldb/include/lldb/Expression/IRForTarget.h
@@ -61,6 +61,12 @@ namespace lldb_private {
class IRForTarget : public llvm::ModulePass
{
public:
+ enum class LookupResult {
+ Success,
+ Fail,
+ Ignore
+ };
+
//------------------------------------------------------------------
/// Constructor
///
@@ -201,7 +207,7 @@ private:
/// @return
/// The pointer.
//------------------------------------------------------------------
- bool
+ LookupResult
GetFunctionAddress (llvm::Function *function,
uint64_t &ptr,
lldb_private::ConstString &name,
diff --git a/lldb/include/lldb/Expression/IRMemoryMap.h b/lldb/include/lldb/Expression/IRMemoryMap.h
index affe19350e3..750ff684d78 100644
--- a/lldb/include/lldb/Expression/IRMemoryMap.h
+++ b/lldb/include/lldb/Expression/IRMemoryMap.h
@@ -66,7 +66,7 @@ public:
uint32_t GetAddressByteSize();
// This function can return NULL.
- ExecutionContextScope *GetBestExecutionContextScope();
+ ExecutionContextScope *GetBestExecutionContextScope() const;
protected:
// This function should only be used if you know you are using the JIT.
diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h
index 862b1ed7943..61c391b0129 100644
--- a/lldb/include/lldb/Host/Host.h
+++ b/lldb/include/lldb/Host/Host.h
@@ -539,6 +539,9 @@ public:
MakeDirectory (const char* path, uint32_t mode);
static Error
+ RemoveDirectory (const char* path, bool recurse);
+
+ static Error
GetFilePermissions (const char* path, uint32_t &file_permissions);
static Error
diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h
index afa1f9b4090..cf17c3d5b15 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -21,6 +21,36 @@
#include "lldb/Symbol/UnwindTable.h"
namespace lldb_private {
+
+class ObjectFileJITDelegate
+{
+public:
+ ObjectFileJITDelegate ()
+ {
+ }
+
+ virtual
+ ~ObjectFileJITDelegate()
+ {
+ }
+
+ virtual lldb::ByteOrder
+ GetByteOrder () const = 0;
+
+ virtual uint32_t
+ GetAddressByteSize () const = 0;
+
+ virtual void
+ PopulateSymtab (lldb_private::ObjectFile *obj_file,
+ lldb_private::Symtab &symtab) = 0;
+
+ virtual void
+ PopulateSectionList (lldb_private::ObjectFile *obj_file,
+ lldb_private::SectionList &section_list) = 0;
+
+ virtual bool
+ GetArchitecture (lldb_private::ArchSpec &arch) = 0;
+};
//----------------------------------------------------------------------
/// @class ObjectFile ObjectFile.h "lldb/Symbol/ObjectFile.h"
@@ -68,6 +98,7 @@ public:
eTypeObjectFile, /// An intermediate object file
eTypeSharedLibrary, /// A shared library that can be used during execution
eTypeStubLibrary, /// A library that can be linked against but not used for execution
+ eTypeJIT, /// JIT code that has symbols, sections and possibly debug info
eTypeUnknown
} Type;
@@ -77,7 +108,8 @@ public:
eStrataUnknown,
eStrataUser,
eStrataKernel,
- eStrataRawImage
+ eStrataRawImage,
+ eStrataJIT
} Strata;
//------------------------------------------------------------------
@@ -91,7 +123,7 @@ public:
const FileSpec *file_spec_ptr,
lldb::offset_t file_offset,
lldb::offset_t length,
- lldb::DataBufferSP& data_sp,
+ const lldb::DataBufferSP& data_sp,
lldb::offset_t data_offset);
ObjectFile (const lldb::ModuleSP &module_sp,
@@ -756,12 +788,12 @@ public:
size_t
CopyData (off_t offset, size_t length, void *dst) const;
- size_t
+ virtual size_t
ReadSectionData (const Section *section,
off_t section_offset,
void *dst,
size_t dst_len) const;
- size_t
+ virtual size_t
ReadSectionData (const Section *section,
DataExtractor& section_data) const;
diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h
index e65a511ab77..85d283df391 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -201,6 +201,7 @@ public:
m_stop_others(true),
m_debug(false),
m_trap_exceptions(true),
+ m_generate_debug_info(false),
m_use_dynamic(lldb::eNoDynamicValues),
m_timeout_usec(default_timeout)
{}
@@ -335,6 +336,20 @@ public:
SetDebug(bool b)
{
m_debug = b;
+ if (m_debug)
+ m_generate_debug_info = true;
+ }
+
+ bool
+ GetGenerateDebugInfo() const
+ {
+ return m_generate_debug_info;
+ }
+
+ void
+ SetGenerateDebugInfo(bool b)
+ {
+ m_generate_debug_info = b;
}
bool
@@ -360,6 +375,7 @@ private:
bool m_stop_others;
bool m_debug;
bool m_trap_exceptions;
+ bool m_generate_debug_info;
lldb::DynamicValueType m_use_dynamic;
uint32_t m_timeout_usec;
};
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index 6c522c1d9a9..f5539bc3062 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -128,6 +128,7 @@ class OptionGroup;
class OptionGroupOptions;
class OptionGroupPlatform;
class ObjectFile;
+class ObjectFileJITDelegate;
class OperatingSystem;
class Options;
class OptionValue;
@@ -316,6 +317,8 @@ namespace lldb {
typedef std::weak_ptr<lldb_private::Module> ModuleWP;
typedef std::shared_ptr<lldb_private::ObjectFile> ObjectFileSP;
typedef std::weak_ptr<lldb_private::ObjectFile> ObjectFileWP;
+ typedef std::shared_ptr<lldb_private::ObjectFileJITDelegate> ObjectFileJITDelegateSP;
+ typedef std::weak_ptr<lldb_private::ObjectFileJITDelegate> ObjectFileJITDelegateWP;
typedef std::shared_ptr<lldb_private::OptionValue> OptionValueSP;
typedef std::weak_ptr<lldb_private::OptionValue> OptionValueWP;
typedef std::shared_ptr<lldb_private::OptionValueArch> OptionValueArchSP;
diff --git a/lldb/include/lldb/lldb-private-enumerations.h b/lldb/include/lldb/lldb-private-enumerations.h
index c2273f5dfe2..d9b06820048 100644
--- a/lldb/include/lldb/lldb-private-enumerations.h
+++ b/lldb/include/lldb/lldb-private-enumerations.h
@@ -118,7 +118,7 @@ typedef enum PathType
ePathTypePythonDir, // Find Python modules (PYTHONPATH) directory
ePathTypeLLDBSystemPlugins, // System plug-ins directory
ePathTypeLLDBUserPlugins, // User plug-ins directory
- ePathTypeLLDBTempSystemDir // The LLDB temp directory for this system
+ ePathTypeLLDBTempSystemDir // The LLDB temp directory for this system that will be cleaned up on exit
} PathType;
OpenPOWER on IntegriCloud