<div dir="ltr">Oops, thanks.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature">-- Ryan Brown<br></div></div>
<br><div class="gmail_quote">On Mon, Nov 2, 2015 at 12:53 PM, Zachary Turner <span dir="ltr"><<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Ryan, my change to the test system seems to have crossed paths with this CL.  tests don't go in lldb/test anymore, they go in lldb/packages/Python/lldbsuite/test.  Right now these are the only tests still in the wrong location, so they aren't getting run.  You will need to move them over to the new location.</div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Mon, Nov 2, 2015 at 11:33 AM Ryan Brown via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ribrdb<br>
Date: Mon Nov  2 13:30:40 2015<br>
New Revision: 251820<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=251820&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=251820&view=rev</a><br>
Log:<br>
Create an expression parser for Go.<br>
<br>
The Go interpreter doesn't JIT or use LLVM, so this also<br>
moves all the JIT related code from UserExpression to a new class LLVMUserExpression.<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D13073" rel="noreferrer" target="_blank">http://reviews.llvm.org/D13073</a><br>
<br>
Fix merge<br>
<br>
Added:<br>
    lldb/trunk/include/lldb/Expression/LLVMUserExpression.h<br>
    lldb/trunk/source/Expression/LLVMUserExpression.cpp<br>
    lldb/trunk/source/Plugins/ExpressionParser/Go/<br>
    lldb/trunk/source/Plugins/ExpressionParser/Go/CMakeLists.txt<br>
    lldb/trunk/source/Plugins/ExpressionParser/Go/GoAST.h<br>
    lldb/trunk/source/Plugins/ExpressionParser/Go/GoLexer.cpp<br>
    lldb/trunk/source/Plugins/ExpressionParser/Go/GoLexer.h<br>
    lldb/trunk/source/Plugins/ExpressionParser/Go/GoParser.cpp<br>
    lldb/trunk/source/Plugins/ExpressionParser/Go/GoParser.h<br>
    lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp<br>
    lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h<br>
    lldb/trunk/source/Plugins/ExpressionParser/Go/Makefile<br>
    lldb/trunk/source/Plugins/ExpressionParser/Go/gen_go_ast.py<br>
    lldb/trunk/test/lang/go/expressions/<br>
    lldb/trunk/test/lang/go/expressions/TestExpressions.py<br>
    lldb/trunk/test/lang/go/expressions/main.go<br>
    lldb/trunk/unittests/Expression/<br>
    lldb/trunk/unittests/Expression/CMakeLists.txt<br>
    lldb/trunk/unittests/Expression/GoParserTest.cpp<br>
Modified:<br>
    lldb/trunk/.clang-format<br>
    lldb/trunk/cmake/LLDBDependencies.cmake<br>
    lldb/trunk/include/lldb/Expression/UserExpression.h<br>
    lldb/trunk/include/lldb/Symbol/GoASTContext.h<br>
    lldb/trunk/lldb.xcodeproj/project.pbxproj<br>
    lldb/trunk/source/API/SBFrame.cpp<br>
    lldb/trunk/source/Expression/CMakeLists.txt<br>
    lldb/trunk/source/Expression/UserExpression.cpp<br>
    lldb/trunk/source/Plugins/ExpressionParser/CMakeLists.txt<br>
    lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp<br>
    lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h<br>
    lldb/trunk/source/Symbol/GoASTContext.cpp<br>
    lldb/trunk/unittests/CMakeLists.txt<br>
<br>
Modified: lldb/trunk/.clang-format<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/.clang-format?rev=251820&r1=251819&r2=251820&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/.clang-format?rev=251820&r1=251819&r2=251820&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/.clang-format (original)<br>
+++ lldb/trunk/.clang-format Mon Nov  2 13:30:40 2015<br>
@@ -4,5 +4,5 @@ ColumnLimit:     120<br>
 BreakBeforeBraces: Allman<br>
 AlwaysBreakAfterDefinitionReturnType: true<br>
 AllowShortFunctionsOnASingleLine: Inline<br>
-BreakConstructorInitializersBeforeComma: true<br>
+ConstructorInitializerAllOnOneLineOrOnePerLine: true<br>
 IndentCaseLabels: true<br>
<br>
Modified: lldb/trunk/cmake/LLDBDependencies.cmake<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/LLDBDependencies.cmake?rev=251820&r1=251819&r2=251820&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/LLDBDependencies.cmake?rev=251820&r1=251819&r2=251820&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/cmake/LLDBDependencies.cmake (original)<br>
+++ lldb/trunk/cmake/LLDBDependencies.cmake Mon Nov  2 13:30:40 2015<br>
@@ -74,6 +74,7 @@ set( LLDB_USED_LIBS<br>
   lldbPluginProcessElfCore<br>
   lldbPluginJITLoaderGDB<br>
   lldbPluginExpressionParserClang<br>
+  lldbPluginExpressionParserGo<br>
   )<br>
<br>
 # Windows-only libraries<br>
