[Lldb-commits] [lldb] r251887 - Add the ability to pass an EvaluateExpressionOptions when you make a UserExpression. This

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Mon Nov 2 18:11:24 PST 2015


Author: jingham
Date: Mon Nov  2 20:11:24 2015
New Revision: 251887

URL: http://llvm.org/viewvc/llvm-project?rev=251887&view=rev
Log:
Add the ability to pass an EvaluateExpressionOptions when you make a UserExpression.  This
isn't used in this commit but will be in a future commit.

Modified:
    lldb/trunk/include/lldb/Expression/Expression.h
    lldb/trunk/include/lldb/Expression/LLVMUserExpression.h
    lldb/trunk/include/lldb/Expression/UserExpression.h
    lldb/trunk/include/lldb/Symbol/ClangASTContext.h
    lldb/trunk/include/lldb/Symbol/GoASTContext.h
    lldb/trunk/include/lldb/Symbol/TypeSystem.h
    lldb/trunk/include/lldb/Target/Target.h
    lldb/trunk/source/Breakpoint/BreakpointLocation.cpp
    lldb/trunk/source/Breakpoint/Watchpoint.cpp
    lldb/trunk/source/Expression/LLVMUserExpression.cpp
    lldb/trunk/source/Expression/UserExpression.cpp
    lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
    lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
    lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
    lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h
    lldb/trunk/source/Symbol/ClangASTContext.cpp
    lldb/trunk/source/Symbol/GoASTContext.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/Expression/Expression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/Expression.h?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/Expression.h (original)
+++ lldb/trunk/include/lldb/Expression/Expression.h Mon Nov  2 20:11:24 2015
@@ -109,6 +109,8 @@ public:
     virtual bool
     NeedsVariableResolution () = 0;
 
+    virtual EvaluateExpressionOptions *GetOptions() { return nullptr; };
+
     //------------------------------------------------------------------
     /// Return the address of the function's JIT-compiled code, or
     /// LLDB_INVALID_ADDRESS if the function is not JIT compiled

Modified: lldb/trunk/include/lldb/Expression/LLVMUserExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/LLVMUserExpression.h?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/LLVMUserExpression.h (original)
+++ lldb/trunk/include/lldb/Expression/LLVMUserExpression.h Mon Nov  2 20:11:24 2015
@@ -35,15 +35,23 @@ namespace lldb_private
 class LLVMUserExpression : public UserExpression
 {
   public:
-    LLVMUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
-                       lldb::LanguageType language, ResultType desired_type);
+    LLVMUserExpression(ExecutionContextScope &exe_scope,
+                       const char *expr,
+                       const char *expr_prefix,
+                       lldb::LanguageType language,
+                       ResultType desired_type,
+                       const EvaluateExpressionOptions &options);
     ~LLVMUserExpression() override;
 
-    lldb::ExpressionResults Execute(Stream &error_stream, ExecutionContext &exe_ctx,
-                                    const EvaluateExpressionOptions &options, lldb::UserExpressionSP &shared_ptr_to_me,
+    lldb::ExpressionResults Execute(Stream &error_stream,
+                                    ExecutionContext &exe_ctx,
+                                    const EvaluateExpressionOptions &options,
+                                    lldb::UserExpressionSP &shared_ptr_to_me,
                                     lldb::ExpressionVariableSP &result) override;
 
-    bool FinalizeJITExecution(Stream &error_stream, ExecutionContext &exe_ctx, lldb::ExpressionVariableSP &result,
+    bool FinalizeJITExecution(Stream &error_stream,
+                              ExecutionContext &exe_ctx,
+                              lldb::ExpressionVariableSP &result,
                               lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,
                               lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS) override;
 

Modified: lldb/trunk/include/lldb/Expression/UserExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/UserExpression.h?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/UserExpression.h (original)
+++ lldb/trunk/include/lldb/Expression/UserExpression.h Mon Nov  2 20:11:24 2015
@@ -24,6 +24,7 @@
 #include "lldb/Expression/Expression.h"
 #include "lldb/Expression/Materializer.h"
 #include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Target.h"
 
 namespace lldb_private
 {
@@ -67,7 +68,8 @@ public:
                     const char *expr,
                     const char *expr_prefix,
                     lldb::LanguageType language,
-                    ResultType desired_type);
+                    ResultType desired_type,
+                    const EvaluateExpressionOptions &options);
 
     //------------------------------------------------------------------
     /// Destructor
@@ -236,6 +238,12 @@ public:
         return true;
     }
     
