summaryrefslogtreecommitdiff
path: root/include/lldb/Expression
diff options
context:
space:
mode:
Diffstat (limited to 'include/lldb/Expression')
-rw-r--r--include/lldb/Expression/ASTStructExtractor.h2
-rw-r--r--include/lldb/Expression/ClangExpressionDeclMap.h8
-rw-r--r--include/lldb/Expression/ClangExpressionParser.h15
-rw-r--r--include/lldb/Expression/ClangExpressionVariable.h10
-rw-r--r--include/lldb/Expression/ClangFunction.h14
-rw-r--r--include/lldb/Expression/ClangUserExpression.h23
-rw-r--r--include/lldb/Expression/ClangUtilityFunction.h8
-rw-r--r--include/lldb/Expression/DWARFExpression.h13
-rw-r--r--include/lldb/Expression/ExpressionSourceCode.h5
-rw-r--r--include/lldb/Expression/IRExecutionUnit.h87
-rw-r--r--include/lldb/Expression/IRForTarget.h12
-rw-r--r--include/lldb/Expression/IRMemoryMap.h12
12 files changed, 146 insertions, 63 deletions
diff --git a/include/lldb/Expression/ASTStructExtractor.h b/include/lldb/Expression/ASTStructExtractor.h
index a1518de83d6d1..9e467797a3982 100644
--- a/include/lldb/Expression/ASTStructExtractor.h
+++ b/include/lldb/Expression/ASTStructExtractor.h
@@ -30,7 +30,7 @@ namespace lldb_private {
///
/// The definition of this struct is itself in the body of the wrapper function,
/// so Clang does the structure layout itself. ASTStructExtractor reads through
-/// the AST for the wrapper funtion and finds the struct.
+/// the AST for the wrapper function and finds the struct.
//----------------------------------------------------------------------
class ASTStructExtractor : public clang::SemaConsumer
{
diff --git a/include/lldb/Expression/ClangExpressionDeclMap.h b/include/lldb/Expression/ClangExpressionDeclMap.h
index b04e1bd6f1163..8a4aa82b8727e 100644
--- a/include/lldb/Expression/ClangExpressionDeclMap.h
+++ b/include/lldb/Expression/ClangExpressionDeclMap.h
@@ -167,7 +167,7 @@ public:
const ConstString &name,
llvm::Value *value,
size_t size,
- off_t alignment);
+ lldb::offset_t alignment);
//------------------------------------------------------------------
/// [Used by IRForTarget] Finalize the struct, laying out the position
@@ -198,7 +198,7 @@ public:
bool
GetStructInfo (uint32_t &num_elements,
size_t &size,
- off_t &alignment);
+ lldb::offset_t &alignment);
//------------------------------------------------------------------
/// [Used by IRForTarget] Get specific information about one field
@@ -234,7 +234,7 @@ public:
bool
GetStructElement (const clang::NamedDecl *&decl,
llvm::Value *&value,
- off_t &offset,
+ lldb::offset_t &offset,
ConstString &name,
uint32_t index);
@@ -461,7 +461,7 @@ private:
{
}
- off_t m_struct_alignment; ///< The alignment of the struct in bytes.
+ lldb::offset_t m_struct_alignment; ///< The alignment of the struct in bytes.
size_t m_struct_size; ///< The size of the struct in bytes.
bool m_struct_laid_out; ///< True if the struct has been laid out and the layout is valid (that is, no new fields have been added since).
ConstString m_result_name; ///< The name of the result variable ($1, for example)
diff --git a/include/lldb/Expression/ClangExpressionParser.h b/include/lldb/Expression/ClangExpressionParser.h
index 3247f2094ba63..c79494d1a521a 100644
--- a/include/lldb/Expression/ClangExpressionParser.h
+++ b/include/lldb/Expression/ClangExpressionParser.h
@@ -40,7 +40,7 @@ public:
//------------------------------------------------------------------
/// Constructor
///
- /// Initializes class variabes.
+ /// Initializes class variables.
///
/// @param[in] exe_scope,
/// If non-NULL, an execution context scope that can help to
@@ -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/include/lldb/Expression/ClangExpressionVariable.h b/include/lldb/Expression/ClangExpressionVariable.h
index 620e604fb18cf..5ee7a3058946d 100644
--- a/include/lldb/Expression/ClangExpressionVariable.h
+++ b/include/lldb/Expression/ClangExpressionVariable.h
@@ -162,9 +162,9 @@ public:
{
}
- off_t m_alignment; ///< The required alignment of the variable, in bytes
- size_t m_size; ///< The space required for the variable, in bytes
- off_t m_offset; ///< The offset of the variable in the struct, in bytes
+ lldb::offset_t m_alignment; ///< The required alignment of the variable, in bytes
+ size_t m_size; ///< The space required for the variable, in bytes
+ lldb::offset_t m_offset; ///< The offset of the variable in the struct, in bytes
};
private:
@@ -237,8 +237,8 @@ public:
// this function is used to copy the address-of m_live_sp into m_frozen_sp
// this is necessary because the results of certain cast and pointer-arithmetic
// operations (such as those described in bugzilla issues 11588 and 11618) generate
- // frozen objcts that do not have a valid address-of, which can be troublesome when
- // using synthetic children providers. transferring the address-of the live object
+ // frozen objects that do not have a valid address-of, which can be troublesome when
+ // using synthetic children providers. Transferring the address-of the live object
// solves these issues and provides the expected user-level behavior
void
TransferAddress (bool force = false);
diff --git a/include/lldb/Expression/ClangFunction.h b/include/lldb/Expression/ClangFunction.h
index e150d389b416f..61d56729f93db 100644
--- a/include/lldb/Expression/ClangFunction.h
+++ b/include/lldb/Expression/ClangFunction.h
@@ -88,7 +88,8 @@ public:
ClangFunction (ExecutionContextScope &exe_scope,
Function &function_ptr,
ClangASTContext *ast_context,
- const ValueList &arg_value_list);
+ const ValueList &arg_value_list,
+ const char *name);
//------------------------------------------------------------------
/// Constructor
@@ -114,7 +115,8 @@ public:
ClangFunction (ExecutionContextScope &exe_scope,
const ClangASTType &return_type,
const Address& function_address,
- const ValueList &arg_value_list);
+ const ValueList &arg_value_list,
+ const char *name);
//------------------------------------------------------------------
/// Destructor
@@ -251,9 +253,9 @@ public:
/// The result value will be put here after running the function.
///
/// @return
- /// Returns one of the ExecutionResults enum indicating function call status.
+ /// Returns one of the ExpressionResults enum indicating function call status.
//------------------------------------------------------------------
- ExecutionResults
+ lldb::ExpressionResults
ExecuteFunction(ExecutionContext &exe_ctx,
lldb::addr_t *args_addr_ptr,
const EvaluateExpressionOptions &options,
@@ -410,7 +412,9 @@ 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;
+ std::string m_name; ///< The name of this clang function - for debugging purposes.
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/include/lldb/Expression/ClangUserExpression.h b/include/lldb/Expression/ClangUserExpression.h
index 83fdf1c21955a..9d2e9093c0bd9 100644
--- a/include/lldb/Expression/ClangUserExpression.h
+++ b/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 ()
@@ -143,7 +144,7 @@ public:
/// @return
/// A Process::Execution results value.
//------------------------------------------------------------------
- ExecutionResults
+ lldb::ExpressionResults
Execute (Stream &error_stream,
ExecutionContext &exe_ctx,
const EvaluateExpressionOptions& options,
@@ -166,7 +167,7 @@ public:
///
/// @param[in] function_stack_pointer
/// A pointer to the base of the function's stack frame. This
- /// is used to determine whether the expession result resides in
+ /// is used to determine whether the expression result resides in
/// memory that will still be valid, or whether it needs to be
/// treated as homeless for the purpose of future expressions.
///
@@ -295,9 +296,9 @@ public:
/// fails to parse, run, or evaluated.
///
/// @result
- /// A Process::ExecutionResults value. eExecutionCompleted for success.
+ /// A Process::ExpressionResults value. eExpressionCompleted for success.
//------------------------------------------------------------------
- static ExecutionResults
+ static lldb::ExpressionResults
Evaluate (ExecutionContext &exe_ctx,
const EvaluateExpressionOptions& options,
const char *expr_cstr,
@@ -308,7 +309,7 @@ public:
static const Error::ValueType kNoResult = 0x1001; ///< ValueObject::GetError() returns this if there is no result from the expression.
private:
//------------------------------------------------------------------
- /// Populate m_cplusplus and m_objetivec based on the environment.
+ /// Populate m_cplusplus and m_objectivec based on the environment.
//------------------------------------------------------------------
void
@@ -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/include/lldb/Expression/ClangUtilityFunction.h b/include/lldb/Expression/ClangUtilityFunction.h
index 6da8e5ec3a8be..bb5601fa2914c 100644
--- a/include/lldb/Expression/ClangUtilityFunction.h
+++ b/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/include/lldb/Expression/DWARFExpression.h b/include/lldb/Expression/DWARFExpression.h
index 5ecdf7fe9ee58..9ddecc053e007 100644
--- a/include/lldb/Expression/DWARFExpression.h
+++ b/include/lldb/Expression/DWARFExpression.h
@@ -222,6 +222,17 @@ public:
lldb::offset_t data_offset,
lldb::offset_t data_length);
+ void
+ CopyOpcodeData (const void *data,
+ lldb::offset_t data_length,
+ lldb::ByteOrder byte_order,
+ uint8_t addr_byte_size);
+
+ void
+ CopyOpcodeData (uint64_t const_value,
+ lldb::offset_t const_value_byte_size,
+ uint8_t addr_byte_size);
+
//------------------------------------------------------------------
/// Tells the expression that it refers to a location list.
@@ -347,7 +358,7 @@ public:
const DataExtractor& opcodes,
const lldb::offset_t offset,
const lldb::offset_t length,
- const uint32_t reg_set,
+ const lldb::RegisterKind reg_set,
const Value* initial_value_ptr,
Value& result,
Error *error_ptr);
diff --git a/include/lldb/Expression/ExpressionSourceCode.h b/include/lldb/Expression/ExpressionSourceCode.h
index be1014ae30479..2dd09378fcd2f 100644
--- a/include/lldb/Expression/ExpressionSourceCode.h
+++ b/include/lldb/Expression/ExpressionSourceCode.h
@@ -17,6 +17,8 @@
namespace lldb_private
{
+class ExecutionContext;
+
class ExpressionSourceCode
{
public:
@@ -53,7 +55,8 @@ public:
bool GetText (std::string &text,
lldb::LanguageType wrapping_language,
bool const_object,
- bool static_method) const;
+ bool static_method,
+ ExecutionContext &exe_ctx) const;
private:
ExpressionSourceCode (const char *name,
diff --git a/include/lldb/Expression/IRExecutionUnit.h b/include/lldb/Expression/IRExecutionUnit.h
index 2820317e108e2..3f28351a69283 100644
--- a/include/lldb/Expression/IRExecutionUnit.h
+++ b/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
//------------------------------------------------------------------
@@ -423,7 +456,7 @@ private:
//------------------------------------------------------------------
/// Constructor
///
- /// Initializes class variabes.
+ /// Initializes class variables.
///
/// @param[in] name
/// The name of the function.
@@ -450,31 +483,47 @@ private:
//----------------------------------------------------------------------
/// @class AllocationRecord IRExecutionUnit.h "lldb/Expression/IRExecutionUnit.h"
- /// @brief Enacpsulates a single allocation request made by the JIT.
+ /// @brief Encapsulates a single allocation request made by the JIT.
///
/// 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/include/lldb/Expression/IRForTarget.h b/include/lldb/Expression/IRForTarget.h
index 502f796d15a11..0ad34904f563c 100644
--- a/include/lldb/Expression/IRForTarget.h
+++ b/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
///
@@ -182,7 +188,7 @@ private:
//------------------------------------------------------------------
//------------------------------------------------------------------
- /// Get the address of a fuction, and a location to put the complete
+ /// Get the address of a function, and a location to put the complete
/// Value of the function if one is available.
///
/// @param[in] function
@@ -201,7 +207,7 @@ private:
/// @return
/// The pointer.
//------------------------------------------------------------------
- bool
+ LookupResult
GetFunctionAddress (llvm::Function *function,
uint64_t &ptr,
lldb_private::ConstString &name,
@@ -573,7 +579,7 @@ private:
ReplaceStrings ();
//------------------------------------------------------------------
- /// A basick block-level pass to find all literals that will be
+ /// A basic block-level pass to find all literals that will be
/// allocated as statics by the JIT (in contrast to the Strings,
/// which already are statics) and synthesize loads for them.
//------------------------------------------------------------------
diff --git a/include/lldb/Expression/IRMemoryMap.h b/include/lldb/Expression/IRMemoryMap.h
index affe19350e3f2..4faa5226d9b44 100644
--- a/include/lldb/Expression/IRMemoryMap.h
+++ b/include/lldb/Expression/IRMemoryMap.h
@@ -27,7 +27,8 @@ namespace lldb_private
/// This class encapsulates a group of memory objects that must be readable
/// or writable from the host process regardless of whether the process
/// exists. This allows the IR interpreter as well as JITted code to access
-/// the same memory.
+/// the same memory. All allocations made by this class are represented as
+/// disjoint intervals.
///
/// Point queries against this group of memory objects can be made by the
/// address in the tar at which they reside. If the inferior does not
@@ -66,7 +67,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.
@@ -118,7 +119,12 @@ private:
lldb::addr_t FindSpace (size_t size);
bool ContainsHostOnlyAllocations ();
AllocationMap::iterator FindAllocation (lldb::addr_t addr, size_t size);
- bool IntersectsAllocation (lldb::addr_t addr, size_t size);
+
+ // Returns true if the given allocation intersects any allocation in the memory map.
+ bool IntersectsAllocation (lldb::addr_t addr, size_t size) const;
+
+ // Returns true if the two given allocations intersect each other.
+ static bool AllocationsIntersect (lldb::addr_t addr1, size_t size1, lldb::addr_t addr2, size_t size2);
};
}