<br>
Added: lldb/trunk/include/lldb/Expression/LLVMUserExpression.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/LLVMUserExpression.h?rev=251820&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/LLVMUserExpression.h?rev=251820&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/include/lldb/Expression/LLVMUserExpression.h (added)<br>
+++ lldb/trunk/include/lldb/Expression/LLVMUserExpression.h Mon Nov  2 13:30:40 2015<br>
@@ -0,0 +1,108 @@<br>
+//===-- LLVMUserExpression.h ------------------------------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#ifndef liblldb_LLVMUserExpression_h<br>
+#define liblldb_LLVMUserExpression_h<br>
+<br>
+// C Includes<br>
+// C++ Includes<br>
+#include <string><br>
+#include <map><br>
+#include <vector><br>
+<br>
+// Project includes<br>
+#include "lldb/Expression/UserExpression.h"<br>
+<br>
+namespace lldb_private<br>
+{<br>
+<br>
+//----------------------------------------------------------------------<br>
+/// @class LLVMUserExpression LLVMUserExpression.h "lldb/Expression/LLVMUserExpression.h"<br>
+/// @brief Encapsulates a one-time expression for use in lldb.<br>
+///<br>
+/// LLDB uses expressions for various purposes, notably to call functions<br>
+/// and as a backend for the expr command.  LLVMUserExpression is a virtual base<br>
+/// class that encapsulates the objects needed to parse and JIT an expression.<br>
+/// The actual parsing part will be provided by the specific implementations<br>
+/// of LLVMUserExpression - which will be vended through the appropriate TypeSystem.<br>
+//----------------------------------------------------------------------<br>
+class LLVMUserExpression : public UserExpression<br>
+{<br>
+  public:<br>
+    LLVMUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,<br>
+                       lldb::LanguageType language, ResultType desired_type);<br>
+    ~LLVMUserExpression() override;<br>
+<br>
+    lldb::ExpressionResults Execute(Stream &error_stream, ExecutionContext &exe_ctx,<br>
+                                    const EvaluateExpressionOptions &options, lldb::UserExpressionSP &shared_ptr_to_me,<br>
+                                    lldb::ExpressionVariableSP &result) override;<br>
+<br>
+    bool FinalizeJITExecution(Stream &error_stream, ExecutionContext &exe_ctx, lldb::ExpressionVariableSP &result,<br>
+                              lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,<br>
+                              lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS) override;<br>
+<br>
+    bool<br>
+    CanInterpret() override<br>
+    {<br>
+        return m_can_interpret;<br>
+    }<br>
+<br>
+    //------------------------------------------------------------------<br>
+    /// Return the string that the parser should parse.  Must be a full<br>
+    /// translation unit.<br>
+    //------------------------------------------------------------------<br>
+    const char *<br>
+    Text() override<br>
+    {<br>
+        return m_transformed_text.c_str();<br>
+    }<br>
+<br>
+    lldb::ModuleSP GetJITModule() override;<br>
+<br>
+  protected:<br>
+    virtual void ScanContext(ExecutionContext &exe_ctx, lldb_private::Error &err) = 0;<br>
+<br>
+    bool PrepareToExecuteJITExpression(Stream &error_stream, ExecutionContext &exe_ctx, lldb::addr_t &struct_address);<br>
+    virtual bool<br>
+    AddInitialArguments(ExecutionContext &exe_ctx, std::vector<lldb::addr_t> &args, Stream &error_stream)<br>
+    {<br>
+        return true;<br>
+    }<br>
+<br>
+    lldb::addr_t m_stack_frame_bottom; ///< The bottom of the allocated stack frame.<br>
+    lldb::addr_t m_stack_frame_top;    ///< The top of the allocated stack frame.<br>
+<br>
+    bool m_allow_cxx;               ///< True if the language allows C++.<br>
+    bool m_allow_objc;              ///< True if the language allows Objective-C.<br>
+    std::string m_transformed_text; ///< The text of the expression, as send to the parser<br>
+<br>
+    std::shared_ptr<IRExecutionUnit> m_execution_unit_sp; ///< The execution unit the expression is stored in.<br>
+    std::unique_ptr<Materializer> m_materializer_ap;      ///< The materializer to use when running the expression.<br>
+    lldb::ModuleWP m_jit_module_wp;<br>
+    bool m_enforce_valid_object; ///< True if the expression parser should enforce the presence of a valid class pointer<br>
+                                 ///in order to generate the expression as a method.<br>
+    bool m_in_cplusplus_method;  ///< True if the expression is compiled as a C++ member function (true if it was parsed<br>
+                                 ///when exe_ctx was in a C++ method).<br>
+    bool m_in_objectivec_method; ///< True if the expression is compiled as an Objective-C method (true if it was parsed<br>
+                                 ///when exe_ctx was in an Objective-C method).<br>
+    bool m_in_static_method; ///< True if the expression is compiled as a static (or class) method (currently true if it<br>
+                             ///was parsed when exe_ctx was in an Objective-C class method).<br>
+    bool m_needs_object_ptr; ///< True if "this" or "self" must be looked up and passed in.  False if the expression<br>
+                             ///doesn't really use them and they can be NULL.<br>
+    bool m_const_object;     ///< True if "this" is const.<br>
+    Target *m_target;        ///< The target for storing persistent data like types and variables.<br>
+<br>
+    bool m_can_interpret; ///< True if the expression could be evaluated statically; false otherwise.<br>
+    lldb::addr_t<br>
+        m_materialized_address; ///< The address at which the arguments to the expression have been materialized.<br>
+    Materializer::DematerializerSP m_dematerializer_sp; ///< The dematerializer.<br>
+};<br>
+<br>
+} // namespace lldb_private<br>
+#endif<br>
<br>
Modified: lldb/trunk/include/lldb/Expression/UserExpression.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/UserExpression.h?rev=251820&r1=251819&r2=251820&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/UserExpression.h?rev=251820&r1=251819&r2=251820&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/include/lldb/Expression/UserExpression.h (original)<br>
+++ lldb/trunk/include/lldb/Expression/UserExpression.h Mon Nov  2 13:30:40 2015<br>
@@ -102,11 +102,7 @@ public:<br>
            bool keep_result_in_memory,<br>
            bool generate_debug_info) = 0;<br>
<br>
-    bool<br>
-    CanInterpret ()<br>
-    {<br>
-        return m_can_interpret;<br>
-    }<br>
+    virtual bool CanInterpret() = 0;<br>
<br>
     bool<br>
     MatchesContext (ExecutionContext &exe_ctx);<br>
@@ -138,12 +134,10 @@ public:<br>
     /// @return<br>
     ///     A Process::Execution results value.<br>
     //------------------------------------------------------------------<br>
-    lldb::ExpressionResults<br>
-    Execute (Stream &error_stream,<br>
-             ExecutionContext &exe_ctx,<br>
-             const EvaluateExpressionOptions& options,<br>
-             lldb::UserExpressionSP &shared_ptr_to_me,<br>
-             lldb::ExpressionVariableSP &result);<br>
+    virtual lldb::ExpressionResults Execute(Stream &error_stream, ExecutionContext &exe_ctx,<br>
+                                            const EvaluateExpressionOptions &options,<br>
+                                            lldb::UserExpressionSP &shared_ptr_to_me,<br>
+                                            lldb::ExpressionVariableSP &result) = 0;<br>
<br>
     //------------------------------------------------------------------<br>
     /// Apply the side effects of the function to program state.<br>
@@ -168,21 +162,18 @@ public:<br>
     /// @return<br>
     ///     A Process::Execution results value.<br>
     //------------------------------------------------------------------<br>
-    bool<br>
-    FinalizeJITExecution (Stream &error_stream,<br>
-                          ExecutionContext &exe_ctx,<br>
-                          lldb::ExpressionVariableSP &result,<br>
-                          lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,<br>
-                          lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS);<br>
+    virtual bool FinalizeJITExecution(Stream &error_stream, ExecutionContext &exe_ctx,<br>
+                                      lldb::ExpressionVariableSP &result,<br>
+                                      lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,<br>
+                                      lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS) = 0;<br>
<br>
     //------------------------------------------------------------------<br>
-    /// Return the string that the parser should parse.  Must be a full<br>
-    /// translation unit.<br>
+    /// Return the string that the parser should parse.<br>
     //------------------------------------------------------------------<br>
     const char *<br>
     Text() override<br>
     {<br>
-        return m_transformed_text.c_str();<br>
+        return m_expr_text.c_str();<br>
     }<br>
<br>
     //------------------------------------------------------------------<br>
@@ -251,6 +242,12 @@ public:<br>
         return lldb::ExpressionVariableSP();<br>
     }<br>
<br>
+    virtual lldb::ModuleSP<br>
+    GetJITModule()<br>
+    {<br>
+        return lldb::ModuleSP();<br>
+    }<br>
+<br>
     //------------------------------------------------------------------<br>
     /// Evaluate one expression in the scratch context of the<br>
     /// target passed in the exe_ctx and return its result.<br>
@@ -308,23 +305,6 @@ protected:<br>
     /// Populate m_in_cplusplus_method and m_in_objectivec_method based on the environment.<br>
     //------------------------------------------------------------------<br>
<br>
-    virtual void<br>
-    ScanContext (ExecutionContext &exe_ctx,<br>
-                 lldb_private::Error &err) = 0;<br>
-<br>
-    bool<br>
-    PrepareToExecuteJITExpression (Stream &error_stream,<br>
-                                   ExecutionContext &exe_ctx,<br>
-                                   lldb::addr_t &struct_address);<br>
-<br>
-    virtual bool<br>
-    AddInitialArguments (ExecutionContext &exe_ctx,<br>
-                         std::vector<lldb::addr_t> &args,<br>
-                         Stream &error_stream)<br>
-    {<br>
-        return true;<br>
-    }<br>
-<br>
     void<br>
     InstallContext (ExecutionContext &exe_ctx);<br>
<br>
@@ -335,31 +315,11 @@ protected:<br>
                          lldb::StackFrameSP &frame_sp);<br>
<br>
     Address                                     m_address;              ///< The address the process is stopped in.<br>
-    lldb::addr_t                                m_stack_frame_bottom;   ///< The bottom of the allocated stack frame.<br>
-    lldb::addr_t                                m_stack_frame_top;      ///< The top of the allocated stack frame.<br>
-<br>
     std::string                                 m_expr_text;            ///< The text of the expression, as typed by the user<br>
     std::string                                 m_expr_prefix;          ///< The text of the translation-level definitions, as provided by the user<br>
     lldb::LanguageType                          m_language;             ///< The language to use when parsing (eLanguageTypeUnknown means use defaults)<br>