+    EvaluateExpressionOptions *
+    GetOptions() override
+    {
+        return &m_options;
+    }
+    
     virtual lldb::ExpressionVariableSP
     GetResultAfterDematerialization(ExecutionContextScope *exe_scope)
     {
@@ -319,7 +327,7 @@ protected:
     std::string                                 m_expr_prefix;          ///< The text of the translation-level definitions, as provided by the user
     lldb::LanguageType                          m_language;             ///< The language to use when parsing (eLanguageTypeUnknown means use defaults)
     ResultType                                  m_desired_type;         ///< The type to coerce the expression's result to.  If eResultTypeAny, inferred from the expression.
-
+    EvaluateExpressionOptions                   m_options;              ///< Additional options provided by the user.
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Mon Nov  2 20:11:24 2015
@@ -1184,7 +1184,8 @@ public:
     GetUserExpression (const char *expr,
                        const char *expr_prefix,
                        lldb::LanguageType language,
-                       Expression::ResultType desired_type) override;
+                       Expression::ResultType desired_type,
+                       const EvaluateExpressionOptions &options) override;
     
     FunctionCaller *
     GetFunctionCaller (const CompilerType &return_type,

Modified: lldb/trunk/include/lldb/Symbol/GoASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/GoASTContext.h?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/GoASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/GoASTContext.h Mon Nov  2 20:11:24 2015
@@ -398,7 +398,8 @@ class GoASTContextForExpr : public GoAST
   public:
     GoASTContextForExpr(lldb::TargetSP target) : m_target_wp(target) {}
     UserExpression *GetUserExpression(const char *expr, const char *expr_prefix, lldb::LanguageType language,
-                                      Expression::ResultType desired_type) override;
+                                      Expression::ResultType desired_type,
+                                      const EvaluateExpressionOptions &options) override;
 
   private:
     lldb::TargetWP m_target_wp;

Modified: lldb/trunk/include/lldb/Symbol/TypeSystem.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/TypeSystem.h (original)
+++ lldb/trunk/include/lldb/Symbol/TypeSystem.h Mon Nov  2 20:11:24 2015
@@ -496,7 +496,8 @@ public:
     GetUserExpression (const char *expr,
                        const char *expr_prefix,
                        lldb::LanguageType language,
-                       Expression::ResultType desired_type)
+                       Expression::ResultType desired_type,
+                       const EvaluateExpressionOptions &options)
     {
         return nullptr;
     }

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Mon Nov  2 20:11:24 2015
@@ -1256,6 +1256,7 @@ public:
                                  const char *expr_prefix,
                                  lldb::LanguageType language,
                                  Expression::ResultType desired_type,
+                                 const EvaluateExpressionOptions &options,
                                  Error &error);
     
     // Creates a FunctionCaller for the given language, the rest of the parameters have the

