|
12 | 12 |
|
13 | 13 | #if OG_TARGET_OS_DARWIN |
14 | 14 |
|
| 15 | +/** |
| 16 | + * @header OGDebugServer.h |
| 17 | + * @abstract OpenGraph Debug Server API for runtime debugging and inspection. |
| 18 | + * @discussion The debug server provides runtime debugging capabilities for OpenGraph applications, |
| 19 | + * allowing external tools to connect and inspect graph state, dependencies, and execution. |
| 20 | + * This API is only available on Darwin platforms and requires network interface access |
| 21 | + * when used in network mode. |
| 22 | + */ |
| 23 | + |
15 | 24 | OG_ASSUME_NONNULL_BEGIN |
16 | 25 |
|
17 | 26 | OG_IMPLICIT_BRIDGING_ENABLED |
18 | 27 |
|
| 28 | +/** |
| 29 | + * @typedef OGDebugServerRef |
| 30 | + * @abstract An opaque reference to a debug server instance. |
| 31 | + * @discussion The debug server manages a connection endpoint that external debugging tools |
| 32 | + * can use to inspect OpenGraph runtime state. Only one debug server instance |
| 33 | + * can be active at a time. |
| 34 | + */ |
19 | 35 | typedef struct OGDebugServerStorage *OGDebugServerRef OG_SWIFT_STRUCT OG_SWIFT_NAME(DebugServer); |
20 | 36 |
|
| 37 | +/** |
| 38 | + * @typedef OGDebugServerMode |
| 39 | + * @abstract Configuration modes for the debug server. |
| 40 | + * @discussion These flags control how the debug server operates and what interfaces it exposes. |
| 41 | + * Multiple modes can be combined using bitwise OR operations. |
| 42 | + */ |
21 | 43 | typedef OG_OPTIONS(uint32_t, OGDebugServerMode) { |
| 44 | + /** |
| 45 | + * @abstract No debug server functionality. |
| 46 | + * @discussion Use this mode to disable all debug server operations. |
| 47 | + */ |
22 | 48 | OGDebugServerModeNone = 0, |
| 49 | + |
| 50 | + /** |
| 51 | + * @abstract Enable basic debug server validation and setup. |
| 52 | + * @discussion This mode enables the debug server with minimal functionality and is required |
| 53 | + * for any debug server operation. All other modes must be combined with this flag. |
| 54 | + */ |
23 | 55 | OGDebugServerModeValid = 1 << 0, |
| 56 | + |
| 57 | + /** |
| 58 | + * @abstract Enable network interface for remote debugging. |
| 59 | + * @discussion When enabled, the debug server will listen on a network interface, allowing |
| 60 | + * remote debugging tools to connect. Requires OGDebugServerModeValid to be set. |
| 61 | + */ |
24 | 62 | OGDebugServerModeNetworkInterface = 1 << 1, |
25 | 63 | } OG_SWIFT_NAME(OGDebugServerRef.Mode); |
26 | 64 |
|
27 | 65 | // MARK: - Exported C functions |
28 | 66 |
|
29 | 67 | OG_EXTERN_C_BEGIN |
30 | 68 |
|
| 69 | +/** |
| 70 | + * @function OGDebugServerStart |
| 71 | + * @abstract Starts the shared debug server with the specified mode. |
| 72 | + * @discussion Creates and starts a new shared debug server instance. If a server is already |
| 73 | + * running, this function will return the existing instance. |
| 74 | + * |
| 75 | + * The returned reference should not be manually managed. Use OGDebugServerStop() |
| 76 | + * to properly shut down the shared server. |
| 77 | + * @param mode Configuration flags controlling server behavior. |
| 78 | + * Must include OGDebugServerModeValid for basic operation. |
| 79 | + * @result A reference to the started shared debug server, or NULL if the server |
| 80 | + * could not be started (e.g., due to network permissions, conflicts, or existing server). |
| 81 | + */ |
31 | 82 | OG_EXPORT |
| 83 | +OG_REFINED_FOR_SWIFT |
32 | 84 | OGDebugServerRef _Nullable OGDebugServerStart(OGDebugServerMode mode) OG_SWIFT_NAME(OGDebugServerRef.start(mode:)); |
33 | 85 |
|
| 86 | +/** |
| 87 | + * @function OGDebugServerStop |
| 88 | + * @abstract Stops and deletes the running shared debug server. |
| 89 | + * @discussion Shuts down the active shared debug server instance and cleans up all associated |
| 90 | + * resources. If no shared debug server is currently running, this function has no effect. |
| 91 | + * |
| 92 | + * This function should be called before application termination to ensure |
| 93 | + * proper cleanup of network resources and connections. |
| 94 | + */ |
34 | 95 | OG_EXPORT |
| 96 | +OG_REFINED_FOR_SWIFT |
35 | 97 | void OGDebugServerStop(void) OG_SWIFT_NAME(OGDebugServerRef.stop()); |
36 | 98 |
|
| 99 | +/** |
| 100 | + * @function OGDebugServerCopyURL |
| 101 | + * @abstract Returns the URL for connecting to the shared debug server. |
| 102 | + * @discussion Returns the URL that external debugging tools should use to connect to |
| 103 | + * the currently running shared debug server. The URL format depends on the server |
| 104 | + * configuration and may be a local or network address. |
| 105 | + * |
| 106 | + * The returned URL is only valid while the shared debug server is running. |
| 107 | + * It may change if the server is restarted. |
| 108 | + * @result A CFURLRef containing the connection URL, or NULL if no shared debug server |
| 109 | + * is currently running or if the server doesn't expose a connectable interface. |
| 110 | + * The caller is responsible for releasing the returned URL. |
| 111 | + */ |
37 | 112 | OG_EXPORT |
| 113 | +OG_REFINED_FOR_SWIFT |
38 | 114 | CFURLRef _Nullable OGDebugServerCopyURL(void) OG_SWIFT_NAME(OGDebugServerRef.copyURL()); |
39 | 115 |
|
| 116 | +/** |
| 117 | + * @function OGDebugServerRun |
| 118 | + * @abstract Runs the shared debug server event loop. |
| 119 | + */ |
40 | 120 | OG_EXPORT |
| 121 | +OG_REFINED_FOR_SWIFT |
41 | 122 | void OGDebugServerRun(int timeout) OG_SWIFT_NAME(OGDebugServerRef.run(timeout:)); |
42 | 123 |
|
43 | 124 | OG_EXTERN_C_END |
|
0 commit comments