-    bool                                        m_allow_cxx;            ///< True if the language allows C++.<br>
-    bool                                        m_allow_objc;           ///< True if the language allows Objective-C.<br>
-    std::string                                 m_transformed_text;     ///< The text of the expression, as send to the parser<br>
     ResultType                                  m_desired_type;         ///< The type to coerce the expression's result to.  If eResultTypeAny, inferred from the expression.<br>
<br>
-    std::shared_ptr<IRExecutionUnit>            m_execution_unit_sp;    ///< The execution unit the expression is stored in.<br>
-    std::unique_ptr<Materializer>               m_materializer_ap;      ///< The materializer to use when running the expression.<br>
-    lldb::ModuleWP                              m_jit_module_wp;<br>
-    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.<br>
-    bool                                        m_in_cplusplus_method;  ///< True if the expression is compiled as a C++ member function (true if it was parsed when exe_ctx was in a C++ method).<br>
-    bool                                        m_in_objectivec_method; ///< 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).<br>
-    bool                                        m_in_static_method;     ///< True if the expression is compiled as a static (or class) method (currently true if it was parsed when exe_ctx was in an Objective-C class method).<br>
-    bool                                        m_needs_object_ptr;     ///< True if "this" or "self" must be looked up and passed in.  False if the expression doesn't really use them and they can be nullptr.<br>
-    bool                                        m_const_object;         ///< True if "this" is const.<br>
-    Target                                     *m_target;               ///< The target for storing persistent data like types and variables.<br>
-<br>
-    bool                                        m_can_interpret;        ///< True if the expression could be evaluated statically; false otherwise.<br>
-    lldb::addr_t                                m_materialized_address; ///< The address at which the arguments to the expression have been materialized.<br>
-    Materializer::DematerializerSP              m_dematerializer_sp;    ///< The dematerializer.<br>
 };<br>
<br>
 } // namespace lldb_private<br>
<br>
Modified: lldb/trunk/include/lldb/Symbol/GoASTContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/GoASTContext.h?rev=251820&r1=251819&r2=251820&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/GoASTContext.h?rev=251820&r1=251819&r2=251820&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/include/lldb/Symbol/GoASTContext.h (original)<br>
+++ lldb/trunk/include/lldb/Symbol/GoASTContext.h Mon Nov  2 13:30:40 2015<br>
@@ -254,8 +254,7 @@ class GoASTContext : public TypeSystem<br>
<br>
     lldb::BasicType GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override;<br>
<br>
-    CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,<br>
-                                                     size_t bit_size) override;<br>
+    CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override;<br>
<br>
     uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override;<br>
<br>
@@ -394,6 +393,15 @@ class GoASTContext : public TypeSystem<br>
     const GoASTContext &operator=(const GoASTContext &) = delete;<br>
 };<br>
<br>
-} // namespace lldb_private<br>
+class GoASTContextForExpr : public GoASTContext<br>
+{<br>
+  public:<br>
+    GoASTContextForExpr(lldb::TargetSP target) : m_target_wp(target) {}<br>
+    UserExpression *GetUserExpression(const char *expr, const char *expr_prefix, lldb::LanguageType language,<br>
+                                      Expression::ResultType desired_type) override;<br>
<br>
+  private:<br>
+    lldb::TargetWP m_target_wp;<br>
+};<br>
+}<br>
 #endif // liblldb_GoASTContext_h_<br>
<br>
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=251820&r1=251819&r2=251820&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=251820&r1=251819&r2=251820&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)<br>
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Nov  2 13:30:40 2015<br>
@@ -839,10 +839,14 @@<br>
                9AC703AF117675410086C050 /* SBInstruction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703AE117675410086C050 /* SBInstruction.cpp */; };<br>
                9AC703B1117675490086C050 /* SBInstructionList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703B0117675490086C050 /* SBInstructionList.cpp */; };<br>
                A36FF33C17D8E94600244D40 /* OptionParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A36FF33B17D8E94600244D40 /* OptionParser.cpp */; };<br>
+               AE44FB301BB07EB20033EB62 /* GoUserExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AE44FB2C1BB07DD80033EB62 /* GoUserExpression.cpp */; };<br>
+               AE44FB311BB07EB80033EB62 /* GoLexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AE44FB2A1BB07DD80033EB62 /* GoLexer.cpp */; };<br>
+               AE44FB321BB07EBC0033EB62 /* GoParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AE44FB2B1BB07DD80033EB62 /* GoParser.cpp */; };<br>
                AE44FB3E1BB485960033EB62 /* GoLanguageRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AE44FB3D1BB485960033EB62 /* GoLanguageRuntime.cpp */; };<br>
                AE6897281B94F6DE0018845D /* DWARFASTParserGo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AE6897261B94F6DE0018845D /* DWARFASTParserGo.cpp */; };<br>
                AE7F56291B8FE418001377A8 /* GoASTContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AEFFBA7C1AC4835D0087B932 /* GoASTContext.cpp */; };<br>
                AE8F624919EF3E1E00326B21 /* OperatingSystemGo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AE8F624719EF3E1E00326B21 /* OperatingSystemGo.cpp */; };<br>
+               AEB0E4591BD6E9F800B24093 /* LLVMUserExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AEB0E4581BD6E9F800B24093 /* LLVMUserExpression.cpp */; };<br>
                AEEA34051AC88A7400AB639D /* TypeSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AEEA34041AC88A7400AB639D /* TypeSystem.cpp */; };<br>
                AF061F87182C97ED00B6A19C /* RegisterContextHistory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF061F85182C97ED00B6A19C /* RegisterContextHistory.cpp */; };<br>
                AF0C112818580CD800C4C45B /* QueueItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF0C112718580CD800C4C45B /* QueueItem.cpp */; };<br>
