33 std::string text, std::string name,
34 bool enable_debugging)
39 std::move(name), enable_debugging) {
42 if (enable_debugging) {
44 llvm::SmallString<128> result_path;
45 llvm::sys::fs::createTemporaryFile(
"lldb",
"expr", temp_fd, result_path);
48 text =
"#line 1 \"" + std::string(result_path) +
"\"\n" + text;
49 size_t bytes_written = text.size();
50 file.
Write(text.c_str(), bytes_written);
51 if (bytes_written == text.size()) {
110 bool keep_result_in_memory =
false;
114 if (!
DeclMap()->WillParse(exe_ctx,
nullptr)) {
117 "current process state is unsuitable for expression parsing");
121 const bool generate_debug_info =
true;
123 generate_debug_info);
125 unsigned num_errors = parser.
Parse(diagnostic_manager);
137 bool can_interpret =
false;
152 jit_module_sp->SetFileSpecAndObjectName(jit_file,
ConstString());
166 const char *error_cstr = jit_error.
AsCString();
167 if (error_cstr && error_cstr[0]) {
171 "expression can't be interpreted or run");
181 std::shared_ptr<ClangASTImporter> ast_importer;
182 auto *state = exe_ctx.
GetTargetSP()->GetPersistentExpressionStateForLanguage(
185 auto *persistent_vars = llvm::cast<ClangPersistentVariables>(state);
186 ast_importer = persistent_vars->GetClangASTImporter();
189 keep_result_in_memory,
nullptr, exe_ctx.
GetTargetSP(), ast_importer,
void DidParse()
Disable the state needed for parsing and IR transformation.
"lldb/Expression/ClangExpressionParser.h" Encapsulates an instance of Clang that can parse expression...
unsigned Parse(DiagnosticManager &diagnostic_manager)
Parse a single expression and convert it to IR using Clang.
static const char * g_expression_prefix
static const char * g_expression_suffix
std::unique_ptr< ClangExpressionDeclMap > m_expr_decl_map_up
~ClangUtilityFunction() override
ClangExpressionDeclMap * DeclMap()
ClangUtilityFunction(ExecutionContextScope &exe_scope, std::string text, std::string name, bool enable_debugging)
Constructor.
bool Install(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx) override
Install the utility function into a process.
A uniqued constant string class.
size_t void PutString(lldb::Severity severity, llvm::StringRef str)
size_t Printf(lldb::Severity severity, const char *format,...) __attribute__((format(printf
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
const lldb::TargetSP & GetTargetSP() const
Get accessor to get the target shared pointer.
Target * GetTargetPtr() const
Returns a pointer to the target object.
Process * GetProcessPtr() const
Returns a pointer to the process object.
bool GetGenerateDebugInfo() const
Status PrepareForExecution(lldb::addr_t &func_addr, lldb::addr_t &func_end, std::shared_ptr< IRExecutionUnit > &execution_unit_sp, ExecutionContext &exe_ctx, bool &can_interpret, lldb_private::ExecutionPolicy execution_policy)
Ready an already-parsed expression for execution, possibly evaluating it statically.
lldb::addr_t m_jit_end_addr
The address of the JITted function within the JIT allocation.
lldb::ProcessWP m_jit_process_wp
Expression's always have to have a target...
lldb::addr_t m_jit_start_addr
An expression might have a process, but it doesn't need to (e.g.
void SetFilename(ConstString filename)
Filename string set accessor.
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
Status Close() override
Flush any buffers and release any resources owned by the file.
Status Write(const void *buf, size_t &num_bytes) override
Write bytes from buf to a file at the current file position.
A plug-in interface definition class for debugging a process.
lldb::StateType GetState()
Get accessor for the current process state.
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
bool Success() const
Test for success condition.
const ModuleList & GetImages() const
Get accessor for the images for this process.
"lldb/Expression/UtilityFunction.h" Encapsulates a bit of source code that provides a function that i...
const char * FunctionName() override
Return the function name that should be used for executing the expression.
lldb::ModuleWP m_jit_module_wp
std::shared_ptr< IRExecutionUnit > m_execution_unit_sp
std::string m_function_text
The text of the function. Must be a well-formed translation unit.
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
@ eStateStopped
Process or thread is stopped and can be examined.
@ eLanguageTypeC
Non-standardized C, such as K&R.
std::shared_ptr< lldb_private::Module > ModuleSP