MLIR  20.0.0git
Classes | Public Types | Public Member Functions | List of all members
mlir::tracing::ExecutionContext Class Reference

The ExecutionContext is the main orchestration of the infrastructure, it acts as a handler in the MLIRContext for executing an Action. More...

#include "mlir/Debug/ExecutionContext.h"

Classes

struct  Observer
 This abstract class defines the interface used to observe an Action execution. More...
 

Public Types

enum  Control {
  Apply = 1 , Skip = 2 , Step = 3 , Next = 4 ,
  Finish = 5
}
 Enum that allows the client of the context to control the execution of the action. More...
 
using CallbackTy = function_ref< Control(const ActionActiveStack *)>
 The type of the callback that is used to control the execution. More...
 

Public Member Functions

 ExecutionContext (CallbackTy callback)
 Create an ExecutionContext with a callback that is used to control the execution. More...
 
 ExecutionContext ()=default
 
void setCallback (CallbackTy callback)
 Set the callback that is used to control the execution. More...
 
void registerObserver (Observer *observer)
 Register a new Observer on this context. More...
 
void addBreakpointManager (BreakpointManager *manager)
 Register a new BreakpointManager on this context. More...
 
void operator() (function_ref< void()> transform, const Action &action)
 Process the given action. More...
 

Detailed Description

The ExecutionContext is the main orchestration of the infrastructure, it acts as a handler in the MLIRContext for executing an Action.

When an action is dispatched, it'll query its set of Breakpoints managers for a breakpoint matching this action. If a breakpoint is hit, it passes the action and the breakpoint information to a callback. The callback is responsible for controlling the execution of the action through an enum value it returns. Optionally, observers can be registered to be notified before and after the callback is executed.

Definition at line 54 of file ExecutionContext.h.

Member Typedef Documentation

◆ CallbackTy

The type of the callback that is used to control the execution.

The callback is passed the current action.

Definition at line 72 of file ExecutionContext.h.

Member Enumeration Documentation

◆ Control

Enum that allows the client of the context to control the execution of the action.

  • Apply: The action is executed.
  • Skip: The action is skipped.
  • Step: The action is executed and the execution is paused before the next action, including for nested actions encountered before the current action finishes.
  • Next: The action is executed and the execution is paused after the current action finishes before the next action.
  • Finish: The action is executed and the execution is paused only when we reach the parent/enclosing operation. If there are no enclosing operation, the execution continues without stopping.
Enumerator
Apply 
Skip 
Step 
Next 
Finish 

Definition at line 68 of file ExecutionContext.h.

Constructor & Destructor Documentation

◆ ExecutionContext() [1/2]

mlir::tracing::ExecutionContext::ExecutionContext ( CallbackTy  callback)
inline

Create an ExecutionContext with a callback that is used to control the execution.

Definition at line 76 of file ExecutionContext.h.

References setCallback().

◆ ExecutionContext() [2/2]

mlir::tracing::ExecutionContext::ExecutionContext ( )
default

Member Function Documentation

◆ addBreakpointManager()

void mlir::tracing::ExecutionContext::addBreakpointManager ( BreakpointManager manager)
inline

Register a new BreakpointManager on this context.

It'll have a chance to match an action before it gets executed. Note that this method is not thread-safe: it isn't supported to add a new manager while actions may be executed.

Definition at line 114 of file ExecutionContext.h.

◆ operator()()

void ExecutionContext::operator() ( function_ref< void()>  transform,
const Action action 
)

Process the given action.

This is the operator called by MLIRContext on executeAction().

Definition at line 57 of file ExecutionContext.cpp.

References actionStack, Apply, Finish, mlir::tracing::ActionActiveStack::getDepth(), mlir::tracing::ActionActiveStack::getParent(), Next, Skip, and Step.

◆ registerObserver()

void ExecutionContext::registerObserver ( Observer observer)

Register a new Observer on this context.

It'll be notified before and after executing an action. Note that this method is not thread-safe: it isn't supported to add a new observer while actions may be executed.

Definition at line 53 of file ExecutionContext.cpp.

◆ setCallback()

void mlir::tracing::ExecutionContext::setCallback ( CallbackTy  callback)
inline

Set the callback that is used to control the execution.

Definition at line 80 of file ExecutionContext.h.

Referenced by ExecutionContext(), and mlir::setupDebuggerExecutionContextHook().


The documentation for this class was generated from the following files: