[Lldb-commits] [lldb] r123855 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Expression/ include/lldb/Target/ source/Expression/

Greg Clayton gclayton at apple.com
Wed Jan 19 15:00:49 PST 2011


Author: gclayton
Date: Wed Jan 19 17:00:49 2011
New Revision: 123855

URL: http://llvm.org/viewvc/llvm-project?rev=123855&view=rev
Log:
Make expressions clean up their JIT'ed code allocation.


Modified:
    lldb/trunk/include/lldb/Core/ClangForward.h
    lldb/trunk/include/lldb/Expression/ClangExpression.h
    lldb/trunk/include/lldb/Expression/ClangExpressionParser.h
    lldb/trunk/include/lldb/Expression/ClangFunction.h
    lldb/trunk/include/lldb/Expression/ClangUserExpression.h
    lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h
    lldb/trunk/include/lldb/Expression/RecordingMemoryManager.h
    lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h
    lldb/trunk/include/lldb/lldb-forward.h
    lldb/trunk/source/Expression/ClangExpressionParser.cpp
    lldb/trunk/source/Expression/ClangFunction.cpp
    lldb/trunk/source/Expression/ClangUserExpression.cpp
    lldb/trunk/source/Expression/ClangUtilityFunction.cpp

Modified: lldb/trunk/include/lldb/Core/ClangForward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ClangForward.h?rev=123855&r1=123854&r2=123855&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ClangForward.h (original)
+++ lldb/trunk/include/lldb/Core/ClangForward.h Wed Jan 19 17:00:49 2011
@@ -118,5 +118,10 @@
     struct PrintingPolicy;
 }
 
+namespace llvm
+{
+    class ExecutionEngine;
+}
+
 #endif  // #if defined(__cplusplus)
 #endif  // liblldb_ClangForward_h_

Modified: lldb/trunk/include/lldb/Expression/ClangExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpression.h?rev=123855&r1=123854&r2=123855&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangExpression.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangExpression.h Wed Jan 19 17:00:49 2011
@@ -23,7 +23,7 @@
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-private.h"
 #include "lldb/Core/ClangForward.h"