Modified: lldb/trunk/source/Breakpoint/BreakpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocation.cpp?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointLocation.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointLocation.cpp Mon Nov  2 20:11:24 2015
@@ -293,6 +293,7 @@ BreakpointLocation::ConditionSaysStop (E
                                                                             nullptr,
                                                                             language,
                                                                             Expression::eResultTypeAny,
+                                                                            EvaluateExpressionOptions(),
                                                                             error));
         if (error.Fail())
         {

Modified: lldb/trunk/source/Breakpoint/Watchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Watchpoint.cpp?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/Watchpoint.cpp (original)
+++ lldb/trunk/source/Breakpoint/Watchpoint.cpp Mon Nov  2 20:11:24 2015
@@ -387,6 +387,7 @@ Watchpoint::SetCondition (const char *co
                                                                    nullptr,
                                                                    lldb::eLanguageTypeUnknown,
                                                                    UserExpression::eResultTypeAny,
+                                                                   EvaluateExpressionOptions(),
                                                                    error));
         if (error.Fail())
         {

Modified: lldb/trunk/source/Expression/LLVMUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/LLVMUserExpression.cpp?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/source/Expression/LLVMUserExpression.cpp (original)
+++ lldb/trunk/source/Expression/LLVMUserExpression.cpp Mon Nov  2 20:11:24 2015
@@ -40,9 +40,13 @@
 
 using namespace lldb_private;
 
-LLVMUserExpression::LLVMUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
-                                       lldb::LanguageType language, ResultType desired_type)
-    : UserExpression(exe_scope, expr, expr_prefix, language, desired_type),
+LLVMUserExpression::LLVMUserExpression(ExecutionContextScope &exe_scope, 
+                                       const char *expr, 
+                                       const char *expr_prefix,
+                                       lldb::LanguageType language, 
+                                       ResultType desired_type, 
+                                       const EvaluateExpressionOptions &options)
+    : UserExpression(exe_scope, expr, expr_prefix, language, desired_type, options),
       m_stack_frame_bottom(LLDB_INVALID_ADDRESS),
       m_stack_frame_top(LLDB_INVALID_ADDRESS),
       m_transformed_text(),

Modified: lldb/trunk/source/Expression/UserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/UserExpression.cpp?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/source/Expression/UserExpression.cpp (original)
+++ lldb/trunk/source/Expression/UserExpression.cpp Mon Nov  2 20:11:24 2015
@@ -45,13 +45,18 @@
 
 using namespace lldb_private;
 
-UserExpression::UserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
-                               lldb::LanguageType language, ResultType desired_type)
-    : Expression(exe_scope),
+UserExpression::UserExpression (ExecutionContextScope &exe_scope,
+                                const char *expr,
+                                const char *expr_prefix,
+                                lldb::LanguageType language,
+                                ResultType desired_type,
+                                const EvaluateExpressionOptions &options) :
+      Expression(exe_scope),
       m_expr_text(expr),
       m_expr_prefix(expr_prefix ? expr_prefix : ""),
       m_language(language),
-      m_desired_type(desired_type)
+      m_desired_type(desired_type),
+      m_options (options)
 {
 }
 
@@ -219,6 +224,7 @@ UserExpression::Evaluate (ExecutionConte
                                                                                     full_prefix,
                                                                                     language,
                                                                                     desired_type,
+                                                                                    options,
                                                                                     error));
     if (error.Fail())
     {

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Mon Nov  2 20:11:24 2015
@@ -55,10 +55,14 @@
 
 using namespace lldb_private;
 
-ClangUserExpression::ClangUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
-                                         lldb::LanguageType language, ResultType desired_type)
-    : LLVMUserExpression(exe_scope, expr, expr_prefix, language, desired_type),
-      m_type_system_helper(*m_target_wp.lock().get())
+ClangUserExpression::ClangUserExpression (ExecutionContextScope &exe_scope,
+                                          const char *expr,
+                                          const char *expr_prefix,
+                                          lldb::LanguageType language,
+                                          ResultType desired_type,
+                                          const EvaluateExpressionOptions &options) :
+    LLVMUserExpression (exe_scope, expr, expr_prefix, language, desired_type, options),
+    m_type_system_helper(*m_target_wp.lock().get())
 {
     switch (m_language)
     {

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h Mon Nov  2 20:11:24 2015
@@ -118,7 +118,8 @@ public:
                          const char *expr,
                          const char *expr_prefix,
                          lldb::LanguageType language,
-                         ResultType desired_type);
+                         ResultType desired_type,
+                         const EvaluateExpressionOptions &options);
 
     ~ClangUserExpression() override;
 