@@ -2683,12 +2687,21 @@<br>
                9AF16CC7114086A1007A7B3F /* SBBreakpointLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBBreakpointLocation.cpp; path = source/API/SBBreakpointLocation.cpp; sourceTree = "<group>"; };<br>
                A36FF33B17D8E94600244D40 /* OptionParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionParser.cpp; sourceTree = "<group>"; };<br>
                A36FF33D17D8E98800244D40 /* OptionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OptionParser.h; path = include/lldb/Host/OptionParser.h; sourceTree = "<group>"; };<br>
+               AE44FB261BB07DC60033EB62 /* GoAST.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = GoAST.h; path = ExpressionParser/Go/GoAST.h; sourceTree = "<group>"; };<br>
+               AE44FB271BB07DC60033EB62 /* GoLexer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = GoLexer.h; path = ExpressionParser/Go/GoLexer.h; sourceTree = "<group>"; };<br>
+               AE44FB281BB07DC60033EB62 /* GoParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = GoParser.h; path = ExpressionParser/Go/GoParser.h; sourceTree = "<group>"; };<br>
+               AE44FB291BB07DC60033EB62 /* GoUserExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = GoUserExpression.h; path = ExpressionParser/Go/GoUserExpression.h; sourceTree = "<group>"; };<br>
+               AE44FB2A1BB07DD80033EB62 /* GoLexer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GoLexer.cpp; path = ExpressionParser/Go/GoLexer.cpp; sourceTree = "<group>"; };<br>
+               AE44FB2B1BB07DD80033EB62 /* GoParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GoParser.cpp; path = ExpressionParser/Go/GoParser.cpp; sourceTree = "<group>"; };<br>
+               AE44FB2C1BB07DD80033EB62 /* GoUserExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GoUserExpression.cpp; path = ExpressionParser/Go/GoUserExpression.cpp; sourceTree = "<group>"; };<br>
                AE44FB3C1BB4858A0033EB62 /* GoLanguageRuntime.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = GoLanguageRuntime.h; path = <a href="https://goto.google.com/GoLanguageRuntime" target="_blank">Go/GoLanguageRuntime</a>.h; sourceTree = "<group>"; };<br>
                AE44FB3D1BB485960033EB62 /* GoLanguageRuntime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GoLanguageRuntime.cpp; path = <a href="https://goto.google.com/GoLanguageRuntime" target="_blank">Go/GoLanguageRuntime</a>.cpp; sourceTree = "<group>"; };<br>
                AE6897261B94F6DE0018845D /* DWARFASTParserGo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DWARFASTParserGo.cpp; sourceTree = "<group>"; };<br>
                AE6897271B94F6DE0018845D /* DWARFASTParserGo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWARFASTParserGo.h; sourceTree = "<group>"; };<br>
                AE8F624719EF3E1E00326B21 /* OperatingSystemGo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OperatingSystemGo.cpp; path = <a href="https://goto.google.com/OperatingSystemGo" target="_blank">Go/OperatingSystemGo</a>.cpp; sourceTree = "<group>"; };<br>
                AE8F624819EF3E1E00326B21 /* OperatingSystemGo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OperatingSystemGo.h; path = <a href="https://goto.google.com/OperatingSystemGo" target="_blank">Go/OperatingSystemGo</a>.h; sourceTree = "<group>"; };<br>
+               AEB0E4581BD6E9F800B24093 /* LLVMUserExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LLVMUserExpression.cpp; path = source/Expression/LLVMUserExpression.cpp; sourceTree = "<group>"; };<br>
+               AEB0E45A1BD6EA1400B24093 /* LLVMUserExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = LLVMUserExpression.h; path = include/lldb/Expression/LLVMUserExpression.h; sourceTree = "<group>"; };<br>
                AEEA33F61AC74FE700AB639D /* TypeSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TypeSystem.h; path = include/lldb/Symbol/TypeSystem.h; sourceTree = "<group>"; };<br>
                AEEA34041AC88A7400AB639D /* TypeSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TypeSystem.cpp; path = source/Symbol/TypeSystem.cpp; sourceTree = "<group>"; };<br>
                AEEA340F1ACA08A000AB639D /* GoASTContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GoASTContext.h; path = include/lldb/Symbol/GoASTContext.h; sourceTree = "<group>"; };<br>
@@ -4528,6 +4541,8 @@<br>
                                4C0083321B9A5DE200D5CF24 /* FunctionCaller.cpp */,<br>
                                4C00832E1B9A58A700D5CF24 /* UserExpression.h */,<br>
                                4C0083331B9A5DE200D5CF24 /* UserExpression.cpp */,<br>
+                               AEB0E45A1BD6EA1400B24093 /* LLVMUserExpression.h */,<br>
+                               AEB0E4581BD6E9F800B24093 /* LLVMUserExpression.cpp */,<br>
                                4C00833D1B9F9B8400D5CF24 /* UtilityFunction.h */,<br>
                                4C00833F1B9F9BA900D5CF24 /* UtilityFunction.cpp */,<br>
                                49A1CAC11430E21D00306AC9 /* ExpressionSourceCode.h */,<br>
@@ -5207,6 +5222,7 @@<br>
                        isa = PBXGroup;<br>
                        children = (<br>
                                4984BA0C1B97620B008658D4 /* Clang */,<br>
+                               AE44FB371BB35A2E0033EB62 /* Go */,<br>
                        );<br>
                        name = ExpressionParser;<br>
                        sourceTree = "<group>";<br>
@@ -5580,6 +5596,20 @@<br>
                        name = "SysV-mips";<br>
                        sourceTree = "<group>";<br>
                };<br>