-#include "llvm/ExecutionEngine/JITMemoryManager.h"
+#include "lldb/Target/Process.h"
 
 namespace lldb_private {
 
@@ -41,11 +41,20 @@
 class ClangExpression
 {
 public:
+    ClangExpression () :
+        m_jit_process_sp(),
+        m_jit_alloc (LLDB_INVALID_ADDRESS),
+        m_jit_start_addr (LLDB_INVALID_ADDRESS),
+        m_jit_end_addr (LLDB_INVALID_ADDRESS)
+    {
+    }
+
     //------------------------------------------------------------------
     /// Destructor
     //------------------------------------------------------------------
     virtual ~ClangExpression ()
     {
+        DeallocateJITFunction ();
     }
     
     //------------------------------------------------------------------
@@ -112,6 +121,38 @@
     //------------------------------------------------------------------
     virtual bool
     NeedsVariableResolution () = 0;
+
+    void
+    DeallocateJITFunction ()
+    {
+        if (m_jit_process_sp && m_jit_alloc != LLDB_INVALID_ADDRESS)
+        {
+            m_jit_process_sp->DeallocateMemory (m_jit_alloc);
+            // If this process is ever used for anything else, we can not clear it 
+            // here. For now it is only used in order to deallocate any code if
+            // m_jit_alloc is a valid address.
+            m_jit_process_sp.reset(); 
+            m_jit_alloc = LLDB_INVALID_ADDRESS;
+        }
+    }
+
+    //------------------------------------------------------------------
+    /// Return the address of the function's JIT-compiled code, or
+    /// LLDB_INVALID_ADDRESS if the function is not JIT compiled
+    //------------------------------------------------------------------
+    lldb::addr_t
+    StartAddress ()
+    {
+        return m_jit_start_addr;
+    }
+
+protected:
+
+    lldb::ProcessSP m_jit_process_sp;
+    lldb::addr_t    m_jit_alloc;            ///< The address of the block containing JITted code.  LLDB_INVALID_ADDRESS if invalid.
+    lldb::addr_t    m_jit_start_addr;       ///< The address of the JITted function within the JIT allocation.  LLDB_INVALID_ADDRESS if invalid.
+    lldb::addr_t    m_jit_end_addr;         ///< The address of the JITted function within the JIT allocation.  LLDB_INVALID_ADDRESS if invalid.
+
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/include/lldb/Expression/ClangExpressionParser.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionParser.h?rev=123855&r1=123854&r2=123855&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangExpressionParser.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangExpressionParser.h Wed Jan 19 17:00:49 2011
@@ -17,15 +17,9 @@
 #include <string>
 #include <vector>
 
-namespace llvm
-{
-    class ExecutionEngine;
-}
-
 namespace lldb_private
 {
 
-class Process;
 class RecordingMemoryManager;
     
 //----------------------------------------------------------------------
@@ -96,6 +90,10 @@
     //------------------------------------------------------------------
     /// JIT-compile the IR for an already-parsed expression.
     ///
+    /// @param[out] func_allocation_addr
+    ///     The address which can be used to deallocate the code for this
+    ///     JIT'ed function
+    ///
     /// @param[out] func_addr
     ///     The address to which the function has been written.
     ///
@@ -117,7 +115,8 @@
     ///     Test with Success().
     //------------------------------------------------------------------
     Error
-    MakeJIT (lldb::addr_t &func_addr,
+    MakeJIT (lldb::addr_t &func_allocation_addr, 
+             lldb::addr_t &func_addr,
              lldb::addr_t &func_end,
              ExecutionContext &exe_ctx,
              lldb::ClangExpressionVariableSP *const_result = NULL);
@@ -136,7 +135,9 @@
     ///     The error generated.  If .Success() is true, disassembly succeeded.
     //------------------------------------------------------------------
     Error
-    DisassembleFunction (Stream &stream, ExecutionContext &exc_context);
+    DisassembleFunction (Stream &stream, 
+                         ExecutionContext &exe_ctx,
+                         RecordingMemoryManager *jit_memory_manager);
     
 private:
     //----------------------------------------------------------------------
@@ -187,7 +188,6 @@
     std::auto_ptr<clang::SelectorTable>         m_selector_table;       ///< Selector table for Objective-C methods
     std::auto_ptr<clang::ASTContext>            m_ast_context;          ///< The AST context used to hold types and names for the parser
     std::auto_ptr<clang::CodeGenerator>         m_code_generator;       ///< [owned by the Execution Engine] The Clang object that generates IR
-    RecordingMemoryManager                     *m_jit_mm;               ///< The memory manager for the LLVM JIT
     std::auto_ptr<llvm::ExecutionEngine>        m_execution_engine;     ///< The LLVM JIT
     std::vector<JittedFunction>                 m_jitted_functions;     ///< A vector of all functions that have been JITted into machine code (just one, if ParseExpression() was called)
 };

Modified: lldb/trunk/include/lldb/Expression/ClangFunction.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangFunction.h?rev=123855&r1=123854&r2=123855&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangFunction.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangFunction.h Wed Jan 19 17:00:49 2011
@@ -477,7 +477,7 @@
                                  bool discard_on_error = true)
     {
         return ClangFunction::GetThreadPlanToCallFunction (exe_ctx, 
-                                                           m_wrapper_function_addr, 
+                                                           m_jit_start_addr, 
                                                            args_addr_ref, 
                                                            errors, 
                                                            stop_others, 
@@ -618,7 +618,6 @@
     std::string                     m_wrapper_function_name;        ///< The name of the wrapper function.
     std::string                     m_wrapper_function_text;        ///< The contents of the wrapper function.
     std::string                     m_wrapper_struct_name;          ///< The name of the struct that contains the target function address, arguments, and result.
-    lldb::addr_t                    m_wrapper_function_addr;        ///< The address of the wrapper function.
     std::list<lldb::addr_t>         m_wrapper_args_addrs;           ///< The addresses of the arguments to the wrapper function.
     
     bool                            m_struct_valid;                 ///< True if the ASTStructExtractor has populated the variables below.

Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=123855&r1=123854&r2=123855&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Wed Jan 19 17:00:49 2011
@@ -291,7 +291,6 @@
     std::auto_ptr<ClangExpressionDeclMap>       m_expr_decl_map;        ///< The map to use when parsing and materializing the expression.
     std::auto_ptr<ClangExpressionVariableList> m_local_variables;      ///< The local expression variables, if the expression is DWARF.
     std::auto_ptr<StreamString>                 m_dwarf_opcodes;        ///< The DWARF opcodes for the expression.  May be NULL.
-    lldb::addr_t                                m_jit_addr;             ///< The address of the JITted code.  LLDB_INVALID_ADDRESS if invalid.
     
     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).

Modified: lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h?rev=123855&r1=123854&r2=123855&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h Wed Jan 19 17:00:49 2011
@@ -88,18 +88,9 @@
     {
         // nothing is both >= LLDB_INVALID_ADDRESS and < LLDB_INVALID_ADDRESS,
         // so this always returns false if the function is not JIT compiled yet
-        return (address >= m_jit_begin && address < m_jit_end);
+        return (address >= m_jit_start_addr && address < m_jit_end_addr);
     }
     
-    //------------------------------------------------------------------
-    /// Return the address of the function's JIT-compiled code, or
-    /// LLDB_INVALID_ADDRESS if the function is not JIT compiled
-    //------------------------------------------------------------------
-    lldb::addr_t
-    StartAddress ()
-    {
-        return m_jit_begin;
-    }
     
     //------------------------------------------------------------------
     /// Return the string that the parser should parse.  Must be a full
@@ -191,9 +182,6 @@
     
     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.
-    
-    lldb::addr_t                            m_jit_begin;        ///< The address of the JITted code.  LLDB_INVALID_ADDRESS if invalid.
-    lldb::addr_t                            m_jit_end;          ///< The end of the JITted code.  LLDB_INVALID_ADDRESS if invalid.
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/include/lldb/Expression/RecordingMemoryManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/RecordingMemoryManager.h?rev=123855&r1=123854&r2=123855&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/RecordingMemoryManager.h (original)
+++ lldb/trunk/include/lldb/Expression/RecordingMemoryManager.h Wed Jan 19 17:00:49 2011
@@ -52,11 +52,6 @@
 //----------------------------------------------------------------------
 class RecordingMemoryManager : public llvm::JITMemoryManager
 {
-friend Error ClangExpressionParser::MakeJIT (uint64_t &, 
-                                             uint64_t&, 
-                                             ExecutionContext &,
-                                             lldb::ClangExpressionVariableSP *);
-
 public:
     //------------------------------------------------------------------
     /// Constructor
@@ -329,6 +324,8 @@
     AddToLocalToRemoteMap (lldb::addr_t lstart, size_t size, lldb::addr_t rstart);
 
     std::vector<LocalToRemoteAddressRange> m_address_map;   ///< The base address of the remote allocation
+    
+    friend class ClangExpressionParser;
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h?rev=123855&r1=123854&r2=123855&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h Wed Jan 19 17:00:49 2011
@@ -26,13 +26,13 @@
 {
 public:
     ThreadPlanCallUserExpression (Thread &thread,
-                            Address &function,
-                            lldb::addr_t arg,
-                            bool stop_other_threads,
-                            bool discard_on_error,
-                            lldb::addr_t *this_arg,
-                            lldb::addr_t *cmd_arg,
-                            ClangUserExpression::ClangUserExpressionSP &user_expression_sp);
+                                  Address &function,
+                                  lldb::addr_t arg,
+                                  bool stop_other_threads,
+                                  bool discard_on_error,
+                                  lldb::addr_t *this_arg,
+                                  lldb::addr_t *cmd_arg,
+                                  ClangUserExpression::ClangUserExpressionSP &user_expression_sp);
     
     virtual
     ~ThreadPlanCallUserExpression ();
@@ -50,9 +50,9 @@
 
 protected:
 private:
-    ClangUserExpression::ClangUserExpressionSP m_user_expression_sp;  // This is currently just used to ensure the
-                                                          // User expression the initiated this ThreadPlan
-                                                          // lives as long as the thread plan does.
+    ClangUserExpression::ClangUserExpressionSP m_user_expression_sp;    // This is currently just used to ensure the
+                                                                        // User expression the initiated this ThreadPlan
+                                                                        // lives as long as the thread plan does.
     DISALLOW_COPY_AND_ASSIGN (ThreadPlanCallUserExpression);
 };
 

Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=123855&r1=123854&r2=123855&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Wed Jan 19 17:00:49 2011
@@ -45,6 +45,7 @@
 class   ClangNamespaceDecl;
 class   ClangExpression;
 class   ClangExpressionDeclMap;
+class   ClangExpressionParser;
 class   ClangExpressionVariable;
 class   ClangExpressionVariableList;
 class   ClangExpressionVariableList;

Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=123855&r1=123854&r2=123855&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Wed Jan 19 17:00:49 2011
@@ -425,11 +425,15 @@
 }
 
 Error
-ClangExpressionParser::MakeJIT (lldb::addr_t &func_addr, 
+ClangExpressionParser::MakeJIT (lldb::addr_t &func_allocation_addr, 
+                                lldb::addr_t &func_addr, 
                                 lldb::addr_t &func_end, 
                                 ExecutionContext &exe_ctx,
                                 lldb::ClangExpressionVariableSP *const_result)
 {
+    func_allocation_addr = LLDB_INVALID_ADDRESS;
+	func_addr = LLDB_INVALID_ADDRESS;
+	func_end = LLDB_INVALID_ADDRESS;
     lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     Error err;
@@ -488,7 +492,9 @@
         }
     }
     
-    m_jit_mm = new RecordingMemoryManager();
+    // llvm will own this pointer when llvm::ExecutionEngine::createJIT is called 
+    // below so we don't need to free it.
+    RecordingMemoryManager *jit_memory_manager = new RecordingMemoryManager();
     
     std::string error_string;
         
@@ -496,7 +502,7 @@
     
     m_execution_engine.reset(llvm::ExecutionEngine::createJIT (module, 
                                                                &error_string, 
-                                                               m_jit_mm,
+                                                               jit_memory_manager,
                                                                CodeGenOpt::Less,
                                                                true,
                                                                CodeModel::Small));
@@ -544,25 +550,27 @@
     
     size_t alloc_size = 0;
     
-    std::map<uint8_t *, uint8_t *>::iterator fun_pos = m_jit_mm->m_functions.begin();
-    std::map<uint8_t *, uint8_t *>::iterator fun_end = m_jit_mm->m_functions.end();
+    std::map<uint8_t *, uint8_t *>::iterator fun_pos = jit_memory_manager->m_functions.begin();
+    std::map<uint8_t *, uint8_t *>::iterator fun_end = jit_memory_manager->m_functions.end();
     
     for (; fun_pos != fun_end; ++fun_pos)
         alloc_size += (*fun_pos).second - (*fun_pos).first;
     
     Error alloc_error;
-    lldb::addr_t target_addr = exc_context.process->AllocateMemory (alloc_size, lldb::ePermissionsReadable|lldb::ePermissionsExecutable, alloc_error);
+    func_allocation_addr = exc_context.process->AllocateMemory (alloc_size, 
+                                                                lldb::ePermissionsReadable|lldb::ePermissionsExecutable, 
+                                                                alloc_error);
     
-    if (target_addr == LLDB_INVALID_ADDRESS)
+    if (func_allocation_addr == LLDB_INVALID_ADDRESS)
     {
         err.SetErrorToGenericError();
         err.SetErrorStringWithFormat("Couldn't allocate memory for the JITted function: %s", alloc_error.AsCString("unknown error"));
         return err;
     }
     
-    lldb::addr_t cursor = target_addr;
+    lldb::addr_t cursor = func_allocation_addr;
         
-    for (fun_pos = m_jit_mm->m_functions.begin(); fun_pos != fun_end; fun_pos++)
+    for (fun_pos = jit_memory_manager->m_functions.begin(); fun_pos != fun_end; fun_pos++)
     {
         lldb::addr_t lstart = (lldb::addr_t) (*fun_pos).first;
         lldb::addr_t lend = (lldb::addr_t) (*fun_pos).second;
@@ -577,7 +585,7 @@
             return err;
         }
             
-        m_jit_mm->AddToLocalToRemoteMap (lstart, size, cursor);
+        jit_memory_manager->AddToLocalToRemoteMap (lstart, size, cursor);
         cursor += size;
     }
     
@@ -585,11 +593,11 @@
     
     for (pos = m_jitted_functions.begin(); pos != end; pos++)
     {
-        (*pos).m_remote_addr = m_jit_mm->GetRemoteAddressForLocal ((*pos).m_local_addr);
+        (*pos).m_remote_addr = jit_memory_manager->GetRemoteAddressForLocal ((*pos).m_local_addr);
     
         if (!(*pos).m_name.compare(function_name.c_str()))
         {
-            func_end = m_jit_mm->GetRemoteRangeForLocal ((*pos).m_local_addr).second;
+            func_end = jit_memory_manager->GetRemoteRangeForLocal ((*pos).m_local_addr).second;
             func_addr = (*pos).m_remote_addr;
         }
     }
@@ -600,7 +608,7 @@
         
         StreamString disassembly_stream;
         
-        Error err = DisassembleFunction(disassembly_stream, exe_ctx);
+        Error err = DisassembleFunction(disassembly_stream, exe_ctx, jit_memory_manager);
         
         if (!err.Success())
         {
@@ -617,7 +625,7 @@
 }
 
 Error
-ClangExpressionParser::DisassembleFunction (Stream &stream, ExecutionContext &exe_ctx)
+ClangExpressionParser::DisassembleFunction (Stream &stream, ExecutionContext &exe_ctx, RecordingMemoryManager *jit_memory_manager)
 {
     lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
@@ -653,7 +661,7 @@
     
     std::pair <lldb::addr_t, lldb::addr_t> func_range;
     
-    func_range = m_jit_mm->GetRemoteRangeForLocal(func_local_addr);
+    func_range = jit_memory_manager->GetRemoteRangeForLocal(func_local_addr);
     
     if (func_range.first == 0 && func_range.second == 0)
     {

Modified: lldb/trunk/source/Expression/ClangFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=123855&r1=123854&r2=123855&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangFunction.cpp (original)
+++ lldb/trunk/source/Expression/ClangFunction.cpp Wed Jan 19 17:00:49 2011
@@ -61,7 +61,6 @@
     m_clang_ast_context (ast_context),
     m_wrapper_function_name ("__lldb_caller_function"),
     m_wrapper_struct_name ("__lldb_caller_struct"),
-    m_wrapper_function_addr (),
     m_wrapper_args_addrs (),
     m_arg_values (arg_value_list),
     m_compiled (false),
@@ -83,7 +82,6 @@
     m_clang_ast_context (ast_context),
     m_wrapper_function_name ("__lldb_function_caller"),
     m_wrapper_struct_name ("__lldb_caller_struct"),
-    m_wrapper_function_addr (),
     m_wrapper_args_addrs (),
     m_arg_values (arg_value_list),
     m_compiled (false),
@@ -240,12 +238,12 @@
     if (m_JITted)
         return true;
     
-    lldb::addr_t wrapper_function_end;
-    
-    Error jit_error = m_parser->MakeJIT(m_wrapper_function_addr, wrapper_function_end, exe_ctx);
+    Error jit_error (m_parser->MakeJIT (m_jit_alloc, m_jit_start_addr, m_jit_end_addr, exe_ctx));
     
     if (!jit_error.Success())
         return false;
+    if (exe_ctx.process && m_jit_alloc != LLDB_INVALID_ADDRESS)
+        m_jit_process_sp = exe_ctx.process->GetSP();
 
     return true;
 }
@@ -360,7 +358,7 @@
 
     lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
     if (log)
-        log->Printf ("Call Address: 0x%llx Struct Address: 0x%llx.\n", m_wrapper_function_addr, args_addr_ref);
+        log->Printf ("Call Address: 0x%llx Struct Address: 0x%llx.\n", m_jit_start_addr, args_addr_ref);
         
     return true;
 }
@@ -524,8 +522,14 @@
             return lldb::eExecutionSetupError;
     }
     
