Skip to content

Commit b43e974

Browse files
committed
Add trace interfaces
1 parent cf10fbf commit b43e974

File tree

4 files changed

+106
-7
lines changed

4 files changed

+106
-7
lines changed

Sources/OpenGraph_SPI/include/OGGraphTracing.h

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@
77

88
#include "OGBase.h"
99
#include "OGGraph.h"
10+
#include "OGUniqueID.h"
1011

1112
typedef OG_OPTIONS(uint32_t, OGGraphTraceFlags) {
12-
OGGraphTraceFlags_0 = 0,
13-
OGGraphTraceFlags_1 = 1 << 0,
14-
OGGraphTraceFlags_2 = 1 << 1,
13+
OGGraphTraceFlagsEnabled = 1 << 0,
14+
OGGraphTraceFlagsFull = 1 << 1,
15+
OGGraphTraceFlagsBacktrace = 1 << 2,
16+
OGGraphTraceFlagsPrepare = 1 << 3,
17+
OGGraphTraceFlagsCustom = 1 << 4,
18+
OGGraphTraceFlagsAll = 1 << 5,
1519
} OG_SWIFT_NAME(OGGraphRef.TraceFlags);
1620

21+
typedef struct OGTrace *OGTraceRef;
22+
1723
OG_ASSUME_NONNULL_BEGIN
1824

1925
OG_IMPLICIT_BRIDGING_ENABLED
@@ -22,16 +28,25 @@ OG_EXTERN_C_BEGIN
2228

2329
OG_EXPORT
2430
OG_REFINED_FOR_SWIFT
25-
void OGGraphStartTracing(_Nullable OGGraphRef graph, OGGraphTraceFlags options) OG_SWIFT_NAME(OGGraphRef.startTracing(_:options:));
31+
void OGGraphStartTracing(_Nullable OGGraphRef graph, OGGraphTraceFlags flags) OG_SWIFT_NAME(OGGraphRef.startTracing(_:flags:));
2632

2733
OG_EXPORT
2834
OG_REFINED_FOR_SWIFT
29-
void OGGraphStartTracing2(_Nullable OGGraphRef graph, OGGraphTraceFlags options, _Nullable CFArrayRef array);
35+
void OGGraphStartTracing2(_Nullable OGGraphRef graph, OGGraphTraceFlags flags, _Nullable CFArrayRef subsystems) OG_SWIFT_NAME(OGGraphRef.startTracing(_:flags:subsystems:));
3036

3137
OG_EXPORT
3238
OG_REFINED_FOR_SWIFT
3339
void OGGraphStopTracing(_Nullable OGGraphRef graph) OG_SWIFT_NAME(OGGraphRef.stopTracing(_:));
3440

41+
OG_EXPORT
42+
OG_REFINED_FOR_SWIFT
43+
OGUniqueID OGGraphAddTrace(OGGraphRef graph, const OGTraceRef trace, void *_Nullable context)
44+
OG_SWIFT_NAME(OGGraphRef.addTrace(self:_:context:));
45+
46+
OG_EXPORT
47+
OG_REFINED_FOR_SWIFT
48+
void OGGraphRemoveTrace(OGGraphRef graph, OGUniqueID trace_id) OG_SWIFT_NAME(OGGraphRef.removeTrace(self:traceID:));
49+
3550
OG_EXTERN_C_END
3651

