11 #include "llvm/ADT/ScopeExit.h"
12 #include "llvm/Support/FormatVariadic.h"
24 os <<
"ActionActiveStack depth " <<
getDepth() <<
"\n";
28 llvm::errs() << llvm::formatv(
"#{0,3}: ", count++);
29 current->action.
print(llvm::errs());
32 if (withContext && !context.empty()) {
33 llvm::errs() <<
"Context:\n";
37 llvm::errs() <<
" - ";
38 unit.print(llvm::errs());
40 [&]() { llvm::errs() <<
"\n"; });
43 current = current->parent;
54 observers.push_back(observer);
69 auto handleUserInput = [&]() ->
bool {
70 if (!onBreakpointControlExecutionCallback)
72 auto todoNext = onBreakpointControlExecutionCallback(
actionStack);
75 depthToBreak = std::nullopt;
78 depthToBreak = std::nullopt;
81 depthToBreak = depth + 1;
87 depthToBreak = depth - 1;
90 llvm::report_fatal_error(
"Unknown control request");
95 for (
auto *breakpointManager : breakpoints) {
96 breakpoint = breakpointManager->match(action);
100 info.setBreakpoint(breakpoint);
102 bool shouldExecuteAction =
true;
105 if (breakpoint || (depthToBreak && depth <= depthToBreak))
106 shouldExecuteAction = handleUserInput();
109 for (
auto *observer : observers)
110 observer->beforeExecute(
actionStack, breakpoint, shouldExecuteAction);
112 if (shouldExecuteAction) {
117 for (
auto *observer : observers)
121 if (depthToBreak && depth <= depthToBreak)
static const LLVM_THREAD_LOCAL ActionActiveStack * actionStack
IRUnit is a union of the different types of IR objects that consistute 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.