|
8 | 8 |
|
9 | 9 | #include <executorch/runtime/core/array_ref.h>
|
10 | 10 | #include <executorch/runtime/core/evalue.h>
|
| 11 | +#include <executorch/runtime/core/result.h> |
11 | 12 | #include <executorch/runtime/platform/platform.h>
|
12 | 13 | #include <stdlib.h>
|
13 | 14 | #include <cstdint>
|
@@ -67,6 +68,43 @@ enum class EventTracerDebugLogLevel {
|
67 | 68 | kIntermediateOutputs,
|
68 | 69 | };
|
69 | 70 |
|
| 71 | +/** |
| 72 | + * EventTracerFilterBase is an abstract base class that provides an interface |
| 73 | + * for filtering events based on their name or delegate debug index. |
| 74 | + * Derived classes should implement the filter method to define specific |
| 75 | + * filtering logic. |
| 76 | + */ |
| 77 | +class EventTracerFilterBase { |
| 78 | + public: |
| 79 | + /** |
| 80 | + * Filters events based on the given name or delegate debug index. |
| 81 | + * |
| 82 | + * Note that only one of either the name or delegate_debug_index should be |
| 83 | + * passed in. |
| 84 | + * |
| 85 | + * @param[in] name A pointer to a string representing the `name` of the |
| 86 | + * event. If `delegate_debug_index` is not set to kUnsetDebugHandle, `name` |
| 87 | + * should be set to nullptr. |
| 88 | + * |
| 89 | + * @param[in] delegate_debug_index A DebugHandle representing the debug index |
| 90 | + * of the delegate. If `name` is not nullptr, this should be set to |
| 91 | + * kUnsetDebugHandle. |
| 92 | + * |
| 93 | + * @return A Result<bool> indicating whether the event matches the filter |
| 94 | + * criteria. |
| 95 | + * - True if the event matches the filter. |
| 96 | + * - False if the event does not match or is unknown. |
| 97 | + * - An error code if an error occurs during filtering. |
| 98 | + */ |
| 99 | + virtual Result<bool> filter(char* name, DebugHandle delegate_debug_index); |
| 100 | + |
| 101 | + /** |
| 102 | + * Virtual destructor for the EventTracerFilterBase class. |
| 103 | + * Ensures proper cleanup of derived class objects. |
| 104 | + */ |
| 105 | + virtual ~EventTracerFilterBase(); |
| 106 | +}; |
| 107 | + |
70 | 108 | /**
|
71 | 109 | * Indicates the level of profiling that should be enabled. Profiling
|
72 | 110 | * events will be logged in increasing order of verbosity as we go down the
|
@@ -443,6 +481,12 @@ class EventTracer {
|
443 | 481 | event_tracer_profiling_level_ = profiling_level;
|
444 | 482 | }
|
445 | 483 |
|
| 484 | + /** |
| 485 | + * Set the filter of event tracer for delegation intermediate outputs. |
| 486 | + */ |
| 487 | + void set_delegation_intermediate_output_filter( |
| 488 | + EventTracerFilterBase* event_tracer_filter); |
| 489 | + |
446 | 490 | /**
|
447 | 491 | * Return the current level of event tracer profiling.
|
448 | 492 | */
|
|
0 commit comments