77// ===----------------------------------------------------------------------===//
88
99#include " lldb/Expression/IRInterpreter.h"
10+ #include " lldb/Core/Debugger.h"
1011#include " lldb/Core/Module.h"
1112#include " lldb/Core/ModuleSpec.h"
1213#include " lldb/Core/ValueObject.h"
@@ -464,6 +465,8 @@ static const char *unsupported_operand_error =
464465 " Interpreter doesn't handle one of the expression's operands" ;
465466static const char *interpreter_internal_error =
466467 " Interpreter encountered an internal error" ;
468+ static const char *interrupt_error =
469+ " Interrupted while interpreting expression" ;
467470static const char *bad_value_error =
468471 " Interpreter couldn't resolve a value during execution" ;
469472static const char *memory_allocation_error =
@@ -726,6 +729,9 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
726729
727730 frame.Jump (&function.front ());
728731
732+ lldb_private::Process *process = exe_ctx.GetProcessPtr ();
733+ lldb_private::Target *target = exe_ctx.GetTargetPtr ();
734+
729735 using clock = std::chrono::steady_clock;
730736
731737 // Compute the time at which the timeout has been exceeded.
@@ -741,6 +747,16 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
741747 return false ;
742748 }
743749
750+ // If we have access to the debugger we can honor an interrupt request.
751+ if (target) {
752+ if (INTERRUPT_REQUESTED (target->GetDebugger (),
753+ " Interrupted in IR interpreting." )) {
754+ error.SetErrorToGenericError ();
755+ error.SetErrorString (interrupt_error);
756+ return false ;
757+ }
758+ }
759+
744760 const Instruction *inst = &*frame.m_ii ;
745761
746762 LLDB_LOGF (log, " Interpreting %s" , PrintValue (inst).c_str ());
@@ -1432,7 +1448,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
14321448 }
14331449
14341450 // Make sure we have a valid process
1435- if (!exe_ctx. GetProcessPtr () ) {
1451+ if (!process ) {
14361452 error.SetErrorToGenericError ();
14371453 error.SetErrorString (" unable to get the process" );
14381454 return false ;
@@ -1538,11 +1554,11 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
15381554 return false ;
15391555 }
15401556
1541- exe_ctx. GetProcessPtr () ->SetRunningUserExpression (true );
1557+ process ->SetRunningUserExpression (true );
15421558
15431559 // Execute the actual function call thread plan
1544- lldb::ExpressionResults res = exe_ctx. GetProcessRef (). RunThreadPlan (
1545- exe_ctx, call_plan_sp, options, diagnostics);
1560+ lldb::ExpressionResults res =
1561+ process-> RunThreadPlan ( exe_ctx, call_plan_sp, options, diagnostics);
15461562
15471563 // Check that the thread plan completed successfully
15481564 if (res != lldb::ExpressionResults::eExpressionCompleted) {
@@ -1551,7 +1567,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
15511567 return false ;
15521568 }
15531569
1554- exe_ctx. GetProcessPtr () ->SetRunningUserExpression (false );
1570+ process ->SetRunningUserExpression (false );
15551571
15561572 // Void return type
15571573 if (returnType->isVoidTy ()) {
0 commit comments