blob: 35ad705fa698bd81cc2350da2d4c8b170524606d [file] [log] [blame]
Sean Callanan1a8d4092010-08-27 01:01:44 +00001//===-- ClangExpressionParser.cpp -------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Eugene Zelenko4c3f2b92015-10-21 01:03:30 +000010// C Includes
11// C++ Includes
12// Other libraries and framework includes
Sean Callanan1a8d4092010-08-27 01:01:44 +000013#include "clang/AST/ASTContext.h"
14#include "clang/AST/ExternalASTSource.h"
15#include "clang/Basic/FileManager.h"
Jim Ingham151c0322015-09-15 21:13:50 +000016#include "clang/Basic/SourceLocation.h"
Sean Callanan1a8d4092010-08-27 01:01:44 +000017#include "clang/Basic/TargetInfo.h"
18#include "clang/Basic/Version.h"
Sean Callanan1a8d4092010-08-27 01:01:44 +000019#include "clang/CodeGen/CodeGenAction.h"
20#include "clang/CodeGen/ModuleBuilder.h"
Sean Callanan1a8d4092010-08-27 01:01:44 +000021#include "clang/Frontend/CompilerInstance.h"
22#include "clang/Frontend/CompilerInvocation.h"
23#include "clang/Frontend/FrontendActions.h"
24#include "clang/Frontend/FrontendDiagnostic.h"
25#include "clang/Frontend/FrontendPluginRegistry.h"
26#include "clang/Frontend/TextDiagnosticBuffer.h"
27#include "clang/Frontend/TextDiagnosticPrinter.h"
Sean Callanan1a8d4092010-08-27 01:01:44 +000028#include "clang/Lex/Preprocessor.h"
Sean Callanane2ef6e32010-09-23 03:01:22 +000029#include "clang/Parse/ParseAST.h"
Sean Callanan3d654b32012-09-24 22:25:51 +000030#include "clang/Rewrite/Frontend/FrontendActions.h"
Sean Callanan1a8d4092010-08-27 01:01:44 +000031#include "clang/Sema/SemaConsumer.h"
Sean Callananfb0b7582011-03-15 00:17:19 +000032#include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
Sean Callanan1a8d4092010-08-27 01:01:44 +000033
34#include "llvm/ADT/StringRef.h"
35#include "llvm/ExecutionEngine/ExecutionEngine.h"
Sean Callanan3d654b32012-09-24 22:25:51 +000036#include "llvm/Support/Debug.h"
Rafael Espindola4609ea82013-06-26 14:10:56 +000037#include "llvm/Support/FileSystem.h"
Sean Callanan880e6802011-10-07 23:18:13 +000038#include "llvm/Support/TargetSelect.h"
Greg Clayton70b57652011-05-15 01:25:55 +000039
Ed Mastea09ed032014-03-18 18:55:06 +000040#include "llvm/ExecutionEngine/MCJIT.h"
Chandler Carruth1e157582013-01-02 12:20:07 +000041#include "llvm/IR/LLVMContext.h"
42#include "llvm/IR/Module.h"
Sean Callanan1a8d4092010-08-27 01:01:44 +000043#include "llvm/Support/ErrorHandling.h"
44#include "llvm/Support/MemoryBuffer.h"
Greg Clayton38a61402010-12-02 23:20:03 +000045#include "llvm/Support/DynamicLibrary.h"
46#include "llvm/Support/Host.h"
47#include "llvm/Support/Signals.h"
Sean Callanan1a8d4092010-08-27 01:01:44 +000048
Eugene Zelenko4c3f2b92015-10-21 01:03:30 +000049// Project includes
50#include "ClangExpressionParser.h"
51
52#include "ClangASTSource.h"
53#include "ClangExpressionHelper.h"
54#include "ClangExpressionDeclMap.h"
55#include "ClangModulesDeclVendor.h"
56#include "ClangPersistentVariables.h"
57#include "IRForTarget.h"
58
59#include "lldb/Core/ArchSpec.h"
60#include "lldb/Core/DataBufferHeap.h"
61#include "lldb/Core/Debugger.h"
62#include "lldb/Core/Disassembler.h"
63#include "lldb/Core/Log.h"
64#include "lldb/Core/Module.h"
65#include "lldb/Core/Stream.h"
66#include "lldb/Core/StreamFile.h"
67#include "lldb/Core/StreamString.h"
68#include "lldb/Expression/IRExecutionUnit.h"
69#include "lldb/Expression/IRDynamicChecks.h"
70#include "lldb/Expression/IRInterpreter.h"
71#include "lldb/Host/File.h"
72#include "lldb/Host/HostInfo.h"
73#include "lldb/Symbol/ClangASTContext.h"
74#include "lldb/Symbol/SymbolVendor.h"
75#include "lldb/Target/ExecutionContext.h"
76#include "lldb/Target/ObjCLanguageRuntime.h"
77#include "lldb/Target/Process.h"
78#include "lldb/Target/Target.h"
79
Sean Callanan1a8d4092010-08-27 01:01:44 +000080using namespace clang;
81using namespace llvm;
82using namespace lldb_private;
83
84//===----------------------------------------------------------------------===//
85// Utility Methods for Clang
86//===----------------------------------------------------------------------===//
87
88std::string GetBuiltinIncludePath(const char *Argv0) {
Rafael Espindola4609ea82013-06-26 14:10:56 +000089 SmallString<128> P(llvm::sys::fs::getMainExecutable(
90 Argv0, (void *)(intptr_t) GetBuiltinIncludePath));
91
92 if (!P.empty()) {
93 llvm::sys::path::remove_filename(P); // Remove /clang from foo/bin/clang
94 llvm::sys::path::remove_filename(P); // Remove /bin from foo/bin
95
Sean Callanan1a8d4092010-08-27 01:01:44 +000096 // Get foo/lib/clang/<version>/include
Rafael Espindola4609ea82013-06-26 14:10:56 +000097 llvm::sys::path::append(P, "lib", "clang", CLANG_VERSION_STRING,
98 "include");
Sean Callanan1a8d4092010-08-27 01:01:44 +000099 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000100
Sean Callanan1a8d4092010-08-27 01:01:44 +0000101 return P.str();
102}
103
Sean Callananc8278af2014-12-05 01:27:35 +0000104class ClangExpressionParser::LLDBPreprocessorCallbacks : public PPCallbacks
105{
Sean Callananf0c5aeb2015-04-20 16:31:29 +0000106 ClangModulesDeclVendor &m_decl_vendor;
107 ClangPersistentVariables &m_persistent_vars;
108 StreamString m_error_stream;
109 bool m_has_errors = false;
Eugene Zelenko4c3f2b92015-10-21 01:03:30 +0000110
Sean Callananc8278af2014-12-05 01:27:35 +0000111public:
Sean Callananf0c5aeb2015-04-20 16:31:29 +0000112 LLDBPreprocessorCallbacks(ClangModulesDeclVendor &decl_vendor,
113 ClangPersistentVariables &persistent_vars) :
114 m_decl_vendor(decl_vendor),
115 m_persistent_vars(persistent_vars)
Sean Callananc8278af2014-12-05 01:27:35 +0000116 {
117 }
118
Eugene Zelenko4c3f2b92015-10-21 01:03:30 +0000119 void
120 moduleImport(SourceLocation import_location,
121 clang::ModuleIdPath path,
122 const clang::Module * /*null*/) override
Sean Callananc8278af2014-12-05 01:27:35 +0000123 {
Sean Callananf0c5aeb2015-04-20 16:31:29 +0000124 std::vector<ConstString> string_path;
Sean Callananc8278af2014-12-05 01:27:35 +0000125
126 for (const std::pair<IdentifierInfo *, SourceLocation> &component : path)
127 {
Sean Callananf0c5aeb2015-04-20 16:31:29 +0000128 string_path.push_back(ConstString(component.first->getName()));
Sean Callananc8278af2014-12-05 01:27:35 +0000129 }
130
131 StreamString error_stream;
132
Sean Callananf0c5aeb2015-04-20 16:31:29 +0000133 ClangModulesDeclVendor::ModuleVector exported_modules;
134
135 if (!m_decl_vendor.AddModule(string_path, &exported_modules, m_error_stream))
Sean Callananc8278af2014-12-05 01:27:35 +0000136 {
137 m_has_errors = true;
138 }
Sean Callananf0c5aeb2015-04-20 16:31:29 +0000139
140 for (ClangModulesDeclVendor::ModuleID module : exported_modules)
141 {
142 m_persistent_vars.AddHandLoadedClangModule(module);
143 }
Sean Callananc8278af2014-12-05 01:27:35 +0000144 }
145
146 bool hasErrors()
147 {
148 return m_has_errors;
149 }
150
151 const std::string &getErrorString()
152 {
153 return m_error_stream.GetString();
154 }
155};
156
Sean Callanan1a8d4092010-08-27 01:01:44 +0000157//===----------------------------------------------------------------------===//
158// Implementation of ClangExpressionParser
159//===----------------------------------------------------------------------===//
160
Greg Clayton514487e2011-02-15 21:59:32 +0000161ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
Jim Ingham151c0322015-09-15 21:13:50 +0000162 Expression &expr,
Greg Clayton23f8c952014-03-24 23:10:19 +0000163 bool generate_debug_info) :
Jim Ingham151c0322015-09-15 21:13:50 +0000164 ExpressionParser (exe_scope, expr, generate_debug_info),
Sean Callanan1a8d4092010-08-27 01:01:44 +0000165 m_compiler (),
Zachary Turner22ac8712014-12-05 22:54:56 +0000166 m_code_generator (),
167 m_pp_callbacks(nullptr)
Sean Callanan1a8d4092010-08-27 01:01:44 +0000168{
Sean Callanan1a8d4092010-08-27 01:01:44 +0000169 // 1. Create a new compiler instance.
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000170 m_compiler.reset(new CompilerInstance());
171
Sean Callanan3d654b32012-09-24 22:25:51 +0000172 // 2. Install the target.
173
174 lldb::TargetSP target_sp;
175 if (exe_scope)
176 target_sp = exe_scope->CalculateTarget();
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000177
Sean Callanan3d654b32012-09-24 22:25:51 +0000178 // TODO: figure out what to really do when we don't have a valid target.
179 // Sometimes this will be ok to just use the host target triple (when we
180 // evaluate say "2+3", but other expressions like breakpoint conditions
181 // and other things that _are_ target specific really shouldn't just be
182 // using the host triple. This needs to be fixed in a better way.
183 if (target_sp && target_sp->GetArchitecture().IsValid())
184 {
185 std::string triple = target_sp->GetArchitecture().GetTriple().str();
Sean Callanan3d654b32012-09-24 22:25:51 +0000186 m_compiler->getTargetOpts().Triple = triple;
187 }
188 else
189 {
190 m_compiler->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
191 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000192
Sean Callananb45a6f02013-02-21 01:04:23 +0000193 if (target_sp->GetArchitecture().GetMachine() == llvm::Triple::x86 ||
194 target_sp->GetArchitecture().GetMachine() == llvm::Triple::x86_64)
195 {
196 m_compiler->getTargetOpts().Features.push_back("+sse");
197 m_compiler->getTargetOpts().Features.push_back("+sse2");
198 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000199
Jason Molendaa3329782014-03-29 18:54:20 +0000200 // Any arm32 iOS environment, but not on arm64
Sean Callanan60400ec2014-06-23 21:00:25 +0000201 if (m_compiler->getTargetOpts().Triple.find("arm64") == std::string::npos &&
202 m_compiler->getTargetOpts().Triple.find("arm") != std::string::npos &&
203 m_compiler->getTargetOpts().Triple.find("ios") != std::string::npos)
Jason Molendaa3329782014-03-29 18:54:20 +0000204 {
Sean Callanan3d654b32012-09-24 22:25:51 +0000205 m_compiler->getTargetOpts().ABI = "apcs-gnu";
Jason Molendaa3329782014-03-29 18:54:20 +0000206 }
207
Sean Callananb1de8dd2013-01-22 02:20:20 +0000208 m_compiler->createDiagnostics();
Jason Molendaa3329782014-03-29 18:54:20 +0000209
Sean Callanan3d654b32012-09-24 22:25:51 +0000210 // Create the target instance.
Alp Toker5f838642014-07-06 05:36:57 +0000211 m_compiler->setTarget(TargetInfo::CreateTargetInfo(
212 m_compiler->getDiagnostics(), m_compiler->getInvocation().TargetOpts));
213
Sean Callanan3d654b32012-09-24 22:25:51 +0000214 assert (m_compiler->hasTarget());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000215
Sean Callanan3d654b32012-09-24 22:25:51 +0000216 // 3. Set options.
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000217
Sean Callananc7b65062011-11-07 23:35:40 +0000218 lldb::LanguageType language = expr.Language();
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000219
Sean Callananc7b65062011-11-07 23:35:40 +0000220 switch (language)
221 {
222 case lldb::eLanguageTypeC:
Dawn Perchik009d1102015-09-04 01:02:30 +0000223 case lldb::eLanguageTypeC89:
224 case lldb::eLanguageTypeC99:
225 case lldb::eLanguageTypeC11:
226 // FIXME: the following language option is a temporary workaround,
227 // to "ask for C, get C++."
228 // For now, the expression parser must use C++ anytime the
229 // language is a C family language, because the expression parser
230 // uses features of C++ to capture values.
231 m_compiler->getLangOpts().CPlusPlus = true;
Sean Callananc7b65062011-11-07 23:35:40 +0000232 break;
233 case lldb::eLanguageTypeObjC:
234 m_compiler->getLangOpts().ObjC1 = true;
235 m_compiler->getLangOpts().ObjC2 = true;
Dawn Perchik009d1102015-09-04 01:02:30 +0000236 // FIXME: the following language option is a temporary workaround,
237 // to "ask for ObjC, get ObjC++" (see comment above).
238 m_compiler->getLangOpts().CPlusPlus = true;
Sean Callananc7b65062011-11-07 23:35:40 +0000239 break;
240 case lldb::eLanguageTypeC_plus_plus:
Dawn Perchik009d1102015-09-04 01:02:30 +0000241 case lldb::eLanguageTypeC_plus_plus_11:
242 case lldb::eLanguageTypeC_plus_plus_14:
Chandler Carruth38336a12013-01-02 12:55:00 +0000243 m_compiler->getLangOpts().CPlusPlus11 = true;
Jim Ingham26c7bf92014-10-11 00:38:27 +0000244 m_compiler->getHeaderSearchOpts().UseLibcxx = true;
Dawn Perchik009d1102015-09-04 01:02:30 +0000245 // fall thru ...
246 case lldb::eLanguageTypeC_plus_plus_03:
247 m_compiler->getLangOpts().CPlusPlus = true;
248 // FIXME: the following language option is a temporary workaround,
249 // to "ask for C++, get ObjC++". Apple hopes to remove this requirement
250 // on non-Apple platforms, but for now it is needed.
251 m_compiler->getLangOpts().ObjC1 = true;
Sean Callananc7b65062011-11-07 23:35:40 +0000252 break;
253 case lldb::eLanguageTypeObjC_plus_plus:
Dawn Perchik009d1102015-09-04 01:02:30 +0000254 case lldb::eLanguageTypeUnknown:
Sean Callananc7b65062011-11-07 23:35:40 +0000255 default:
256 m_compiler->getLangOpts().ObjC1 = true;
257 m_compiler->getLangOpts().ObjC2 = true;
258 m_compiler->getLangOpts().CPlusPlus = true;
Chandler Carruth38336a12013-01-02 12:55:00 +0000259 m_compiler->getLangOpts().CPlusPlus11 = true;
Jim Ingham26c7bf92014-10-11 00:38:27 +0000260 m_compiler->getHeaderSearchOpts().UseLibcxx = true;
Sean Callananc7b65062011-11-07 23:35:40 +0000261 break;
262 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000263
Sean Callananaa0f9cb2012-10-17 22:09:59 +0000264 m_compiler->getLangOpts().Bool = true;
265 m_compiler->getLangOpts().WChar = true;
Sean Callananeeb43842013-04-01 22:12:37 +0000266 m_compiler->getLangOpts().Blocks = true;
Sean Callanan226b70c2012-03-08 02:39:03 +0000267 m_compiler->getLangOpts().DebuggerSupport = true; // Features specifically for debugger clients
Jim Ingham151c0322015-09-15 21:13:50 +0000268 if (expr.DesiredResultType() == Expression::eResultTypeId)
Sean Callanan226b70c2012-03-08 02:39:03 +0000269 m_compiler->getLangOpts().DebuggerCastResultToId = true;
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000270
Tamas Berghammerdccbfaf2015-03-31 10:21:50 +0000271 m_compiler->getLangOpts().CharIsSigned =
272 ArchSpec(m_compiler->getTargetOpts().Triple.c_str()).CharIsSignedByDefault();
273
Sean Callanan0765c822012-04-17 00:49:48 +0000274 // Spell checking is a nice feature, but it ends up completing a
275 // lot of types that we didn't strictly speaking need to complete.
276 // As a result, we spend a long time parsing and importing debug
277 // information.
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000278 m_compiler->getLangOpts().SpellChecking = false;
279
Greg Claytond9e416c2012-02-18 05:35:26 +0000280 lldb::ProcessSP process_sp;
Greg Clayton514487e2011-02-15 21:59:32 +0000281 if (exe_scope)
Greg Claytond9e416c2012-02-18 05:35:26 +0000282 process_sp = exe_scope->CalculateProcess();
Greg Clayton514487e2011-02-15 21:59:32 +0000283
Greg Claytond9e416c2012-02-18 05:35:26 +0000284 if (process_sp && m_compiler->getLangOpts().ObjC1)
Sean Callananc3a16002011-01-17 23:42:46 +0000285 {
Greg Claytond9e416c2012-02-18 05:35:26 +0000286 if (process_sp->GetObjCLanguageRuntime())
Sean Callananc3a16002011-01-17 23:42:46 +0000287 {
Enrico Granata15a67f492015-09-23 20:12:19 +0000288 if (process_sp->GetObjCLanguageRuntime()->GetRuntimeVersion() == ObjCLanguageRuntime::ObjCRuntimeVersions::eAppleObjC_V2)
Sean Callanan3d654b32012-09-24 22:25:51 +0000289 m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::MacOSX, VersionTuple(10, 7));
290 else
291 m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::FragileMacOSX, VersionTuple(10, 7));
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000292
Sean Callanan226b70c2012-03-08 02:39:03 +0000293 if (process_sp->GetObjCLanguageRuntime()->HasNewLiteralsAndIndexing())
Sean Callanan226b70c2012-03-08 02:39:03 +0000294 m_compiler->getLangOpts().DebuggerObjCLiteral = true;
Sean Callananc3a16002011-01-17 23:42:46 +0000295 }
296 }
Greg Claytonf83f32d2011-01-15 01:32:14 +0000297
Sean Callanan1a8d4092010-08-27 01:01:44 +0000298 m_compiler->getLangOpts().ThreadsafeStatics = false;
299 m_compiler->getLangOpts().AccessControl = false; // Debuggers get universal access
300 m_compiler->getLangOpts().DollarIdents = true; // $ indicates a persistent variable name
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000301
Sean Callanan1a8d4092010-08-27 01:01:44 +0000302 // Set CodeGen options
303 m_compiler->getCodeGenOpts().EmitDeclMetadata = true;
304 m_compiler->getCodeGenOpts().InstrumentFunctions = false;
Greg Claytonbc3122e2013-11-04 19:50:49 +0000305 m_compiler->getCodeGenOpts().DisableFPElim = true;
306 m_compiler->getCodeGenOpts().OmitLeafFramePointer = false;
Greg Clayton23f8c952014-03-24 23:10:19 +0000307 if (generate_debug_info)
308 m_compiler->getCodeGenOpts().setDebugInfo(CodeGenOptions::FullDebugInfo);
309 else
310 m_compiler->getCodeGenOpts().setDebugInfo(CodeGenOptions::NoDebugInfo);
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000311
Sean Callanan1a8d4092010-08-27 01:01:44 +0000312 // Disable some warnings.
Hafiz Abid Qadeer101e4902014-08-07 12:54:20 +0000313 m_compiler->getDiagnostics().setSeverityForGroup(clang::diag::Flavor::WarningOrError,
Alp Toker10933d12014-06-12 11:14:32 +0000314 "unused-value", clang::diag::Severity::Ignored, SourceLocation());
Hafiz Abid Qadeer101e4902014-08-07 12:54:20 +0000315 m_compiler->getDiagnostics().setSeverityForGroup(clang::diag::Flavor::WarningOrError,
Alp Toker10933d12014-06-12 11:14:32 +0000316 "odr", clang::diag::Severity::Ignored, SourceLocation());
317
Sean Callanan1a8d4092010-08-27 01:01:44 +0000318 // Inform the target of the language options
319 //
320 // FIXME: We shouldn't need to do this, the target should be immutable once
321 // created. This complexity should be lifted elsewhere.
Sylvestre Ledru3cc9d632014-07-06 17:50:36 +0000322 m_compiler->getTarget().adjust(m_compiler->getLangOpts());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000323
Sean Callanan1a8d4092010-08-27 01:01:44 +0000324 // 4. Set up the diagnostic buffer for reporting errors
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000325
Sean Callanane2ef6e32010-09-23 03:01:22 +0000326 m_compiler->getDiagnostics().setClient(new clang::TextDiagnosticBuffer);
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000327
Sean Callanan1a8d4092010-08-27 01:01:44 +0000328 // 5. Set up the source management objects inside the compiler
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000329
Greg Clayton38a61402010-12-02 23:20:03 +0000330 clang::FileSystemOptions file_system_options;
331 m_file_manager.reset(new clang::FileManager(file_system_options));
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000332
Sean Callanan1a8d4092010-08-27 01:01:44 +0000333 if (!m_compiler->hasSourceManager())
Greg Clayton38a61402010-12-02 23:20:03 +0000334 m_compiler->createSourceManager(*m_file_manager.get());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000335
Sean Callanan1a8d4092010-08-27 01:01:44 +0000336 m_compiler->createFileManager();
Ben Langmuir9f0bac52014-03-07 08:31:36 +0000337 m_compiler->createPreprocessor(TU_Complete);
Sean Callananc8278af2014-12-05 01:27:35 +0000338
339 if (ClangModulesDeclVendor *decl_vendor = target_sp->GetClangModulesDeclVendor())
340 {
Sean Callananb92bd752015-10-01 16:28:02 +0000341 ClangPersistentVariables *clang_persistent_vars = llvm::cast<ClangPersistentVariables>(target_sp->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC));
Sean Callanan8f1f9a12015-09-30 19:57:57 +0000342 std::unique_ptr<PPCallbacks> pp_callbacks(new LLDBPreprocessorCallbacks(*decl_vendor, *clang_persistent_vars));
Sean Callananc8278af2014-12-05 01:27:35 +0000343 m_pp_callbacks = static_cast<LLDBPreprocessorCallbacks*>(pp_callbacks.get());
344 m_compiler->getPreprocessor().addPPCallbacks(std::move(pp_callbacks));
345 }
346
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000347 // 6. Most of this we get from the CompilerInstance, but we
Sean Callanan1a8d4092010-08-27 01:01:44 +0000348 // also want to give the context an ExternalASTSource.
Sean Callanan6abfabf2010-11-19 20:20:02 +0000349 m_selector_table.reset(new SelectorTable());
Sean Callanan880e6802011-10-07 23:18:13 +0000350 m_builtin_context.reset(new Builtin::Context());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000351
Greg Clayton7b0992d2013-04-18 22:45:39 +0000352 std::unique_ptr<clang::ASTContext> ast_context(new ASTContext(m_compiler->getLangOpts(),
Sean Callananf0c5aeb2015-04-20 16:31:29 +0000353 m_compiler->getSourceManager(),
354 m_compiler->getPreprocessor().getIdentifierTable(),
355 *m_selector_table.get(),
356 *m_builtin_context.get()));
Sean Callananc8278af2014-12-05 01:27:35 +0000357
Alp Tokercf55e882014-05-03 15:05:45 +0000358 ast_context->InitBuiltinTypes(m_compiler->getTarget());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000359
Jim Ingham151c0322015-09-15 21:13:50 +0000360 ClangExpressionHelper *type_system_helper = dyn_cast<ClangExpressionHelper>(m_expr.GetTypeSystemHelper());
361 ClangExpressionDeclMap *decl_map = type_system_helper->DeclMap();
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000362
Sean Callanan1a8d4092010-08-27 01:01:44 +0000363 if (decl_map)
364 {
Sylvestre Ledru7ba631f2014-02-27 10:46:57 +0000365 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source(decl_map->CreateProxy());
Sean Callananeddeb3b2011-10-28 23:38:38 +0000366 decl_map->InstallASTContext(ast_context.get());
Sean Callanan1a8d4092010-08-27 01:01:44 +0000367 ast_context->setExternalSource(ast_source);
368 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000369
Greg Claytond8d4a572015-08-11 21:38:15 +0000370 m_ast_context.reset(new ClangASTContext(m_compiler->getTargetOpts().Triple.c_str()));
371 m_ast_context->setASTContext(ast_context.get());
Sean Callanan1a8d4092010-08-27 01:01:44 +0000372 m_compiler->setASTContext(ast_context.release());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000373
Greg Clayton7b462cc2010-10-15 22:48:33 +0000374 std::string module_name("$__lldb_module");
Sean Callanan1a8d4092010-08-27 01:01:44 +0000375
Sean Callananfb0b7582011-03-15 00:17:19 +0000376 m_llvm_context.reset(new LLVMContext());
Sean Callanan1a8d4092010-08-27 01:01:44 +0000377 m_code_generator.reset(CreateLLVMCodeGen(m_compiler->getDiagnostics(),
378 module_name,
Tamas Berghammer0b736f12015-06-30 09:26:52 +0000379 m_compiler->getHeaderSearchOpts(),
380 m_compiler->getPreprocessorOpts(),
Sean Callanan1a8d4092010-08-27 01:01:44 +0000381 m_compiler->getCodeGenOpts(),
Sean Callananfb0b7582011-03-15 00:17:19 +0000382 *m_llvm_context));
Sean Callanan1a8d4092010-08-27 01:01:44 +0000383}
384
385ClangExpressionParser::~ClangExpressionParser()
386{
387}
388
389unsigned
390ClangExpressionParser::Parse (Stream &stream)
391{
Sean Callanane2ef6e32010-09-23 03:01:22 +0000392 TextDiagnosticBuffer *diag_buf = static_cast<TextDiagnosticBuffer*>(m_compiler->getDiagnostics().getClient());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000393
Sean Callanane2ef6e32010-09-23 03:01:22 +0000394 diag_buf->FlushDiagnostics (m_compiler->getDiagnostics());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000395
Greg Clayton23f8c952014-03-24 23:10:19 +0000396 const char *expr_text = m_expr.Text();
Rafael Espindola9cb97b62014-05-21 15:08:27 +0000397
398 clang::SourceManager &SourceMgr = m_compiler->getSourceManager();
Greg Clayton23f8c952014-03-24 23:10:19 +0000399 bool created_main_file = false;
400 if (m_compiler->getCodeGenOpts().getDebugInfo() == CodeGenOptions::FullDebugInfo)
401 {
402 std::string temp_source_path;
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000403
Zachary Turnercb5742b2014-10-20 17:46:56 +0000404 int temp_fd = -1;
405 llvm::SmallString<PATH_MAX> result_path;
Greg Clayton23f8c952014-03-24 23:10:19 +0000406 FileSpec tmpdir_file_spec;
Zachary Turner42ff0ad2014-08-21 17:29:12 +0000407 if (HostInfo::GetLLDBPath(lldb::ePathTypeLLDBTempSystemDir, tmpdir_file_spec))
Greg Clayton23f8c952014-03-24 23:10:19 +0000408 {
Zachary Turnercb5742b2014-10-20 17:46:56 +0000409 tmpdir_file_spec.AppendPathComponent("lldb-%%%%%%.expr");
Pavel Labath3a29f8b2015-07-28 09:18:32 +0000410 temp_source_path = tmpdir_file_spec.GetPath();
Zachary Turnercb5742b2014-10-20 17:46:56 +0000411 llvm::sys::fs::createUniqueFile(temp_source_path, temp_fd, result_path);
Greg Clayton23f8c952014-03-24 23:10:19 +0000412 }
413 else
414 {
Zachary Turnercb5742b2014-10-20 17:46:56 +0000415 llvm::sys::fs::createTemporaryFile("lldb", "expr", temp_fd, result_path);
Greg Clayton23f8c952014-03-24 23:10:19 +0000416 }
Jason Molendabc464ee2014-10-16 23:10:03 +0000417
418 if (temp_fd != -1)
Greg Clayton23f8c952014-03-24 23:10:19 +0000419 {
Jason Molendabc464ee2014-10-16 23:10:03 +0000420 lldb_private::File file (temp_fd, true);
Greg Clayton23f8c952014-03-24 23:10:19 +0000421 const size_t expr_text_len = strlen(expr_text);
422 size_t bytes_written = expr_text_len;
423 if (file.Write(expr_text, bytes_written).Success())
424 {
425 if (bytes_written == expr_text_len)
426 {
427 file.Close();
Rafael Espindola9cb97b62014-05-21 15:08:27 +0000428 SourceMgr.setMainFileID(SourceMgr.createFileID(
Zachary Turnercb5742b2014-10-20 17:46:56 +0000429 m_file_manager->getFile(result_path),
Rafael Espindola9cb97b62014-05-21 15:08:27 +0000430 SourceLocation(), SrcMgr::C_User));
Greg Clayton23f8c952014-03-24 23:10:19 +0000431 created_main_file = true;
432 }
433 }
434 }
435 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000436
Greg Clayton23f8c952014-03-24 23:10:19 +0000437 if (!created_main_file)
438 {
Rafael Espindola2443e702014-08-27 20:09:08 +0000439 std::unique_ptr<MemoryBuffer> memory_buffer = MemoryBuffer::getMemBufferCopy(expr_text, __FUNCTION__);
Sean Callanan302be672014-08-30 02:24:56 +0000440 SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(memory_buffer)));
Greg Clayton23f8c952014-03-24 23:10:19 +0000441 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000442
Sean Callanane2ef6e32010-09-23 03:01:22 +0000443 diag_buf->BeginSourceFile(m_compiler->getLangOpts(), &m_compiler->getPreprocessor());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000444
Jim Ingham151c0322015-09-15 21:13:50 +0000445 ClangExpressionHelper *type_system_helper = dyn_cast<ClangExpressionHelper>(m_expr.GetTypeSystemHelper());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000446
Jim Ingham151c0322015-09-15 21:13:50 +0000447 ASTConsumer *ast_transformer = type_system_helper->ASTTransformer(m_code_generator.get());
448
449 if (ClangExpressionDeclMap *decl_map = type_system_helper->DeclMap())
Sean Callanan80c97592015-05-01 00:47:29 +0000450 decl_map->InstallCodeGenerator(m_code_generator.get());
Chaoren Lin57998de2015-08-19 01:24:57 +0000451
Sean Callanan1a8d4092010-08-27 01:01:44 +0000452 if (ast_transformer)
Chaoren Lin57998de2015-08-19 01:24:57 +0000453 {
454 ast_transformer->Initialize(m_compiler->getASTContext());
Sean Callanan1a8d4092010-08-27 01:01:44 +0000455 ParseAST(m_compiler->getPreprocessor(), ast_transformer, m_compiler->getASTContext());
Chaoren Lin57998de2015-08-19 01:24:57 +0000456 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000457 else
Chaoren Lin57998de2015-08-19 01:24:57 +0000458 {
459 m_code_generator->Initialize(m_compiler->getASTContext());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000460 ParseAST(m_compiler->getPreprocessor(), m_code_generator.get(), m_compiler->getASTContext());
Chaoren Lin57998de2015-08-19 01:24:57 +0000461 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000462
Sean Callanane2ef6e32010-09-23 03:01:22 +0000463 diag_buf->EndSourceFile();
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000464
Sean Callanan1a8d4092010-08-27 01:01:44 +0000465 TextDiagnosticBuffer::const_iterator diag_iterator;
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000466
Sean Callanan1a8d4092010-08-27 01:01:44 +0000467 int num_errors = 0;
Sean Callananc8278af2014-12-05 01:27:35 +0000468
Zachary Turner22ac8712014-12-05 22:54:56 +0000469 if (m_pp_callbacks && m_pp_callbacks->hasErrors())
Sean Callananc8278af2014-12-05 01:27:35 +0000470 {
471 num_errors++;
472
473 stream.PutCString(m_pp_callbacks->getErrorString().c_str());
474 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000475
Sean Callanane2ef6e32010-09-23 03:01:22 +0000476 for (diag_iterator = diag_buf->warn_begin();
477 diag_iterator != diag_buf->warn_end();
Sean Callanan1a8d4092010-08-27 01:01:44 +0000478 ++diag_iterator)
479 stream.Printf("warning: %s\n", (*diag_iterator).second.c_str());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000480
Sean Callanane2ef6e32010-09-23 03:01:22 +0000481 for (diag_iterator = diag_buf->err_begin();
482 diag_iterator != diag_buf->err_end();
Sean Callanan1a8d4092010-08-27 01:01:44 +0000483 ++diag_iterator)
484 {
485 num_errors++;
486 stream.Printf("error: %s\n", (*diag_iterator).second.c_str());
487 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000488
Sean Callanan57bbc6e2010-11-01 20:28:09 +0000489 for (diag_iterator = diag_buf->note_begin();
490 diag_iterator != diag_buf->note_end();
491 ++diag_iterator)
492 stream.Printf("note: %s\n", (*diag_iterator).second.c_str());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000493
Sean Callanan77502262011-05-12 23:54:16 +0000494 if (!num_errors)
495 {
Jim Ingham151c0322015-09-15 21:13:50 +0000496 if (type_system_helper->DeclMap() && !type_system_helper->DeclMap()->ResolveUnknownTypes())
Sean Callanan77502262011-05-12 23:54:16 +0000497 {
498 stream.Printf("error: Couldn't infer the type of a variable\n");
499 num_errors++;
500 }
501 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000502
Sean Callanan1a8d4092010-08-27 01:01:44 +0000503 return num_errors;
504}
505
Sean Callanan8dfb68e2013-03-19 00:10:07 +0000506static bool FindFunctionInModule (ConstString &mangled_name,
Sean Callananfc55f5d2010-09-21 00:44:12 +0000507 llvm::Module *module,
508 const char *orig_name)
509{
510 for (llvm::Module::iterator fi = module->getFunctionList().begin(), fe = module->getFunctionList().end();
511 fi != fe;
512 ++fi)
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000513 {
Sean Callananfc55f5d2010-09-21 00:44:12 +0000514 if (fi->getName().str().find(orig_name) != std::string::npos)
515 {
Sean Callanan8dfb68e2013-03-19 00:10:07 +0000516 mangled_name.SetCString(fi->getName().str().c_str());
Sean Callananfc55f5d2010-09-21 00:44:12 +0000517 return true;
518 }
519 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000520
Sean Callananfc55f5d2010-09-21 00:44:12 +0000521 return false;
522}
523
Sean Callanan1a8d4092010-08-27 01:01:44 +0000524Error
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000525ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_addr,
Sean Callanan5a1af4e2013-04-05 02:22:57 +0000526 lldb::addr_t &func_end,
Greg Clayton23f8c952014-03-24 23:10:19 +0000527 std::shared_ptr<IRExecutionUnit> &execution_unit_sp,
Sean Callanan3bfdaa22011-09-15 02:13:07 +0000528 ExecutionContext &exe_ctx,
Sean Callanan1582ee62013-04-18 22:06:33 +0000529 bool &can_interpret,
Sean Callanan3bfdaa22011-09-15 02:13:07 +0000530 ExecutionPolicy execution_policy)
Sean Callanan1a8d4092010-08-27 01:01:44 +0000531{
Greg Clayton22a939a2011-01-19 23:00:49 +0000532 func_addr = LLDB_INVALID_ADDRESS;
533 func_end = LLDB_INVALID_ADDRESS;
Greg Clayton5160ce52013-03-27 23:08:40 +0000534 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
Sean Callananfc55f5d2010-09-21 00:44:12 +0000535
Sean Callanan1a8d4092010-08-27 01:01:44 +0000536 Error err;
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000537
Greg Clayton23f8c952014-03-24 23:10:19 +0000538 std::unique_ptr<llvm::Module> llvm_module_ap (m_code_generator->ReleaseModule());
Sean Callanan1a8d4092010-08-27 01:01:44 +0000539
Greg Clayton23f8c952014-03-24 23:10:19 +0000540 if (!llvm_module_ap.get())
Sean Callanan1a8d4092010-08-27 01:01:44 +0000541 {
542 err.SetErrorToGenericError();
543 err.SetErrorString("IR doesn't contain a module");
544 return err;
545 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000546
Sean Callananfc55f5d2010-09-21 00:44:12 +0000547 // Find the actual name of the function (it's often mangled somehow)
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000548
Sean Callanan8dfb68e2013-03-19 00:10:07 +0000549 ConstString function_name;
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000550
Greg Clayton23f8c952014-03-24 23:10:19 +0000551 if (!FindFunctionInModule(function_name, llvm_module_ap.get(), m_expr.FunctionName()))
Sean Callananfc55f5d2010-09-21 00:44:12 +0000552 {
553 err.SetErrorToGenericError();
554 err.SetErrorStringWithFormat("Couldn't find %s() in the module", m_expr.FunctionName());
555 return err;
556 }
557 else
558 {
Enrico Granata20edcdb2011-07-19 18:03:25 +0000559 if (log)
Sean Callanan8dfb68e2013-03-19 00:10:07 +0000560 log->Printf("Found function %s for %s", function_name.AsCString(), m_expr.FunctionName());
Sean Callananfc55f5d2010-09-21 00:44:12 +0000561 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000562
Greg Clayton23f8c952014-03-24 23:10:19 +0000563 execution_unit_sp.reset(new IRExecutionUnit (m_llvm_context, // handed off here
564 llvm_module_ap, // handed off here
565 function_name,
566 exe_ctx.GetTargetSP(),
567 m_compiler->getTargetOpts().Features));
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000568
Jim Ingham151c0322015-09-15 21:13:50 +0000569 ClangExpressionHelper *type_system_helper = dyn_cast<ClangExpressionHelper>(m_expr.GetTypeSystemHelper());
570 ClangExpressionDeclMap *decl_map = type_system_helper->DeclMap(); // result can be NULL
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000571
Sean Callanan1a8d4092010-08-27 01:01:44 +0000572 if (decl_map)
573 {
Sean Callanan3989fb92011-01-27 01:07:04 +0000574 Stream *error_stream = NULL;
Greg Claytonc14ee322011-09-22 04:58:26 +0000575 Target *target = exe_ctx.GetTargetPtr();
576 if (target)
Greg Clayton44d93782014-01-27 23:43:24 +0000577 error_stream = target->GetDebugger().GetErrorFile().get();
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000578
Sean Callanan3bfdaa22011-09-15 02:13:07 +0000579 IRForTarget ir_for_target(decl_map,
Sean Callanan9e6ed532010-09-13 21:34:21 +0000580 m_expr.NeedsVariableResolution(),
Greg Clayton23f8c952014-03-24 23:10:19 +0000581 *execution_unit_sp,
Sean Callanan3989fb92011-01-27 01:07:04 +0000582 error_stream,
Sean Callanan8dfb68e2013-03-19 00:10:07 +0000583 function_name.AsCString());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000584
Greg Clayton23f8c952014-03-24 23:10:19 +0000585 bool ir_can_run = ir_for_target.runOnModule(*execution_unit_sp->GetModule());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000586
Sean Callanan1582ee62013-04-18 22:06:33 +0000587 Error interpret_error;
Greg Claytonc14ee322011-09-22 04:58:26 +0000588 Process *process = exe_ctx.GetProcessPtr();
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000589
Ewan Crawford90ff7912015-07-14 10:56:58 +0000590 bool interpret_function_calls = !process ? false : process->CanInterpretFunctionCalls();
591 can_interpret = IRInterpreter::CanInterpret(*execution_unit_sp->GetModule(), *execution_unit_sp->GetFunction(), interpret_error, interpret_function_calls);
592
593
Sean Callanan1582ee62013-04-18 22:06:33 +0000594 if (!ir_can_run)
Sean Callanan3bfdaa22011-09-15 02:13:07 +0000595 {
Sean Callanan3d654b32012-09-24 22:25:51 +0000596 err.SetErrorString("The expression could not be prepared to run in the target");
Sean Callanan3d654b32012-09-24 22:25:51 +0000597 return err;
598 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000599
Sean Callanan1582ee62013-04-18 22:06:33 +0000600 if (!can_interpret && execution_policy == eExecutionPolicyNever)
Sean Callanan6961e872010-09-01 00:58:00 +0000601 {
Sean Callanan1582ee62013-04-18 22:06:33 +0000602 err.SetErrorStringWithFormat("Can't run the expression locally: %s", interpret_error.AsCString());
603 return err;
604 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000605
Sean Callanan1582ee62013-04-18 22:06:33 +0000606 if (!process && execution_policy == eExecutionPolicyAlways)
607 {
608 err.SetErrorString("Expression needed to run in the target, but the target can't be run");
609 return err;
610 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000611
Sean Callanan1582ee62013-04-18 22:06:33 +0000612 if (execution_policy == eExecutionPolicyAlways || !can_interpret)
613 {
Sean Callanane8cde682013-05-18 00:38:20 +0000614 if (m_expr.NeedsValidation() && process)
615 {
616 if (!process->GetDynamicCheckers())
Sean Callanan90539452011-09-20 23:01:51 +0000617 {
Sean Callanane8cde682013-05-18 00:38:20 +0000618 DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions();
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000619
Sean Callanane8cde682013-05-18 00:38:20 +0000620 StreamString install_errors;
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000621
Sean Callanane8cde682013-05-18 00:38:20 +0000622 if (!dynamic_checkers->Install(install_errors, exe_ctx))
623 {
624 if (install_errors.GetString().empty())
625 err.SetErrorString ("couldn't install checkers, unknown error");
626 else
627 err.SetErrorString (install_errors.GetString().c_str());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000628
Sean Callanane8cde682013-05-18 00:38:20 +0000629 return err;
630 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000631
Sean Callanane8cde682013-05-18 00:38:20 +0000632 process->SetDynamicCheckers(dynamic_checkers);
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000633
Sean Callanane8cde682013-05-18 00:38:20 +0000634 if (log)
635 log->Printf("== [ClangUserExpression::Evaluate] Finished installing dynamic checkers ==");
Sean Callanan90539452011-09-20 23:01:51 +0000636 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000637
Sean Callanan1582ee62013-04-18 22:06:33 +0000638 IRDynamicChecks ir_dynamic_checks(*process->GetDynamicCheckers(), function_name.AsCString());
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000639
Greg Clayton23f8c952014-03-24 23:10:19 +0000640 if (!ir_dynamic_checks.runOnModule(*execution_unit_sp->GetModule()))
Sean Callanan1582ee62013-04-18 22:06:33 +0000641 {
642 err.SetErrorToGenericError();
643 err.SetErrorString("Couldn't add dynamic checks to the expression");
644 return err;
645 }
Sean Callanan90539452011-09-20 23:01:51 +0000646 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000647
Greg Clayton23f8c952014-03-24 23:10:19 +0000648 execution_unit_sp->GetRunnableInfo(err, func_addr, func_end);
Sean Callanan9e6ed532010-09-13 21:34:21 +0000649 }
Sean Callanan1a8d4092010-08-27 01:01:44 +0000650 }
Sean Callanan1582ee62013-04-18 22:06:33 +0000651 else
652 {
Greg Clayton23f8c952014-03-24 23:10:19 +0000653 execution_unit_sp->GetRunnableInfo(err, func_addr, func_end);
Sean Callanan1582ee62013-04-18 22:06:33 +0000654 }
Sylvestre Ledruceab3ac2014-07-06 17:54:58 +0000655
Sean Callanan1a8d4092010-08-27 01:01:44 +0000656 return err;
657}