3752
OG_IMPLICIT_BRIDGING_DISABLED
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
//
2+
// OGTrace.h
3+
// OpenGraph_SPI
4+
5+
#ifndef OGTrace_hpp
6+
#define OGTrace_hpp
7+
8+
#include "OGBase.h"
9+
#include "OGGraph.h"
10+
11+
OG_ASSUME_NONNULL_BEGIN
12+
13+
typedef OG_ENUM(uint64_t, OGTraceEvents) {
14+
OGTraceEventsCustom = 1,
15+
OGTraceEventsNamed = 2,
16+
OGTraceEventsDeadline = 3,
17+
OGTraceEventsCompareFailed = 4,
18+
};
19+
20+
typedef struct OGTrace {
21+
OGTraceEvents events;
22+
23+
void (*_Nullable begin_trace)(void *_Nullable context, OGGraphRef graph);
24+
void (*_Nullable end_trace)(void *_Nullable context, OGGraphRef graph);
25+
26+
void (*_Nullable begin_update_subgraph)(void *_Nullable context, OGSubgraphRef subgraph, uint32_t options);
27+
void (*_Nullable end_update_subgraph)(void *_Nullable context, OGSubgraphRef subgraph);
28+
void (*_Nullable begin_update_stack)(void *_Nullable context, OGAttribute attribute);
29+
void (*_Nullable end_update_stack)(void *_Nullable context, bool changed);
30+
void (*_Nullable begin_update_attribute)(void *_Nullable context, OGAttribute attribute);
31+
void (*_Nullable end_update_attribute)(void *_Nullable context, OGAttribute attribute, bool changed);
32+
void (*_Nullable begin_update_graph)(void *_Nullable context, OGGraphRef graph);
33+
void (*_Nullable end_update_graph)(void *_Nullable context, OGGraphRef graph);
34+
35+
void (*_Nullable begin_invalidation)(void *_Nullable context, OGGraphRef graph, OGAttribute attribute);
36+
void (*_Nullable end_invalidation)(void *_Nullable context, OGGraphRef graph, OGAttribute attribute);
37+
38+
void (*_Nullable begin_modify)(void *_Nullable context, OGAttribute attribute);
39+
void (*_Nullable end_modify)(void *_Nullable context, OGAttribute attribute);
40+
41+
void (*_Nullable begin_event)(void *_Nullable context, OGAttribute attribute, const char *event_name);
42+
void (*_Nullable end_event)(void *_Nullable context, OGAttribute attribute, const char *event_name);
43+
44+
void (*_Nullable created_graph)(void *_Nullable context, OGGraphRef graph);
45+
void (*_Nullable destroy_graph)(void *_Nullable context, OGGraphRef graph);
46+
void (*_Nullable needs_update)(void *_Nullable context, OGGraphRef graph);
47+
48+
void (*_Nullable created_subgraph)(void *_Nullable context, OGSubgraphRef subgraph);
49+
void (*_Nullable invalidate_subgraph)(void *_Nullable context, OGSubgraphRef subgraph);
50+
void (*_Nullable add_child_subgraph)(void *_Nullable context, OGSubgraphRef subgraph, OGSubgraphRef child);
51+
void (*_Nullable remove_child_subgraph)(void *_Nullable context, OGSubgraphRef subgraph, OGSubgraphRef child);
52+
53+
void (*_Nullable added_attribute)(void *_Nullable context, OGAttribute attribute);
54+
void (*_Nullable add_edge)(void *_Nullable context, OGAttribute attribute, OGAttribute input, unsigned int flags);
55+
void (*_Nullable remove_edge)(void *_Nullable context, OGAttribute attribute, size_t index);
56+
void (*_Nullable set_edge_pending)(void *_Nullable context, OGAttribute attribute, OGAttribute input, bool pending);
57+
58+
void (*_Nullable set_dirty)(void *_Nullable context, OGAttribute attribute, bool dirty);
59+
void (*_Nullable set_pending)(void *_Nullable context, OGAttribute attribute, bool pending);
60+
void (*_Nullable set_value)(void *_Nullable context, OGAttribute attribute);
61+
void (*_Nullable mark_value)(void *_Nullable context, OGAttribute attribute);
62+
63+
void (*_Nullable added_indirect_attribute)(void *_Nullable context, OGAttribute attribute);
64+
void (*_Nullable set_source)(void *_Nullable context, OGAttribute attribute, OGAttribute source);
65+
void (*_Nullable set_dependency)(void *_Nullable context, OGAttribute attribute, OGAttribute dependency);
66+
67+
void (*_Nullable mark_profile)(void *_Nullable context, const char *event_name);
68+
69+
void (*_Nullable custom_event)(void *_Nullable context, OGGraphRef graph, const char *event_name, const void *value,
70+
OGTypeID type);
71+
void (*_Nullable named_event)(void *_Nullable context, OGGraphRef graph, uint32_t eventID, uint32_t eventArgCount,
72+
const void *eventArgs, CFDataRef data, uint32_t arg6);
73+
bool (*_Nullable named_event_enabled)(void *_Nullable context);
74+
75+
void (*_Nullable set_deadline)(void *_Nullable context);
76+
void (*_Nullable passed_deadline)(void *_Nullable context);
77+
78+
void (*_Nullable compare_failed)(void *_Nullable context, OGAttribute attribute, OGComparisonState comparisonState);
79+
} OGTrace;
80+
81+
OG_ASSUME_NONNULL_END
82+
83+
#endif /* OGTrace_hpp */

Sources/OpenGraph_SPI/include/OpenGraph.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "OGInputOptions.h"
1717
#include "OGSearchOptions.h"
1818
#include "OGSubgraph.h"
19+
#include "OGTrace.h"
1920
#include "OGTupleType.h"
2021
#include "OGTypeID.h"
2122
#include "OGUniqueID.h"

Tests/OpenGraphCompatibilityTests/Graph/GraphTracingCompatibilityTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ struct GraphTracingCompatibilityTests {
88
@Test
99
func tracing() {
1010
let graph = Graph()
11-
Graph.startTracing(graph, options: [])
11+
Graph.startTracing(graph, flags: [])
1212
Graph.stopTracing(graph)
1313
}
1414

1515
@Test
1616
func tracingAll() {
17-
Graph.startTracing(nil, options: [])
17+
Graph.startTracing(nil, flags: [])
1818
Graph.stopTracing(nil)
1919
}
2020

0 commit comments

Comments
 (0)