+               AE44FB371BB35A2E0033EB62 /* Go */ = {<br>
+                       isa = PBXGroup;<br>
+                       children = (<br>
+                               AE44FB261BB07DC60033EB62 /* GoAST.h */,<br>
+                               AE44FB271BB07DC60033EB62 /* GoLexer.h */,<br>
+                               AE44FB2A1BB07DD80033EB62 /* GoLexer.cpp */,<br>
+                               AE44FB281BB07DC60033EB62 /* GoParser.h */,<br>
+                               AE44FB2B1BB07DD80033EB62 /* GoParser.cpp */,<br>
+                               AE44FB291BB07DC60033EB62 /* GoUserExpression.h */,<br>
+                               AE44FB2C1BB07DD80033EB62 /* GoUserExpression.cpp */,<br>
+                       );<br>
+                       name = Go;<br>
+                       sourceTree = "<group>";<br>
+               };<br>
                AE44FB3B1BB485730033EB62 /* Go */ = {<br>
                        isa = PBXGroup;<br>
                        children = (<br>
@@ -6281,6 +6311,7 @@<br>
                                2689FFDA13353D9D00698AC0 /* lldb.cpp in Sources */,<br>
                                4C0083401B9F9BA900D5CF24 /* UtilityFunction.cpp in Sources */,<br>
                                26474CCD18D0CB5B0073DEBA /* RegisterContextPOSIX_x86.cpp in Sources */,<br>
+                               AEB0E4591BD6E9F800B24093 /* LLVMUserExpression.cpp in Sources */,<br>
                                2689FFEF13353DB600698AC0 /* Breakpoint.cpp in Sources */,<br>
                                267A47FB1B1411C40021A5BC /* NativeRegisterContext.cpp in Sources */,<br>
                                2689FFF113353DB600698AC0 /* BreakpointID.cpp in Sources */,<br>
@@ -6410,6 +6441,7 @@<br>
                                3F81691A1ABA2419001DA9DF /* NameMatches.cpp in Sources */,<br>
                                94B9E5121BBF20F4000A48DC /* NSString.cpp in Sources */,<br>
                                AF0E22F018A09FB20009B7D1 /* AppleGetItemInfoHandler.cpp in Sources */,<br>
+                               AE44FB301BB07EB20033EB62 /* GoUserExpression.cpp in Sources */,<br>
                                2689004E13353E0400698AC0 /* Stream.cpp in Sources */,<br>
                                2689004F13353E0400698AC0 /* StreamFile.cpp in Sources */,<br>
                                2689005013353E0400698AC0 /* StreamString.cpp in Sources */,<br>
@@ -6528,6 +6560,7 @@<br>
                                949EEDA31BA76577008C63CF /* Cocoa.cpp in Sources */,<br>
                                3FDFE56C19AF9C44009756A7 /* HostProcessPosix.cpp in Sources */,<br>
                                268900B413353E5000698AC0 /* RegisterContextMacOSXFrameBackchain.cpp in Sources */,<br>
+                               AE44FB321BB07EBC0033EB62 /* GoParser.cpp in Sources */,<br>
                                3F8169311ABB7A6D001DA9DF /* SystemInitializer.cpp in Sources */,<br>
                                949EEDB21BA76731008C63CF /* NSIndexPath.cpp in Sources */,<br>
                                3FDFED2D19C257A0009756A7 /* HostProcess.cpp in Sources */,<br>
@@ -6689,6 +6722,7 @@<br>
                                26D5E163135BB054006EA0A7 /* OptionGroupPlatform.cpp in Sources */,<br>
                                94CD131A19BA33B400DB7BED /* TypeValidator.cpp in Sources */,<br>
                                26BD407F135D2AE000237D80 /* FileLineResolver.cpp in Sources */,<br>
+                               AE44FB311BB07EB80033EB62 /* GoLexer.cpp in Sources */,<br>
                                26A7A035135E6E4200FB369E /* OptionValue.cpp in Sources */,<br>
                                9A22A161135E30370024DDC3 /* EmulateInstructionARM.cpp in Sources */,<br>
                                AFDFDFD119E34D3400EAE509 /* ConnectionFileDescriptorPosix.cpp in Sources */,<br>
<br>
Modified: lldb/trunk/source/API/SBFrame.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=251820&r1=251819&r2=251820&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=251820&r1=251819&r2=251820&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/API/SBFrame.cpp (original)<br>
+++ lldb/trunk/source/API/SBFrame.cpp Mon Nov  2 13:30:40 2015<br>
@@ -1389,6 +1389,10 @@ SBFrame::EvaluateExpression (const char<br>
         lldb::DynamicValueType fetch_dynamic_value = frame->CalculateTarget()->GetPreferDynamicValue();<br>
         options.SetFetchDynamicValue (fetch_dynamic_value);<br>
         options.SetUnwindOnError (true);<br>
+        if (target->GetLanguage() != eLanguageTypeUnknown)<br>
+            options.SetLanguage(target->GetLanguage());<br>
+        else<br>
+            options.SetLanguage(frame->GetLanguage());<br>
         return EvaluateExpression (expr, options);<br>
     }<br>
     return result;<br>
@@ -1400,6 +1404,13 @@ SBFrame::EvaluateExpression (const char<br>
     SBExpressionOptions options;<br>
     options.SetFetchDynamicValue (fetch_dynamic_value);<br>
     options.SetUnwindOnError (true);<br>
+    ExecutionContext exe_ctx(m_opaque_sp.get());<br>
+    StackFrame *frame = exe_ctx.GetFramePtr();<br>
+    Target *target = exe_ctx.GetTargetPtr();<br>
+    if (target && target->GetLanguage() != eLanguageTypeUnknown)<br>
+        options.SetLanguage(target->GetLanguage());<br>
+    else if (frame)<br>
+        options.SetLanguage(frame->GetLanguage());<br>
     return EvaluateExpression (expr, options);<br>
 }<br>
<br>
@@ -1407,8 +1418,15 @@ SBValue<br>
 SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value, bool unwind_on_error)<br>
 {<br>
     SBExpressionOptions options;<br>
+    ExecutionContext exe_ctx(m_opaque_sp.get());<br>
     options.SetFetchDynamicValue (fetch_dynamic_value);<br>
     options.SetUnwindOnError (unwind_on_error);<br>
+    StackFrame *frame = exe_ctx.GetFramePtr();<br>
+    Target *target = exe_ctx.GetTargetPtr();<br>
+    if (target && target->GetLanguage() != eLanguageTypeUnknown)<br>
+        options.SetLanguage(target->GetLanguage());<br>
+    else if (frame)<br>
+        options.SetLanguage(frame->GetLanguage());<br>
     return EvaluateExpression (expr, options);<br>
 }<br>
<br>
<br>
Modified: lldb/trunk/source/Expression/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/CMakeLists.txt?rev=251820&r1=251819&r2=251820&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/CMakeLists.txt?rev=251820&r1=251819&r2=251820&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Expression/CMakeLists.txt (original)<br>
+++ lldb/trunk/source/Expression/CMakeLists.txt Mon Nov  2 13:30:40 2015<br>
@@ -8,6 +8,7 @@ add_lldb_library(lldbExpression<br>
   IRExecutionUnit.cpp<br>
   IRInterpreter.cpp<br>
   IRMemoryMap.cpp<br>
+  LLVMUserExpression.cpp<br>
   Materializer.cpp<br>
   REPL.cpp<br>
   UserExpression.cpp<br>
<br>
Added: lldb/trunk/source/Expression/LLVMUserExpression.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/LLVMUserExpression.cpp?rev=251820&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/LLVMUserExpression.cpp?rev=251820&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/source/Expression/LLVMUserExpression.cpp (added)<br>
+++ lldb/trunk/source/Expression/LLVMUserExpression.cpp Mon Nov  2 13:30:40 2015<br>
@@ -0,0 +1,353 @@<br>
+//===-- LLVMUserExpression.cpp ----------------------------------*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+// C Includes<br>
+// C++ Includes<br>
+<br>
+// Project includes<br>
+#include "lldb/Expression/LLVMUserExpression.h"<br>
+#include "lldb/Core/ConstString.h"<br>
+#include "lldb/Core/Log.h"<br>
+#include "lldb/Core/Module.h"<br>
+#include "lldb/Core/StreamFile.h"<br>
+#include "lldb/Core/StreamString.h"<br>
+#include "lldb/Core/ValueObjectConstResult.h"<br>
+#include "lldb/Expression/ExpressionSourceCode.h"<br>
+#include "lldb/Expression/IRExecutionUnit.h"<br>
+#include "lldb/Expression/IRInterpreter.h"<br>
+#include "lldb/Expression/Materializer.h"<br>
+#include "lldb/Host/HostInfo.h"<br>
+#include "lldb/Symbol/Block.h"<br>
+#include "lldb/Symbol/ClangASTContext.h"<br>
+#include "lldb/Symbol/Function.h"<br>
+#include "lldb/Symbol/ObjectFile.h"<br>
+#include "lldb/Symbol/SymbolVendor.h"<br>
+#include "lldb/Symbol/Type.h"<br>
+#include "lldb/Symbol/ClangExternalASTSourceCommon.h"<br>
+#include "lldb/Symbol/VariableList.h"<br>
+#include "lldb/Target/ExecutionContext.h"<br>
+#include "lldb/Target/Process.h"<br>
+#include "lldb/Target/StackFrame.h"<br>
+#include "lldb/Target/Target.h"<br>
+#include "lldb/Target/ThreadPlan.h"<br>
+#include "lldb/Target/ThreadPlanCallUserExpression.h"<br>
+<br>
+using namespace lldb_private;<br>
+<br>
+LLVMUserExpression::LLVMUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,<br>
+                                       lldb::LanguageType language, ResultType desired_type)<br>
+    : UserExpression(exe_scope, expr, expr_prefix, language, desired_type),<br>
+      m_stack_frame_bottom(LLDB_INVALID_ADDRESS),<br>
+      m_stack_frame_top(LLDB_INVALID_ADDRESS),<br>
+      m_transformed_text(),<br>
+      m_execution_unit_sp(),<br>
+      m_materializer_ap(),<br>
+      m_jit_module_wp(),<br>
+      m_enforce_valid_object(true),<br>
+      m_in_cplusplus_method(false),<br>
+      m_in_objectivec_method(false),<br>
+      m_in_static_method(false),<br>
+      m_needs_object_ptr(false),<br>
+      m_const_object(false),<br>
+      m_target(NULL),<br>
+      m_can_interpret(false),<br>
+      m_materialized_address(LLDB_INVALID_ADDRESS)<br>
+{<br>
+}<br>
+<br>
+LLVMUserExpression::~LLVMUserExpression()<br>
+{<br>
+    if (m_target)<br>
+    {<br>
+        lldb::ModuleSP jit_module_sp(m_jit_module_wp.lock());<br>
+        if (jit_module_sp)<br>
+            m_target->GetImages().Remove(jit_module_sp);<br>
+    }<br>
+}<br>
+<br>
+lldb::ExpressionResults<br>
+LLVMUserExpression::Execute(Stream &error_stream, ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options,<br>
+                            lldb::UserExpressionSP &shared_ptr_to_me, lldb::ExpressionVariableSP &result)<br>
+{<br>
+    // The expression log is quite verbose, and if you're just tracking the execution of the<br>
+    // expression, it's quite convenient to have these logs come out with the STEP log as well.<br>
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));<br>
+<br>
+    if (m_jit_start_addr != LLDB_INVALID_ADDRESS || m_can_interpret)<br>
+    {<br>
+        lldb::addr_t struct_address = LLDB_INVALID_ADDRESS;<br>
+<br>
+        if (!PrepareToExecuteJITExpression(error_stream, exe_ctx, struct_address))<br>
+        {<br>
+            error_stream.Printf("Errored out in %s, couldn't PrepareToExecuteJITExpression", __FUNCTION__);<br>
+            return lldb::eExpressionSetupError;<br>
+        }<br>
+<br>
+        lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS;<br>
+        lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS;<br>
+<br>
+        if (m_can_interpret)<br>
+        {<br>
+            llvm::Module *module = m_execution_unit_sp->GetModule();<br>
+            llvm::Function *function = m_execution_unit_sp->GetFunction();<br>
+<br>
+            if (!module || !function)<br>
+            {<br>
+                error_stream.Printf("Supposed to interpret, but nothing is there");<br>
+                return lldb::eExpressionSetupError;<br>
+            }<br>
+<br>
+            Error interpreter_error;<br>
+<br>
+            std::vector<lldb::addr_t> args;<br>
+<br>
+            if (!AddInitialArguments(exe_ctx, args, error_stream))<br>
+            {<br>
+                error_stream.Printf("Errored out in %s, couldn't AddInitialArguments", __FUNCTION__);<br>
+                return lldb::eExpressionSetupError;<br>
+            }<br>
+<br>
+            args.push_back(struct_address);<br>
+<br>
+            function_stack_bottom = m_stack_frame_bottom;<br>
+            function_stack_top = m_stack_frame_top;<br>
+<br>
+            IRInterpreter::Interpret(*module, *function, args, *m_execution_unit_sp.get(), interpreter_error,<br>
+                                     function_stack_bottom, function_stack_top, exe_ctx);<br>
+<br>
+            if (!interpreter_error.Success())<br>
+            {<br>
+                error_stream.Printf("Supposed to interpret, but failed: %s", interpreter_error.AsCString());<br>
+                return lldb::eExpressionDiscarded;<br>
+            }<br>
+        }<br>
+        else<br>
+        {<br>
+            if (!exe_ctx.HasThreadScope())<br>
+            {<br>
+                error_stream.Printf("UserExpression::Execute called with no thread selected.");<br>
+                return lldb::eExpressionSetupError;<br>
+            }<br>
+<br>
+            Address wrapper_address(m_jit_start_addr);<br>
+<br>
+            std::vector<lldb::addr_t> args;<br>
+<br>
+            if (!AddInitialArguments(exe_ctx, args, error_stream))<br>
+            {<br>
+                error_stream.Printf("Errored out in %s, couldn't AddInitialArguments", __FUNCTION__);<br>
+                return lldb::eExpressionSetupError;<br>
+            }<br>
+<br>
+            args.push_back(struct_address);<br>
+<br>
+            lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression(exe_ctx.GetThreadRef(), wrapper_address,<br>
+                                                                             args, options, shared_ptr_to_me));<br>
+<br>
+            if (!call_plan_sp || !call_plan_sp->ValidatePlan(&error_stream))<br>
+                return lldb::eExpressionSetupError;<br>
+<br>
+            ThreadPlanCallUserExpression *user_expression_plan =<br>
+                static_cast<ThreadPlanCallUserExpression *>(call_plan_sp.get());<br>
+<br>
+            lldb::addr_t function_stack_pointer = user_expression_plan->GetFunctionStackPointer();<br>
+<br>
+            function_stack_bottom = function_stack_pointer - HostInfo::GetPageSize();<br>
+            function_stack_top = function_stack_pointer;<br>
+<br>
+            if (log)<br>
+                log->Printf("-- [UserExpression::Execute] Execution of expression begins --");<br>
+<br>
+            if (exe_ctx.GetProcessPtr())<br>
+                exe_ctx.GetProcessPtr()->SetRunningUserExpression(true);<br>
+<br>
+            lldb::ExpressionResults execution_result =<br>
+                exe_ctx.GetProcessRef().RunThreadPlan(exe_ctx, call_plan_sp, options, error_stream);<br>
+<br>
+            if (exe_ctx.GetProcessPtr())<br>
+                exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);<br>
+<br>
+            if (log)<br>
+                log->Printf("-- [UserExpression::Execute] Execution of expression completed --");<br>
+<br>
+            if (execution_result == lldb::eExpressionInterrupted || execution_result == lldb::eExpressionHitBreakpoint)<br>
+            {<br>
+                const char *error_desc = NULL;<br>
+<br>
+                if (call_plan_sp)<br>
+                {<br>
+                    lldb::StopInfoSP real_stop_info_sp = call_plan_sp->GetRealStopInfo();<br>
+                    if (real_stop_info_sp)<br>
+                        error_desc = real_stop_info_sp->GetDescription();<br>
+                }<br>
+                if (error_desc)<br>
+                    error_stream.Printf("Execution was interrupted, reason: %s.", error_desc);<br>
+                else<br>
+                    error_stream.PutCString("Execution was interrupted.");<br>
+<br>
+                if ((execution_result == lldb::eExpressionInterrupted && options.DoesUnwindOnError()) ||<br>
+                    (execution_result == lldb::eExpressionHitBreakpoint && options.DoesIgnoreBreakpoints()))<br>
+                    error_stream.PutCString(<br>
+                        "\nThe process has been returned to the state before expression evaluation.");<br>
+                else<br>
+                {<br>
+                    if (execution_result == lldb::eExpressionHitBreakpoint)<br>
+                        user_expression_plan->TransferExpressionOwnership();<br>
+                    error_stream.PutCString(<br>
+                        "\nThe process has been left at the point where it was interrupted, "<br>
+                        "use \"thread return -x\" to return to the state before expression evaluation.");<br>
+                }<br>
+<br>
+                return execution_result;<br>
+            }<br>
+            else if (execution_result == lldb::eExpressionStoppedForDebug)<br>
+            {<br>
+                error_stream.PutCString(<br>
+                    "Execution was halted at the first instruction of the expression "<br>
+                    "function because \"debug\" was requested.\n"<br>
+                    "Use \"thread return -x\" to return to the state before expression evaluation.");<br>
+                return execution_result;<br>
+            }<br>
+            else if (execution_result != lldb::eExpressionCompleted)<br>
+            {<br>
+                error_stream.Printf("Couldn't execute function; result was %s\n",<br>
+                                    Process::ExecutionResultAsCString(execution_result));<br>
+                return execution_result;<br>
+            }<br>
+        }<br>
+<br>
+        if (FinalizeJITExecution(error_stream, exe_ctx, result, function_stack_bottom, function_stack_top))<br>
+        {<br>
+            return lldb::eExpressionCompleted;<br>
+        }<br>
+        else<br>
+        {<br>
+            return lldb::eExpressionResultUnavailable;<br>
+        }<br>
+    }<br>
+    else<br>
+    {<br>
+        error_stream.Printf("Expression can't be run, because there is no JIT compiled function");<br>
+        return lldb::eExpressionSetupError;<br>
+    }<br>
+}<br>
+<br>
+bool<br>
+LLVMUserExpression::FinalizeJITExecution(Stream &error_stream, ExecutionContext &exe_ctx,<br>
+                                         lldb::ExpressionVariableSP &result, lldb::addr_t function_stack_bottom,<br>
+                                         lldb::addr_t function_stack_top)<br>
+{<br>
+    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));<br>
+<br>
+    if (log)<br>
+        log->Printf("-- [UserExpression::FinalizeJITExecution] Dematerializing after execution --");<br>
+<br>
+    if (!m_dematerializer_sp)<br>
+    {<br>
+        error_stream.Printf("Couldn't apply expression side effects : no dematerializer is present");<br>
+        return false;<br>
+    }<br>
+<br>
+    Error dematerialize_error;<br>
+<br>
+    m_dematerializer_sp->Dematerialize(dematerialize_error, function_stack_bottom, function_stack_top);<br>
+<br>
+    if (!dematerialize_error.Success())<br>
+    {<br>
+        error_stream.Printf("Couldn't apply expression side effects : %s\n",<br>
+                            dematerialize_error.AsCString("unknown error"));<br>
+        return false;<br>
+    }<br>
+<br>
+    result = GetResultAfterDematerialization(exe_ctx.GetBestExecutionContextScope());<br>
+<br>
+    if (result)<br>
+        result->TransferAddress();<br>
+<br>
+    m_dematerializer_sp.reset();<br>
+<br>
+    return true;<br>
+}<br>
+<br>
+bool<br>
+LLVMUserExpression::PrepareToExecuteJITExpression(Stream &error_stream, ExecutionContext &exe_ctx,<br>
+                                                  lldb::addr_t &struct_address)<br>
+{<br>
+    lldb::TargetSP target;<br>
+    lldb::ProcessSP process;<br>
+    lldb::StackFrameSP frame;<br>
+<br>
+    if (!LockAndCheckContext(exe_ctx, target, process, frame))<br>
+    {<br>
+        error_stream.Printf("The context has changed before we could JIT the expression!\n");<br>
+        return false;<br>
+    }<br>
+<br>
+    if (m_jit_start_addr != LLDB_INVALID_ADDRESS || m_can_interpret)<br>
+    {<br>
+        if (m_materialized_address == LLDB_INVALID_ADDRESS)<br>
+        {<br>
+            Error alloc_error;<br>
+<br>
+            IRMemoryMap::AllocationPolicy policy =<br>
+                m_can_interpret ? IRMemoryMap::eAllocationPolicyHostOnly : IRMemoryMap::eAllocationPolicyMirror;<br>
+<br>
+            m_materialized_address = m_execution_unit_sp->Malloc(<br>
+                m_materializer_ap->GetStructByteSize(), m_materializer_ap->GetStructAlignment(),<br>
+                lldb::ePermissionsReadable | lldb::ePermissionsWritable, policy, alloc_error);<br>
+<br>
+            if (!alloc_error.Success())<br>
+            {<br>
+                error_stream.Printf("Couldn't allocate space for materialized struct: %s\n", alloc_error.AsCString());<br>
+                return false;<br>
+            }<br>
+        }<br>
+<br>
+        struct_address = m_materialized_address;<br>
+<br>
+        if (m_can_interpret && m_stack_frame_bottom == LLDB_INVALID_ADDRESS)<br>
+        {<br>
+            Error alloc_error;<br>
+<br>
+            const size_t stack_frame_size = 512 * 1024;<br>
+<br>
+            m_stack_frame_bottom = m_execution_unit_sp->Malloc(stack_frame_size, 8,<br>
+                                                               lldb::ePermissionsReadable | lldb::ePermissionsWritable,<br>
+                                                               IRMemoryMap::eAllocationPolicyHostOnly, alloc_error);<br>
+<br>
+            m_stack_frame_top = m_stack_frame_bottom + stack_frame_size;<br>
+<br>
+            if (!alloc_error.Success())<br>
+            {<br>
+                error_stream.Printf("Couldn't allocate space for the stack frame: %s\n", alloc_error.AsCString());<br>
+                return false;<br>
+            }<br>
+        }<br>
+<br>
+        Error materialize_error;<br>
+<br>
+        m_dematerializer_sp =<br>
+            m_materializer_ap->Materialize(frame, *m_execution_unit_sp, struct_address, materialize_error);<br>
+<br>
+        if (!materialize_error.Success())<br>
+        {<br>
+            error_stream.Printf("Couldn't materialize: %s\n", materialize_error.AsCString());<br>
+            return false;<br>
+        }<br>
+    }<br>
+    return true;<br>
+}<br>
+<br>
+lldb::ModuleSP<br>
+LLVMUserExpression::GetJITModule()<br>
+{<br>
+    if (m_execution_unit_sp)<br>
+        return m_execution_unit_sp->GetJITModule();<br>
+    return lldb::ModuleSP();<br>
+}<br>
<br>
Modified: lldb/trunk/source/Expression/UserExpression.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/UserExpression.cpp?rev=251820&r1=251819&r2=251820&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/UserExpression.cpp?rev=251820&r1=251819&r2=251820&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Expression/UserExpression.cpp (original)<br>
+++ lldb/trunk/source/Expression/UserExpression.cpp Mon Nov  2 13:30:40 2015<br>
@@ -45,42 +45,18 @@<br>
<br>
 using namespace lldb_private;<br>
