11 #include "llvm/ADT/ScopeExit.h"
12 #include "llvm/Support/FormatVariadic.h"
22 os <<
"ActionActiveStack depth " <<
getDepth() <<
"\n";
26 llvm::errs() << llvm::formatv(
"#{0,3}: ", count++);
27 current->action.
print(llvm::errs());
30 if (withContext && !context.empty()) {
31 llvm::errs() <<
"Context:\n";
35 llvm::errs() <<
" - ";
36 unit.print(llvm::errs());
38 [&]() { llvm::errs() <<
"\n"; });
41 current = current->parent;
52 observers.push_back(observer);
67 auto handleUserInput = [&]() ->
bool {
68 if (!onBreakpointControlExecutionCallback)
70 auto todoNext = onBreakpointControlExecutionCallback(
actionStack);
73 depthToBreak = std::nullopt;
76 depthToBreak = std::nullopt;
79 depthToBreak = depth + 1;
85 depthToBreak = depth - 1;
88 llvm::report_fatal_error(
"Unknown control request");
93 for (
auto *breakpointManager : breakpoints) {
94 breakpoint = breakpointManager->match(action);
98 info.setBreakpoint(breakpoint);
100 bool shouldExecuteAction =
true;
103 if (breakpoint || (depthToBreak && depth <= depthToBreak))
104 shouldExecuteAction = handleUserInput();
107 for (
auto *observer : observers)
108 observer->beforeExecute(
actionStack, breakpoint, shouldExecuteAction);
110 if (shouldExecuteAction) {
115 for (
auto *observer : observers)
119 if (depthToBreak && depth <= depthToBreak)
static const LLVM_THREAD_LOCAL ActionActiveStack * actionStack
IRUnit is a union of the different types of IR objects that constitute the IR structure (other than T...
An action is a specific action that is to be taken by the compiler, that can be toggled and controlle...
virtual void print(raw_ostream &os) const
virtual ArrayRef< IRUnit > getContextIRUnits() const
Return the set of IR units that are associated with this action.
This abstract class represents a breakpoint.
void registerObserver(Observer *observer)
Register a new Observer on this context.
void operator()(function_ref< void()> transform, const Action &action)
Process the given action.
Include the generated interface declarations.
This class is used to keep track of the active actions in the stack.
const ActionActiveStack * getParent() const
void print(raw_ostream &os, bool withContext) const
This abstract class defines the interface used to observe an Action execution.