-    return_value = ClangFunction::ExecuteFunction(exe_ctx, m_wrapper_function_addr, args_addr, stop_others, 
-                                                  try_all_threads, discard_on_error, single_thread_timeout_usec, errors);
+    return_value = ClangFunction::ExecuteFunction (exe_ctx, 
+                                                   m_jit_start_addr, 
+                                                   args_addr, 
+                                                   stop_others, 
+                                                   try_all_threads, 
+                                                   discard_on_error, 
+                                                   single_thread_timeout_usec, 
+                                                   errors);
 
     if (args_addr_ptr != NULL)
         *args_addr_ptr = args_addr;

Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=123855&r1=123854&r2=123855&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangUserExpression.cpp Wed Jan 19 17:00:49 2011
@@ -41,15 +41,15 @@
 
 ClangUserExpression::ClangUserExpression (const char *expr,
                                           const char *expr_prefix) :
-    m_expr_text(expr),
-    m_expr_prefix(expr_prefix ? expr_prefix : ""),
-    m_transformed_text(),
-    m_jit_addr(LLDB_INVALID_ADDRESS),
-    m_cplusplus(false),
-    m_objectivec(false),
-    m_needs_object_ptr(false),
-    m_const_object(false),
-    m_desired_type(NULL, NULL)
+    ClangExpression (),
+    m_expr_text (expr),
+    m_expr_prefix (expr_prefix ? expr_prefix : ""),
+    m_transformed_text (),
+    m_cplusplus (false),
+    m_objectivec (false),
+    m_needs_object_ptr (false),
+    m_const_object (false),
+    m_desired_type (NULL, NULL)
 {
 }
 
