34 std::string text, std::string name,
35 bool enable_debugging)
40 std::move(name), enable_debugging) {
43 if (enable_debugging) {
45 llvm::SmallString<128> result_path;
46 llvm::sys::fs::createTemporaryFile(
"lldb",
"expr", temp_fd, result_path);
49 text =
"#line 1 \"" + std::string(result_path) +
"\"\n" + text;
50 size_t bytes_written = text.size();
51 file.
Write(text.c_str(), bytes_written);
52 if (bytes_written == text.size()) {
112 bool keep_result_in_memory =
false;
116 if (!
DeclMap()->WillParse(exe_ctx,
nullptr)) {
119 "current process state is unsuitable for expression parsing");
123 const bool generate_debug_info =
true;
125 generate_debug_info);
127 unsigned num_errors = parser.
Parse(diagnostic_manager);
139 bool can_interpret =
false;
154 jit_module_sp->SetFileSpecAndObjectName(jit_file,
ConstString());
168 const char *error_cstr = jit_error.
AsCString();
169 if (error_cstr && error_cstr[0]) {
173 "expression can't be interpreted or run");
183 std::shared_ptr<ClangASTImporter> ast_importer;
184 auto *state = exe_ctx.
GetTargetSP()->GetPersistentExpressionStateForLanguage(
187 auto *persistent_vars = llvm::cast<ClangPersistentVariables>(state);
188 ast_importer = persistent_vars->GetClangASTImporter();
191 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...
Status PrepareForExecution(lldb::addr_t &func_addr, lldb::addr_t &func_end, lldb::IRExecutionUnitSP &execution_unit_sp, ExecutionContext &exe_ctx, bool &can_interpret, lldb_private::ExecutionPolicy execution_policy) override
Ready an already-parsed expression for execution, possibly evaluating it statically.
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 Printf(DiagnosticSeverity severity, const char *format,...) __attribute__((format(printf
size_t void PutString(DiagnosticSeverity severity, llvm::StringRef str)
"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
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.
@ eDiagnosticSeverityError
@ eDiagnosticSeverityWarning
@ eStateStopped
Process or thread is stopped and can be examined.
@ eLanguageTypeC
Non-standardized C, such as K&R.