<br>
-UserExpression::UserExpression (ExecutionContextScope &exe_scope,<br>
-                                const char *expr,<br>
-                                const char *expr_prefix,<br>
-                                lldb::LanguageType language,<br>
-                                ResultType desired_type) :<br>
-    Expression (exe_scope),<br>
-    m_stack_frame_bottom (LLDB_INVALID_ADDRESS),<br>
-    m_stack_frame_top (LLDB_INVALID_ADDRESS),<br>
-    m_expr_text (expr),<br>
-    m_expr_prefix (expr_prefix ? expr_prefix : ""),<br>
-    m_language (language),<br>
-    m_transformed_text (),<br>
-    m_desired_type (desired_type),<br>
-    m_execution_unit_sp(),<br>
-    m_materializer_ap(),<br>
-    m_jit_module_wp(),<br>
-    m_enforce_valid_object (true),<br>
-    m_in_cplusplus_method (false),<br>
-    m_in_objectivec_method (false),<br>
-    m_in_static_method(false),<br>
-    m_needs_object_ptr (false),<br>
-    m_const_object (false),<br>
-    m_target (NULL),<br>
-    m_can_interpret (false),<br>
-    m_materialized_address (LLDB_INVALID_ADDRESS)<br>
+UserExpression::UserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,<br>
+                               lldb::LanguageType language, ResultType desired_type)<br>
+    : Expression(exe_scope),<br>
+      m_expr_text(expr),<br>
+      m_expr_prefix(expr_prefix ? expr_prefix : ""),<br>
+      m_language(language),<br>
+      m_desired_type(desired_type)<br>
 {<br>
 }<br>
