Sean Callanan | 79763a4 | 2011-05-23 21:40:23 +0000 | [diff] [blame] | 1 | //===-- ClangUserExpression.cpp ---------------------------------*- C++ -*-===// |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
Haibo Huang | c6551bf | 2019-08-07 06:15:01 +0000 | [diff] [blame^] | 9 | #include "lldb/Host/Config.h" |
| 10 | |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 11 | #include <stdio.h> |
| 12 | #if HAVE_SYS_TYPES_H |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 13 | #include <sys/types.h> |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 14 | #endif |
| 15 | |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 16 | #include <cstdlib> |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 17 | #include <map> |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 18 | #include <string> |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 19 | |
Sean Callanan | 4dbb271 | 2015-09-25 20:35:58 +0000 | [diff] [blame] | 20 | #include "ClangUserExpression.h" |
| 21 | |
| 22 | #include "ASTResultSynthesizer.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 23 | #include "ClangDiagnostic.h" |
Sean Callanan | 4dbb271 | 2015-09-25 20:35:58 +0000 | [diff] [blame] | 24 | #include "ClangExpressionDeclMap.h" |
| 25 | #include "ClangExpressionParser.h" |
Jim Ingham | ea401ec | 2019-03-06 22:43:25 +0000 | [diff] [blame] | 26 | #include "ClangExpressionSourceCode.h" |
Sean Callanan | 4dbb271 | 2015-09-25 20:35:58 +0000 | [diff] [blame] | 27 | #include "ClangModulesDeclVendor.h" |
| 28 | #include "ClangPersistentVariables.h" |
| 29 | |
Sean Callanan | bda7ef8 | 2016-06-22 17:32:17 +0000 | [diff] [blame] | 30 | #include "lldb/Core/Debugger.h" |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 31 | #include "lldb/Core/Module.h" |
Greg Clayton | c4e411f | 2011-01-18 19:36:39 +0000 | [diff] [blame] | 32 | #include "lldb/Core/StreamFile.h" |
Greg Clayton | b71f384 | 2010-10-05 03:13:51 +0000 | [diff] [blame] | 33 | #include "lldb/Core/ValueObjectConstResult.h" |
Sean Callanan | 9bc8384 | 2011-09-26 18:45:31 +0000 | [diff] [blame] | 34 | #include "lldb/Expression/ExpressionSourceCode.h" |
Sean Callanan | 14b1bae | 2013-04-16 23:25:35 +0000 | [diff] [blame] | 35 | #include "lldb/Expression/IRExecutionUnit.h" |
Sean Callanan | 1582ee6 | 2013-04-18 22:06:33 +0000 | [diff] [blame] | 36 | #include "lldb/Expression/IRInterpreter.h" |
Sean Callanan | 96d2730 | 2013-04-11 00:09:05 +0000 | [diff] [blame] | 37 | #include "lldb/Expression/Materializer.h" |
Zachary Turner | 97a14e6 | 2014-08-19 17:18:29 +0000 | [diff] [blame] | 38 | #include "lldb/Host/HostInfo.h" |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 39 | #include "lldb/Symbol/Block.h" |
Jim Ingham | 5fdeed4 | 2012-10-30 23:35:54 +0000 | [diff] [blame] | 40 | #include "lldb/Symbol/ClangASTContext.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 41 | #include "lldb/Symbol/ClangExternalASTSourceCommon.h" |
Raphael Isemann | 6c0bbfc | 2019-03-12 17:09:33 +0000 | [diff] [blame] | 42 | #include "lldb/Symbol/CompileUnit.h" |
Jim Ingham | 5fdeed4 | 2012-10-30 23:35:54 +0000 | [diff] [blame] | 43 | #include "lldb/Symbol/Function.h" |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 44 | #include "lldb/Symbol/ObjectFile.h" |
| 45 | #include "lldb/Symbol/SymbolVendor.h" |
Jim Ingham | 5fdeed4 | 2012-10-30 23:35:54 +0000 | [diff] [blame] | 46 | #include "lldb/Symbol/Type.h" |
Sean Callanan | fc55f5d | 2010-09-21 00:44:12 +0000 | [diff] [blame] | 47 | #include "lldb/Symbol/VariableList.h" |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 48 | #include "lldb/Target/ExecutionContext.h" |
Greg Clayton | 8f343b0 | 2010-11-04 01:54:29 +0000 | [diff] [blame] | 49 | #include "lldb/Target/Process.h" |
Jason Molenda | b57e4a1 | 2013-11-04 09:33:30 +0000 | [diff] [blame] | 50 | #include "lldb/Target/StackFrame.h" |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 51 | #include "lldb/Target/Target.h" |
Jim Ingham | f48169b | 2010-11-30 02:22:11 +0000 | [diff] [blame] | 52 | #include "lldb/Target/ThreadPlan.h" |
| 53 | #include "lldb/Target/ThreadPlanCallUserExpression.h" |
Zachary Turner | bf9a773 | 2017-02-02 21:39:50 +0000 | [diff] [blame] | 54 | #include "lldb/Utility/ConstString.h" |
Zachary Turner | 6f9e690 | 2017-03-03 20:56:28 +0000 | [diff] [blame] | 55 | #include "lldb/Utility/Log.h" |
Zachary Turner | bf9a773 | 2017-02-02 21:39:50 +0000 | [diff] [blame] | 56 | #include "lldb/Utility/StreamString.h" |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 57 | |
Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 58 | #include "clang/AST/DeclCXX.h" |
| 59 | #include "clang/AST/DeclObjC.h" |
| 60 | |
Tatyana Krasnukha | edebf12 | 2019-04-26 16:41:04 +0000 | [diff] [blame] | 61 | #include "llvm/ADT/ScopeExit.h" |
| 62 | |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 63 | using namespace lldb_private; |
| 64 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 65 | ClangUserExpression::ClangUserExpression( |
Zachary Turner | c5d7df9 | 2016-11-08 04:52:16 +0000 | [diff] [blame] | 66 | ExecutionContextScope &exe_scope, llvm::StringRef expr, |
| 67 | llvm::StringRef prefix, lldb::LanguageType language, |
Aleksandr Urakov | 40624a0 | 2019-02-05 09:14:36 +0000 | [diff] [blame] | 68 | ResultType desired_type, const EvaluateExpressionOptions &options, |
| 69 | ValueObject *ctx_obj) |
Zachary Turner | c5d7df9 | 2016-11-08 04:52:16 +0000 | [diff] [blame] | 70 | : LLVMUserExpression(exe_scope, expr, prefix, language, desired_type, |
Adrian Prantl | 7e34d78 | 2019-03-13 19:46:30 +0000 | [diff] [blame] | 71 | options, eKindClangUserExpression), |
Jonas Devlieghere | 70355ac | 2019-02-12 03:47:39 +0000 | [diff] [blame] | 72 | m_type_system_helper(*m_target_wp.lock(), options.GetExecutionPolicy() == |
| 73 | eExecutionPolicyTopLevel), |
| 74 | m_result_delegate(exe_scope.CalculateTarget()), m_ctx_obj(ctx_obj) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 75 | switch (m_language) { |
| 76 | case lldb::eLanguageTypeC_plus_plus: |
| 77 | m_allow_cxx = true; |
| 78 | break; |
| 79 | case lldb::eLanguageTypeObjC: |
| 80 | m_allow_objc = true; |
| 81 | break; |
| 82 | case lldb::eLanguageTypeObjC_plus_plus: |
| 83 | default: |
| 84 | m_allow_cxx = true; |
| 85 | m_allow_objc = true; |
| 86 | break; |
| 87 | } |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 88 | } |
| 89 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 90 | ClangUserExpression::~ClangUserExpression() {} |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 91 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 92 | void ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Status &err) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 93 | Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); |
Sean Callanan | 7038508 | 2012-12-01 00:08:33 +0000 | [diff] [blame] | 94 | |
Jonas Devlieghere | 63e5fb7 | 2019-07-24 17:56:10 +0000 | [diff] [blame] | 95 | LLDB_LOGF(log, "ClangUserExpression::ScanContext()"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 96 | |
| 97 | m_target = exe_ctx.GetTargetPtr(); |
| 98 | |
| 99 | if (!(m_allow_cxx || m_allow_objc)) { |
Jonas Devlieghere | 63e5fb7 | 2019-07-24 17:56:10 +0000 | [diff] [blame] | 100 | LLDB_LOGF(log, " [CUE::SC] Settings inhibit C++ and Objective-C"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 101 | return; |
| 102 | } |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 103 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 104 | StackFrame *frame = exe_ctx.GetFramePtr(); |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 105 | if (frame == nullptr) { |
Jonas Devlieghere | 63e5fb7 | 2019-07-24 17:56:10 +0000 | [diff] [blame] | 106 | LLDB_LOGF(log, " [CUE::SC] Null stack frame"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 107 | return; |
| 108 | } |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 109 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 110 | SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction | |
| 111 | lldb::eSymbolContextBlock); |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 112 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 113 | if (!sym_ctx.function) { |
Jonas Devlieghere | 63e5fb7 | 2019-07-24 17:56:10 +0000 | [diff] [blame] | 114 | LLDB_LOGF(log, " [CUE::SC] Null function"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 115 | return; |
| 116 | } |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 117 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 118 | // Find the block that defines the function represented by "sym_ctx" |
| 119 | Block *function_block = sym_ctx.GetFunctionBlock(); |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 120 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 121 | if (!function_block) { |
Jonas Devlieghere | 63e5fb7 | 2019-07-24 17:56:10 +0000 | [diff] [blame] | 122 | LLDB_LOGF(log, " [CUE::SC] Null function block"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 123 | return; |
| 124 | } |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 125 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 126 | CompilerDeclContext decl_context = function_block->GetDeclContext(); |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 127 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 128 | if (!decl_context) { |
Jonas Devlieghere | 63e5fb7 | 2019-07-24 17:56:10 +0000 | [diff] [blame] | 129 | LLDB_LOGF(log, " [CUE::SC] Null decl context"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 130 | return; |
| 131 | } |
Greg Clayton | 685c88c | 2012-07-14 00:53:55 +0000 | [diff] [blame] | 132 | |
Aleksandr Urakov | 40624a0 | 2019-02-05 09:14:36 +0000 | [diff] [blame] | 133 | if (m_ctx_obj) { |
| 134 | switch (m_ctx_obj->GetObjectRuntimeLanguage()) { |
| 135 | case lldb::eLanguageTypeC: |
| 136 | case lldb::eLanguageTypeC89: |
| 137 | case lldb::eLanguageTypeC99: |
| 138 | case lldb::eLanguageTypeC11: |
| 139 | case lldb::eLanguageTypeC_plus_plus: |
| 140 | case lldb::eLanguageTypeC_plus_plus_03: |
| 141 | case lldb::eLanguageTypeC_plus_plus_11: |
| 142 | case lldb::eLanguageTypeC_plus_plus_14: |
| 143 | m_in_cplusplus_method = true; |
| 144 | break; |
| 145 | case lldb::eLanguageTypeObjC: |
| 146 | case lldb::eLanguageTypeObjC_plus_plus: |
| 147 | m_in_objectivec_method = true; |
| 148 | break; |
| 149 | default: |
| 150 | break; |
| 151 | } |
| 152 | m_needs_object_ptr = true; |
| 153 | } else if (clang::CXXMethodDecl *method_decl = |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 154 | ClangASTContext::DeclContextGetAsCXXMethodDecl(decl_context)) { |
| 155 | if (m_allow_cxx && method_decl->isInstance()) { |
| 156 | if (m_enforce_valid_object) { |
| 157 | lldb::VariableListSP variable_list_sp( |
| 158 | function_block->GetBlockVariableList(true)); |
Greg Clayton | 685c88c | 2012-07-14 00:53:55 +0000 | [diff] [blame] | 159 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 160 | const char *thisErrorString = "Stopped in a C++ method, but 'this' " |
| 161 | "isn't available; pretending we are in a " |
| 162 | "generic context"; |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 163 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 164 | if (!variable_list_sp) { |
| 165 | err.SetErrorString(thisErrorString); |
| 166 | return; |
Sean Callanan | 3670ba5 | 2010-12-01 21:35:54 +0000 | [diff] [blame] | 167 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 168 | |
| 169 | lldb::VariableSP this_var_sp( |
| 170 | variable_list_sp->FindVariable(ConstString("this"))); |
| 171 | |
| 172 | if (!this_var_sp || !this_var_sp->IsInScope(frame) || |
| 173 | !this_var_sp->LocationIsValidForFrame(frame)) { |
| 174 | err.SetErrorString(thisErrorString); |
| 175 | return; |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | m_in_cplusplus_method = true; |
| 180 | m_needs_object_ptr = true; |
Sean Callanan | 3670ba5 | 2010-12-01 21:35:54 +0000 | [diff] [blame] | 181 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 182 | } else if (clang::ObjCMethodDecl *method_decl = |
| 183 | ClangASTContext::DeclContextGetAsObjCMethodDecl( |
| 184 | decl_context)) { |
| 185 | if (m_allow_objc) { |
| 186 | if (m_enforce_valid_object) { |
| 187 | lldb::VariableListSP variable_list_sp( |
| 188 | function_block->GetBlockVariableList(true)); |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 189 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 190 | const char *selfErrorString = "Stopped in an Objective-C method, but " |
| 191 | "'self' isn't available; pretending we " |
| 192 | "are in a generic context"; |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 193 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 194 | if (!variable_list_sp) { |
| 195 | err.SetErrorString(selfErrorString); |
| 196 | return; |
| 197 | } |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 198 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 199 | lldb::VariableSP self_variable_sp = |
| 200 | variable_list_sp->FindVariable(ConstString("self")); |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 201 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 202 | if (!self_variable_sp || !self_variable_sp->IsInScope(frame) || |
| 203 | !self_variable_sp->LocationIsValidForFrame(frame)) { |
| 204 | err.SetErrorString(selfErrorString); |
| 205 | return; |
| 206 | } |
| 207 | } |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 208 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 209 | m_in_objectivec_method = true; |
| 210 | m_needs_object_ptr = true; |
| 211 | |
| 212 | if (!method_decl->isInstanceMethod()) |
| 213 | m_in_static_method = true; |
| 214 | } |
| 215 | } else if (clang::FunctionDecl *function_decl = |
| 216 | ClangASTContext::DeclContextGetAsFunctionDecl(decl_context)) { |
| 217 | // We might also have a function that said in the debug information that it |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 218 | // captured an object pointer. The best way to deal with getting to the |
| 219 | // ivars at present is by pretending that this is a method of a class in |
| 220 | // whatever runtime the debug info says the object pointer belongs to. Do |
| 221 | // that here. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 222 | |
| 223 | ClangASTMetadata *metadata = |
| 224 | ClangASTContext::DeclContextGetMetaData(decl_context, function_decl); |
| 225 | if (metadata && metadata->HasObjectPtr()) { |
| 226 | lldb::LanguageType language = metadata->GetObjectPtrLanguage(); |
| 227 | if (language == lldb::eLanguageTypeC_plus_plus) { |
| 228 | if (m_enforce_valid_object) { |
| 229 | lldb::VariableListSP variable_list_sp( |
| 230 | function_block->GetBlockVariableList(true)); |
| 231 | |
| 232 | const char *thisErrorString = "Stopped in a context claiming to " |
| 233 | "capture a C++ object pointer, but " |
| 234 | "'this' isn't available; pretending we " |
| 235 | "are in a generic context"; |
| 236 | |
| 237 | if (!variable_list_sp) { |
| 238 | err.SetErrorString(thisErrorString); |
| 239 | return; |
| 240 | } |
| 241 | |
| 242 | lldb::VariableSP this_var_sp( |
| 243 | variable_list_sp->FindVariable(ConstString("this"))); |
| 244 | |
| 245 | if (!this_var_sp || !this_var_sp->IsInScope(frame) || |
| 246 | !this_var_sp->LocationIsValidForFrame(frame)) { |
| 247 | err.SetErrorString(thisErrorString); |
| 248 | return; |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | m_in_cplusplus_method = true; |
| 253 | m_needs_object_ptr = true; |
| 254 | } else if (language == lldb::eLanguageTypeObjC) { |
| 255 | if (m_enforce_valid_object) { |
| 256 | lldb::VariableListSP variable_list_sp( |
| 257 | function_block->GetBlockVariableList(true)); |
| 258 | |
| 259 | const char *selfErrorString = |
| 260 | "Stopped in a context claiming to capture an Objective-C object " |
| 261 | "pointer, but 'self' isn't available; pretending we are in a " |
| 262 | "generic context"; |
| 263 | |
| 264 | if (!variable_list_sp) { |
| 265 | err.SetErrorString(selfErrorString); |
| 266 | return; |
| 267 | } |
| 268 | |
| 269 | lldb::VariableSP self_variable_sp = |
| 270 | variable_list_sp->FindVariable(ConstString("self")); |
| 271 | |
| 272 | if (!self_variable_sp || !self_variable_sp->IsInScope(frame) || |
| 273 | !self_variable_sp->LocationIsValidForFrame(frame)) { |
| 274 | err.SetErrorString(selfErrorString); |
| 275 | return; |
| 276 | } |
| 277 | |
| 278 | Type *self_type = self_variable_sp->GetType(); |
| 279 | |
| 280 | if (!self_type) { |
| 281 | err.SetErrorString(selfErrorString); |
| 282 | return; |
| 283 | } |
| 284 | |
| 285 | CompilerType self_clang_type = self_type->GetForwardCompilerType(); |
| 286 | |
| 287 | if (!self_clang_type) { |
| 288 | err.SetErrorString(selfErrorString); |
| 289 | return; |
| 290 | } |
| 291 | |
| 292 | if (ClangASTContext::IsObjCClassType(self_clang_type)) { |
| 293 | return; |
| 294 | } else if (ClangASTContext::IsObjCObjectPointerType( |
| 295 | self_clang_type)) { |
Dawn Perchik | 53f34c8 | 2015-07-01 00:54:02 +0000 | [diff] [blame] | 296 | m_in_objectivec_method = true; |
Sean Callanan | 9bc8384 | 2011-09-26 18:45:31 +0000 | [diff] [blame] | 297 | m_needs_object_ptr = true; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 298 | } else { |
| 299 | err.SetErrorString(selfErrorString); |
| 300 | return; |
| 301 | } |
| 302 | } else { |
| 303 | m_in_objectivec_method = true; |
| 304 | m_needs_object_ptr = true; |
Sean Callanan | 9bc8384 | 2011-09-26 18:45:31 +0000 | [diff] [blame] | 305 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 306 | } |
Sean Callanan | 3670ba5 | 2010-12-01 21:35:54 +0000 | [diff] [blame] | 307 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 308 | } |
Sean Callanan | fc55f5d | 2010-09-21 00:44:12 +0000 | [diff] [blame] | 309 | } |
| 310 | |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 311 | // This is a really nasty hack, meant to fix Objective-C expressions of the |
| 312 | // form (int)[myArray count]. Right now, because the type information for |
| 313 | // count is not available, [myArray count] returns id, which can't be directly |
| 314 | // cast to int without causing a clang error. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 315 | static void ApplyObjcCastHack(std::string &expr) { |
Sean Callanan | cf5498f | 2010-10-22 23:25:16 +0000 | [diff] [blame] | 316 | #define OBJC_CAST_HACK_FROM "(int)[" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 317 | #define OBJC_CAST_HACK_TO "(int)(long long)[" |
Sean Callanan | cf5498f | 2010-10-22 23:25:16 +0000 | [diff] [blame] | 318 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 319 | size_t from_offset; |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 320 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 321 | while ((from_offset = expr.find(OBJC_CAST_HACK_FROM)) != expr.npos) |
| 322 | expr.replace(from_offset, sizeof(OBJC_CAST_HACK_FROM) - 1, |
| 323 | OBJC_CAST_HACK_TO); |
Sean Callanan | cf5498f | 2010-10-22 23:25:16 +0000 | [diff] [blame] | 324 | |
| 325 | #undef OBJC_CAST_HACK_TO |
| 326 | #undef OBJC_CAST_HACK_FROM |
| 327 | } |
| 328 | |
Raphael Isemann | ba800e7d | 2018-07-10 22:12:39 +0000 | [diff] [blame] | 329 | bool ClangUserExpression::SetupPersistentState(DiagnosticManager &diagnostic_manager, |
| 330 | ExecutionContext &exe_ctx) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 331 | if (Target *target = exe_ctx.GetTargetPtr()) { |
| 332 | if (PersistentExpressionState *persistent_state = |
| 333 | target->GetPersistentExpressionStateForLanguage( |
| 334 | lldb::eLanguageTypeC)) { |
| 335 | m_result_delegate.RegisterPersistentState(persistent_state); |
| 336 | } else { |
Zachary Turner | e2411fa | 2016-11-12 19:12:56 +0000 | [diff] [blame] | 337 | diagnostic_manager.PutString( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 338 | eDiagnosticSeverityError, |
| 339 | "couldn't start parsing (no persistent data)"); |
| 340 | return false; |
Sean Callanan | 9fda9d2 | 2015-10-03 09:09:01 +0000 | [diff] [blame] | 341 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 342 | } else { |
Zachary Turner | e2411fa | 2016-11-12 19:12:56 +0000 | [diff] [blame] | 343 | diagnostic_manager.PutString(eDiagnosticSeverityError, |
| 344 | "error: couldn't start parsing (no target)"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 345 | return false; |
| 346 | } |
Raphael Isemann | ba800e7d | 2018-07-10 22:12:39 +0000 | [diff] [blame] | 347 | return true; |
| 348 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 349 | |
Raphael Isemann | ba800e7d | 2018-07-10 22:12:39 +0000 | [diff] [blame] | 350 | static void SetupDeclVendor(ExecutionContext &exe_ctx, Target *target) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 351 | if (ClangModulesDeclVendor *decl_vendor = |
Raphael Isemann | ba800e7d | 2018-07-10 22:12:39 +0000 | [diff] [blame] | 352 | target->GetClangModulesDeclVendor()) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 353 | const ClangModulesDeclVendor::ModuleVector &hand_imported_modules = |
| 354 | llvm::cast<ClangPersistentVariables>( |
Raphael Isemann | ba800e7d | 2018-07-10 22:12:39 +0000 | [diff] [blame] | 355 | target->GetPersistentExpressionStateForLanguage( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 356 | lldb::eLanguageTypeC)) |
| 357 | ->GetHandLoadedClangModules(); |
| 358 | ClangModulesDeclVendor::ModuleVector modules_for_macros; |
| 359 | |
| 360 | for (ClangModulesDeclVendor::ModuleID module : hand_imported_modules) { |
| 361 | modules_for_macros.push_back(module); |
| 362 | } |
| 363 | |
Raphael Isemann | ba800e7d | 2018-07-10 22:12:39 +0000 | [diff] [blame] | 364 | if (target->GetEnableAutoImportClangModules()) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 365 | if (StackFrame *frame = exe_ctx.GetFramePtr()) { |
| 366 | if (Block *block = frame->GetFrameBlock()) { |
| 367 | SymbolContext sc; |
| 368 | |
| 369 | block->CalculateSymbolContext(&sc); |
| 370 | |
| 371 | if (sc.comp_unit) { |
| 372 | StreamString error_stream; |
| 373 | |
| 374 | decl_vendor->AddModulesForCompileUnit( |
| 375 | *sc.comp_unit, modules_for_macros, error_stream); |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | } |
Raphael Isemann | ba800e7d | 2018-07-10 22:12:39 +0000 | [diff] [blame] | 381 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 382 | |
Raphael Isemann | 5eb87cf | 2019-08-05 20:31:47 +0000 | [diff] [blame] | 383 | void ClangUserExpression::UpdateLanguageForExpr() { |
| 384 | m_expr_lang = lldb::LanguageType::eLanguageTypeUnknown; |
| 385 | if (m_options.GetExecutionPolicy() == eExecutionPolicyTopLevel) |
| 386 | return; |
| 387 | if (m_in_cplusplus_method) |
| 388 | m_expr_lang = lldb::eLanguageTypeC_plus_plus; |
| 389 | else if (m_in_objectivec_method) |
| 390 | m_expr_lang = lldb::eLanguageTypeObjC; |
| 391 | else |
| 392 | m_expr_lang = lldb::eLanguageTypeC; |
| 393 | } |
| 394 | |
| 395 | void ClangUserExpression::CreateSourceCode( |
Raphael Isemann | 6c0bbfc | 2019-03-12 17:09:33 +0000 | [diff] [blame] | 396 | DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, |
Raphael Isemann | 71569d0 | 2019-05-02 10:12:56 +0000 | [diff] [blame] | 397 | std::vector<std::string> modules_to_import, bool for_completion) { |
Raphael Isemann | ba800e7d | 2018-07-10 22:12:39 +0000 | [diff] [blame] | 398 | |
| 399 | std::string prefix = m_expr_prefix; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 400 | |
| 401 | if (m_options.GetExecutionPolicy() == eExecutionPolicyTopLevel) { |
| 402 | m_transformed_text = m_expr_text; |
| 403 | } else { |
Jim Ingham | ea401ec | 2019-03-06 22:43:25 +0000 | [diff] [blame] | 404 | std::unique_ptr<ClangExpressionSourceCode> source_code( |
| 405 | ClangExpressionSourceCode::CreateWrapped(prefix.c_str(), |
Raphael Isemann | 5eb87cf | 2019-08-05 20:31:47 +0000 | [diff] [blame] | 406 | m_expr_text.c_str())); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 407 | |
Raphael Isemann | dababf7 | 2018-09-27 10:12:54 +0000 | [diff] [blame] | 408 | if (!source_code->GetText(m_transformed_text, m_expr_lang, |
Raphael Isemann | 6c0bbfc | 2019-03-12 17:09:33 +0000 | [diff] [blame] | 409 | m_in_static_method, exe_ctx, !m_ctx_obj, |
Raphael Isemann | 71569d0 | 2019-05-02 10:12:56 +0000 | [diff] [blame] | 410 | for_completion, modules_to_import)) { |
Zachary Turner | e2411fa | 2016-11-12 19:12:56 +0000 | [diff] [blame] | 411 | diagnostic_manager.PutString(eDiagnosticSeverityError, |
| 412 | "couldn't construct expression body"); |
Raphael Isemann | dababf7 | 2018-09-27 10:12:54 +0000 | [diff] [blame] | 413 | return; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 414 | } |
Raphael Isemann | 7482973 | 2018-08-30 17:29:37 +0000 | [diff] [blame] | 415 | |
| 416 | // Find and store the start position of the original code inside the |
| 417 | // transformed code. We need this later for the code completion. |
| 418 | std::size_t original_start; |
| 419 | std::size_t original_end; |
| 420 | bool found_bounds = source_code->GetOriginalBodyBounds( |
Raphael Isemann | dababf7 | 2018-09-27 10:12:54 +0000 | [diff] [blame] | 421 | m_transformed_text, m_expr_lang, original_start, original_end); |
Raphael Isemann | d59c8d3 | 2019-04-24 12:55:00 +0000 | [diff] [blame] | 422 | if (found_bounds) |
Raphael Isemann | 7482973 | 2018-08-30 17:29:37 +0000 | [diff] [blame] | 423 | m_user_expression_start_pos = original_start; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 424 | } |
Raphael Isemann | ba800e7d | 2018-07-10 22:12:39 +0000 | [diff] [blame] | 425 | } |
| 426 | |
Raphael Isemann | 6c0bbfc | 2019-03-12 17:09:33 +0000 | [diff] [blame] | 427 | static bool SupportsCxxModuleImport(lldb::LanguageType language) { |
| 428 | switch (language) { |
| 429 | case lldb::eLanguageTypeC_plus_plus: |
| 430 | case lldb::eLanguageTypeC_plus_plus_03: |
| 431 | case lldb::eLanguageTypeC_plus_plus_11: |
| 432 | case lldb::eLanguageTypeC_plus_plus_14: |
| 433 | case lldb::eLanguageTypeObjC_plus_plus: |
| 434 | return true; |
| 435 | default: |
| 436 | return false; |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | std::vector<std::string> |
| 441 | ClangUserExpression::GetModulesToImport(ExecutionContext &exe_ctx) { |
| 442 | Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); |
| 443 | |
| 444 | if (!SupportsCxxModuleImport(Language())) |
| 445 | return {}; |
| 446 | |
| 447 | Target *target = exe_ctx.GetTargetPtr(); |
| 448 | if (!target || !target->GetEnableImportStdModule()) |
| 449 | return {}; |
| 450 | |
| 451 | StackFrame *frame = exe_ctx.GetFramePtr(); |
| 452 | if (!frame) |
| 453 | return {}; |
| 454 | |
| 455 | Block *block = frame->GetFrameBlock(); |
| 456 | if (!block) |
| 457 | return {}; |
| 458 | |
| 459 | SymbolContext sc; |
| 460 | block->CalculateSymbolContext(&sc); |
| 461 | if (!sc.comp_unit) |
| 462 | return {}; |
| 463 | |
| 464 | if (log) { |
| 465 | for (const SourceModule &m : sc.comp_unit->GetImportedModules()) { |
| 466 | LLDB_LOG(log, "Found module in compile unit: {0:$[.]} - include dir: {1}", |
| 467 | llvm::make_range(m.path.begin(), m.path.end()), m.search_path); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | for (const SourceModule &m : sc.comp_unit->GetImportedModules()) |
| 472 | m_include_directories.push_back(m.search_path); |
| 473 | |
| 474 | // Check if we imported 'std' or any of its submodules. |
| 475 | // We currently don't support importing any other modules in the expression |
| 476 | // parser. |
| 477 | for (const SourceModule &m : sc.comp_unit->GetImportedModules()) |
Raphael Isemann | 05cfdb0 | 2019-04-26 07:21:36 +0000 | [diff] [blame] | 478 | if (!m.path.empty() && m.path.front() == "std") |
Raphael Isemann | 6c0bbfc | 2019-03-12 17:09:33 +0000 | [diff] [blame] | 479 | return {"std"}; |
| 480 | |
| 481 | return {}; |
| 482 | } |
| 483 | |
Raphael Isemann | ba800e7d | 2018-07-10 22:12:39 +0000 | [diff] [blame] | 484 | bool ClangUserExpression::PrepareForParsing( |
Raphael Isemann | 71569d0 | 2019-05-02 10:12:56 +0000 | [diff] [blame] | 485 | DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, |
| 486 | bool for_completion) { |
Raphael Isemann | 6c0bbfc | 2019-03-12 17:09:33 +0000 | [diff] [blame] | 487 | Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); |
| 488 | |
Raphael Isemann | ba800e7d | 2018-07-10 22:12:39 +0000 | [diff] [blame] | 489 | InstallContext(exe_ctx); |
| 490 | |
| 491 | if (!SetupPersistentState(diagnostic_manager, exe_ctx)) |
| 492 | return false; |
| 493 | |
| 494 | Status err; |
| 495 | ScanContext(exe_ctx, err); |
| 496 | |
| 497 | if (!err.Success()) { |
| 498 | diagnostic_manager.PutString(eDiagnosticSeverityWarning, err.AsCString()); |
| 499 | } |
| 500 | |
| 501 | //////////////////////////////////// |
| 502 | // Generate the expression |
| 503 | // |
| 504 | |
| 505 | ApplyObjcCastHack(m_expr_text); |
| 506 | |
| 507 | SetupDeclVendor(exe_ctx, m_target); |
Raphael Isemann | dababf7 | 2018-09-27 10:12:54 +0000 | [diff] [blame] | 508 | |
Raphael Isemann | 6c0bbfc | 2019-03-12 17:09:33 +0000 | [diff] [blame] | 509 | std::vector<std::string> used_modules = GetModulesToImport(exe_ctx); |
| 510 | m_imported_cpp_modules = !used_modules.empty(); |
| 511 | |
| 512 | LLDB_LOG(log, "List of imported modules in expression: {0}", |
| 513 | llvm::make_range(used_modules.begin(), used_modules.end())); |
| 514 | |
Raphael Isemann | 5eb87cf | 2019-08-05 20:31:47 +0000 | [diff] [blame] | 515 | UpdateLanguageForExpr(); |
| 516 | CreateSourceCode(diagnostic_manager, exe_ctx, used_modules, for_completion); |
Raphael Isemann | ba800e7d | 2018-07-10 22:12:39 +0000 | [diff] [blame] | 517 | return true; |
| 518 | } |
| 519 | |
| 520 | bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, |
| 521 | ExecutionContext &exe_ctx, |
| 522 | lldb_private::ExecutionPolicy execution_policy, |
| 523 | bool keep_result_in_memory, |
| 524 | bool generate_debug_info) { |
| 525 | Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); |
| 526 | |
Raphael Isemann | 71569d0 | 2019-05-02 10:12:56 +0000 | [diff] [blame] | 527 | if (!PrepareForParsing(diagnostic_manager, exe_ctx, /*for_completion*/ false)) |
Raphael Isemann | ba800e7d | 2018-07-10 22:12:39 +0000 | [diff] [blame] | 528 | return false; |
| 529 | |
Jonas Devlieghere | 63e5fb7 | 2019-07-24 17:56:10 +0000 | [diff] [blame] | 530 | LLDB_LOGF(log, "Parsing the following code:\n%s", m_transformed_text.c_str()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 531 | |
| 532 | //////////////////////////////////// |
| 533 | // Set up the target and compiler |
| 534 | // |
| 535 | |
| 536 | Target *target = exe_ctx.GetTargetPtr(); |
| 537 | |
| 538 | if (!target) { |
Zachary Turner | e2411fa | 2016-11-12 19:12:56 +0000 | [diff] [blame] | 539 | diagnostic_manager.PutString(eDiagnosticSeverityError, "invalid target"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 540 | return false; |
| 541 | } |
| 542 | |
| 543 | ////////////////////////// |
| 544 | // Parse the expression |
| 545 | // |
| 546 | |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 547 | m_materializer_up.reset(new Materializer()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 548 | |
| 549 | ResetDeclMap(exe_ctx, m_result_delegate, keep_result_in_memory); |
| 550 | |
Tatyana Krasnukha | edebf12 | 2019-04-26 16:41:04 +0000 | [diff] [blame] | 551 | auto on_exit = llvm::make_scope_exit([this]() { ResetDeclMap(); }); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 552 | |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 553 | if (!DeclMap()->WillParse(exe_ctx, m_materializer_up.get())) { |
Zachary Turner | e2411fa | 2016-11-12 19:12:56 +0000 | [diff] [blame] | 554 | diagnostic_manager.PutString( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 555 | eDiagnosticSeverityError, |
| 556 | "current process state is unsuitable for expression parsing"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 557 | return false; |
| 558 | } |
| 559 | |
| 560 | if (m_options.GetExecutionPolicy() == eExecutionPolicyTopLevel) { |
| 561 | DeclMap()->SetLookupsEnabled(true); |
| 562 | } |
| 563 | |
| 564 | Process *process = exe_ctx.GetProcessPtr(); |
| 565 | ExecutionContextScope *exe_scope = process; |
| 566 | |
| 567 | if (!exe_scope) |
| 568 | exe_scope = exe_ctx.GetTargetPtr(); |
| 569 | |
| 570 | // We use a shared pointer here so we can use the original parser - if it |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 571 | // succeeds or the rewrite parser we might make if it fails. But the |
| 572 | // parser_sp will never be empty. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 573 | |
Raphael Isemann | 6c0bbfc | 2019-03-12 17:09:33 +0000 | [diff] [blame] | 574 | ClangExpressionParser parser(exe_scope, *this, generate_debug_info, |
| 575 | m_include_directories); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 576 | |
| 577 | unsigned num_errors = parser.Parse(diagnostic_manager); |
| 578 | |
| 579 | // Check here for FixItHints. If there are any try to apply the fixits and |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 580 | // set the fixed text in m_fixed_text before returning an error. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 581 | if (num_errors) { |
| 582 | if (diagnostic_manager.HasFixIts()) { |
| 583 | if (parser.RewriteExpression(diagnostic_manager)) { |
| 584 | size_t fixed_start; |
| 585 | size_t fixed_end; |
| 586 | const std::string &fixed_expression = |
| 587 | diagnostic_manager.GetFixedExpression(); |
Jim Ingham | ea401ec | 2019-03-06 22:43:25 +0000 | [diff] [blame] | 588 | if (ClangExpressionSourceCode::GetOriginalBodyBounds( |
Raphael Isemann | dababf7 | 2018-09-27 10:12:54 +0000 | [diff] [blame] | 589 | fixed_expression, m_expr_lang, fixed_start, fixed_end)) |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 590 | m_fixed_text = |
| 591 | fixed_expression.substr(fixed_start, fixed_end - fixed_start); |
| 592 | } |
Sean Callanan | 9fda9d2 | 2015-10-03 09:09:01 +0000 | [diff] [blame] | 593 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 594 | return false; |
| 595 | } |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 596 | |
Raphael Isemann | 54d99bf | 2019-04-24 12:21:03 +0000 | [diff] [blame] | 597 | ////////////////////////////////////////////////////////////////////////////// |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 598 | // Prepare the output of the parser for execution, evaluating it statically |
| 599 | // if possible |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 600 | // |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 601 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 602 | { |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 603 | Status jit_error = parser.PrepareForExecution( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 604 | m_jit_start_addr, m_jit_end_addr, m_execution_unit_sp, exe_ctx, |
| 605 | m_can_interpret, execution_policy); |
Sean Callanan | fc55f5d | 2010-09-21 00:44:12 +0000 | [diff] [blame] | 606 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 607 | if (!jit_error.Success()) { |
| 608 | const char *error_cstr = jit_error.AsCString(); |
| 609 | if (error_cstr && error_cstr[0]) |
Zachary Turner | e2411fa | 2016-11-12 19:12:56 +0000 | [diff] [blame] | 610 | diagnostic_manager.PutString(eDiagnosticSeverityError, error_cstr); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 611 | else |
Zachary Turner | e2411fa | 2016-11-12 19:12:56 +0000 | [diff] [blame] | 612 | diagnostic_manager.PutString(eDiagnosticSeverityError, |
| 613 | "expression can't be interpreted or run"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 614 | return false; |
| 615 | } |
| 616 | } |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 617 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 618 | if (exe_ctx.GetProcessPtr() && execution_policy == eExecutionPolicyTopLevel) { |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 619 | Status static_init_error = |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 620 | parser.RunStaticInitializers(m_execution_unit_sp, exe_ctx); |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 621 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 622 | if (!static_init_error.Success()) { |
| 623 | const char *error_cstr = static_init_error.AsCString(); |
| 624 | if (error_cstr && error_cstr[0]) |
| 625 | diagnostic_manager.Printf(eDiagnosticSeverityError, |
| 626 | "couldn't run static initializers: %s\n", |
| 627 | error_cstr); |
| 628 | else |
Zachary Turner | e2411fa | 2016-11-12 19:12:56 +0000 | [diff] [blame] | 629 | diagnostic_manager.PutString(eDiagnosticSeverityError, |
| 630 | "couldn't run static initializers\n"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 631 | return false; |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | if (m_execution_unit_sp) { |
| 636 | bool register_execution_unit = false; |
| 637 | |
| 638 | if (m_options.GetExecutionPolicy() == eExecutionPolicyTopLevel) { |
| 639 | register_execution_unit = true; |
Sean Callanan | b995119 | 2011-08-01 18:18:33 +0000 | [diff] [blame] | 640 | } |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 641 | |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 642 | // If there is more than one external function in the execution unit, it |
| 643 | // needs to keep living even if it's not top level, because the result |
| 644 | // could refer to that function. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 645 | |
| 646 | if (m_execution_unit_sp->GetJittedFunctions().size() > 1) { |
| 647 | register_execution_unit = true; |
Sean Callanan | 00294b3 | 2016-03-22 21:05:51 +0000 | [diff] [blame] | 648 | } |
| 649 | |
Raphael Isemann | efe5fd1 | 2019-08-06 08:07:45 +0000 | [diff] [blame] | 650 | if (register_execution_unit) |
| 651 | exe_ctx.GetTargetPtr() |
| 652 | ->GetPersistentExpressionStateForLanguage(m_language) |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 653 | ->RegisterExecutionUnit(m_execution_unit_sp); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 654 | } |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 655 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 656 | if (generate_debug_info) { |
| 657 | lldb::ModuleSP jit_module_sp(m_execution_unit_sp->GetJITModule()); |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 658 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 659 | if (jit_module_sp) { |
| 660 | ConstString const_func_name(FunctionName()); |
| 661 | FileSpec jit_file; |
| 662 | jit_file.GetFilename() = const_func_name; |
| 663 | jit_module_sp->SetFileSpecAndObjectName(jit_file, ConstString()); |
| 664 | m_jit_module_wp = jit_module_sp; |
| 665 | target->GetImages().Append(jit_module_sp); |
Sean Callanan | 00294b3 | 2016-03-22 21:05:51 +0000 | [diff] [blame] | 666 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 667 | } |
Sean Callanan | 00294b3 | 2016-03-22 21:05:51 +0000 | [diff] [blame] | 668 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 669 | if (process && m_jit_start_addr != LLDB_INVALID_ADDRESS) |
| 670 | m_jit_process_wp = lldb::ProcessWP(process->shared_from_this()); |
| 671 | return true; |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 672 | } |
| 673 | |
Raphael Isemann | 7482973 | 2018-08-30 17:29:37 +0000 | [diff] [blame] | 674 | /// Converts an absolute position inside a given code string into |
| 675 | /// a column/line pair. |
| 676 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 677 | /// \param[in] abs_pos |
Raphael Isemann | 7482973 | 2018-08-30 17:29:37 +0000 | [diff] [blame] | 678 | /// A absolute position in the code string that we want to convert |
| 679 | /// to a column/line pair. |
| 680 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 681 | /// \param[in] code |
Raphael Isemann | 7482973 | 2018-08-30 17:29:37 +0000 | [diff] [blame] | 682 | /// A multi-line string usually representing source code. |
| 683 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 684 | /// \param[out] line |
Raphael Isemann | 7482973 | 2018-08-30 17:29:37 +0000 | [diff] [blame] | 685 | /// The line in the code that contains the given absolute position. |
| 686 | /// The first line in the string is indexed as 1. |
| 687 | /// |
Adrian Prantl | f05b42e | 2019-03-11 17:09:29 +0000 | [diff] [blame] | 688 | /// \param[out] column |
Raphael Isemann | 7482973 | 2018-08-30 17:29:37 +0000 | [diff] [blame] | 689 | /// The column in the line that contains the absolute position. |
| 690 | /// The first character in a line is indexed as 0. |
Raphael Isemann | bfc5ef6 | 2018-09-22 13:33:08 +0000 | [diff] [blame] | 691 | static void AbsPosToLineColumnPos(size_t abs_pos, llvm::StringRef code, |
Raphael Isemann | 7482973 | 2018-08-30 17:29:37 +0000 | [diff] [blame] | 692 | unsigned &line, unsigned &column) { |
| 693 | // Reset to code position to beginning of the file. |
| 694 | line = 0; |
| 695 | column = 0; |
| 696 | |
| 697 | assert(abs_pos <= code.size() && "Absolute position outside code string?"); |
| 698 | |
| 699 | // We have to walk up to the position and count lines/columns. |
| 700 | for (std::size_t i = 0; i < abs_pos; ++i) { |
| 701 | // If we hit a line break, we go back to column 0 and enter a new line. |
| 702 | // We only handle \n because that's what we internally use to make new |
| 703 | // lines for our temporary code strings. |
| 704 | if (code[i] == '\n') { |
| 705 | ++line; |
| 706 | column = 0; |
| 707 | continue; |
| 708 | } |
| 709 | ++column; |
| 710 | } |
| 711 | } |
| 712 | |
| 713 | bool ClangUserExpression::Complete(ExecutionContext &exe_ctx, |
Raphael Isemann | c11a780 | 2018-08-30 21:26:32 +0000 | [diff] [blame] | 714 | CompletionRequest &request, |
| 715 | unsigned complete_pos) { |
Raphael Isemann | 7482973 | 2018-08-30 17:29:37 +0000 | [diff] [blame] | 716 | Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); |
| 717 | |
| 718 | // We don't want any visible feedback when completing an expression. Mostly |
| 719 | // because the results we get from an incomplete invocation are probably not |
| 720 | // correct. |
| 721 | DiagnosticManager diagnostic_manager; |
| 722 | |
Raphael Isemann | 71569d0 | 2019-05-02 10:12:56 +0000 | [diff] [blame] | 723 | if (!PrepareForParsing(diagnostic_manager, exe_ctx, /*for_completion*/ true)) |
Raphael Isemann | 7482973 | 2018-08-30 17:29:37 +0000 | [diff] [blame] | 724 | return false; |
| 725 | |
Jonas Devlieghere | 63e5fb7 | 2019-07-24 17:56:10 +0000 | [diff] [blame] | 726 | LLDB_LOGF(log, "Parsing the following code:\n%s", m_transformed_text.c_str()); |
Raphael Isemann | 7482973 | 2018-08-30 17:29:37 +0000 | [diff] [blame] | 727 | |
| 728 | ////////////////////////// |
| 729 | // Parse the expression |
| 730 | // |
| 731 | |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 732 | m_materializer_up.reset(new Materializer()); |
Raphael Isemann | 7482973 | 2018-08-30 17:29:37 +0000 | [diff] [blame] | 733 | |
| 734 | ResetDeclMap(exe_ctx, m_result_delegate, /*keep result in memory*/ true); |
| 735 | |
Tatyana Krasnukha | edebf12 | 2019-04-26 16:41:04 +0000 | [diff] [blame] | 736 | auto on_exit = llvm::make_scope_exit([this]() { ResetDeclMap(); }); |
Raphael Isemann | 7482973 | 2018-08-30 17:29:37 +0000 | [diff] [blame] | 737 | |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 738 | if (!DeclMap()->WillParse(exe_ctx, m_materializer_up.get())) { |
Raphael Isemann | 7482973 | 2018-08-30 17:29:37 +0000 | [diff] [blame] | 739 | diagnostic_manager.PutString( |
| 740 | eDiagnosticSeverityError, |
| 741 | "current process state is unsuitable for expression parsing"); |
| 742 | |
| 743 | return false; |
| 744 | } |
| 745 | |
| 746 | if (m_options.GetExecutionPolicy() == eExecutionPolicyTopLevel) { |
| 747 | DeclMap()->SetLookupsEnabled(true); |
| 748 | } |
| 749 | |
| 750 | Process *process = exe_ctx.GetProcessPtr(); |
| 751 | ExecutionContextScope *exe_scope = process; |
| 752 | |
| 753 | if (!exe_scope) |
| 754 | exe_scope = exe_ctx.GetTargetPtr(); |
| 755 | |
| 756 | ClangExpressionParser parser(exe_scope, *this, false); |
| 757 | |
| 758 | // We have to find the source code location where the user text is inside |
| 759 | // the transformed expression code. When creating the transformed text, we |
| 760 | // already stored the absolute position in the m_transformed_text string. The |
| 761 | // only thing left to do is to transform it into the line:column format that |
| 762 | // Clang expects. |
| 763 | |
| 764 | // The line and column of the user expression inside the transformed source |
| 765 | // code. |
| 766 | unsigned user_expr_line, user_expr_column; |
| 767 | if (m_user_expression_start_pos.hasValue()) |
| 768 | AbsPosToLineColumnPos(*m_user_expression_start_pos, m_transformed_text, |
| 769 | user_expr_line, user_expr_column); |
| 770 | else |
| 771 | return false; |
| 772 | |
| 773 | // The actual column where we have to complete is the start column of the |
| 774 | // user expression + the offset inside the user code that we were given. |
| 775 | const unsigned completion_column = user_expr_column + complete_pos; |
Raphael Isemann | c11a780 | 2018-08-30 21:26:32 +0000 | [diff] [blame] | 776 | parser.Complete(request, user_expr_line, completion_column, complete_pos); |
Raphael Isemann | 7482973 | 2018-08-30 17:29:37 +0000 | [diff] [blame] | 777 | |
| 778 | return true; |
| 779 | } |
| 780 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 781 | bool ClangUserExpression::AddArguments(ExecutionContext &exe_ctx, |
| 782 | std::vector<lldb::addr_t> &args, |
| 783 | lldb::addr_t struct_address, |
| 784 | DiagnosticManager &diagnostic_manager) { |
| 785 | lldb::addr_t object_ptr = LLDB_INVALID_ADDRESS; |
| 786 | lldb::addr_t cmd_ptr = LLDB_INVALID_ADDRESS; |
Sean Callanan | 579e70c | 2016-03-19 00:03:59 +0000 | [diff] [blame] | 787 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 788 | if (m_needs_object_ptr) { |
| 789 | lldb::StackFrameSP frame_sp = exe_ctx.GetFrameSP(); |
| 790 | if (!frame_sp) |
| 791 | return true; |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 792 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 793 | ConstString object_name; |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 794 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 795 | if (m_in_cplusplus_method) { |
| 796 | object_name.SetCString("this"); |
| 797 | } else if (m_in_objectivec_method) { |
| 798 | object_name.SetCString("self"); |
| 799 | } else { |
Zachary Turner | e2411fa | 2016-11-12 19:12:56 +0000 | [diff] [blame] | 800 | diagnostic_manager.PutString( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 801 | eDiagnosticSeverityError, |
| 802 | "need object pointer but don't know the language"); |
| 803 | return false; |
Jim Ingham | 51148e9 | 2015-11-05 00:24:18 +0000 | [diff] [blame] | 804 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 805 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 806 | Status object_ptr_error; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 807 | |
Aleksandr Urakov | 40624a0 | 2019-02-05 09:14:36 +0000 | [diff] [blame] | 808 | if (m_ctx_obj) { |
| 809 | AddressType address_type; |
| 810 | object_ptr = m_ctx_obj->GetAddressOf(false, &address_type); |
| 811 | if (object_ptr == LLDB_INVALID_ADDRESS || |
| 812 | address_type != eAddressTypeLoad) |
| 813 | object_ptr_error.SetErrorString("Can't get context object's " |
| 814 | "debuggee address"); |
| 815 | } else |
| 816 | object_ptr = GetObjectPointer(frame_sp, object_name, object_ptr_error); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 817 | |
| 818 | if (!object_ptr_error.Success()) { |
| 819 | exe_ctx.GetTargetRef().GetDebugger().GetAsyncOutputStream()->Printf( |
Jason Molenda | 599558e | 2017-02-21 05:09:26 +0000 | [diff] [blame] | 820 | "warning: `%s' is not accessible (substituting 0)\n", |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 821 | object_name.AsCString()); |
| 822 | object_ptr = 0; |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 823 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 824 | |
| 825 | if (m_in_objectivec_method) { |
| 826 | ConstString cmd_name("_cmd"); |
| 827 | |
| 828 | cmd_ptr = GetObjectPointer(frame_sp, cmd_name, object_ptr_error); |
| 829 | |
| 830 | if (!object_ptr_error.Success()) { |
| 831 | diagnostic_manager.Printf( |
| 832 | eDiagnosticSeverityWarning, |
| 833 | "couldn't get cmd pointer (substituting NULL): %s", |
| 834 | object_ptr_error.AsCString()); |
| 835 | cmd_ptr = 0; |
| 836 | } |
| 837 | } |
| 838 | |
| 839 | args.push_back(object_ptr); |
| 840 | |
| 841 | if (m_in_objectivec_method) |
| 842 | args.push_back(cmd_ptr); |
| 843 | |
| 844 | args.push_back(struct_address); |
| 845 | } else { |
| 846 | args.push_back(struct_address); |
| 847 | } |
| 848 | return true; |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 849 | } |
| 850 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 851 | lldb::ExpressionVariableSP ClangUserExpression::GetResultAfterDematerialization( |
| 852 | ExecutionContextScope *exe_scope) { |
| 853 | return m_result_delegate.GetVariable(); |
Sean Callanan | 9fda9d2 | 2015-10-03 09:09:01 +0000 | [diff] [blame] | 854 | } |
| 855 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 856 | void ClangUserExpression::ClangUserExpressionHelper::ResetDeclMap( |
| 857 | ExecutionContext &exe_ctx, |
| 858 | Materializer::PersistentVariableDelegate &delegate, |
Aleksandr Urakov | 40624a0 | 2019-02-05 09:14:36 +0000 | [diff] [blame] | 859 | bool keep_result_in_memory, |
| 860 | ValueObject *ctx_obj) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 861 | m_expr_decl_map_up.reset( |
Aleksandr Urakov | 40624a0 | 2019-02-05 09:14:36 +0000 | [diff] [blame] | 862 | new ClangExpressionDeclMap(keep_result_in_memory, &delegate, exe_ctx, |
| 863 | ctx_obj)); |
Sylvestre Ledru | ceab3ac | 2014-07-06 17:54:58 +0000 | [diff] [blame] | 864 | } |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 865 | |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame] | 866 | clang::ASTConsumer * |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 867 | ClangUserExpression::ClangUserExpressionHelper::ASTTransformer( |
| 868 | clang::ASTConsumer *passthrough) { |
| 869 | m_result_synthesizer_up.reset( |
| 870 | new ASTResultSynthesizer(passthrough, m_top_level, m_target)); |
Sean Callanan | c673a6e | 2010-12-07 10:00:20 +0000 | [diff] [blame] | 871 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 872 | return m_result_synthesizer_up.get(); |
Sean Callanan | 1a8d409 | 2010-08-27 01:01:44 +0000 | [diff] [blame] | 873 | } |
| 874 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 875 | void ClangUserExpression::ClangUserExpressionHelper::CommitPersistentDecls() { |
Jonas Devlieghere | 70355ac | 2019-02-12 03:47:39 +0000 | [diff] [blame] | 876 | if (m_result_synthesizer_up) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 877 | m_result_synthesizer_up->CommitPersistentDecls(); |
| 878 | } |
Sean Callanan | 00294b3 | 2016-03-22 21:05:51 +0000 | [diff] [blame] | 879 | } |
| 880 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 881 | ConstString ClangUserExpression::ResultDelegate::GetName() { |
Adrian Prantl | 03219f7 | 2018-04-30 23:59:17 +0000 | [diff] [blame] | 882 | auto prefix = m_persistent_state->GetPersistentVariablePrefix(); |
| 883 | return m_persistent_state->GetNextPersistentVariableName(*m_target_sp, |
| 884 | prefix); |
Sean Callanan | 9fda9d2 | 2015-10-03 09:09:01 +0000 | [diff] [blame] | 885 | } |
| 886 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 887 | void ClangUserExpression::ResultDelegate::DidDematerialize( |
| 888 | lldb::ExpressionVariableSP &variable) { |
| 889 | m_variable = variable; |
Sean Callanan | 9fda9d2 | 2015-10-03 09:09:01 +0000 | [diff] [blame] | 890 | } |
| 891 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 892 | void ClangUserExpression::ResultDelegate::RegisterPersistentState( |
| 893 | PersistentExpressionState *persistent_state) { |
| 894 | m_persistent_state = persistent_state; |
Sean Callanan | 9fda9d2 | 2015-10-03 09:09:01 +0000 | [diff] [blame] | 895 | } |
| 896 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 897 | lldb::ExpressionVariableSP &ClangUserExpression::ResultDelegate::GetVariable() { |
| 898 | return m_variable; |
Sean Callanan | 9fda9d2 | 2015-10-03 09:09:01 +0000 | [diff] [blame] | 899 | } |