MLIR  19.0.0git
DebuggerExecutionContextHook.h
Go to the documentation of this file.
1 //===- DebuggerExecutionContextHook.h - Debugger Support --------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains a set of C API functions that are used by the debugger to
10 // interact with the ExecutionContext.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_SUPPORT_DEBUGGEREXECUTIONCONTEXTHOOK_H
15 #define MLIR_SUPPORT_DEBUGGEREXECUTIONCONTEXTHOOK_H
16 
17 #include "mlir-c/IR.h"
19 #include "llvm/Support/Compiler.h"
20 
21 extern "C" {
22 struct MLIRBreakpoint;
23 struct MLIRIRunit;
24 typedef struct MLIRBreakpoint *BreakpointHandle;
25 typedef struct MLIRIRunit *irunitHandle;
26 
27 /// This is used by the debugger to control what to do after a breakpoint is
28 /// hit. See tracing::ExecutionContext::Control for more information.
29 void mlirDebuggerSetControl(int controlOption);
30 
31 /// Print the available context for the current Action.
33 
34 /// Print the current action backtrace.
35 void mlirDebuggerPrintActionBacktrace(bool withContext);
36 
37 //===----------------------------------------------------------------------===//
38 // Cursor Management: The cursor is used to select an IRUnit from the context
39 // and to navigate through the IRUnit hierarchy.
40 //===----------------------------------------------------------------------===//
41 
42 /// Print the current IR unit cursor.
43 void mlirDebuggerCursorPrint(bool withRegion);
44 
45 /// Select the IR unit from the current context by ID.
47 
48 /// Select the parent IR unit of the provided IR unit, or print an error if the
49 /// IR unit has no parent.
51 
52 /// Select the child IR unit at the provided index, print an error if the index
53 /// is out of bound. For example if the irunit is an operation, the children IR
54 /// units will be the operation's regions.
56 
57 /// Return the next IR unit logically in the IR. For example if the irunit is a
58 /// Region the next IR unit will be the next region in the parent operation or
59 /// nullptr if there is no next region.
61 
62 /// Return the previous IR unit logically in the IR. For example if the irunit
63 /// is a Region, the previous IR unit will be the previous region in the parent
64 /// operation or nullptr if there is no previous region.
66 
67 //===----------------------------------------------------------------------===//
68 // Breakpoint Management
69 //===----------------------------------------------------------------------===//
70 
71 /// Enable the provided breakpoint.
73 
74 /// Disable the provided breakpoint.
76 
77 /// Add a breakpoint matching exactly the provided tag.
79 
80 /// Add a breakpoint matching a pattern by name.
81 void mlirDebuggerAddRewritePatternBreakpoint(const char *patternNameInfo);
82 
83 /// Add a breakpoint matching a file, line and column.
84 void mlirDebuggerAddFileLineColLocBreakpoint(const char *file, int line,
85  int col);
86 
87 } // extern "C"
88 
89 namespace mlir {
90 // Setup the debugger hooks as a callback on the provided ExecutionContext.
92  tracing::ExecutionContext &executionContext);
93 
94 } // namespace mlir
95 
96 #endif // MLIR_SUPPORT_DEBUGGEREXECUTIONCONTEXTHOOK_H
void mlirDebuggerEnableBreakpoint(BreakpointHandle breakpoint)
Enable the provided breakpoint.
void mlirDebuggerCursorPrint(bool withRegion)
Print the current IR unit cursor.
void mlirDebuggerPrintActionBacktrace(bool withContext)
Print the current action backtrace.
struct MLIRIRunit * irunitHandle
void mlirDebuggerCursorSelectChildIRUnit(int index)
Select the child IR unit at the provided index, print an error if the index is out of bound.
struct MLIRBreakpoint * BreakpointHandle
void mlirDebuggerPrintContext()
Print the available context for the current Action.
void mlirDebuggerCursorSelectIRUnitFromContext(int index)
Select the IR unit from the current context by ID.
void mlirDebuggerAddRewritePatternBreakpoint(const char *patternNameInfo)
Add a breakpoint matching a pattern by name.
void mlirDebuggerDisableBreakpoint(BreakpointHandle breakpoint)
Disable the provided breakpoint.
void mlirDebuggerAddFileLineColLocBreakpoint(const char *file, int line, int col)
Add a breakpoint matching a file, line and column.
void mlirDebuggerSetControl(int controlOption)
This is used by the debugger to control what to do after a breakpoint is hit.
void mlirDebuggerCursorSelectPreviousIRUnit()
Return the next IR unit logically in the IR.
void mlirDebuggerCursorSelectNextIRUnit()
Return the previous IR unit logically in the IR.
BreakpointHandle mlirDebuggerAddTagBreakpoint(const char *tag)
Add a breakpoint matching exactly the provided tag.
void mlirDebuggerCursorSelectParentIRUnit()
Select the parent IR unit of the provided IR unit, or print an error if the IR unit has no parent.
Include the generated interface declarations.
void setupDebuggerExecutionContextHook(tracing::ExecutionContext &executionContext)