<br>
 UserExpression::~UserExpression ()<br>
 {<br>
-    if (m_target)<br>
-    {<br>
-        lldb::ModuleSP jit_module_sp (m_jit_module_wp.lock());<br>
-        if (jit_module_sp)<br>
-            m_target->GetImages().Remove(jit_module_sp);<br>
-    }<br>
 }<br>
<br>
 void<br>
@@ -170,295 +146,6 @@ UserExpression::GetObjectPointer (lldb::<br>
     return ret;<br>
 }<br>
<br>
-bool<br>
-UserExpression::PrepareToExecuteJITExpression (Stream &error_stream,<br>
-                                                    ExecutionContext &exe_ctx,<br>
-                                                    lldb::addr_t &struct_address)<br>
-{<br>
-    lldb::TargetSP target;<br>
-    lldb::ProcessSP process;<br>
-    lldb::StackFrameSP frame;<br>
-<br>
-    if (!LockAndCheckContext(exe_ctx,<br>
-                             target,<br>
-                             process,<br>
-                             frame))<br>
-    {<br>
-        error_stream.Printf("The context has changed before we could JIT the expression!\n");<br>
-        return false;<br>
-    }<br>
-<br>
-    if (m_jit_start_addr != LLDB_INVALID_ADDRESS || m_can_interpret)<br>
-    {<br>
-        if (m_materialized_address == LLDB_INVALID_ADDRESS)<br>
-        {<br>
-            Error alloc_error;<br>
-<br>
-            IRMemoryMap::AllocationPolicy policy = m_can_interpret ? IRMemoryMap::eAllocationPolicyHostOnly : IRMemoryMap::eAllocationPolicyMirror;<br>
-<br>
-            m_materialized_address = m_execution_unit_sp->Malloc(m_materializer_ap->GetStructByteSize(),<br>
-                                                                 m_materializer_ap->GetStructAlignment(),<br>
-                                                                 lldb::ePermissionsReadable | lldb::ePermissionsWritable,<br>
-                                                                 policy,<br>
-                                                                 alloc_error);<br>
-<br>
-            if (!alloc_error.Success())<br>
-            {<br>
-                error_stream.Printf("Couldn't allocate space for materialized struct: %s\n", alloc_error.AsCString());<br>
-                return false;<br>
-            }<br>
-        }<br>
-<br>
-        struct_address = m_materialized_address;<br>
-<br>
-        if (m_can_interpret && m_stack_frame_bottom == LLDB_INVALID_ADDRESS)<br>
-        {<br>
-            Error alloc_error;<br>
-<br>
-            const size_t stack_frame_size = 512 * 1024;<br>
-<br>
-            m_stack_frame_bottom = m_execution_unit_sp->Malloc(stack_frame_size,<br>
-                                                               8,<br>
-                                                               lldb::ePermissionsReadable | lldb::ePermissionsWritable,<br>
-                                                               IRMemoryMap::eAllocationPolicyHostOnly,<br>
-                                                               alloc_error);<br>
-<br>
-            m_stack_frame_top = m_stack_frame_bottom + stack_frame_size;<br>
-<br>
-            if (!alloc_error.Success())<br>
-            {<br>
-                error_stream.Printf("Couldn't allocate space for the stack frame: %s\n", alloc_error.AsCString());<br>
-                return false;<br>
-            }<br>
-        }<br>
-<br>
-        Error materialize_error;<br>
-<br>
-        m_dematerializer_sp = m_materializer_ap->Materialize(frame, *m_execution_unit_sp, struct_address, materialize_error);<br>
-<br>
-        if (!materialize_error.Success())<br>
-        {<br>
-            error_stream.Printf("Couldn't materialize: %s\n", materialize_error.AsCString());<br>
-            return false;<br>
-        }<br>
-    }<br>
-    return true;<br>
-}<br>
-<br>
-bool<br>
-UserExpression::FinalizeJITExecution (Stream &error_stream,<br>
-                                           ExecutionContext &exe_ctx,<br>
-                                           lldb::ExpressionVariableSP &result,<br>
-                                           lldb::addr_t function_stack_bottom,<br>
-                                           lldb::addr_t function_stack_top)<br>
-{<br>
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));<br>
-<br>
-    if (log)<br>
-        log->Printf("-- [UserExpression::FinalizeJITExecution] Dematerializing after execution --");<br>
-<br>
-    if (!m_dematerializer_sp)<br>
-    {<br>
-        error_stream.Printf ("Couldn't apply expression side effects : no dematerializer is present");<br>
-        return false;<br>
-    }<br>
-<br>
-    Error dematerialize_error;<br>
-<br>
-    m_dematerializer_sp->Dematerialize(dematerialize_error, function_stack_bottom, function_stack_top);<br>
-<br>
-    if (!dematerialize_error.Success())<br>
-    {<br>
-        error_stream.Printf ("Couldn't apply expression side effects : %s\n", dematerialize_error.AsCString("unknown error"));<br>
-        return false;<br>
-    }<br>
-<br>
-    result = GetResultAfterDematerialization(exe_ctx.GetBestExecutionContextScope());<br>
-<br>
-    if (result)<br>
-        result->TransferAddress();<br>
-<br>
-    m_dematerializer_sp.reset();<br>
-<br>
-    return true;<br>
-}<br>
-<br>
-lldb::ExpressionResults<br>
-UserExpression::Execute (Stream &error_stream,<br>
-                              ExecutionContext &exe_ctx,<br>
-                              const EvaluateExpressionOptions& options,<br>
-                              lldb::UserExpressionSP &shared_ptr_to_me,<br>
-                              lldb::ExpressionVariableSP &result)<br>
-{<br>
-    // The expression log is quite verbose, and if you're just tracking the execution of the<br>
-    // expression, it's quite convenient to have these logs come out with the STEP log as well.<br>
-    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));<br>
-<br>
-    if (m_jit_start_addr != LLDB_INVALID_ADDRESS || m_can_interpret)<br>
-    {<br>
-        lldb::addr_t struct_address = LLDB_INVALID_ADDRESS;<br>
-<br>
-        if (!PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address))<br>
-        {<br>
-            error_stream.Printf("Errored out in %s, couldn't PrepareToExecuteJITExpression", __FUNCTION__);<br>
-            return lldb::eExpressionSetupError;<br>
-        }<br>
-<br>
-        lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS;<br>
-        lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS;<br>
-<br>
-        if (m_can_interpret)<br>
-        {<br>
-            llvm::Module *module = m_execution_unit_sp->GetModule();<br>
-            llvm::Function *function = m_execution_unit_sp->GetFunction();<br>
-<br>
-            if (!module || !function)<br>
-            {<br>
-                error_stream.Printf("Supposed to interpret, but nothing is there");<br>
-                return lldb::eExpressionSetupError;<br>
-            }<br>
-<br>
-            Error interpreter_error;<br>
-<br>
-            std::vector<lldb::addr_t> args;<br>
-<br>
-            if (!AddInitialArguments(exe_ctx, args, error_stream))<br>
-            {<br>
-                error_stream.Printf ("Errored out in %s, couldn't AddInitialArguments", __FUNCTION__);<br>
-                return lldb::eExpressionSetupError;<br>
-            }<br>
-<br>
-            args.push_back(struct_address);<br>
-<br>
-            function_stack_bottom = m_stack_frame_bottom;<br>
-            function_stack_top = m_stack_frame_top;<br>
-<br>
-            IRInterpreter::Interpret (*module,<br>
-                                      *function,<br>
-                                      args,<br>
-                                      *m_execution_unit_sp.get(),<br>
-                                      interpreter_error,<br>
-                                      function_stack_bottom,<br>
-                                      function_stack_top,<br>
-                                      exe_ctx);<br>
-<br>
-            if (!interpreter_error.Success())<br>
-            {<br>
-                error_stream.Printf("Supposed to interpret, but failed: %s", interpreter_error.AsCString());<br>
-                return lldb::eExpressionDiscarded;<br>
-            }<br>
-        }<br>
-        else<br>
-        {<br>
-            if (!exe_ctx.HasThreadScope())<br>
-            {<br>
-                error_stream.Printf("UserExpression::Execute called with no thread selected.");<br>
-                return lldb::eExpressionSetupError;<br>
-            }<br>
-<br>
-            Address wrapper_address (m_jit_start_addr);<br>
-<br>
-            std::vector<lldb::addr_t> args;<br>
-<br>
-            if (!AddInitialArguments(exe_ctx, args, error_stream))<br>
-            {<br>
-                error_stream.Printf ("Errored out in %s, couldn't AddInitialArguments", __FUNCTION__);<br>
-                return lldb::eExpressionSetupError;<br>
-            }<br>
-<br>
-            args.push_back(struct_address);<br>
-<br>
-            lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (exe_ctx.GetThreadRef(),<br>
-                                                                              wrapper_address,<br>
-                                                                              args,<br>
-                                                                              options,<br>
-                                                                              shared_ptr_to_me));<br>
-<br>
-            if (!call_plan_sp || !call_plan_sp->ValidatePlan (&error_stream))<br>
-                return lldb::eExpressionSetupError;<br>
-<br>
-            ThreadPlanCallUserExpression *user_expression_plan = static_cast<ThreadPlanCallUserExpression *>(call_plan_sp.get());<br>
-<br>
-            lldb::addr_t function_stack_pointer = user_expression_plan->GetFunctionStackPointer();<br>
-<br>
-            function_stack_bottom = function_stack_pointer - HostInfo::GetPageSize();<br>
-            function_stack_top = function_stack_pointer;<br>
-<br>
-            if (log)<br>
-                log->Printf("-- [UserExpression::Execute] Execution of expression begins --");<br>
-<br>
-            if (exe_ctx.GetProcessPtr())<br>
-                exe_ctx.GetProcessPtr()->SetRunningUserExpression(true);<br>
-<br>
-            lldb::ExpressionResults execution_result = exe_ctx.GetProcessRef().RunThreadPlan (exe_ctx,<br>
-                                                                                       call_plan_sp,<br>
-                                                                                       options,<br>
-                                                                                       error_stream);<br>
-<br>
-            if (exe_ctx.GetProcessPtr())<br>
-                exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);<br>
-<br>
-            if (log)<br>
-          </blockquote></div>
</div></div></blockquote></div><br></div>