@@ -295,14 +295,14 @@
     
     m_dwarf_opcodes.reset();
     
-    lldb::addr_t jit_end;
-        
-    Error jit_error = parser.MakeJIT (m_jit_addr, jit_end, exe_ctx, const_result);
+    Error jit_error = parser.MakeJIT (m_jit_alloc, m_jit_start_addr, m_jit_end_addr, exe_ctx, const_result);
     
     m_expr_decl_map->DidParse();
     
     if (jit_error.Success())
     {
+        if (exe_ctx.process && m_jit_alloc != LLDB_INVALID_ADDRESS)
+            m_jit_process_sp = exe_ctx.process->GetSP();        
         return true;
     }
     else
@@ -321,7 +321,7 @@
 {
     lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
-    if (m_jit_addr != LLDB_INVALID_ADDRESS)
+    if (m_jit_start_addr != LLDB_INVALID_ADDRESS)
     {
         Error materialize_error;
         
@@ -370,14 +370,14 @@
 #if 0
 		// jingham: look here
         StreamFile logfile ("/tmp/exprs.txt", "a");
-        logfile.Printf("0x%16.16llx: thread = 0x%4.4x, expr = '%s'\n", m_jit_addr, exe_ctx.thread ? exe_ctx.thread->GetID() : -1, m_expr_text.c_str());
+        logfile.Printf("0x%16.16llx: thread = 0x%4.4x, expr = '%s'\n", m_jit_start_addr, exe_ctx.thread ? exe_ctx.thread->GetID() : -1, m_expr_text.c_str());
 #endif
         
         if (log)
         {
             log->Printf("-- [ClangUserExpression::PrepareToExecuteJITExpression] Materializing for execution --");
             
-            log->Printf("  Function address  : 0x%llx", (uint64_t)m_jit_addr);
+            log->Printf("  Function address  : 0x%llx", (uint64_t)m_jit_start_addr);
             
             if (m_needs_object_ptr)
                 log->Printf("  Object pointer    : 0x%llx", (uint64_t)object_ptr);
@@ -420,7 +420,7 @@
     // forcing unwind_on_error to be true here, in practical terms that can't happen.
     
     return ClangFunction::GetThreadPlanToCallFunction (exe_ctx, 
-                                                       m_jit_addr, 
+                                                       m_jit_start_addr, 
                                                        struct_address, 
                                                        error_stream,
                                                        true,
@@ -484,7 +484,7 @@
         
         return lldb::eExecutionSetupError;
     }
-    else if (m_jit_addr != LLDB_INVALID_ADDRESS)
+    else if (m_jit_start_addr != LLDB_INVALID_ADDRESS)
     {
         lldb::addr_t struct_address;
                 
@@ -497,7 +497,7 @@
         const bool stop_others = true;
         const bool try_all_threads = true;
         
-        Address wrapper_address (NULL, m_jit_addr);
+        Address wrapper_address (NULL, m_jit_start_addr);
         lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (*(exe_ctx.thread), 
                                                                           wrapper_address, 
                                                                           struct_address, 

Modified: lldb/trunk/source/Expression/ClangUtilityFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUtilityFunction.cpp?rev=123855&r1=123854&r2=123855&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUtilityFunction.cpp (original)
+++ lldb/trunk/source/Expression/ClangUtilityFunction.cpp Wed Jan 19 17:00:49 2011
@@ -38,10 +38,9 @@
 //------------------------------------------------------------------
 ClangUtilityFunction::ClangUtilityFunction (const char *text, 
                                             const char *name) :
-    m_function_text(text),
-    m_function_name(name),
-    m_jit_begin(LLDB_INVALID_ADDRESS),
-    m_jit_end(LLDB_INVALID_ADDRESS)
+    ClangExpression (),
+    m_function_text (text),
+    m_function_name (name)
 {
 }
 
@@ -65,7 +64,7 @@
 ClangUtilityFunction::Install (Stream &error_stream,
                                ExecutionContext &exe_ctx)
 {
-    if (m_jit_begin != LLDB_INVALID_ADDRESS)
+    if (m_jit_start_addr != LLDB_INVALID_ADDRESS)
     {
         error_stream.PutCString("error: already installed\n");
         return false;
@@ -123,13 +122,16 @@
     // JIT the output of the parser
     //
         
-    Error jit_error = parser.MakeJIT (m_jit_begin, m_jit_end, exe_ctx);
+    Error jit_error = parser.MakeJIT (m_jit_alloc, m_jit_start_addr, m_jit_end_addr, exe_ctx);
+    
+    if (exe_ctx.process && m_jit_start_addr != LLDB_INVALID_ADDRESS)
+        m_jit_process_sp = exe_ctx.process->GetSP();
     
 #if 0
 	// jingham: look here
     StreamFile logfile ("/tmp/exprs.txt", "a");
     logfile.Printf ("0x%16.16llx: func = %s, source =\n%s\n", 
-                    m_jit_begin, 
+                    m_jit_start_addr, 
                     m_function_name.c_str(), 
                     m_function_text.c_str());
 #endif





More information about the lldb-commits mailing list