Modified: lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp Mon Nov  2 20:11:24 2015
@@ -218,8 +218,9 @@ LookupType(TargetSP target, ConstString
     return CompilerType();
 }
 GoUserExpression::GoUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
-                                   lldb::LanguageType language, ResultType desired_type)
-    : UserExpression(exe_scope, expr, expr_prefix, language, desired_type)
+                                   lldb::LanguageType language, ResultType desired_type,
+                                   const EvaluateExpressionOptions &options)
+    : UserExpression(exe_scope, expr, expr_prefix, language, desired_type, options)
 {
 }
 

Modified: lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h Mon Nov  2 20:11:24 2015
@@ -66,7 +66,7 @@ class GoUserExpression : public UserExpr
 {
   public:
     GoUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
-                     lldb::LanguageType language, ResultType desired_type);
+                     lldb::LanguageType language, ResultType desired_type, const EvaluateExpressionOptions &options);
 
     virtual bool Parse(Stream &error_stream, ExecutionContext &exe_ctx, lldb_private::ExecutionPolicy execution_policy,
                        bool keep_result_in_memory, bool generate_debug_info) override;

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Mon Nov  2 20:11:24 2015
@@ -9227,13 +9227,14 @@ UserExpression *
 ClangASTContextForExpressions::GetUserExpression (const char *expr,
                    const char *expr_prefix,
                    lldb::LanguageType language,
-                   Expression::ResultType desired_type)
+                   Expression::ResultType desired_type,
+                   const EvaluateExpressionOptions &options)
 {
     TargetSP target_sp = m_target_wp.lock();
     if (!target_sp)
         return nullptr;
     
-    return new ClangUserExpression(*target_sp.get(), expr, expr_prefix, language, desired_type);
+    return new ClangUserExpression(*target_sp.get(), expr, expr_prefix, language, desired_type, options);
 }
 
 FunctionCaller *

Modified: lldb/trunk/source/Symbol/GoASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/GoASTContext.cpp?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/GoASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/GoASTContext.cpp Mon Nov  2 20:11:24 2015
@@ -1509,10 +1509,10 @@ GoASTContext::GetDWARFParser()
 
 UserExpression *
 GoASTContextForExpr::GetUserExpression(const char *expr, const char *expr_prefix, lldb::LanguageType language,
-                                       Expression::ResultType desired_type)
+                                       Expression::ResultType desired_type, const EvaluateExpressionOptions &options)
 {
     TargetSP target = m_target_wp.lock();
     if (target)
-        return new GoUserExpression(*target, expr, expr_prefix, language, desired_type);
+        return new GoUserExpression(*target, expr, expr_prefix, language, desired_type, options);
     return nullptr;
 }

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=251887&r1=251886&r2=251887&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Mon Nov  2 20:11:24 2015
@@ -1993,6 +1993,7 @@ Target::GetUserExpressionForLanguage(con
                                      const char *expr_prefix,
                                      lldb::LanguageType language,
                                      Expression::ResultType desired_type,
+                                     const EvaluateExpressionOptions &options,
                                      Error &error)
 {
     Error type_system_error;
@@ -2006,7 +2007,7 @@ Target::GetUserExpressionForLanguage(con
         return nullptr;
     }
     
-    user_expr = type_system->GetUserExpression(expr, expr_prefix, language, desired_type);
+    user_expr = type_system->GetUserExpression(expr, expr_prefix, language, desired_type, options);
     if (!user_expr)
         error.SetErrorStringWithFormat("Could not create an expression for language %s", Language::GetNameForLanguageType(language));
     




More information about the lldb-commits mailing list